Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
pnp.h
Go to the documentation of this file.
1/** @file pnp.h
2 */
3/**
4# Ohmic conduction flux of charged species
5
6This function computes the fluxes due to ohmic conduction appearing in
7the [Nernst--Planck
8equation](http://en.wikipedia.org/wiki/Nernst%E2%80%93Planck_equation). The
9species charge concentrations are then updated using the explicit
10scheme
11\f[
12c^{n+1}_i = c^n_i +\Delta t \, \nabla \cdot( K_i c^n_i \nabla \phi^n)
13\f]
14where \f$c_i\f$ is the volume density of the \f$i\f$-specie, \f$K_i\f$ its volume
15electric conductivity and \f$\phi\f$ the electric potential. */
16
17extern scalar phi;
18
19void ohmic_flux (scalar * c, // A list of the species concentration...
20 int * z, // ... and their corresponding valences
21 double dt,
22 vector * K = NULL) // electric mobility (default the valence)
23{
24 /**
25 If the volume conductivity is not provided it is set to the value of
26 the valence. */
27
28 if (!K) { // fixme: this does not work yet
29 int i = 0;
30 for (int _s = 0; _s < 1; _s++) /* scalar in c */ {
31 const vector kc[] = {z[i], z[i]}; i++;
32 K = vectors_append (K, kc); // fixme: K should be freed eventually
33 }
34 }
35
36 scalar s;
37 const vector k;
38 for (s, k in c, K) {
39
40 /**
41 The fluxes of each specie through each face due to ohmic transport
42 are */
43
44 vector f[];
45 for (int _i = 0; _i < _N; _i++) /* foreach_face */
46 f.x[] = k.x[]*(s[] + s[-1])*(phi[] - phi[-1])/(2.*Delta);
47
48 /**
49 The specie concentration is updated using the net amount of that
50 specie leaving/entering each cell through the face in the interval
51 \f$dt\f$ */
52
53 for (int _i = 0; _i < _N; _i++) /* foreach */
54 for (int _d = 0; _d < dimension; _d++)
55 s[] += dt*(f.x[1] - f.x[])/Delta;
56 }
57}
#define dimension
Definition bitree.h:3
define k
int x
Definition common.h:76
int z
Definition common.h:76
vector * vectors_append(vector *list, vector v)
Definition common.h:258
scalar f[]
The primary fields are:
Definition two-phase.h:56
double dt
vector K[]
Definition implicit.h:35
scalar s
Definition embed-tree.h:56
scalar int i
Definition embed.h:74
void ohmic_flux(scalar *c, int *z, double dt, vector *K=NULL)
Definition pnp.h:19
scalar phi
The electric potential and the volume charge density are scalars while the permittivity and conductiv...
Definition implicit.h:34
def _i
Definition stencils.h:405
scalar c
Definition vof.h:57