simsopt.mhd package¶
Submodules¶
simsopt.mhd.boozer module¶
This module provides a class that handles the transformation to Boozer coordinates, and an optimization target for quasisymmetry.
-
class
simsopt.mhd.boozer.
Boozer
(equil: simsopt.mhd.vmec.Vmec, mpol: int = 32, ntor: int = 32)¶ Bases:
simsopt.core.optimizable.Optimizable
This class handles the transformation to Boozer coordinates.
A Boozer instance maintains a set “s”, which is a registry of the surfaces on which other objects want Boozer-coordinate data. When the run() method is called, the Boozer transformation is carried out on all these surfaces. The registry can be cleared at any time by setting the s attribute to {}.
-
get_dofs
()¶ This base Optimizable object has no degrees of freedom, so return an empty array
-
register
(s: Union[float, Iterable[float]]) → None¶ This function is called by objects that depend on this Boozer object, to indicate that they will want Boozer data on the given set of surfaces.
- Parameters
s – 1 or more surfaces on which Boozer data will be requested.
-
run
()¶ Run booz_xform on all the surfaces that have been registered.
-
set_dofs
(x)¶ This base Optimizable object has no degrees of freedom, so do nothing.
-
-
class
simsopt.mhd.boozer.
Quasisymmetry
(boozer: simsopt.mhd.boozer.Boozer, s: Union[float, Iterable[float]], m: int, n: int, normalization: str = 'B00', weight: str = 'even')¶ Bases:
simsopt.core.optimizable.Optimizable
This class is used to compute the departure from quasisymmetry on a given flux surface based on the Boozer spectrum.
-
J
() → Iterable¶ Carry out the calculation of the quasisymmetry error.
-
get_dofs
()¶ This base Optimizable object has no degrees of freedom, so return an empty array
-
set_dofs
(x)¶ This base Optimizable object has no degrees of freedom, so do nothing.
-
-
simsopt.mhd.boozer.
closest_index
(grid: Iterable[float], val: float) → int¶ Given a grid of values, find the grid point that is closest to an abitrary value.
- Parameters
grid – A list of values.
val – We will return the index of the closest grid point to this value.
simsopt.mhd.spec module¶
This module provides a class that handles the SPEC equilibrium code.
-
class
simsopt.mhd.spec.
Residue
(spec, pp, qq, vol=1, theta=0, s_guess=None, s_min=- 1.0, s_max=1.0, rtol=1e-09)¶ Bases:
simsopt.core.optimizable.Optimizable
Greene’s residue, evaluated from a Spec equilibrum
-
J
()¶ Run Spec if needed, find the periodic field line, and return the residue
-
get_dofs
()¶ This base Optimizable object has no degrees of freedom, so return an empty array
-
set_dofs
(x)¶ This base Optimizable object has no degrees of freedom, so do nothing.
-
-
class
simsopt.mhd.spec.
Spec
(filename=None, exe='xspec')¶ Bases:
simsopt.core.optimizable.Optimizable
This class represents the SPEC equilibrium code.
Philosophy regarding mpol and ntor: The Spec object keeps track of mpol and ntor values that are independent of those for the boundary Surface object. If the Surface object has different mpol/ntor values, the Surface’s rbc/zbs arrays are first copied, then truncated or expanded to fit the mpol/ntor values of the Spec object to before Spec is run. Therefore, you may sometimes need to manually change the mpol and ntor values for the Spec object.
-
get_dofs
()¶ This base Optimizable object has no degrees of freedom, so return an empty array
-
iota
()¶ Return the rotational transform in the middle of the volume.
-
run
()¶ Run SPEC, if needed.
-
set_dofs
(x)¶ This base Optimizable object has no degrees of freedom, so do nothing.
-
update_resolution
(mpol, ntor)¶ For convenience, to save “.nml”
-
volume
()¶ Return the volume inside the VMEC last closed flux surface.
-
-
simsopt.mhd.spec.
nested_lists_to_array
(ll)¶ Convert a ragged list of lists to a 2D numpy array. Any entries that are None are replaced by 0.
This function is applied to the RBC and ZBS arrays in the input namelist.
simsopt.mhd.vmec module¶
This module provides a class that handles the VMEC equilibrium code.
-
class
simsopt.mhd.vmec.
Vmec
(filename=None, mpi=None)¶ Bases:
simsopt.core.optimizable.Optimizable
This class represents the VMEC equilibrium code.
-
__repr__
()¶ Print the object in an informative way.
-
aspect
()¶ Return the plasma aspect ratio.
-
get_dofs
()¶ This base Optimizable object has no degrees of freedom, so return an empty array
-
get_max_mn
()¶ Look through the rbc and zbs data in fortran to determine the largest m and n for which rbc or zbs is nonzero.
-
iota_axis
()¶ Return the rotational transform on axis
-
iota_edge
()¶ Return the rotational transform at the boundary
-
load_wout
()¶
-
run
()¶ Run VMEC, if needed.
-
set_dofs
(x)¶ This base Optimizable object has no degrees of freedom, so do nothing.
-
volume
()¶ Return the volume inside the VMEC last closed flux surface.
-