Skip to content
Projects

Mhd

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

hlld_flux

functionsource

The HLLD flux through faces between two states.

speeds
SL=min⁡(uL,uR)−max⁡(cfL,cfR),SR=max⁡(uL,uR)+max⁡(cfL,cfR),SL∗=SM−∣Bn∣ρL∗,SR∗=SM+∣Bn∣ρR∗S_L = \min(u_L, u_R) - \max(c_{fL}, c_{fR}), \quad S_R = \max(u_L, u_R) + \max(c_{fL}, c_{fR}), \quad S_L^* = S_M - \frac{|B_n|}{\sqrt{\rho_L^*}}, \quad S_R^* = S_M + \frac{|B_n|}{\sqrt{\rho_R^*}}
contact
SM=(SR−uR)ρRuR−(SL−uL)ρLuL−pTR+pTL(SR−uR)ρR−(SL−uL)ρLS_M = \frac{(S_R - u_R)\rho_R u_R - (S_L - u_L)\rho_L u_L - p_{TR} + p_{TL}}{(S_R - u_R)\rho_R - (S_L - u_L)\rho_L}
star
ρK∗=ρKSK−uKSK−SM,vtK∗=vtK−BnBtKSM−uKρK(SK−uK)(SK−SM)−Bn2,BtK∗=BtKρK(SK−uK)2−Bn2ρK(SK−uK)(SK−SM)−Bn2\rho^*_K = \rho_K\frac{S_K - u_K}{S_K - S_M}, \quad \mathbf v^*_{tK} = \mathbf v_{tK} - B_n\mathbf B_{tK}\frac{S_M - u_K}{\rho_K(S_K - u_K)(S_K - S_M) - B_n^2}, \quad \mathbf B^*_{tK} = \mathbf B_{tK}\frac{\rho_K(S_K - u_K)^2 - B_n^2}{\rho_K(S_K - u_K)(S_K - S_M) - B_n^2}
double star
vt∗∗=ρL∗vtL∗+ρR∗vtR∗+(BtR∗−BtL∗)sgn⁡BnρL∗+ρR∗\mathbf v^{**}_t = \frac{\sqrt{\rho_L^*}\mathbf v^*_{tL} + \sqrt{\rho_R^*}\mathbf v^*_{tR} + (\mathbf B^*_{tR} - \mathbf B^*_{tL})\operatorname{sgn}B_n}{\sqrt{\rho_L^*} + \sqrt{\rho_R^*}}
Assumes
  • ideal MHD, a gamma-law gas; the normal field is one value on both sides of the face
  • where the star denominator vanishes (B_t = 0 and B_n^2 = rho (S - u)(S - S_M)) the tangential velocity and field keep their values
References

MHD2D

classsource

MHD (2.5D) on the patches of a patchwork hierarchy; see the module docstring.

mass
∂tρ+∇⋅(ρu)=0\partial_t\rho + \nabla\cdot(\rho\mathbf u) = 0
momentum
∂t(ρu)+∇⋅(ρuu+pTI−BB)=0,pT=p+12∣B∣2\partial_t(\rho\mathbf u) + \nabla\cdot\big(\rho\mathbf u\mathbf u + p_T\mathbf I - \mathbf B\mathbf B\big) = 0, \qquad p_T = p + \tfrac12|\mathbf B|^2
energy
∂tE+∇⋅((E+pT)u−(u⋅B)B)=0,E=pγ−1+12ρ∣u∣2+12∣B∣2\partial_t E + \nabla\cdot\big((E + p_T)\mathbf u - (\mathbf u\cdot\mathbf B)\mathbf B\big) = 0, \qquad E = \frac{p}{\gamma - 1} + \tfrac12\rho|\mathbf u|^2 + \tfrac12|\mathbf B|^2
field
Bx=B0x+∂yAz,By=B0y−∂xAz,∂tAz=−Ez=uxBy−uyBx−ηJz,∂tBz+∇⋅(Bzu−uzB)=η∇2BzB_x = B_{0x} + \partial_y A_z, \quad B_y = B_{0y} - \partial_x A_z, \quad \partial_t A_z = -E_z = u_x B_y - u_y B_x - \eta J_z, \quad \partial_t B_z + \nabla\cdot(B_z\mathbf u - u_z\mathbf B) = \eta\nabla^2 B_z
resistive
E+=ηJ,J=∇×B,energy flux+=η J×B\mathbf E \mathrel{+}= \eta\mathbf J, \quad \mathbf J = \nabla\times\mathbf B, \quad \text{energy flux} \mathrel{+}= \eta\,\mathbf J\times\mathbf B
conduction
q=−κ∥b(b⋅∇T)−κ⊥∇T,T=p/ρ,∂yT∣x-face=MC(MC(δi−1+,δi−1−),MC(δi+,δi−))\mathbf q = -\kappa_\parallel\mathbf b(\mathbf b\cdot\nabla T) - \kappa_\perp\nabla T, \quad T = p/\rho, \quad \partial_y T|_{x\text{-face}} = \mathrm{MC}\big(\mathrm{MC}(\delta^+_{i-1}, \delta^-_{i-1}), \mathrm{MC}(\delta^+_i, \delta^-_i)\big)
gravity
∂t(ρu)+=ρg,∂tE+=ρu⋅g\partial_t(\rho\mathbf u) \mathrel{+}= \rho\mathbf g, \qquad \partial_t E \mathrel{+}= \rho\mathbf u\cdot\mathbf g
walls
mirrored halo, un→−un,Az(w−k)=2Az(w)−Az(w+k),Ez∣w=0\text{mirrored halo}, \ u_n \to -u_n, \quad A_z(w - k) = 2A_z(w) - A_z(w + k), \quad E_z|_w = 0
ct contact
Ez=14(∑facesEzf)+14(∑4 half-faces(Ezf−Ezc)upwind)E_z = \tfrac14\big(\textstyle\sum_\text{faces} E_z^f\big) + \tfrac14\big(\textstyle\sum_\text{4 half-faces} (E_z^f - E_z^c)_\text{upwind}\big)
Order
2
Assumes
  • MHD in the plane with three velocity and field components; Heaviside–Lorentz units (μ0=1\mu_0 = 1); uniform resistivity η\eta, explicit
  • in-plane field from a nodal AzA_z: zero discrete divergence per cell and on the composite mesh, to round-off
  • MUSCL on the primitives, HLLD, CT-contact electric field, Heun (SSP-RK2) at CFL 0.4; refluxing at coarse–fine faces
  • Cartesian, uniform levels, one time step for all levels; periodic, outflow or conducting-wall faces; regridding interpolates AzA_z bilinearly
  • uniform κ∥\kappa_\parallel, κ⊥\kappa_\perp and g\mathbf g; Sharma–Hammett limited transverse gradients; gravity not well balanced
  • the order is that of a smooth Alfvén wave with the unlimited reconstruction
References
Built from