Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
restrepo
GitHub Repository: restrepo/ComputationalMethods
Path: blob/master/activities/ficks-law.ipynb
934 views
Kernel: Python 2

Task

This homework is an activity intended to apply the integration formulas given in class. The objective is to solve the error function and applying it to a problem of diffusion in fluids.


Error Function and Fick's Law

Error Function

The error function is a special and non-elementary function that is widely used in probability, statistics and diffussion processes. It is defined through the integral:

erf(x)=2π0xet2dt\mbox{erf}(x)=\frac{2}{\sqrt{\pi}}\int_0^{x}e^{-t^2}dt

1. Using the substitution u=t2u=t^2 it is possible to use the described methods for impropers integrals in order to evaluate the error function. Create a routine called ErrorFunction that, given a value of x, return the respective value of the integral.

Fick's Law

In fluid physics and thermodynamics, Fick's law is a quantitative law that describes several diffusion processes for matter or heat. Situations in which there are gradients of concentration or heat, a flux that tends to homogenise the fluid arises as a consequence of random motion of constituent particles, as predicted by the second law of thermodynamics.

The Fick's law then says:

j=Dc\vec{j} = -D \nabla \vec{c}

where j\vec{j} is the associated flux of particles of some specie or flux of heat, DD is the diffusion coefficient for gradients of concentrations, or the thermal conductivity in case of gradients of heat. Finally, cc is the studied property, concentration or temperature.

A very simple solution of this problem is obtained when studying diffusion of a set of particles in one dimension, from a boundary located at x=0x=0 and a concentration fixed at n0n_0.

n(x,t)=n0[1erf(x2Dt)]n(x,t) = n_0\left[ 1 - \mbox{erf}\left( \frac{x}{2\sqrt{Dt}} \right)\right]

2. Using n0=1n_0 = 1 and D=1m2/sD = 1m^2/s, and the previous routine for calculating the error function, plot the resulting density number of particles nn as a function of the position for different times (i.e. plot several curves associated with each time).