Skip to content
Projects

Fluid 2D

The equations of carafe.spatial.fluid, declared on the code that implements them and checked by the tests.

Fluid2D

classsource

The plasma on the cells of a grid; see the module docstring.

continuity
∂tns+∇⋅Γs=Ss\partial_t n_s + \nabla\cdot\boldsymbol\Gamma_s = S_s
ion momentum
∂t(nivi)+∇⋅(nivivi)=zieMiniE−eTgMi∇ni−νinivi−Livi\partial_t(n_i\mathbf v_i) + \nabla\cdot(n_i\mathbf v_i\mathbf v_i) = \frac{z_i e}{M_i} n_i\mathbf E - \frac{e T_g}{M_i}\nabla n_i - \nu_i n_i\mathbf v_i - L_i\mathbf v_i
ion friction
νi=eMiμiorνi=8eTg/(πMi)+∣vi∣2λi\nu_i = \frac{e}{M_i\mu_i} \quad \text{or} \quad \nu_i = \frac{\sqrt{8 e T_g/(\pi M_i) + |\mathbf v_i|^2}}{\lambda_i}
electrons
Γe=−μene(E−Fe)−∇(Dene),F=−e2Re(u n^×B∗),μe=emeν\boldsymbol\Gamma_e = -\mu_e n_e\left(\mathbf E - \frac{\mathbf F}{e}\right) - \nabla(D_e n_e), \qquad \mathbf F = -\frac{e}{2}\mathrm{Re}\left(u\,\hat{\mathbf n}\times\mathbf B^*\right), \qquad \mu_e = \frac{e}{m_e \nu}
energy
∂tw+∇⋅Γw=−Γe⋅E−∑R εe+pRFe,pRF=12Re(JE∗)\partial_t w + \nabla\cdot\boldsymbol\Gamma_w = -\boldsymbol\Gamma_e\cdot\mathbf E - \sum R\,\varepsilon_e + \frac{p_\mathrm{RF}}{e}, \qquad p_\mathrm{RF} = \tfrac12\mathrm{Re}(J E^*)
quasineutral
ne=∑izini,∇⋅∑szsΓs=0n_e = \sum_i z_i n_i, \qquad \nabla\cdot\sum_s z_s\boldsymbol\Gamma_s = 0
poisson
∇⋅E=eε0∑szsns\nabla\cdot\mathbf E = \frac{e}{\varepsilon_0}\sum_s z_s n_s
sheath
Γi,wall=n smoothmax(vn,uB),uB=zeTeM,Γe,wall=14nevˉe e−(ϕ−ϕw)/Te,2Te+(ϕ−ϕw) each\Gamma_{i,\mathrm{wall}} = n\,\mathrm{smoothmax}(v_n, u_B), \quad u_B = \sqrt{\frac{z e T_e}{M}}, \qquad \Gamma_{e,\mathrm{wall}} = \tfrac14 n_e \bar v_e\, e^{-(\phi - \phi_w)/T_e}, \quad 2T_e + (\phi - \phi_w) \text{ each}
rusanov
Fn=12(nlvl+nhvh)−12c (nh−nl),c=vl2+vh2+e(zTˉe+Tg)/MF_n = \tfrac12(n_l v_l + n_h v_h) - \tfrac12 c\,(n_h - n_l), \qquad c = \sqrt{v_l^2 + v_h^2 + e(z\bar T_e + T_g)/M}
divergence
(∇⋅Γ)cell=1Vcell∑fAfΓf(one flux per face, across levels too)(\nabla\cdot\boldsymbol\Gamma)_\mathrm{cell} = \frac{1}{V_\mathrm{cell}}\sum_f A_f \Gamma_f \quad (\text{one flux per face, across levels too})
Order
1
Assumes
  • Scharfetter-Gummel fluxes for electrons and drift-diffusion ions with face coefficients the mean of the two cells; Rusanov (first order) for the inertial ions
  • ions at TgT_g, born at rest, LiL_i the rate of the reactions destroying them; the gas a fixed background unless coupled
  • the quasi-neutral sheath edge takes the wall cell's density, a first-order error uBh/(2D)u_B h/(2D); Poisson needs the Debye length resolved
  • smoothmax(a,b)=12(a+b+(a−b)2+ϵ2)\mathrm{smoothmax}(a, b) = \tfrac12(a + b + \sqrt{(a - b)^2 + \epsilon^2}), ϵ=10−2uB\epsilon = 10^{-2} u_B; the RF force does no work
  • coarse-fine faces: the coarse value interpolated quadratically along the face to its middle (logarithms of positive fields)
  • the order is that of ambipolar diffusion in a slab from a uniform source (the problem of the tests)
References
Built from

steady_state

functionsource

Return the steady state.

backward euler
un+1−unΔt=F(un+1),u=(ln⁡ns, vi, ln⁡w, ϕ)\frac{u^{n+1} - u^n}{\Delta t} = F(u^{n+1}), \qquad u = (\ln n_s,\ \mathbf v_i,\ \ln w,\ \phi)
newton
J δ=−r,J:,j≈r(u+ϵjej)−r(u)ϵj,ϵj=10−7max⁡(1,∣uj∣)J\,\delta = -r, \qquad J_{:,j} \approx \frac{r(u + \epsilon_j e_j) - r(u)}{\epsilon_j}, \quad \epsilon_j = 10^{-7}\max(1, |u_j|)
damping
∣δln⁡∣≤2,∣δϕ∣≤2max⁡Te,∣δv∣≤0.5emax⁡Te/M|\delta_{\ln}| \le 2, \qquad |\delta\phi| \le 2\max T_e, \qquad |\delta\mathbf v| \le 0.5\sqrt{e\max T_e/M}
pseudo time
Δt←growth2 Δt after at most 4 iterations, else growth⋅Δt;Δt←Δt/4 after a failure\Delta t \leftarrow \text{growth}^2\,\Delta t \text{ after at most 4 iterations, else growth}\cdot\Delta t; \qquad \Delta t \leftarrow \Delta t/4 \text{ after a failure}
Assumes
  • forward differences on a distance-2 colouring of the cells; the LU (splu) reused while undamped steps shrink fourfold
  • converged when every log change is below 10−1010^{-10} and every linear one below 10−10(1+∣u∣)10^{-10}(1 + |u|); 15 iterations per step, 40 for the steady equations