spectre.file_io.input_parameters ================================ .. py:module:: spectre.file_io.input_parameters .. autoapi-nested-parse:: Define the data models for SPEC input parameters using Pydantic. The model uses serializers to generate human-readable files for writing with toml (in toml_io.py), and uses validators to cast incoming data into the format expected by SPEC, which are numpy arrays of much larger sizes. Module Contents --------------- .. py:data:: mnvol :value: 256 .. py:data:: mmpol :value: 128 .. py:data:: mntor :value: 128 .. py:data:: mnmax :value: 33025 .. py:data:: arrays_of_length_nvol :value: ['pressure', 'adiabatic', 'mu', 'isurf'] .. py:data:: arrays_of_length_mvol :value: ['lrad', 'tflux', 'ivolume', 'pflux', 'helicity', 'pl', 'ql', 'pr', 'qr', 'lp', 'lq', 'rp', 'rq'] .. py:data:: arrays_of_length_mvol_plus :value: ['iota', 'oita'] .. py:data:: arrays_of_length_nvol_minus_1 :value: [] .. py:data:: arrays_fourier :value: ['rbc', 'zbs', 'rbs', 'zbc', 'rwc', 'zws', 'rws', 'zwc', 'vns', 'bns', 'vnc', 'bnc'] .. py:class:: PhysicsParameters Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: igeometry :type: int .. py:attribute:: nfp :type: int :value: 1 .. py:attribute:: nvol :type: int :value: 1 .. py:attribute:: mpol :type: int :value: 0 .. py:attribute:: ntor :type: int :value: 0 .. py:attribute:: lconstraint :type: int :value: -1 .. py:attribute:: mupfits :type: int :value: 8 .. py:attribute:: ladiabatic :type: int :value: 0 .. py:attribute:: num_modes :type: int .. py:attribute:: mupftol :type: float :value: 1e-14 .. py:attribute:: rpol :type: float :value: 1.0 .. py:attribute:: rtor :type: float :value: 1.0 .. py:attribute:: lreflect :type: int :value: 0 .. py:attribute:: lbdybnzero :type: bool :value: True .. py:attribute:: lbnszero :type: bool :value: False .. py:attribute:: lfreebound :type: int :value: 0 .. py:attribute:: phiedge :type: float :value: 1.0 .. py:attribute:: curtor :type: float :value: 0.0 .. py:attribute:: curpol :type: float :value: 0.0 .. py:attribute:: gamma :type: float :value: 0.0 .. py:attribute:: pscale :type: float :value: 0.0 .. py:attribute:: enforce_stell_sym :type: bool :value: True .. py:attribute:: lrad :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: pl :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: ql :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: pr :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: qr :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: lp :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: lq :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: rp :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: rq :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: tflux :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: pflux :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: pressure :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: adiabatic :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: mu :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: ivolume :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: iota :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: oita :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: isurf :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: helicity :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: rac :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: zas :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: ras :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: zac :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: rbc :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: zbs :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: rbs :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: zbc :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: rwc :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: zws :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: rws :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: zwc :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: vns :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: bns :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: vnc :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: bnc :type: numpy.typing.NDArray[numpy.float64] .. py:attribute:: allrzrz :type: numpy.typing.NDArray[numpy.float64] :value: None .. py:attribute:: mmrzrz :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: nnrzrz :type: numpy.typing.NDArray[numpy.int32] .. py:attribute:: model_config .. py:method:: serialize_radial_arrays_nvol(value) serialize the radial arrays that provide a value for each volume/interface internal to the configuration .. py:method:: serialize_radial_arrays_mvol(value) serialize the arrays that are not always nvol long but depending on freeboundary can be one longer (are thus defined in the vacuum region enclosing the plasma). .. py:method:: serialize_radial_arrays_mvol_plus(value) serialize the arrays that are not always nvol long but depending on freeboundary can be one longer (are thus defined in the vacuum region enclosing the plasma). .. py:method:: serialize_radial_arrays_nvol_minus_1(value) serialize the radial arrays that are only nvol-1 long .. py:method:: serialize_toroidal_arrays(value) .. py:method:: serialize_fourier_arrays(value) .. py:method:: serialize_guess(allrzrz) The interface guess is stored in allrzrz with index helper arrays mmrzrz and nnrzrz. Our job is to reconstruct a human readable mapping from this. This helper array has the shape it has because it was dumped at the end of the namelist. In the future this will be deprecated for direct writing of the interface guesses one by one. .. py:method:: set_guess(values) :classmethod: prepare the allrzrz array from the input mapping if provided. don't judge me, this keeps the toml file with a clean, readable guess, and keeps the changes to the interface to the SPEC fortran side minimal. In the future the input_list_mod will (hopefully) be replaced with a interface_mod that passes all relevant information for the SPEC state to the FORTRAN memory, allowing switching between configurations without running all intialization steps... .. py:method:: pad_radial_int_arrays(value) pad the 1D int arrays to the SPEC expected size .. py:method:: pad_radial_float_arrays_mnvolplus(value) pad the 1D float arrays to the SPEC expected size .. py:method:: pad_radial_float_arrays_mnvol(value) pad the 1D float arrays to the SPEC expected size .. py:method:: pad_toroidal_arrays(value) pad the 1D toroidal arrays to the SPEC expected size .. py:method:: pad_fourier_arrays(value) pad the 2D fourier arrays to the SPEC expected size. .. py:method:: pad_fourier_arrays_input() pad the fourier arrays to the spec expected size if they were not suppied as a nested dict (for example if read as a namelist or supplied by a different code). The array is expected to be of shape (ntor_input+1, 2*mpol_input+1) (VMEC convention) with negative m values stored in the upper half of the second axis. .. py:method:: check_correct_fields_provided(values) :classmethod: ensure that depending on lconstraint, the necessary info was provided .. py:class:: NumericParameters Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: linitialize :type: int :value: 0 .. py:attribute:: lchangeangle :type: bool :value: False .. py:attribute:: lautoinitbn :type: int :value: 1 .. py:attribute:: lzerovac :type: int :value: 0 .. py:attribute:: ndiscrete :type: int :value: 2 .. py:attribute:: nquad :type: int :value: -1 .. py:attribute:: impol :type: int :value: -4 .. py:attribute:: intor :type: int :value: -4 .. py:attribute:: lsparse :type: int :value: 0 .. py:attribute:: lsvdiota :type: int :value: 0 .. py:attribute:: lrzaxis :type: int :value: 1 .. py:attribute:: ntoraxis :type: int :value: 3 .. py:attribute:: lvcgrid :type: int :value: 0 .. py:class:: GlobalParameters Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: escale :type: float :value: 0.0 .. py:attribute:: opsilon :type: float :value: 1.0 .. py:attribute:: pcondense :type: float :value: 2.0 .. py:attribute:: epsilon :type: float :value: 0.0 .. py:attribute:: wpoloidal :type: float :value: 1.0 .. py:attribute:: upsilon :type: float :value: 1.0 .. py:attribute:: mfreeits :type: int :value: 0 .. py:attribute:: gbntol :type: float :value: 1e-06 .. py:attribute:: gbnbld :type: float :value: 0.666 .. py:attribute:: vcasingeps :type: float :value: 1e-12 .. py:attribute:: vcasingtol :type: float :value: 1e-08 .. py:attribute:: vcasingits :type: int :value: 8 .. py:attribute:: vcasingper :type: int :value: 1 .. py:attribute:: vcnt :type: int :value: 256 .. py:attribute:: vcnz :type: int :value: 256 .. py:class:: DiagnosticsParameters Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: odetol :type: float :value: 1e-07 .. py:attribute:: nppts :type: int :value: 0 .. py:attribute:: ppts :type: float :value: 0.0 .. py:attribute:: nptrj :type: int | numpy.typing.NDArray[numpy.int32] .. py:attribute:: lhevalues :type: bool :value: False .. py:attribute:: lhevectors :type: bool :value: False .. py:attribute:: lhmatrix :type: bool :value: False .. py:attribute:: lerrortype :type: int :value: 0 .. py:attribute:: ngrid :type: int :value: -1 .. py:attribute:: lcheck :type: int :value: 0 .. py:attribute:: ltransform :type: bool :value: False .. py:attribute:: model_config .. py:method:: pad_nptrj(value) pad the 1D toroidal arrays to the SPEC expected size .. py:method:: serialize_nptrj(value) Serialize the 1D toroidal arrays to the SPEC expected format .. py:class:: ScreenParameters Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: wmanual :type: bool :value: False .. py:attribute:: wrzaxis :type: bool :value: False .. py:attribute:: wpackxi :type: bool :value: False .. py:attribute:: wvolume :type: bool :value: False .. py:attribute:: wcompute_coordinates :type: bool :value: False .. py:attribute:: wbasefn :type: bool :value: False .. py:attribute:: wmemory :type: bool :value: False .. py:attribute:: wcompute_metric_quantities :type: bool :value: False .. py:attribute:: wvolume_integrate_chebyshev :type: bool :value: False .. py:attribute:: wmatrix :type: bool :value: False .. py:attribute:: wspsint :type: bool :value: False .. py:attribute:: wsolve_beltrami_system :type: bool :value: False .. py:attribute:: wconstruct_beltrami_field :type: bool :value: False .. py:attribute:: wpackab :type: bool :value: False .. py:attribute:: wcompute_rotational_transform :type: bool :value: False .. py:attribute:: wcompute_plasma_current :type: bool :value: False .. py:attribute:: wdf0ab :type: bool :value: False .. py:attribute:: wlforce :type: bool :value: False .. py:attribute:: wintghs :type: bool :value: False .. py:attribute:: wmtrxhs :type: bool :value: False .. py:attribute:: wlbpol :type: bool :value: False .. py:attribute:: wbroadcast_profile_data :type: bool :value: False .. py:attribute:: wdfp100 :type: bool :value: False .. py:attribute:: wdfp200 :type: bool :value: False .. py:attribute:: wdforce :type: bool :value: False .. py:attribute:: wnewton :type: bool :value: False .. py:attribute:: wcasing :type: bool :value: False .. py:attribute:: wbnorml :type: bool :value: False .. py:attribute:: wcompute_beltrami_error :type: bool :value: False .. py:attribute:: wconstruct_poincare_plot :type: bool :value: False .. py:attribute:: wpp00ab :type: bool :value: False .. py:attribute:: wget_position_vetor_x :type: bool :value: False .. py:attribute:: whesian :type: bool :value: False .. py:attribute:: wwrite_vector_potentials :type: bool :value: False .. py:attribute:: wnumrec :type: bool :value: False .. py:attribute:: wdcuhre :type: bool :value: False .. py:attribute:: wminpack :type: bool :value: False .. py:attribute:: wiqpack :type: bool :value: False .. py:attribute:: wrksuite :type: bool :value: False .. py:attribute:: wi1mach :type: bool :value: False .. py:attribute:: wd1mach :type: bool :value: False .. py:attribute:: wilut :type: bool :value: False .. py:attribute:: witers :type: bool :value: False .. py:attribute:: wsphdf5 :type: bool :value: False .. py:attribute:: winitialize_internal_arrays :type: bool :value: False .. py:attribute:: wglobal :type: bool :value: False .. py:attribute:: wxspech :type: bool :value: False .. py:attribute:: wbuild_vector_potential :type: bool :value: False .. py:attribute:: wreadin :type: bool :value: False .. py:attribute:: wwrtend :type: bool :value: False .. py:attribute:: wmacros :type: bool :value: False .. py:class:: MinimizationParameters Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: gtol :type: float :value: 1e-13 .. py:attribute:: xtol :type: float :value: 1e-22 .. py:attribute:: ftol :type: float :value: 1e-13 .. py:attribute:: max_nfev :type: int :value: 10000 .. py:attribute:: max_niter :type: int :value: 10000 .. py:attribute:: method :type: Literal['trf', 'dogbox', 'lm'] :value: 'dogbox' .. py:attribute:: rcond_lstsq :type: float | None :value: None .. py:attribute:: save_xin_fixb :type: bool :value: True .. py:attribute:: freeb_max_iter :type: int :value: 1 .. py:attribute:: freeb_bnorm_tol :type: float :value: 1e-05 .. py:attribute:: nt_dbb :type: int | None :value: None .. py:attribute:: nz_dbb :type: int | None :value: None .. py:attribute:: filter_stellsym :type: bool :value: True .. py:attribute:: objective :type: Literal['freal', 'freal,len'] :value: 'freal' .. py:attribute:: resume :type: bool :value: False .. py:attribute:: mpol_rz :type: int | None :value: None .. py:attribute:: ntor_rz :type: int | None :value: None .. py:attribute:: len_factor :type: float :value: 1.0 .. py:attribute:: inface_repr :type: Literal['fourier', 'fourier red', 'henn'] :value: 'fourier' .. py:attribute:: mmax :type: int :value: 8 .. py:attribute:: nmax :type: int :value: 8 .. py:class:: InputParameters Bases: :py:obj:`pydantic.BaseModel` .. py:attribute:: minimization :type: MinimizationParameters .. py:attribute:: physics :type: PhysicsParameters .. py:attribute:: numeric :type: NumericParameters .. py:attribute:: global_ :type: GlobalParameters .. py:attribute:: diagnostics :type: DiagnosticsParameters .. py:method:: validate_parameters() -> InputParameters Placeholder for cross-field validation between parameter groups. .. py:method:: check_henneberg_res(values) :classmethod: Ensure that resolution used for Henneberg representation is representable (mmax