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
6
This function computes the fluxes due to ohmic conduction appearing in
7
the [Nernst--Planck
8
equation](http://en.wikipedia.org/wiki/Nernst%E2%80%93Planck_equation). The
9
species charge concentrations are then updated using the explicit
10
scheme
11
\f[
12
c^{n+1}_i = c^n_i +\Delta t \, \nabla \cdot( K_i c^n_i \nabla \phi^n)
13
\f]
14
where \f$c_i\f$ is the volume density of the \f$i\f$-specie, \f$K_i\f$ its volume
15
electric conductivity and \f$\phi\f$ the electric potential. */
16
17
extern
scalar
phi
;
18
19
void
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
}
dimension
#define dimension
Definition
bitree.h:3
k
define k
Definition
cartesian-common.h:8
x
int x
Definition
common.h:76
z
int z
Definition
common.h:76
vectors_append
vector * vectors_append(vector *list, vector v)
Definition
common.h:258
f
scalar f[]
The primary fields are:
Definition
two-phase.h:56
dt
double dt
Definition
predictor-corrector.h:18
K
vector K[]
Definition
implicit.h:35
s
scalar s
Definition
embed-tree.h:56
i
scalar int i
Definition
embed.h:74
ohmic_flux
void ohmic_flux(scalar *c, int *z, double dt, vector *K=NULL)
Definition
pnp.h:19
phi
scalar phi
The electric potential and the volume charge density are scalars while the permittivity and conductiv...
Definition
implicit.h:34
_i
def _i
Definition
stencils.h:405
scalar
Definition
common.h:44
vector
Definition
common.h:46
c
scalar c
Definition
vof.h:57
ehd
pnp.h
Generated by
1.9.8