Base classes#
Base classes for MHD equilibria.
- class struphy.fields_background.base.FluidEquilibrium[source]#
Bases:
objectBase class for callable fluid equilibria consisting of at least u (velocity), p (pressure) and n (density).
Any child class must provide the following callables:
either
u_xyzor overrideuveither
p_xyzor overridep0either
n_xyzor overriden0
- property params: dict#
Parameters passed to __init__() of the class in equils.py, as dictionary.
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- uv(*etas, squeeze_out=False)[source]#
Contra-variant components of velocity on logical cube [0, 1]^3.
- u_cart(*etas, squeeze_out=False)[source]#
Cartesian components of velocity evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- s0_monoatomic(*etas, squeeze_out=False)[source]#
0-form entropy density on logical cube [0, 1]^3. Hard coded assumption : gamma = 5/3 (monoatomic perfect gaz)
- s3_monoatomic(*etas, squeeze_out=False)[source]#
3-form entropy density on logical cube [0, 1]^3. Hard coded assumption : gamma = 5/3 (monoatomic perfect gaz)
- s0_diatomic(*etas, squeeze_out=False)[source]#
0-form entropy density on logical cube [0, 1]^3. Hard coded assumption : gamma = 7/5 (diatomic perfect gaz)
- class struphy.fields_background.base.CartesianFluidEquilibrium[source]#
Bases:
FluidEquilibriumThe callables
u_xyz,p_xyzandn_xyzmust be provided in Cartesian coordinates.- abstract u_xyz(x, y, z)[source]#
Cartesian velocity in physical space. Must return the components as a tuple.
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- class struphy.fields_background.base.LogicalFluidEquilibrium[source]#
Bases:
FluidEquilibriumThe callables
uv,p0andn0must be provided on the logical cube [0, 1]^3.- abstract uv(*etas, squeeze_out=False)[source]#
Contra-variant (vector field) velocity on logical cube [0, 1]^3. Must return the components as a tuple.
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- class struphy.fields_background.base.NumericalFluidEquilibrium[source]#
Bases:
LogicalFluidEquilibriumMust provide a (numerical) mapping from the logical cube [0, 1]^3 to the physical domain. Overrides base class domain.
- abstract property numerical_domain#
Numerically computed mapping from the logical cube [0, 1]^3 to the physical domain in the form of a
Domainobject.
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- class struphy.fields_background.base.FluidEquilibriumWithB[source]#
Bases:
FluidEquilibriumFluidEquilibrium with B (magnetic field) in addition.
Any child class must provide the following callables:
either
b_xyzor overridebveither
gradB_xyzor overridegradB1
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- bv(*etas, squeeze_out=False)[source]#
Contra-variant components of magnetic field on logical cube [0, 1]^3.
- b_cart(*etas, squeeze_out=False)[source]#
Cartesian components of magnetic field evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- unit_b1(*etas, squeeze_out=False)[source]#
Unit vector components of magnetic field (1-form) on logical cube [0, 1]^3.
- unit_b2(*etas, squeeze_out=False)[source]#
Unit vector components of magnetic field (2-form) on logical cube [0, 1]^3.
- unit_bv(*etas, squeeze_out=False)[source]#
Unit vector components of magnetic field (contra-variant) on logical cube [0, 1]^3.
- unit_b_cart(*etas, squeeze_out=False)[source]#
Unit vector Cartesian components of magnetic field evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- gradB1(*etas, squeeze_out=False)[source]#
1-form components of gradient of magnetic field strength evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- gradB2(*etas, squeeze_out=False)[source]#
2-form components of gradient of magnetic field strength evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- gradBv(*etas, squeeze_out=False)[source]#
Contra-variant components of gradient of magnetic field strength evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- gradB_cart(*etas, squeeze_out=False)[source]#
Cartesian components of gradient of magnetic field strength evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- a1(*etas, squeeze_out=False)[source]#
1-form components of vector potential on logical cube [0, 1]^3.
- a2(*etas, squeeze_out=False)[source]#
2-form components of vector potential on logical cube [0, 1]^3.
- av(*etas, squeeze_out=False)[source]#
Contra-variant components of vector potneital on logical cube [0, 1]^3.
- absB0(*etas, squeeze_out=False)[source]#
0-form absolute value of magnetic field on logical cube [0, 1]^3.
- class struphy.fields_background.base.CartesianFluidEquilibriumWithB[source]#
Bases:
CartesianFluidEquilibriumThe callables
b_xyzandgradB_xyzmust be provided in Cartesian coordinates.- abstract b_xyz(x, y, z)[source]#
Cartesian magnetic field in physical space. Must return the components as a tuple.
- abstract gradB_xyz(x, y, z)[source]#
Cartesian gradient of magnetic field strength in physical space. Must return the components as a tuple.
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- class struphy.fields_background.base.LogicalFluidEquilibriumWithB[source]#
Bases:
LogicalFluidEquilibriumThe callable
bvmust be provided on the logical cube [0, 1]^3.- abstract bv(*etas, squeeze_out=False)[source]#
Contra-variant (vector field) magnetic field on logical cube [0, 1]^3. Must return the components as a tuple.
- abstract gradB1(*etas, squeeze_out=False)[source]#
Co-variant (1-from) gradient of magnetic field strength on logical cube [0, 1]^3. Must return the components as a tuple.
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- class struphy.fields_background.base.NumericalFluidEquilibriumWithB[source]#
Bases:
LogicalFluidEquilibriumWithBMust provide a (numerical) mapping from the logical cube [0, 1]^3 to the physical domain. Overrides base class domain.
- abstract property numerical_domain#
Numerically computed mapping from the logical cube [0, 1]^3 to the physical domain in the form of a
Domainobject.
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- class struphy.fields_background.base.MHDequilibrium[source]#
Bases:
FluidEquilibriumWithBFluidEquilibriumWithB with j (current density) in addition. The mean velocity is returned as j/n (overriding the base class).
Any child class must provide the following callables:
either
j_xyzor overridejv
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- jv(*etas, squeeze_out=False)[source]#
Contra-variant components of current on logical cube [0, 1]^3.
- j_cart(*etas, squeeze_out=False)[source]#
Cartesian components of current evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- u1(*etas, squeeze_out=False)[source]#
1-form components of mean velocity evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- u2(*etas, squeeze_out=False)[source]#
2-form components of mean velocity evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- uv(*etas, squeeze_out=False)[source]#
Contra-variant components of mean velocity evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- u_cart(*etas, squeeze_out=False)[source]#
Cartesian components of mean velocity evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- curl_unit_b1(*etas, squeeze_out=False)[source]#
1-form components of curl of unit magnetic field evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- curl_unit_b2(*etas, squeeze_out=False)[source]#
2-form components of curl of unit magnetic field evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- curl_unit_bv(*etas, squeeze_out=False)[source]#
Contra-variant components of curl of unit magnetic field evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- curl_unit_b_cart(*etas, squeeze_out=False)[source]#
Cartesian components of curl of unit magnetic field evaluated on logical cube [0, 1]^3. Returns also (x,y,z).
- curl_unit_b_dot_b0(*etas, squeeze_out=False)[source]#
0-form of \((\nabla \times \mathbf b_0) \times \mathbf b_0\) evaluated on logical cube [0, 1]^3.
- show(n1=16, n2=33, n3=21, n_planes=5)[source]#
Generate vtk files of equilibirum and do some 2d plots with matplotlib.
- Parameters:
n1 (int) – Evaluation points of mapping in each direcion.
n2 (int) – Evaluation points of mapping in each direcion.
n3 (int) – Evaluation points of mapping in each direcion.
n_planes (int) – Number of planes to show perpendicular to eta3.
- class struphy.fields_background.base.CartesianMHDequilibrium[source]#
Bases:
MHDequilibriumThe callables
b_xyz,j_xyz,p_xyz,n_xyzandgradB_xyzmust be provided in Cartesian coordinates.- abstract b_xyz(x, y, z)[source]#
Cartesian magnetic field in physical space. Must return the components as a tuple.
- abstract j_xyz(x, y, z)[source]#
Cartesian current (curl of magnetic field) in physical space. Must return the components as a tuple.
- abstract gradB_xyz(x, y, z)[source]#
Cartesian gradient of magnetic field strength in physical space. Must return the components as a tuple.
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- class struphy.fields_background.base.AxisymmMHDequilibrium[source]#
Bases:
CartesianMHDequilibriumBase class for ideal axisymmetric MHD equilibria based on a poloidal flux function \(\psi(R, Z)\) and a toroidal field function \(g_{tor}(R, Z)\) in a cylindrical coordinate system \((R, \phi, Z)\).
The magnetic field and current density are then given by
\[\mathbf B = \nabla \psi \times \nabla \phi + g_{tor} \nabla \phi\,,\qquad \mathbf j = \nabla \times \mathbf B\,.\]The pressure and density profiles need to be implemented by child classes.
- abstract psi(R, Z, dR=0, dZ=0)[source]#
Poloidal flux function per radian. First AND second derivatives dR=0,1,2 and dZ=0,1,2 must be implemented.
- abstract g_tor(R, Z, dR=0, dZ=0)[source]#
Toroidal field function. First derivatives dR=0,1 and dZ=0,1 must be implemented.
- abstract property psi_range#
Psi on-axis and at plasma boundary returned as list [psi_axis, psi_boundary].
- abstract property psi_axis_RZ#
Location of magnetic axis in R-Z-coordinates returned as list [psi_axis_R, psi_axis_Z].
- b_xyz(x, y, z)[source]#
Cartesian B-field components calculated as BR = -(dpsi/dZ)/R, BPhi = g_tor/R, BZ = (dpsi/dR)/R.
- gradB_xyz(x, y, z)[source]#
Cartesian gradient |B| components calculated as grad(sqrt(BR**2 + BPhi**2 + BZ**2)).
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- class struphy.fields_background.base.LogicalMHDequilibrium[source]#
Bases:
MHDequilibriumThe callables
bv,jv,p0,n0andgradB1must be provided on the logical cube [0, 1]^3.- abstract bv(*etas, squeeze_out=False)[source]#
Contra-variant (vector field) magnetic field on logical cube [0, 1]^3. Must return the components as a tuple.
- abstract jv(*etas, squeeze_out=False)[source]#
Contra-variant (vector field) current density (=curl B) on logical cube [0, 1]^3. Must return the components as a tuple.
- abstract p0(*etas, squeeze_out=False)[source]#
0-form pressure on logical cube [0, 1]^3. Must return the components as a tuple.
- abstract gradB1(*etas, squeeze_out=False)[source]#
1-form gradient of magnetic field strength strength on logical cube [0, 1]^3. Must return the components as a tuple.
- property domain#
Domain object that characterizes the mapping from the logical to the physical domain.
- class struphy.fields_background.base.NumericalMHDequilibrium[source]#
Bases:
LogicalMHDequilibriumMust provide a (numerical) mapping from the logical cube [0, 1]^3 to the physical domain. Overrides base class domain.