Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
implicit.h
Go to the documentation of this file.
1/** @file implicit.h
2 */
3/**
4# Ohmic conduction
5
6This function approximates implicitly the EHD equation set given by
7the electric Poisson equation and the ohmic conduction term of the
8charge density conservation (the advection term is computed elsewhere
9using a tracer advection scheme),
10\f[
11\nabla \cdot( \epsilon \nabla \phi^{n+1}) = -\rho_e^{n+1} \quad \mathrm{and}
12\quad (\rho_e^{n+1}-\rho_e^n) = \Delta t\nabla \cdot (K\nabla \phi^{n+1})
13\f]
14where \f$\rho_e\f$ is the charge density, and \f$\phi\f$ is the electric potential.
15\f$K\f$ and \f$\epsilon\f$ are the conductivity and permittivity respectively.
16
17Substituting the Poisson equation into the conservation equation gives
18the following time-implicit scheme,
19\f[
20\nabla \cdot [(K \, \Delta t + \epsilon) \nabla \phi^{n+1}] = -\rho_e^{n}
21\f]
22
23We need the Poisson solver and the timestep *dt*. */
24
25#include "poisson.h"
26extern double dt;
27
28/**
29The electric potential and the volume charge density are scalars while
30the permittivity and conductivity are face vectors. In *mgphi* we will
31store the statistics for the multigrid resolution of the electric
32poisson equation. */
33
37
38/** @brief Event: defaults (i = 0) */
39void event_defaults (void)
40{
41
42 /**
43 The restriction/refine attributes of the charge density are those of a tracer
44 otherwise the conservation is not guaranteed. */
45
46#if TREE
47 rhoe.restriction = restriction_volume_average;
48 rhoe.refine = refine_linear;
49#endif
50
51 /**
52 By default the permittivity is unity and other quantities are zero. */
53
54 for (int _i = 0; _i < _N; _i++) /* foreach_face */
55 epsilon.x[] = K.x[] = fm.x[];
56}
57
58/** @brief Event: tracer_diffusion (i++) */
60{
61 scalar rhs[];
62
63 /**
64 The r.h.s of the poisson equation is set to \f$-\rho_e^n\f$, */
65
66 for (int _i = 0; _i < _N; _i++) /* foreach */
67 rhs[] = - rhoe[]*cm[];
68
69 if (K.x.i) {
70
71 /**
72 We compute the coefficients of the Laplacian: $(K dt +\epsilon)$. */
73
74 vector f[];
75 for (int _i = 0; _i < _N; _i++) /* foreach_face */
76 f.x[] = K.x[]*dt + epsilon.x[];
77
78 /**
79 The poisson equation is solved to obtain \f$\phi^{n+1}\f$. */
80
81 mgphi = poisson (phi, rhs, f);
82
83 /**
84 Finally \f$\rho_e^{n+1}\f$ is computed as
85 \f$\rho_e^{n+1} = -\nabla \cdot (\epsilon \nabla \phi^{n+1})\f$. */
86
87#if TREE
88 for (int _i = 0; _i < _N; _i++) /* foreach_face */
89 f.x[] = epsilon.x[]*(phi[] - phi[-1])/Delta;
90 for (int _i = 0; _i < _N; _i++) /* foreach */ {
91 rhoe[] = 0.;
92 for (int _d = 0; _d < dimension; _d++)
93 rhoe[] -= f.x[1] - f.x[];
94 rhoe[] /= cm[]*Delta;
95 }
96#else // Cartesian
97 for (int _i = 0; _i < _N; _i++) /* foreach */ {
98 rhoe[] = 0.;
99 for (int _d = 0; _d < dimension; _d++)
100 rhoe[] -= (epsilon.x[1]*(phi[1] - phi[]) -
101 epsilon.x[]*(phi[] - phi[-1]));
102 rhoe[] /= cm[]*sq(Delta);
103 }
104#endif
105 }
106
107 /**
108 In the absence of conductivity, the electric potential only varies
109 if the electrical permittivity varies, */
110
111 else
112 mgphi = poisson (phi, rhs, epsilon);
113}
#define dimension
Definition bitree.h:3
int x
Definition common.h:76
const scalar cm[]
Definition common.h:397
static number sq(number x)
Definition common.h:11
const vector fm[]
Definition common.h:396
scalar f[]
The primary fields are:
Definition two-phase.h:56
double dt
scalar rhoe[]
Definition implicit.h:34
vector epsilon[]
Definition implicit.h:35
void event_tracer_diffusion(void)
Event: tracer_diffusion (i++)
Definition implicit.h:59
mgstats mgphi
Definition implicit.h:36
vector K[]
Definition implicit.h:35
void event_defaults(void)
Event: defaults (i = 0)
Definition implicit.h:39
scalar phi[]
The electric potential and the volume charge density are scalars while the permittivity and conductiv...
Definition implicit.h:34
static void restriction_volume_average(Point point, scalar s)
static void refine_linear(Point point, scalar s)
def _i
Definition stencils.h:405
Information about the convergence of the solver is returned in a structure.
Definition poisson.h:112
int i
Definition common.h:44
scalar x
Definition common.h:47
#define poisson(...)
Finally, we overload the poisson() function called by [two-phase.h]() with our new function.
Definition thermal.h:243