Toy models#
Simple toy models for testing.
- class struphy.models.toy.Maxwell[source]#
Bases:
StruphyModelMaxwell’s equations in vacuum.
\[\hat E = c \hat B\,.\]\[ \begin{align}\begin{aligned}&\frac{\partial \mathbf E}{\partial t} - \nabla\times\mathbf B = 0\,,\\&\frac{\partial \mathbf B}{\partial t} + \nabla\times\mathbf E = 0\,.\end{aligned}\end{align} \]Propagators (called in sequence):
- class EMFields[source]#
Bases:
FieldSpecies
- class struphy.models.toy.Vlasov[source]#
Bases:
StruphyModelVlasov equation in static background magnetic field.
\[\hat v = \hat \Omega_\textnormal{c} \hat x\,.\]\[\frac{\partial f}{\partial t} + \mathbf{v} \cdot \nabla f + \left(\mathbf{v}\times\mathbf{B}_0 \right) \cdot \frac{\partial f}{\partial \mathbf{v}} = 0\,.\]Propagators (called in sequence):
- class KineticIons[source]#
Bases:
ParticleSpecies
- class struphy.models.toy.GuidingCenter[source]#
Bases:
StruphyModelGuiding-center equation in static background magnetic field.
\[\hat v = \hat v_\textnormal{A} \,.\]\[\frac{\partial f}{\partial t} + \left[ v_\parallel \frac{\mathbf{B}^*}{B^*_\parallel} + \frac{\mathbf{E}^* \times \mathbf{b}_0}{B^*_\parallel}\right] \cdot \frac{\partial f}{\partial \mathbf{X}} + \left[\frac{1}{\epsilon} \frac{\mathbf{B}^*}{B^*_\parallel} \cdot \mathbf{E}^*\right] \cdot \frac{\partial f}{\partial v_\parallel} = 0\,.\]where \(f(\mathbf{X}, v_\parallel, \mu, t)\) is the guiding center distribution and
\[\mathbf{E}^* = -\epsilon \mu \nabla |B_0| \,, \qquad \mathbf{B}^* = \mathbf{B}_0 + \epsilon v_\parallel \nabla \times \mathbf{b}_0 \,,\qquad B^*_\parallel = \mathbf B^* \cdot \mathbf b_0 \,.\]Moreover,
\[\epsilon = \frac{1 }{ \hat \Omega_{\textnormal{c}} \hat t}\,,\qquad \textnormal{with} \qquad\hat \Omega_{\textnormal{c}} = \frac{Ze \hat B}{A m_\textnormal{H}}\,.\]Propagators (called in sequence):
- class KineticIons[source]#
Bases:
ParticleSpecies
- class struphy.models.toy.ShearAlfven[source]#
Bases:
StruphyModelShearAlfven propagator from
LinearMHDwith zero-flow equilibrium (\(\mathbf U_0 = 0\)).\[\hat U = \hat v_\textnormal{A} \,.\]\[ \begin{align}\begin{aligned}\rho_0&\frac{\partial \tilde{\mathbf{U}}}{\partial t} =(\nabla\times \tilde{\mathbf{B}})\times\mathbf{B}_0\,,\\&\frac{\partial \tilde{\mathbf{B}}}{\partial t} - \nabla\times(\tilde{\mathbf{U}} \times \mathbf{B}_0) = 0\,.\end{aligned}\end{align} \]Propagators (called in sequence):
- class EMFields[source]#
Bases:
FieldSpecies
- class MHD[source]#
Bases:
FluidSpecies
- class struphy.models.toy.VariationalPressurelessFluid[source]#
Bases:
StruphyModelPressure-less fluid equations discretized with a variational method.
\[\hat u = \hat v_\textnormal{A} \,.\]\[\begin{split}&\partial_t \rho + \nabla \cdot ( \rho \mathbf u ) = 0 \,, \\[4mm] &\partial_t (\rho \mathbf u) + \nabla \cdot (\rho \mathbf u \otimes \mathbf u) = 0 \,.\end{split}\]Propagators (called in sequence):
- class Fluid[source]#
Bases:
FluidSpecies
- generate_default_parameter_file(path=None, prompt=True)[source]#
Generate a parameter file with default options for each species, and save it to the current input path.
The default name is params_<model_name>.yml.
- Parameters:
path (str) – Alternative path to getcwd()/params_MODEL.py.
prompt (bool) – Whether to prompt for overwriting the specified .yml file.
- Returns:
params_path – The path of the parameter file.
- Return type:
str
- class struphy.models.toy.VariationalBarotropicFluid[source]#
Bases:
StruphyModelBarotropic fluid equations discretized with a variational method.
\[\hat u = \hat v_\textnormal{A} \qquad \hat{\mathcal U} = \frac{\hat \rho}{2} \,.\]\[\begin{split}&\partial_t \rho + \nabla \cdot ( \rho \mathbf u ) = 0 \,, \\[4mm] &\partial_t (\rho \mathbf u) + \nabla \cdot (\rho \mathbf u \otimes \mathbf u) + \rho \nabla \frac{(\rho \mathcal U (\rho))}{\partial \rho} = 0 \,.\end{split}\]where the internal energy per unit mass is \(\mathcal U(\rho) = \rho/2\).
Propagators (called in sequence):
- class Fluid[source]#
Bases:
FluidSpecies
- generate_default_parameter_file(path=None, prompt=True)[source]#
Generate a parameter file with default options for each species, and save it to the current input path.
The default name is params_<model_name>.yml.
- Parameters:
path (str) – Alternative path to getcwd()/params_MODEL.py.
prompt (bool) – Whether to prompt for overwriting the specified .yml file.
- Returns:
params_path – The path of the parameter file.
- Return type:
str
- class struphy.models.toy.VariationalCompressibleFluid[source]#
Bases:
StruphyModelFully compressible fluid equations discretized with a variational method.
\[\hat u = \hat v_\textnormal{A}\,, \qquad \hat{\mathcal U} = K\,,\qquad \hat s = \hat \rho C_v \,.\]\[\begin{split}&\partial_t \rho + \nabla \cdot ( \rho \mathbf u ) = 0 \,, \\[4mm] &\partial_t (\rho \mathbf u) + \nabla \cdot (\rho \mathbf u \otimes \mathbf u) + \rho \nabla \frac{(\rho \mathcal U (\rho, s))}{\partial \rho} + s \nabla \frac{(\rho \mathcal U (\rho, s))}{\partial s} = 0 \,, \\[4mm] &\partial_t s + \nabla \cdot ( s \mathbf u ) = 0 \,,\end{split}\]where the internal energy per unit mass is \(\mathcal U(\rho) = \rho^{\gamma-1} \exp(s / \rho)\).
Propagators (called in sequence):
- class Fluid[source]#
Bases:
FluidSpecies
- generate_default_parameter_file(path=None, prompt=True)[source]#
Generate a parameter file with default options for each species, and save it to the current input path.
The default name is params_<model_name>.yml.
- Parameters:
path (str) – Alternative path to getcwd()/params_MODEL.py.
prompt (bool) – Whether to prompt for overwriting the specified .yml file.
- Returns:
params_path – The path of the parameter file.
- Return type:
str
- class struphy.models.toy.Poisson[source]#
Bases:
StruphyModelWeak discretization of Poisson’s equation with diffusion matrix, stabilization and time-depedent right-hand side.
\[\hat D = \frac{\hat n}{\hat x^2}\,,\qquad \hat \rho = \hat n \,.\]Equations: Find \(\phi \in H^1\) such that
\[- \nabla \cdot D_0(\mathbf x) \nabla \phi + n_0(\mathbf x) \phi = \rho(t, \mathbf x)\,,\]where \(n_0, \rho(t):\Omega \to \mathbb R\) are real-valued functions, \(\rho(t)\) parametrized with time \(t\), and \(D_0:\Omega \to \mathbb R^{3\times 3}\) is a positive matrix. Boundary terms from integration by parts are assumed to vanish.
Propagators (called in sequence):
- class EMFields[source]#
Bases:
FieldSpecies
- generate_default_parameter_file(path=None, prompt=True)[source]#
Generate a parameter file with default options for each species, and save it to the current input path.
The default name is params_<model_name>.yml.
- Parameters:
path (str) – Alternative path to getcwd()/params_MODEL.py.
prompt (bool) – Whether to prompt for overwriting the specified .yml file.
- Returns:
params_path – The path of the parameter file.
- Return type:
str
- class struphy.models.toy.DeterministicParticleDiffusion[source]#
Bases:
StruphyModelDiffusion equation discretized with a deterministic particle method; the solution is \(L^2\)-projected onto \(V^0 \subset H^1\) to compute the flux.
\[\hat D := \frac{\hat x^2}{\hat t } \,.\]Equations: Find \(u:\mathbb R\times \Omega\to \mathbb R^+\) such that
\[\frac{\partial u}{\partial t} + \nabla \cdot\left(\mathbf F(u) u\right) = 0\,, \qquad \mathbf F(u) = -\mathbb D\,\frac{\nabla u}{u}\,,\]where \(\mathbb D: \Omega\to \mathbb R^{3\times 3 }\) is a positive diffusion matrix. At the moment only matrices of the form \(D*Id\) are implemented, where \(D > 0\) is a positive diffusion coefficient.
Propagators (called in sequence):
- class Hydrogen[source]#
Bases:
ParticleSpecies
- class struphy.models.toy.RandomParticleDiffusion[source]#
Bases:
StruphyModelDiffusion equation discretized with a (random) particle method; the diffusion is computed through a Wiener process.
\[\hat D := \frac{\hat x^2}{\hat t } \,.\]Equations: Find \(u:\mathbb R\times \Omega\to \mathbb R^+\) such that
\[\frac{\partial u}{\partial t} - D \, \Delta u = 0\,,\]where \(D > 0\) is a positive diffusion coefficient.
Propagators (called in sequence):
- class Hydrogen[source]#
Bases:
ParticleSpecies
- class struphy.models.toy.PressureLessSPH[source]#
Bases:
StruphyModelPressureless fluid discretized with smoothed particle hydrodynamics
\[\begin{split}&\partial_t \rho + \nabla \cdot ( \rho \mathbf u ) = 0 \,, \\[4mm] &\partial_t (\rho \mathbf u) + \nabla \cdot (\rho \mathbf u \otimes \mathbf u) = - \nabla \phi_0 \,,\end{split}\]where \(\phi_0\) is a static external potential.
Propagators (called in sequence):
This is discretized by particles going in straight lines.
- class ColdFluid[source]#
Bases:
ParticleSpecies
- generate_default_parameter_file(path=None, prompt=True)[source]#
Generate a parameter file with default options for each species, and save it to the current input path.
The default name is params_<model_name>.yml.
- Parameters:
path (str) – Alternative path to getcwd()/params_MODEL.py.
prompt (bool) – Whether to prompt for overwriting the specified .yml file.
- Returns:
params_path – The path of the parameter file.
- Return type:
str
- class struphy.models.toy.TwoFluidQuasiNeutralToy[source]#
Bases:
StruphyModelLinearized, quasi-neutral two-fluid model with zero electron inertia.
\[\hat u = \hat v_\textnormal{th}\,,\qquad e\hat \phi = m \hat v_\textnormal{th}^2\,.\]\[\begin{split}\frac{\partial \mathbf u}{\partial t} &= - \nabla \phi + \frac{\mathbf u \times \mathbf B_0}{\varepsilon} + \nu \Delta \mathbf u + \mathbf f\,, \\[2mm] 0 &= \nabla \phi - \frac{\mathbf u_e \times \mathbf B_0}{\varepsilon} + \nu_e \Delta \mathbf u_e + \mathbf f_e \,, \\[3mm] \nabla & \cdot (\mathbf u - \mathbf u_e) = 0\,,\end{split}\]where \(\mathbf B_0\) is a static magnetic field and \(\mathbf f, \mathbf f_e\) are given forcing terms, and with the normalization parameter
\[\varepsilon = \frac{1}{\hat \Omega_\textnormal{c} \hat t} \,,\qquad \textnormal{with} \,,\qquad \hat \Omega_{\textnormal{c}} = \frac{(Ze) \hat B}{(A m_\textnormal{H})}\,,\]Propagators (called in sequence):
References
[1] Juan Vicente Gutiérrez-Santacreu, Omar Maj, Marco Restelli: Finite element discretization of a Stokes-like model arising in plasma physics, Journal of Computational Physics 2018.
- class EMfields[source]#
Bases:
FieldSpecies
- class Ions[source]#
Bases:
FluidSpecies
- class Electrons[source]#
Bases:
FluidSpecies
- generate_default_parameter_file(path=None, prompt=True)[source]#
Generate a parameter file with default options for each species, and save it to the current input path.
The default name is params_<model_name>.yml.
- Parameters:
path (str) – Alternative path to getcwd()/params_MODEL.py.
prompt (bool) – Whether to prompt for overwriting the specified .yml file.
- Returns:
params_path – The path of the parameter file.
- Return type:
str