The project goal is to be able to simulate diffusion. I studied the solution for the diffusion equation or Fick's law equation:
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.
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.
- cvstoroot is for seeing a list of diffusion coefficients for some typical solutes in water in standard pressure at a temperature of 20 and 10 degrees Celsius [10-4 cm2/s]. The function reads the file (coefficients.csv) and makes a tree.
There might be a problem when graphing if you do not ask to show the parameters first.
- SetAndGraph is for graphing in one dimension for different times. The program has pre-assigned values for M and D but you can change them, the graph shows the solution for times t=10n for n=0,1,2,3,4
- SetAndGraph2 is for graphing in two dimensions for different times. The program has pre-assigned values for M, Dx, Dy, and Lz but you can change them, the graph shows the solution for times t=10n for n=0,1,2
- TempGraph is graphing in one dimension for two different coefficients. The program has pre-assigned values for M, t, D20, and D10 but you can change them, the graph shows the solution with D20 parameter en red and D10 parameter in blue. By choosing the parameters of the same solute at different temperatures we can observe difference of concentration if the temperature changes or we can also graph two different solutes.
Click here to get the program code here
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:
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.
The factors 4π 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:
Setting the terms within the bracket to zero provides one solution,
which has the solution
With A0 an arbitrary constant, the above equation gives us a specific form for the proposed solution
Since the total mass must be conserved over time, for all time
so that A0=M.
The final solution is expressed as:
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
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:
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
we get to:
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.
Difusion for hydrogen ion at 20 degrees Celsius
Difusion for ammonia at 20 degrees Celsius
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.
Difusion for coefficients Dx=Dy=0.28
Difusion for coefficients Dx=0.28 and Dy=0.15
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.
Difusion of Sulfate SO4-2 at 20 and 10 degrees Celsius with red and blue colors respectively at t=1
Difusion of Sulfate SO4-2 at 20 and 10 degrees Celsius with red and blue colors respectively at t=10
Difusion of Sulfate SO4-2 at 20 and 10 degrees Celsius with red and blue colors respectively at t=100
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.