simsopt.mhd

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.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()
set_dofs(x)
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.

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.

simsopt.mhd.vmec.reset_jacdt_flag = 32

value flag-name calls routines to… —– ——— ———————

1 restart_flag reset internal run-control parameters

(for example, if jacobian was bad, to try a smaller time-step)

2 readin_flag read in data from input_file and initialize parameters

or arrays which do not dependent on radial grid size allocate internal grid-dependent arrays used by vmec; initialize internal grid-dependent vmec profiles (xc, iota, etc); setup loop for radial multi-grid meshes or, if ns_index = ictrl_array(4) is > 0, use radial grid points specified by ns_array[ns_index]

4 timestep_flag iterate vmec either by “niter” time steps or until ftol

satisfied, whichever comes first. If numsteps (see below) > 0, vmec will return to caller after numsteps, rather than niter, steps.

8 output_flag write out output files (wout, jxbout)

16 cleanup_flag cleanup (deallocate arrays) - this terminates present

run of the sequence This flag will be ignored if the run might be continued. For example, if ier_flag (see below) returns the value more_iter_flag, the cleanup code will be skipped even if cleanup_flag is set, so that the run could be continued on the next call to runvmec.

32 reset_jacdt_flag Resets ijacobian flag and time step to delt0

thus, setting ictrl_flag = 1+2+4+8+16 will perform ALL the tasks thru cleanup_flag in addition, if ns_index = 0 and numsteps = 0 (see below), vmec will control its own run history

Module contents