Diffusion


Project description:

The project goal is to be able to simulate diffusion. I studied the solution for the diffusion equation or Fick's law equation:
f1

Where C in concentration in mol/m3, t is time in s and D is the diffusion coefficient in m2/s.


I was able to graph the concentration vs distance in one and two dimensions. The boundary conditions where set as an instantaneous point source. By doing this I was able to understand how the concentration changes in time and how temperature affects the diffusion rate.

Program description:

The program in interactive and starts with a menu where you can choose between different functions:
The parameter M stands for mass, D, Dx, Dy, D20, D10 for diffusion coefficient in one direction, in x direction, in y direction, at 20 degrees Celsius and at 10 degrees Celsius respectively, Lz for the thickness of the material and t for time.
There might be a problem when graphing if you do not ask to show the parameters first.
Click here to get the program code here

Theory:

Fick's second law predicts how diffusion causes a change in concentration over time. It is derived from the conservation of mass.
The Solutions below describes the evolution of a slug of mass, M, released instantaneously at time t = 0 into a stationary fluid.
For one dimension Fick's law is written as:
f2
The boundary conditions, initial conditions, are mathematical written as C(x)=Mδ(x), where δ() is the Dirac delta function
From Fick's law we anticipate that the concentration will be a function of M, D, x and t. From dimensional analysis, we form two dimensionless groups that imply the solution of C.
f3 The factors and 4 are added now for convenience, because they appear in the final solution.
Defining η=x/√(4Dt) and evaluating the proposed solution in Fick's law we obtain:
f4 Setting the terms within the bracket to zero provides one solution, f5 which has the solution

f=A0e2

With A0 an arbitrary constant, the above equation gives us a specific form for the proposed solution
f6 Since the total mass must be conserved over time, for all time
f7 so that A0=M.
The final solution is expressed as:
f8
Similarity for an instantaneous point source in two dimensions such that the initial concentration is C(x, y, t=0) = M δ(x)δ(y) . By analyzing the equation
f9 we notice the dependency of the variables and we can propose a solution as follows:
C(x,t=0)=Mδ(x)δ(y), where C1 is not a function of y and C2 is not a function of x.
Evaluating the proposed solution in Fick's law we get:
f10 The trivial solution C1=C2=0 is useless. Instead we look to when each bracket could be zero. By solving for C1 and C2, similar to one dimension analysis. Knowing that the final solution is the multiplication of these two and applying that f11 we get to:
f12

Results and discussion:

The program allows you to choose the parameters to graph. As an example in one dimension I chose hydrogen ion at 20 degrees Celsius, ammonia at 20 degrees Celsius and dihydrogen phosphate at 10 degrees Celsius. The mass was kept constant at M=0.5 in order to appreciate the difference in the diffusion coefficient. The color of each graph corresponds to five different times in logarithmic scale.

Graph 1

graph1

Difusion for hydrogen ion at 20 degrees Celsius

Graph 2

graph2

Difusion for ammonia at 20 degrees Celsius

Graph 3

graph3

Difusion for dihydrogen phosphate at 10 degrees Celsius



A first observation is the sharpness of the curves when changing the diffusion coefficient, the concentration is higher if the diffusion coefficient is low and the range is bigger when the diffusion coefficient is big. We can also notice the difference between the first time and last time; with a small diffusion coefficient the difference in concentration is more appreciable.

The graph in two dimensions look like concenters circles. The graphs are made with three different times in a logarithmic scale with different colors so we can appreciate how the concentration expands as time passes. We see that the red circles are closer together and don't reach as far as the white and black circles. The first image is with equal diffusion coefficients for x and y direction, i.e. Dx=Dy=0.28. The second image was made with the parameters: Dx=0.28 and Dy=0.15 we notice that is elongated towards the x direction this agrees with the analysis made before because the larger the coefficient the larger the range it reaches. The third image was made with the parameters: Dx=0.1 and Dy=0.3 this time the graph is elongated in the y direction.

Graph 4

graph4

Difusion for coefficients Dx=Dy=0.28

Graph 5

graph5

Difusion for coefficients Dx=0.28 and Dy=0.15

Graph 6

graph6

Difusion for coefficients Dx=0.1 and Dy=0.3



To understand how temperature affects the concentration I chose the example of Sulfate SO4-2, the diffusion coefficients are 0.10 and 0.07 at 20 and 10 degrees Celsius respectively and are colored red and blue respectively. I graphed them for three different times; graph 1 shows the concentration at 1 second, graph 2 at 10 seconds and graph 3 at 100 seconds. We can notice that as time passes the difference in concentration between the two temperatures decreases. Since Fick's law is analogous to the heat transportation equations it is expected to find that the hotter solute diffuses more rapidly until it finds equilibrium.

Graph 7

graph7

Difusion of Sulfate SO4-2 at 20 and 10 degrees Celsius with red and blue colors respectively at t=1

Graph 8

graph8

Difusion of Sulfate SO4-2 at 20 and 10 degrees Celsius with red and blue colors respectively at t=10

Graph 9

graph9

Difusion of Sulfate SO4-2 at 20 and 10 degrees Celsius with red and blue colors respectively at t=100



Conclusion:

This project impulse me to understand a topic that I was wondering about for a long time. Even though it was my first time using ROOT I discovered that it is very helpful tool to analyze and save data. When I was researching for the topic I didn't understand how the concentration changed in time or with different temperatures, ROOT made it possible to understand the topic.
Displaying the project in a HTML was a good way to learn how it works and the features it has. I had some trouble to enter formulas so the solution was to enter them as pictures.

References:

http://www.ifh.uni-karlsruhe.de/lehre/envflu_i/Downloads/course_script/ed2/ch1.PDF
http://web.mit.edu/1.061/www/dream/THREE/THREETHEORY.PDF

Thank you!