The Nernst-Planck-Poisson model
PMiKNoM seminars - classes 11 and 12
Introduction
Electro-diffusion is the motion of ions occuring as an effect of two processes:
- diffusion - process driven by concentration gradient
- migration - process driven by electrical potential gradient.
Electro-diffusion processes are discussed in many fields of science, including semi-conductor science, analytical chemistry or neuro-physiology. Tool for the description of electro-diffusion is known as the Nernst-Planck-Poisson Model and can be applied to describe the processes occuring from nano to macro scale. For more details see:
NPP model - basic equations
The NPP model is an initial-boundary problem. Below the solution based on Dirichlet boundary conditions for concentrations and potential is presented.
Mass-balance equation
No reactions are considered, therefore the mass-balance equation takes the form:
Nernst-Planck equation
The Nernst-Planck equation for flux includes the description of diffusion and migration processes (as two components of the sum):
Poisson equation
The Poisson equation relates the potential with the occuring deviation from electroneutrality:
Initial and boundary conditions
Constant initial concentrations of all ions are assumed:
Dirichlet boundary conditions for potential are used, i.e. constant values of potential are assumed at the boundaries:
Alternatively Chang-Jaffe boundary conditions can be applied:
NPP model - numerical solution
Numerical solution of the above equations is based on the Method of Lines (MoL) and on the explicit Euler method.
Method of Lines for concentrations
We divide the considered segment into `n+1` sub-segments, each having the length `h`, to obtain the discrete points `x_0` to `x_{n+1}`. Let's then define `c_{i,k} \equiv c_i(x_k)`, and define the additional points ` x_{k-1/2} ` and ` x_{k+1/2}` in the distance `h/2` from point `x_k`. In these points we will be establishing the fluxes (`J_{i,k-1/2}` and `J_{i,k+1/2}`).
Mass balance equation for the `i`-th component in `k`-th point of space is given as:
Nernst-Planck equation for fluxes `J_{i,k-1/2}` and `J_{i,k+1/2}` takes the form:
After substituting `J_{i,k-1/2}` and `J_{i,k+1/2}` into the mass balance equation, one obtains:
Euler Method
If `c_{i,k}` denotes the concentration at time `t_j` and `c\text{_}n e w_{i,k}` denotes the the concentration at time `t_{j+1}` then:
After inserting the time derivative, one obtains:
Method of Lines for Poisson equation
After substituting the space derivative with the finite difference, one obtains:
After then multiplying by `h^2`, the equation of the `i`-th element is obtained:
Knowing that ` \varphi_0 = \varphi_L = const` and `\varphi_{n+1} =\varphi_R =const`, we can substitute `k=1` and `k=n`, obtaining:
The set of these three equations represent the tri-diagonal matrix:
NPP model - program's algorithm
Declarations - global constants and variables:
- Declare the global constants `l`, `t_{end}`, `p`, `n`, `m`, `F`, `R`, `T` and `\varepsilon`.
- Declare the two-dimensional arrays `c(1` to `p`, `0` to `n+1)` and `c__\text{new}(1` to `p`, `1` to `n)` as well as one-dimensional array `varphi(0` to `n+1)`.
- Declare the arrays `D(1` to `p)`, `z(1` to `p)`, `c_L(1` to `p)`, `c_{ST}(1` to `p)`, `c_R(1` to `p)`, and the variables `varphi_L` and `varphi_R`.
- Declare the variables `h`, `dt` and `gamma`, and arrays `alpha(1` to `p)` and `beta(1` to `p)`, and also variables `i`, `j`, `k`.
Procedure calculating the potential - Sub CalculatePotential():
- Declare the arrays `a(1` to `n-1)`, `b(1` to `n)`, `c c(1` to `n-1)`, `dd(1` to `n)` and variable `s`.
- Assign values on diagonal, i.e. for `k=1` to `n` `dd(k)=-2`.
- Assign values above and below diagonal, i.e. for `k=1` to `n-1`: `c c(k)=1` and `a(k)=1`.
- Assign values of free term b(k) using loop (for `k=1` to `n`):
- reset variable `s`, i.e. `s = 0`,
- calculate `\sum_i z_i c_{i,k}`, i.e. for `i=1` to `p`: `s = s + z(i) \cdot c(i,k)`,
- assign `b(k) = -\gamma \cdot s`.
- Modify `b` for the first and las row, i.e. `b(1)=b(1) - \varphi_L` and `b(n)=b(n) - \varphi_R`.
- Solve the tri-diagonal matrix (as it was done in class 4).
- Rewrite the result to the potential table, i.e. for `k=1` to `n`: `\varphi (k)=b(k)`.
Main procedure - Sub NPP():
- Assign values to arrays `D`, `z`, `c_L`, `c_{ST}`, `c_R` and variables `varphi_L` and `varphi_R`.
- Calculate the step value `h=l/{n+1}`, the time-step value `dt=t_{end}/m` and the values of `alpha(i)`, `beta(i)` and `gamma`.
- Assign the initial values of concentrations `c(i,k)=c_{ST}(i)`. (embeded loop for `k=1` to `n` and for `i=1` to `p`).
- Assign the boundary values of concentrations, i.e. for `i=1` to `p`: `c(i,0)=c_L(i)` and `c(i,n+1)=c_R(i)`.
- Assign the boundary values of potential: `varphi(0)=varphi_L` and `varphi(n+1)=varphi_R`.
- Call the procedure calculating potential, i.e. `Call` `Calcu latePotential`.
- Execute the embeded loop (for `j=1` to `m`), in which for every time-step:
- program calculates the new values of concentration (for `k=1` to `n` and for `i=1` to `p`) and assign them to the array `c_\text{new}` (see equation 3.2.);
- program switches the arrays, i.e. (for `k=1` to `n` and for `i=1` to `p`) `c(i,k)=c_\text{new}(i,k)`;
- program calls the procedure calculating potential, i.e. `Call` `Calcu latePotential`.
- Save the results in the spreadsheet (in following columns: distance, concentrations of ions and potential).
NPP model - the obtained software
- Nernst-Planck-Poisson model - implementation in VBA.
- Comparison of the results with the application written in JavaScript.