API: vaft.code
Generated from each module's __all__ by python -m vaft._api_catalog:
755 published objects in 119 modules.
Signatures and summaries are read from the source; nothing here is written by hand.
All API pages
No object matches.
vaft.code
Lazy namespace for external fusion-code adapters.
BoundaryContourPolicy
class
source
BoundaryContourPolicy(axis_bonus: float = 100.0, closed_bonus: float = 10.0, positive_r_fraction: float = 0.95, positive_r_rule: str = 'reject', positive_r_penalty: float = 100.0) -> None
How to choose among several flux contours at the same target_psin.
5 fields
axis_bonus: floatclosed_bonus: floatpositive_r_fraction: floatpositive_r_rule: strpositive_r_penalty: float
EFIT_FAILURE_CODES
data
EFIT_FAILURE_CODES = ('runtime_error', 'timeout', 'nonzero_returncode', 'missing_kfile', 'missing_gfile', 'missing_afile', 'missing_mfile'...
ExecutableNotLaunchable
class
source
The operating system refused to start an external-code executable.
vaft.code.base
Common protocol objects for external code adapters.
CodeConfig
class
source
CodeConfig(executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), args: Sequence[str] = (), env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, backend: Optional['ExecutionBackend'] = None) -> None
Base runtime configuration for a fusion-code adapter.
Also exported as vaft.code.CodeConfig, vaft.code.chease.CodeConfig.
6 fields
executable: Optional[str]workdir: Path | strargs: Sequence[str]env: Mapping[str, str]timeout: Optional[float]backend: Optional['ExecutionBackend']
CodeInputs
class
source
CodeInputs(workdir: Path, files: tuple[Path, ...] = (), ods: Any = None) -> None
Base input bundle for a code run.
Also exported as vaft.code.CodeInputs, vaft.code.chease.CodeInputs.
3 fields
workdir: Pathfiles: tuple[Path, ...]ods: Any
CodeResult
class
source
CodeResult(returncode: Optional[int], workdir: Path, stdout: str = '', stderr: str = '', logs: tuple[Path, ...] = (), outputs: Mapping[str, tuple[Path, ...]] = <factory>, parsed: Any = None, runtime_status: str = 'completed', elapsed_s: Optional[float] = None) -> None
Base result bundle returned by a code adapter.
Also exported as vaft.code.CodeResult, vaft.code.chease.CodeResult.
9 fields · 1 members
returncode: Optional[int]workdir: Pathstdout: strstderr: strlogs: tuple[Path, ...]outputs: Mapping[str, tuple[Path, ...]]parsed: Anyruntime_status: strelapsed_s: Optional[float]okproperty source
CodeRunner
class
source
CodeRunner(*args, **kwargs)
Protocol implemented by Python-first code runners.
Also exported as vaft.code.CodeRunner, vaft.code.chease.CodeRunner.
1 members
runmethod — Run the configured external code. source
RunOutcome
class
source
RunOutcome()
status and timed_out for a result that carries runtime_status.
vaft.code.chease
Python-first CHEASE equilibrium-refinement workflow adapter.
CHEASE_OUTPUT_NIDEAL
data
CHEASE_OUTPUT_NIDEAL = <builtins.dict>
CHEASEConfig
class
source
CHEASEConfig(executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), target_psin: float = 0.993, relax: float = 0.5, output: str = 'geqdsk', nideal: Optional[int] = None, nw: int = 513, nh: Optional[int] = None, ns: Optional[int] = None, nt: Optional[int] = None, npsi: Optional[int] = None, nchi: Optional[int] = None, epslon_exponent: int = 10, q_constraint_psi_norm: Optional[float] = 0.95, ncscal: int = 1, edge_zero: bool = True, boundary_smoothing: str = 'fft', boundary_fft_num: int = 128, boundary_contour_policy: BoundaryContourPolicy = BoundaryContourPolicy(axis_bonus=100.0, closed_bonus=10.0, positive_r_fraction=0.95, positive_r_rule='reject', positi..., auto_cocos: bool = True, output_cocos: str = 'input', preserve_boundary_limiter: bool = True, create_plot: bool = True, cleanup: bool = False, env: Mapping[str, str] = <factory>, args: Sequence[str] = (), timeout: Optional[float] = None, backend: Optional['ExecutionBackend'] = None) -> None
Runtime and numerical configuration for CHEASE refinement.
Also exported as vaft.code.CHEASEConfig.
28 fields · 3 members
executable: Optional[str]workdir: Path | strtarget_psin: floatrelax: floatoutput: strnideal: Optional[int]nw: intnh: Optional[int]ns: Optional[int]nt: Optional[int]npsi: Optional[int]nchi: Optional[int]epslon_exponent: intq_constraint_psi_norm: Optional[float]ncscal: intedge_zero: boolboundary_smoothing: strboundary_fft_num: intboundary_contour_policy: BoundaryContourPolicyauto_cocos: booloutput_cocos: strpreserve_boundary_limiter: boolcreate_plot: boolcleanup: boolenv: Mapping[str, str]args: Sequence[str]timeout: Optional[float]backend: Optional['ExecutionBackend']resolved_meshproperty — The solver mesh written to the namelist: the NIDEAL default, overridden by whichever ofns/nt/npsi/nchiare set. sourceresolved_nhproperty — TheNZBOXwritten to the namelist:nh, ornwfor a square box. sourceresolved_nidealproperty — TheNIDEALwritten to the namelist. source
CHEASEInputs
class
source
CHEASEInputs(workdir: Path, source: Any = None, input_geqdsk: Path | None = None, expeq: Path | None = None, namelist: Path | None = None, geqdsk: Any = None, files: tuple[Path, ...] = (), manifests: tuple[Path, ...] = (), materialized: Optional[CHEASEMaterializedInput] = None) -> None
Materialized CHEASE input bundle.
Also exported as vaft.code.CHEASEInputs.
9 fields
workdir: Pathsource: Anyinput_geqdsk: Path | Noneexpeq: Path | Nonenamelist: Path | Nonegeqdsk: Anyfiles: tuple[Path, ...]manifests: tuple[Path, ...]materialized: Optional[CHEASEMaterializedInput]
CHEASEMaterializedInput
class
source
CHEASEMaterializedInput(raw_boundary: np.ndarray, boundary: np.ndarray, psi_norm: np.ndarray, pressure: np.ndarray, pprime_resampled: np.ndarray, ffprime_resampled: np.ndarray, pprime: np.ndarray, ffprime: np.ndarray, edge_modified: np.ndarray, q_constraint_psi_norm: Optional[float], qspec: float, csspec: float, sign_transform: Mapping[str, int], parameters: Mapping[str, float]) -> None
What one EXPEQ/namelist pair hands CHEASE, before normalization.
14 fields
raw_boundary: np.ndarrayboundary: np.ndarraypsi_norm: np.ndarraypressure: np.ndarraypprime_resampled: np.ndarrayffprime_resampled: np.ndarraypprime: np.ndarrayffprime: np.ndarrayedge_modified: np.ndarrayq_constraint_psi_norm: Optional[float]qspec: floatcsspec: floatsign_transform: Mapping[str, int]parameters: Mapping[str, float]
CHEASEResult
class
source
CHEASEResult(returncode: Optional[int], workdir: Path, input_geqdsk: Path | None = None, refined_geqdsk: Path | None = None, refined_ods: Any = None, logs: tuple[Path, ...] = (), manifests: tuple[Path, ...] = (), figures: tuple[Path, ...] = (), outputs: Mapping[str, tuple[Path, ...]] = <factory>, comparison: Mapping[str, float] = <factory>, stdout: str = '', stderr: str = '', materialized: Optional['CHEASEMaterializedInput'] = None, runtime_status: str = 'completed', elapsed_s: Optional[float] = None) -> None
CHEASE run status, produced files, and parsed refined equilibrium.
Also exported as vaft.code.CHEASEResult.
15 fields · 1 members
returncode: Optional[int]workdir: Pathinput_geqdsk: Path | Nonerefined_geqdsk: Path | Nonerefined_ods: Anylogs: tuple[Path, ...]manifests: tuple[Path, ...]figures: tuple[Path, ...]outputs: Mapping[str, tuple[Path, ...]]comparison: Mapping[str, float]stdout: strstderr: strmaterialized: Optional['CHEASEMaterializedInput']runtime_status: strelapsed_s: Optional[float]okproperty source
collect_chease_outputs
function
source
collect_chease_outputs(workdir: str | Path, config: CHEASEConfig | None = None, source: Any = None) -> CHEASEResult
Collect CHEASE files from a working directory and parse refined GEQDSK.
comparison_metrics
function
source
comparison_metrics(original: Any, refined: Any) -> dict[str, float]
Quantify how far CHEASE’s refinement moved an EFIT equilibrium.
find_chease_executable
function
source
find_chease_executable(config: CHEASEConfig | None = None) -> Path | None
Resolve CHEASE from explicit config, $CHEASEHOME, or legacy variables.
Also exported as vaft.code.find_chease_executable.
GeqdskSignInfo
class
source
GeqdskSignInfo(psi_axis: float, psi_boundary: float, dpsi: float, bcentr: float, current: float, fpol_median: float, q_median: float, ffprim_median: float, pprime_median: float) -> None
Compact sign-convention diagnostics for a GEQDSK object.
9 fields · 6 members
psi_axis: floatpsi_boundary: floatdpsi: floatbcentr: floatcurrent: floatfpol_median: floatq_median: floatffprim_median: floatpprime_median: floatdpsi_signproperty sourcebcentr_signproperty sourcecurrent_signproperty sourcefpol_signproperty sourceq_signproperty sourceas_dictmethod source
prepare_chease_inputs
function
source
prepare_chease_inputs(source: Any, config: CHEASEConfig | None = None) -> CHEASEInputs
Materialize GEQDSK/EXPEQ/namelist files needed by CHEASE.
Also exported as vaft.code.prepare_chease_inputs.
refine_equilibrium
function
source
refine_equilibrium(source: Any, config: CHEASEConfig | None = None) -> CHEASEResult
Prepare inputs, run CHEASE, and collect the refined equilibrium.
Also exported as vaft.code.refine_equilibrium.
run_chease
function
source
run_chease(inputs: CHEASEInputs, config: CHEASEConfig | None = None) -> CHEASEResult
Run CHEASE with prepared inputs and collect the refined equilibrium.
Also exported as vaft.code.run_chease.
vaft.code.chease_kinetic_iteration
Self-consistent equilibrium / kinetic-profile iteration through CHEASE (#123).
build_consistent_state
function
source
build_consistent_state(equilibrium, spec: EquilibriumKineticSpec, *, config: CHEASEConfig | None = None, workdir: str | Path | None = None, time: float | None = None, resume: SelfConsistentState | None = None, baseline: bool = False) -> SelfConsistentState
Iterate an equilibrium and synthetic kinetic profiles until they are mutually consistent.
current_source_for_update
function
source
current_source_for_update(policy: CurrentPolicy, initial, previous) -> CurrentSource
Build the FF' of the next CHEASE input from the declared current policy.
pressure_roundtrip
function
source
pressure_roundtrip(geqdsk) -> float
max|PRES - (PRES(1) - int PPRIME dpsi)| / max PRES of a g-file, by the trapezoidal rule.
pressure_source_from_kinetic
function
source
pressure_source_from_kinetic(kinetic_psi_norm, p_kin, geqdsk, *, previous=None, relaxation: float = 1.0, monotone_rtol: float = 0.0) -> PressureSource
Build the PRES/PPRIME pair CHEASE reads from a kinetic pressure.
PressureSourceError
class
source
p_kin cannot be handed to CHEASE as a pressure source (non-finite, negative or non-monotone).
validate_chease_update
function
source
validate_chease_update(run: CHEASEResult, *, initial, policy: CurrentPolicy, target: float, criteria: ConvergenceCriteria) -> tuple[str, str, dict[str, Any]]
Accept or refuse one CHEASE update: solver, geometry, normalization and sign checks.
vaft.code.chease_scan
Fixed-boundary equilibrium scans over CHEASE inputs (issue #66).
apply_equilibrium_variation
function
source
apply_equilibrium_variation(geqdsk: Any, variation: EquilibriumVariation, *, refit_boundary: bool = False) -> tuple[Any, Optional[tuple[float, float, float, float]]]
Return a copy of geqdsk carrying variation, and its shape.
Also exported as vaft.code.apply_equilibrium_variation.
CHEASEScanCase
class
source
CHEASEScanCase(variation: EquilibriumVariation, workdir: Path, result: Optional[CHEASEResult] = None, error: Optional[str] = None, shape: Optional[tuple[float, float, float, float]] = None, target_psin: Optional[float] = None, boundary: Optional[Contour] = None, shape_parameters: Mapping[str, float] = <factory>) -> None
What one point of a scan produced, converged or not.
Also exported as vaft.code.CHEASEScanCase.
8 fields · 1 members
variation: EquilibriumVariationworkdir: Pathresult: Optional[CHEASEResult]error: Optional[str]shape: Optional[tuple[float, float, float, float]]target_psin: Optional[float]boundary: Optional[Contour]shape_parameters: Mapping[str, float]convergedproperty — Whether CHEASE actually solved this case. source
EquilibriumVariation
class
source
EquilibriumVariation(label: str, pressure_scale: float = 1.0, current_peaking: float = 0.0, elongation_scale: float = 1.0, triangularity_shift: float = 0.0, boundary: Optional[Contour] = None) -> None
One perturbation of a CHEASE input, named by the physics it moves.
Also exported as vaft.code.EquilibriumVariation.
6 fields · 1 members
label: strpressure_scale: floatcurrent_peaking: floatelongation_scale: floattriangularity_shift: floatboundary: Optional[Contour]reshapes_boundaryproperty — Whether this variation touches the boundary at all. source
scan_chease
function
source
scan_chease(source: Any, variations: Sequence[EquilibriumVariation], *, config: Optional[CHEASEConfig] = None, workdir: Path | str | None = None, on_case: Optional[Callable[[CHEASEScanCase], None]] = None, keep_going: bool = True) -> list[CHEASEScanCase]
Re-solve one equilibrium under each of variations.
Also exported as vaft.code.scan_chease.
vaft.code.chease_synthesis
Fixed-boundary CHEASE equilibria synthesized from 0D descriptors (#120).
build_input_equilibrium
function
source
build_input_equilibrium(spec: ZeroDimensionalEquilibriumSpec, *, q95: float | None = None, resolution: int = 129)
A COCOS 11 EquilibriumData carrying the boundary and source shapes for CHEASE.
construct_boundary
function
source
construct_boundary(spec: ZeroDimensionalEquilibriumSpec, points: int = 256)
The Miller LCFS of a specification, counter-clockwise, as a closed contour.
requested_pressure_shape
function
source
requested_pressure_shape(spec: ZeroDimensionalEquilibriumSpec, psi_n) -> tuple[np.ndarray, np.ndarray]
The pressure a specification asks for, normalized: (p - p(1))/(p(0) - p(1)) and its psi_N gradient.
STATUSES
data
STATUSES = ('success', 'invalid_geometry', 'invalid_source_model', 'unsupported_target', 'non_converged', 'invalid_equilibrium',...
SUPPORTED_TARGETS
data
SUPPORTED_TARGETS = <builtins.dict>
synthesize_equilibrium_from_0d
function
source
synthesize_equilibrium_from_0d(spec: ZeroDimensionalEquilibriumSpec, *, target: str = 'plasma_current', q95: float | None = None, config: CHEASEConfig | None = None, current_tolerance: float = 0.01, q95_tolerance: float = 0.02, boundary_tolerance: float = 0.02, pressure_shape_tolerance: float = 0.02, pprime_peak_tolerance: float = 0.1, pprime_peak_location_tolerance: float = 0.01) -> SyntheticEquilibriumResult
Solve a fixed-boundary CHEASE equilibrium from 0D descriptors and source shapes.
SyntheticEquilibriumResult
class
source
SyntheticEquilibriumResult(status: str, reason: str | None, spec: ZeroDimensionalEquilibriumSpec, target: str, requested: Mapping[str, float], achieved: Mapping[str, float] = <factory>, residuals: Mapping[str, float] = <factory>, boundary: Any = None, source_profiles: Mapping[str, np.ndarray] = <factory>, chease: Optional[CHEASEResult] = None, refined_geqdsk: Optional[Path] = None, refined_ods: Any = None, achieved_profiles: Mapping[str, np.ndarray] = <factory>) -> None
Requested vs achieved: the outcome of synthesize_equilibrium_from_0d.
13 fields · 1 members
status: strreason: str | Nonespec: ZeroDimensionalEquilibriumSpectarget: strrequested: Mapping[str, float]achieved: Mapping[str, float]residuals: Mapping[str, float]boundary: Anysource_profiles: Mapping[str, np.ndarray]chease: Optional[CHEASEResult]refined_geqdsk: Optional[Path]refined_ods: Anyachieved_profiles: Mapping[str, np.ndarray]okproperty source
ZeroDimensionalEquilibriumSpec
class
source
ZeroDimensionalEquilibriumSpec(major_radius: float, minor_radius: float, elongation: float, triangularity: float, toroidal_field: float, plasma_current: float, vertical_position: float = 0.0, squareness: float = 0.0, pressure_fraction: float = 0.5, pressure_alpha: float = 1.0, pressure_beta: float = 2.0, current_alpha: float = 1.0, current_beta: float = 1.0, pressure_profile: 'AnalyticProfile | AnalyticPlasmaState | None' = None, current_profile: 'AnalyticProfile | None' = None) -> None
A fixed-boundary equilibrium request in 0D descriptors and explicit source shapes.
15 fields
major_radius: floatminor_radius: floatelongation: floattriangularity: floattoroidal_field: floatplasma_current: floatvertical_position: floatsquareness: floatpressure_fraction: floatpressure_alpha: floatpressure_beta: floatcurrent_alpha: floatcurrent_beta: floatpressure_profile: 'AnalyticProfile | AnalyticPlasmaState | None'current_profile: 'AnalyticProfile | None'
vaft.code.chease_synthesis_targets
Several 0D targets at once: an outer solve around the CHEASE synthesis (#120).
assign_knobs
function
source
assign_knobs(spec: ZeroDimensionalEquilibriumSpec, targets: Mapping[str, float], knobs: Mapping[str, Any] | None = None) -> tuple[str, dict[str, TargetKnob]]
Choose the imposed normalization and one bounded knob per remaining target.
DEFAULT_KNOBS
data
DEFAULT_KNOBS = <builtins.dict>
MULTI_TARGET_STATUSES
data
MULTI_TARGET_STATUSES = ('converged', 'max_iterations', 'not_reachable', 'stalled', 'chease_failed', 'validation_failed', 'unsupported_target...
MultiTargetSynthesisResult
class
source
MultiTargetSynthesisResult(status: str, reason: Optional[str], spec: ZeroDimensionalEquilibriumSpec, targets: Mapping[str, float], imposed: Optional[str] = None, assignment: Mapping[str, TargetKnob] = <factory>, tolerances: Mapping[str, float] = <factory>, history: list = <factory>, record: Optional[TargetIterationRecord] = None, reachable: Mapping[str, tuple] = <factory>) -> None
The outcome of synthesize_equilibrium_to_targets.
10 fields · 7 members
status: strreason: Optional[str]spec: ZeroDimensionalEquilibriumSpectargets: Mapping[str, float]imposed: Optional[str]assignment: Mapping[str, TargetKnob]tolerances: Mapping[str, float]history: listrecord: Optional[TargetIterationRecord]reachable: Mapping[str, tuple]okproperty sourceresultproperty — The single-target synthesis of the reported solve. sourcefinal_specproperty sourceachievedproperty sourceresidualsproperty sourceiterationsproperty sourcetablemethod — Requested vs achieved per target (achievedNonewhen the solve did not produce it). source
synthesize_equilibrium_to_targets
function
source
synthesize_equilibrium_to_targets(spec: ZeroDimensionalEquilibriumSpec, targets: Mapping[str, float], *, knobs: Mapping[str, Any] | None = None, config: CHEASEConfig | None = None, tolerance: float = 0.01, tolerances: Mapping[str, float] | None = None, max_iterations: int = 10, jacobian_step: float = 0.05, workdir_factory: Callable[[int], Any] | None = None, **synthesis_options: Any) -> MultiTargetSynthesisResult
Meet two or three 0D targets by iterating the source model around CHEASE.
TARGET_DESCRIPTORS
data
TARGET_DESCRIPTORS = <builtins.dict>
TargetIterationRecord
class
source
TargetIterationRecord(solve: int, iteration: int, purpose: str, knobs: Mapping[str, float], requested: Mapping[str, float], achieved: Mapping[str, float], residuals: Mapping[str, float], status: str, reason: Optional[str], result: Optional[SyntheticEquilibriumResult] = None) -> None
One CHEASE solve of the outer iteration: what was asked, what it gave.
10 fields · 1 members
solve: intiteration: intpurpose: strknobs: Mapping[str, float]requested: Mapping[str, float]achieved: Mapping[str, float]residuals: Mapping[str, float]status: strreason: Optional[str]result: Optional[SyntheticEquilibriumResult]okproperty source
TargetKnob
class
source
TargetKnob(name: str, lower: float, upper: float) -> None
A spec field the outer solve may move, and its bounds.
3 fields · 4 members
name: strlower: floatupper: floatlogarithmicproperty — Shape exponents act multiplicatively, so they are iterated inlog. sourceclipmethod sourceto_unitmethod — The knob value as a coordinate in[0, 1]across its bounds (clipped). sourcefrom_unitmethod — Inverse ofto_unit; exact at the bounds. source
vaft.code.efit
Magnetic- and kinetic-constrained EFIT adapter.
EFITReducedLinearSolve
class
source
EFITReducedLinearSolve(solver_a: np.ndarray, solver_rhs: np.ndarray, exact_c: np.ndarray, exact_d: np.ndarray, solver_basis: np.ndarray, physical_from_solver: np.ndarray, solver_offset: np.ndarray, physical_offset: np.ndarray, solver_solution: np.ndarray, basis_kind: np.ndarray, status: int, condno: float, discarded_projection_norm: float, transform_relative_error: float, reproduction_relative_error: float) -> None
Actual reduced-coordinate DGGLSE problem used for a direction row.
15 fields
solver_a: np.ndarraysolver_rhs: np.ndarrayexact_c: np.ndarrayexact_d: np.ndarraysolver_basis: np.ndarrayphysical_from_solver: np.ndarraysolver_offset: np.ndarrayphysical_offset: np.ndarraysolver_solution: np.ndarraybasis_kind: np.ndarraystatus: intcondno: floatdiscarded_projection_norm: floattransform_relative_error: floatreproduction_relative_error: float
vaft.code.efit.applicability
Whether EFIT applies to a shot at all, carried from the constraint step on (#205).
constraints_not_applicable_reason
function
source
constraints_not_applicable_reason(ods: Any) -> str | None
The recorded reason when ods is a not-applicable constraints ODS, else None.
EFIT_NOT_APPLICABLE
data
EFIT_NOT_APPLICABLE = 'EFIT not applicable: '
KFILE_MANIFEST_NOT_APPLICABLE
data
KFILE_MANIFEST_NOT_APPLICABLE = '# EFIT not applicable: '
kfile_manifest_not_applicable_reason
function
source
kfile_manifest_not_applicable_reason(text: str) -> str | None
The reason a k-file manifest records, or None for an ordinary manifest.
kfile_manifest_paths
function
source
kfile_manifest_paths(text: str) -> list[str]
The k-file paths a manifest lists; comment lines are not paths.
kfile_manifest_text
function
source
kfile_manifest_text(reason: str) -> str
The k-file manifest of a shot EFIT does not apply to.
not_applicable_constraints
function
source
not_applicable_constraints(reason: str) -> Any
The constraints ODS of a shot EFIT does not apply to: the verdict and nothing else.
vaft.code.efit.config
Typed scientific configuration for VEST EFIT inputs.
DIAGNOSTIC_GROUPS
data
DIAGNOSTIC_GROUPS = frozenset({'bpol_probe', 'diamagnetic_flux', 'flux_loop', 'pf_current', 'plasma_current'})
efit_parameter_grid
function
source
efit_parameter_grid(base: EFITScientificConfig | None, axes: Mapping[str, Sequence[Any]]) -> tuple[EFITScientificConfig, ...]
Expand dotted scientific-config paths into a deterministic scan grid.
Also exported as vaft.code.efit.efit_parameter_grid, vaft.code.efit_parameter_grid.
EFITAcceptanceEnvelope
class
source
EFITAcceptanceEnvelope(aminor_min: float = 25.0, aminor_max: float = 75.0, rcntr_min: float = 30.0, rcntr_max: float = 160.0, zcntr_min: float = -165.0, zcntr_max: float = 165.0, rcurrt_min: float = 30.0, rcurrt_max: float = 160.0, zcurrt_min: float = -165.0, zcurrt_max: float = 165.0, elong_min: float = 0.8, elong_max: float = 4.0, li_min: float = 0.05, li_max: float = 1.5, betap_max: float = 6.0, betat_max: float = 25.0, qstar_min: float = 1.0, qstar_max: float = 200.0, qout_min: float = 1.0, qout_max: float = 200.0, sepin_check: float = -90.0, gapin_min: float = -0.2, gapout_min: float = -0.2, gaptop_min: float = -0.2, plasma_diff: float = 0.08, dbpli_diff: float = 0.05, delbp_diff: float = 0.08) -> None
The &incheck bounds EFIT accepts a reconstruction within.
27 fields · 3 members
aminor_min: floataminor_max: floatrcntr_min: floatrcntr_max: floatzcntr_min: floatzcntr_max: floatrcurrt_min: floatrcurrt_max: floatzcurrt_min: floatzcurrt_max: floatelong_min: floatelong_max: floatli_min: floatli_max: floatbetap_max: floatbetat_max: floatqstar_min: floatqstar_max: floatqout_min: floatqout_max: floatsepin_check: floatgapin_min: floatgapout_min: floatgaptop_min: floatplasma_diff: floatdbpli_diff: floatdelbp_diff: floatto_namelistmethod — The&incheckkeys, in the spelling EFIT reads. sourceto_dictmethod sourcesha256property source
EFITConstraintConfig
class
source
EFITConstraintConfig(group_weights: Mapping[str, float] = <factory>, objective_scales: Mapping[str, float] = <factory>, uncertainty_scales: Mapping[str, float] = <factory>, uncertainty_mode: str = 'standard_deviation', sigma_floor: float = 0.02, sigma_floor_families: tuple[str, ...] = ('bpol_probe', 'flux_loop'), legacy_vbit: float = 10.0, legacy_weight_scale: float = 10000.0, use_diamagnetic_flux: bool = True, diamagnetic_flux_sign: str = 'imas', diamagnetic_flux_input_units: str = 'Wb', wall_current_mode: str = 'measured', passive_structure_mode: str = 'fixed_currents', use_coil_relation_constraints: bool = True, coil_constraint_matrix: tuple[tuple[float, ...], ...] | None = None, coil_constraint_targets: tuple[float, ...] | None = None, nccoil: int = 0) -> None
Diagnostic, diamagnetic-flux, coil, and passive-structure controls.
Also exported as vaft.code.EFITConstraintConfig, vaft.code.efit.EFITConstraintConfig.
17 fields
group_weights: Mapping[str, float]objective_scales: Mapping[str, float]uncertainty_scales: Mapping[str, float]uncertainty_mode: strsigma_floor: floatsigma_floor_families: tuple[str, ...]legacy_vbit: floatlegacy_weight_scale: floatuse_diamagnetic_flux: booldiamagnetic_flux_sign: strdiamagnetic_flux_input_units: strwall_current_mode: strpassive_structure_mode: struse_coil_relation_constraints: boolcoil_constraint_matrix: tuple[tuple[float, ...], ...] | Nonecoil_constraint_targets: tuple[float, ...] | Nonenccoil: int
EFITInitializationConfig
class
source
EFITInitializationConfig(rzero: float = 0.4, zzero: float = 0.0, minor_radius: float = 0.3, elongation: float = 1.6, current_threshold: float = 15000.0, icinit: int | None = None, ellipse_rzero: float | None = 0.32) -> None
Ellipse and low-current initialization controls.
Also exported as vaft.code.EFITInitializationConfig, vaft.code.efit.EFITInitializationConfig.
7 fields · 1 members
rzero: floatzzero: floatminor_radius: floatelongation: floatcurrent_threshold: floaticinit: int | Noneellipse_rzero: float | Noneseed_rzeroproperty — Where the initial ellipse is centred, whatever drives the rest. source
EFITNumericsConfig
class
source
EFITNumericsConfig(relaxation: float = 1.0, error_tolerance: float = 1e-05, measurement_error_floor: float = 0.0005, max_iterations: int = 514, error_minimum: float | None = 0.0001, chi_squared_target: float | None = 10000000000.0, convergence_mode: int | None = None, inner_iterations: int | None = 1) -> None
Convergence, relaxation, and iteration controls.
Also exported as vaft.code.EFITNumericsConfig, vaft.code.efit.EFITNumericsConfig.
8 fields · 1 members
relaxation: floaterror_tolerance: floatmeasurement_error_floor: floatmax_iterations: interror_minimum: float | Nonechi_squared_target: float | Noneconvergence_mode: int | Noneinner_iterations: int | Nonetermination_keysmethod — The&IN1keys this configuration adds, in namelist spelling. source
EFITProfileConfig
class
source
EFITProfileConfig(kppcur: int = 2, kffcur: int = 1, kppfnc: int = 0, kfffnc: int = 0, pcurbd: int = 1, fcurbd: int = 1, fwtbp: int = 0) -> None
Pressure and FF-prime representation written to the EFIT namelist.
Also exported as vaft.code.EFITProfileConfig, vaft.code.efit.EFITProfileConfig.
7 fields
kppcur: intkffcur: intkppfnc: intkfffnc: intpcurbd: intfcurbd: intfwtbp: int
EFITScientificConfig
class
source
EFITScientificConfig(profile: EFITProfileConfig = <factory>, initialization: EFITInitializationConfig = <factory>, numerics: EFITNumericsConfig = <factory>, constraints: EFITConstraintConfig = <factory>) -> None
Complete scientific configuration a k-file is written from.
Also exported as vaft.code.EFITScientificConfig, vaft.code.efit.EFITScientificConfig.
4 fields · 3 members
profile: EFITProfileConfiginitialization: EFITInitializationConfignumerics: EFITNumericsConfigconstraints: EFITConstraintConfigto_dictmethod — Return a sorted, JSON-compatible resolved representation. sourcefrom_dictclassmethod — Rebuild a validated configuration fromto_dictoutput. sourcesha256property — Stable hash of the resolved scientific configuration. source
IGNORE_CRITERION
data
IGNORE_CRITERION = 1000000.0
routine_constraint_config
function
source
routine_constraint_config(**overrides: Any) -> EFITConstraintConfig
The routine constraints – legacy weights, unit scales, no floor – with overrides.
Also exported as vaft.code.efit.routine_constraint_config.
routine_numerics_config
function
source
routine_numerics_config(**overrides: Any) -> EFITNumericsConfig
The routine numerics – EFIT’s own termination, MXITER 100 – with overrides.
Also exported as vaft.code.efit.routine_numerics_config.
routine_profile_config
function
source
routine_profile_config(**overrides: Any) -> EFITProfileConfig
The routine (2,2) profile basis, with overrides.
Also exported as vaft.code.efit.routine_profile_config.
routine_scientific_config
function
source
routine_scientific_config(**overrides: Any) -> EFITScientificConfig
The legacy routine scientific configuration (the defaults before 2026-10-01).
Also exported as vaft.code.efit.routine_scientific_config.
WORKING_UNCERTAINTY_SCALES
data
WORKING_UNCERTAINTY_SCALES = <builtins.mappingproxy>
vaft.code.efit.efund
EFUND adapter: canonical geometry -> mhdin.dat -> efund -> Green tables.
collect_efund_outputs
function
source
collect_efund_outputs(workdir: str | os.PathLike[str], config: EFUNDConfig, counts: Mapping[str, int], *, returncode: Optional[int] = None, executable: Optional[Path] = None, stdout: str = '', stderr: str = '', reason: str = '') -> EFUNDResult
Check an EFUND working directory against the files config implies.
Also exported as vaft.code.efit.collect_efund_outputs.
efund_config_from_manifest
function
source
efund_config_from_manifest(manifest: Mapping[str, Any], **overrides: Any) -> EFUNDConfig
The EFUNDConfig a table manifest records, with overrides applied.
EFUNDConfig
class
source
EFUNDConfig(workdir: Path | str = PosixPath('.'), nw: int = 129, nh: int = 129, rleft: float = 0.05, rright: float = 1.2, zbotto: float = -1.5, ztop: float = 1.5, igrid: int = 1, ifcoil: int = 1, ivesel: int = 1, iecoil: int = 0, iacoil: int = 0, islpfc: int = 0, isize: int = 0, nsmp2: int = 1, mgaus1: int = 8, mgaus2: int = 10, device: str = 'VEST', executable: Optional[str] = None, env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, stack_size_kb: int | str | None = 'hard', backend: Optional['ExecutionBackend'] = None) -> None
The EFUND-only quantities, explicit and typed.
Also exported as vaft.code.efit.EFUNDConfig.
23 fields · 5 members
workdir: Path | strnw: intnh: intrleft: floatrright: floatzbotto: floatztop: floatigrid: intifcoil: intivesel: intiecoil: intiacoil: intislpfc: intisize: intnsmp2: intmgaus1: intmgaus2: intdevice: strexecutable: Optional[str]env: Mapping[str, str]timeout: Optional[float]stack_size_kb: int | str | Nonebackend: Optional['ExecutionBackend']table_suffixproperty — The<nw><nh>EFUND appends to grid-sized table names. sourceargvproperty — EFUND’s command-line arguments:nwand, when different,nh. sourcein5method — The&in5namelist values. sourceto_dictmethod — The scientific content only: no paths, executable, or timeouts. sourcesha256property source
EFUNDInputs
class
source
EFUNDInputs(workdir: Path, mhdin: Path, mhdin_sha256: str, geometry: EFUNDGeometry, counts: dict[str, int], header: tuple[str, ...] = ()) -> None
What run_efund needs: a working directory holding mhdin.dat.
Also exported as vaft.code.efit.EFUNDInputs.
6 fields
workdir: Pathmhdin: Pathmhdin_sha256: strgeometry: EFUNDGeometrycounts: dict[str, int]header: tuple[str, ...]
EFUNDResult
class
source
EFUNDResult(returncode: Optional[int], workdir: Path, status: str, reason: str = '', files: dict[str, Path] = <factory>, expected: dict[str, Optional[int]] = <factory>, problems: tuple[str, ...] = (), executable: Optional[Path] = None, logs: tuple[Path, ...] = (), stdout: str = '', stderr: str = '', manifest: Optional[Path] = None) -> None
Outcome of an EFUND run or of collecting an existing table directory.
Also exported as vaft.code.efit.EFUNDResult.
12 fields · 1 members
returncode: Optional[int]workdir: Pathstatus: strreason: strfiles: dict[str, Path]expected: dict[str, Optional[int]]problems: tuple[str, ...]executable: Optional[Path]logs: tuple[Path, ...]stdout: strstderr: strmanifest: Optional[Path]okproperty source
expected_table_files
function
source
expected_table_files(config: EFUNDConfig, counts: Mapping[str, int]) -> dict[str, Optional[int]]
File names EFUND writes for config, with exact sizes where the layout is fixed.
fortran_byte_order
function
source
fortran_byte_order(path: str | os.PathLike[str]) -> str
">" or "<": the byte order of a sequential unformatted file.
generate_era_table
function
source
generate_era_table(era: str, output: str | os.PathLike[str], *, config: EFUNDConfig | None = None, base_table_dir: str | os.PathLike[str] | None = None, acceptance_envelope: bool = True, label: str | None = None, extra: Mapping[str, Any] | None = None, replace_incomplete: bool = False) -> EFUNDResult
Build a complete, runnable EFIT table directory for one machine era.
IDENTITY_EXCLUDED_FILES
data
IDENTITY_EXCLUDED_FILES = frozenset({'mhdout.dat'})
LIMITER_NAME
data
LIMITER_NAME = 'lim.dat'
MHDIN_NAME
data
MHDIN_NAME = 'mhdin.dat'
prepare_efund_inputs
function
source
prepare_efund_inputs(static_ods: Any, config: EFUNDConfig, *, manifest: Mapping[str, Any] | None = None, geometry: EFUNDGeometry | None = None, header: Sequence[str] = (), envelope: Any | None = None) -> EFUNDInputs
Project static_ods and write mhdin.dat into config.workdir.
Also exported as vaft.code.efit.prepare_efund_inputs.
read_fortran_arrays
function
source
read_fortran_arrays(path: str | os.PathLike[str], *, int32_records: Sequence[int] = ()) -> list[np.ndarray]
Every record of a table file as a flat array, in file order.
read_fortran_records
function
source
read_fortran_records(path: str | os.PathLike[str]) -> list[bytes]
The raw records of a gfortran sequential unformatted file.
read_table_manifest
function
source
read_table_manifest(directory: str | os.PathLike[str]) -> dict[str, Any] | None
The manifest of a table directory, or None when it has none.
Also exported as vaft.code.efit.read_table_manifest.
run_efund
function
source
run_efund(inputs: EFUNDInputs, config: EFUNDConfig) -> EFUNDResult
Run EFUND in inputs.workdir and collect the tables it wrote.
Also exported as vaft.code.efit.run_efund.
TABLE_DIR_MAX_CHARS
data
TABLE_DIR_MAX_CHARS = 100
table_dir_text
function
source
table_dir_text(directory: str | os.PathLike[str]) -> str
directory as EFIT must be given it: with a trailing separator, and short enough.
table_identity
function
source
table_identity(directory: str | os.PathLike[str]) -> dict[str, Any]
What an EFIT run records about the table directory it consumed.
Also exported as vaft.code.efit.table_identity.
table_machine_era
function
source
table_machine_era(directory: str | os.PathLike[str]) -> str | None
The machine era a table directory was built for, if it records one.
TABLE_MANIFEST_NAME
data
TABLE_MANIFEST_NAME = 'efund_table_manifest.json'
TableExistsError
class
source
The destination already holds a complete table (it has a manifest).
write_limiter_file
function
source
write_limiter_file(static_ods: Any, path: str | os.PathLike[str]) -> Path
Write EFIT’s lim.dat from the static ODS’s limiter outline.
write_mhdin
function
source
write_mhdin(geometry: EFUNDGeometry, config: EFUNDConfig, path: str | os.PathLike[str], *, header: Sequence[str] = (), envelope: Any | None = None) -> Path
Write mhdin.dat for geometry and config; returns the path.
write_table_manifest
function
source
write_table_manifest(result: EFUNDResult, inputs: EFUNDInputs, config: EFUNDConfig, *, label: str | None = None, extra: Mapping[str, Any] | None = None) -> Path
Write TABLE_MANIFEST_NAME beside the tables and return its path.
Also exported as vaft.code.efit.write_table_manifest.
vaft.code.efit.iteration_history
EFIT’s Picard trajectory per slice, as a reusable object (issue #1038).
compare_iteration_histories
function
source
compare_iteration_histories(histories: Mapping[str, EFITIterationHistory], time: float, *, ax: Any = None, show: bool = False, **style: Any) -> tuple[Any, np.ndarray]
The same slice from several runs on one iteration axis.
Also exported as vaft.code.efit.compare_iteration_histories.
EFITIteration
class
source
EFITIteration(cumulative: int, chi2: float, error: float, axis_z: float = nan, dz: float = nan, outer: int | None = None, inner: int | None = None) -> None
One Picard step of one slice.
Also exported as vaft.code.efit.EFITIteration.
EFITIterationHistory
class
source
EFITIterationHistory(slices: tuple[EFITSliceIterationHistory, ...], level: str = 'summary', numbering: Mapping[str, Any] = <factory>, provenance: Mapping[str, Any] = <factory>, schema: str = 'vaft.efit.iteration_history', schema_version: int = 1) -> None
Every slice’s Picard trajectory from one EFIT run.
Also exported as vaft.code.efit.EFITIterationHistory.
6 fields · 5 members
slices: tuple[EFITSliceIterationHistory, ...]level: strnumbering: Mapping[str, Any]provenance: Mapping[str, Any]schema: strschema_version: inttimesproperty sourceat_timemethod — The slice nearesttime(seconds);KeyErrorif none is withintolerance. sourceto_dictmethod sourcefrom_dictclassmethod sourcewrite_jsonmethod — Write the history as JSON; NaN is written asnull. source
EFITSliceIterationHistory
class
source
EFITSliceIterationHistory(time: float, iterations: tuple[EFITIteration, ...] = (), time_ms: int | None = None, exit_path: str | None = None, iconvr: int | None = None, accepted: bool | None = None, collapsed: bool | None = None, failures: tuple[Mapping[str, Any], ...] = (), warnings: tuple[Mapping[str, Any], ...] = (), solver_errors: tuple[Mapping[str, Any], ...] = (), sources: tuple[str, ...] = (), mfile: str | None = None, notes: tuple[str, ...] = ()) -> None
The Picard trajectory of one slice and how EFIT said it ended.
Also exported as vaft.code.efit.EFITSliceIterationHistory.
13 fields · 8 members
time: floatiterations: tuple[EFITIteration, ...]time_ms: int | Noneexit_path: str | Noneiconvr: int | Noneaccepted: bool | Nonecollapsed: bool | Nonefailures: tuple[Mapping[str, Any], ...]warnings: tuple[Mapping[str, Any], ...]solver_errors: tuple[Mapping[str, Any], ...]sources: tuple[str, ...]mfile: str | Nonenotes: tuple[str, ...]iterations_nproperty sourcecumulativeproperty sourcechi2property sourceerrorproperty sourceaxis_zproperty sourcedzproperty sourceto_dictmethod sourcefrom_dictclassmethod source
iteration_history_from_workdir
function
source
iteration_history_from_workdir(workdir: str | Path, *, shot: int | None = None, nxiter: int | None = None) -> EFITIterationHistory
Rebuild the history of a finished run from what it left in workdir.
Also exported as vaft.code.efit.iteration_history_from_workdir.
ITERATION_HISTORY_LEVELS
data
ITERATION_HISTORY_LEVELS = ('none', 'summary')
Also exported as vaft.code.efit.ITERATION_HISTORY_LEVELS.
ITERATION_HISTORY_SCHEMA
data
ITERATION_HISTORY_SCHEMA = 'vaft.efit.iteration_history'
ITERATION_HISTORY_SCHEMA_VERSION
data
ITERATION_HISTORY_SCHEMA_VERSION = 1
parse_iteration_history
function
source
parse_iteration_history(text: str, *, mfiles: Sequence[Any] = (), kfiles: Sequence[Any] = (), configuration: Mapping[str, Any] | None = None, nxiter: int | None = None, provenance: Mapping[str, Any] | None = None) -> EFITIterationHistory
The Picard trajectory of every slice in an EFIT run.
Also exported as vaft.code.efit.parse_iteration_history.
plot_iteration_convergence
function
source
plot_iteration_convergence(history: EFITIterationHistory, time: float | Sequence[float] | None = None, *, ax: Any = None, show: bool = False, **style: Any) -> tuple[Any, np.ndarray]
Chi-square, flux increment and axis height against Picard iteration.
Also exported as vaft.code.efit.plot_iteration_convergence.
printed_ms
function
source
printed_ms(time: float) -> int
The millisecond EFIT prints for a slice at time seconds.
read_iteration_history
function
source
read_iteration_history(path: str | Path) -> EFITIterationHistory
Load a history written by EFITIterationHistory.write_json.
Also exported as vaft.code.efit.read_iteration_history.
SIDECAR_NAME
data
SIDECAR_NAME = 'efit_iteration_history.json'
vaft.code.efit.kfile
EFIT constraints-ODS and k-file generation.
apply_channel_decisions
function
source
apply_channel_decisions(EQ, decisions: ChannelDecisions, *, weighting, families: ProbeFamilies, flux_families: tuple) -> dict
Translate channel decisions into constraint weights and values (issue #296).
Also exported as vaft.code.efit.apply_channel_decisions.
apply_validity_exclusions
function
source
apply_validity_exclusions(ods, EQ, *, min_validity: int = 0) -> dict[tuple[str, int], list[int]]
Zero the weight of every channel unusable at a given reconstruction time.
build_efit_coil_currents
function
source
build_efit_coil_currents(destination, source, *, coilset=None, window=None) -> None
The EFIT current groups, built from the machine’s own PF circuits.
ConstraintErrors
class
source
ConstraintErrors(pf_current: float, b_field_tor_vacuum_r: float, ip: float, diamagnetic_flux: float, probe_inboard: float, probe_side: float, probe_outboard: float, flux_loop_inboard: float, flux_loop_outboard: float) -> None
The relative error assigned to each constraint family.
9 fields · 2 members
pf_current: floatb_field_tor_vacuum_r: floatip: floatdiamagnetic_flux: floatprobe_inboard: floatprobe_side: floatprobe_outboard: floatflux_loop_inboard: floatflux_loop_outboard: floatfrom_sequenceclassmethod — The legacy positional list, in its documented order. sourcecoerceclassmethod source
ConstraintWeights
class
source
ConstraintWeights(pf_current: float, ip: float, diamagnetic_flux: float, probe_inboard: float, probe_side: float, probe_outboard: float, flux_loop_inboard: float, flux_loop_outboard: float) -> None
The fit weight assigned to each constraint family.
diamagnetic_anchored_slices
function
source
diamagnetic_anchored_slices(times, method_name, *, average_window: float) -> list[int]
Slices whose diamagnetic box average reaches a baseline anchor or the zeroed tail.
generate_constraints_ods
functionDeprecated usage
source
generate_constraints_ods(ods, shotnumber, save_dir, efit_table_dir, time, uncertainty, weighting, broken=None, fit=0, fl_correct_coeff=None, FFCUR=2, PPCUR=2, *, decisions: ChannelDecisions | None = None, recovery=None, average_window: float = 0.0005, coil_current_window: tuple[float, float, float] | None = None, expected_table_era: str | None = None, coilset=None) -> ChannelDecisions
Generate the constraints ODS, save_dir/{shotnumber}_constraints.json.
Also exported as vaft.code.efit.generate_constraints_ods, vaft.code.generate_constraints_ods.
generate_kfile
function
source
generate_kfile(ods, shotnumber, npprime=None, nffprime=None, save_dir='./tmp', *, config: EFITConfig | EFITScientificConfig | None = None, coilset=None)
Generate k-files under save_dir/kfile for the requested shot.
Also exported as vaft.code.efit.generate_kfile, vaft.code.generate_kfile.
MissingConstraintInputError
class
source
MissingConstraintInputError(missing: dict[str, str])
A required EFIT constraint input is absent from the ODS.
vaft.code.efit.kinetic
Private kinetic-pressure implementation for vaft.code.efit.
build_kinetic_core_profiles
function
source
build_kinetic_core_profiles(ods: Any, geq: Any, time_ms: float, *, te_mode: str = 'polynomial', ne_mode: str = 'free_exponential', ti_mode: str = 'polynomial', vtor_mode: str = 'polynomial', ion_index: int = 0, time_tolerance_ms: float = 1.0, require_thomson: bool = False, require_ion: bool = False, ti_te_fallback: bool = True, ti_te_ratio: Any = 'auto', coordinate: str = 'auto', shot: Optional[int] = None) -> Any
Fit whatever kinetic diagnostics are present and write core_profiles.profiles_1d.
Also exported as vaft.code.build_kinetic_core_profiles, vaft.code.efit.build_kinetic_core_profiles.
EQE
data
EQE = 1.602176634e-19
Also exported as vaft.code.efit.EQE.
find_efit_executable
function
source
find_efit_executable(config: Optional[KineticEFITConfig] = None) -> Optional[Path]
Public wrapper mirroring vaft.code.chease.find_chease_executable.
inject_pressure_constraint
function
source
inject_pressure_constraint(kfile_text: str, points: PressurePoints, *, encoding: str = 'raw6') -> str
Insert the KPRFIT=1 pressure block before the first IN1 /.
Also exported as vaft.code.efit.inject_pressure_constraint, vaft.code.inject_pressure_constraint.
kinetic_pressure_points
function
source
kinetic_pressure_points(ods: Any, time_ms: float, geq: Any = None, *, encoding: str = 'raw6', sigma_floor: float = 0.05, ti_te_ratio: Any = 'auto', ti_te_ratio_sigma: Optional[float] = None, ion_density_ratio: Optional[Callable[[np.ndarray], np.ndarray]] = None) -> PressurePoints
Build the EFIT KPRFIT pressure points for the requested encoding.
Also exported as vaft.code.efit.kinetic_pressure_points, vaft.code.kinetic_pressure_points.
KineticEFITConfig
class
source
KineticEFITConfig(executable: Optional[str] = None, workdir: Path | str = '.', shot: Optional[int] = None, time_ms: Optional[float] = None, encoding: str = 'raw6', scales: Sequence[float] = (1.0, 0.94, 0.9, 0.85, 0.8, 0.75, 0.7, 0.6, 0.5, 0.4), grid_size: int = 129, ti_te_ratio: Any = 'auto', ti_te_ratio_sigma: Optional[float] = None, base_kfile: Optional[str] = None, env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, efit_preset: Optional[str] = None, ion_density_ratio: Optional[Callable[[np.ndarray], np.ndarray]] = None, ordering_state: Mapping[str, Any] = <factory>) -> None
Configuration for a kinetic-pressure EFIT run.
Also exported as vaft.code.KineticEFITConfig, vaft.code.efit.KineticEFITConfig.
15 fields
executable: Optional[str]workdir: Path | strshot: Optional[int]time_ms: Optional[float]encoding: strscales: Sequence[float]grid_size: intti_te_ratio: Anyti_te_ratio_sigma: Optional[float]base_kfile: Optional[str]env: Mapping[str, str]timeout: Optional[float]efit_preset: Optional[str]ion_density_ratio: Optional[Callable[[np.ndarray], np.ndarray]]ordering_state: Mapping[str, Any]
KineticEFITInputs
class
source
KineticEFITInputs(workdir: Path, ods: Any = None, geqdsk: Any = None, base_kfile_text: str = '', points: Optional[PressurePoints] = None, kfiles: tuple[Path, ...] = ()) -> None
Materialized inputs for a kinetic-pressure EFIT run.
Also exported as vaft.code.KineticEFITInputs, vaft.code.efit.KineticEFITInputs.
6 fields
workdir: Pathods: Anygeqdsk: Anybase_kfile_text: strpoints: Optional[PressurePoints]kfiles: tuple[Path, ...]
KineticEFITResult
class
source
KineticEFITResult(returncode: Optional[int], workdir: Path, gfile: Optional[Path] = None, scale: Optional[float] = None, converged: bool = False, chi2: Optional[float] = None, status: str = 'ok', reason: str = '', efit_result: Any = None) -> None
Result of the PLASMA-scale sweep.
Also exported as vaft.code.KineticEFITResult, vaft.code.efit.KineticEFITResult.
9 fields · 1 members
returncode: Optional[int]workdir: Pathgfile: Optional[Path]scale: Optional[float]converged: boolchi2: Optional[float]status: strreason: strefit_result: Anyokproperty source
prepare_kinetic_efit_inputs
function
source
prepare_kinetic_efit_inputs(ods: Any, geq: Any, config: KineticEFITConfig) -> KineticEFITInputs
Generate the base magnetic kfile and build the kinetic pressure points.
Also exported as vaft.code.efit.prepare_kinetic_efit_inputs, vaft.code.prepare_kinetic_efit_inputs.
PressurePoints
class
source
PressurePoints(rpress: List[float], zpress: Optional[List[float]], pressr: List[float], sigpre: List[float], fwtpre: List[float], encoding: str = 'raw6') -> None
Diagnostic pressure points fed to EFIT’s KPRFIT=1 constraint.
Also exported as vaft.code.PressurePoints, vaft.code.efit.PressurePoints.
6 fields
rpress: List[float]zpress: Optional[List[float]]pressr: List[float]sigpre: List[float]fwtpre: List[float]encoding: str
run_kinetic_chain
function
source
run_kinetic_chain(ods: Any, geq: Any, time_ms: float, *, efit_config: KineticEFITConfig, chease_config: Any = None, **profile_modes: Any) -> dict
Full kinetic chain: profiles -> kinetic EFIT -> optional CHEASE refine.
Also exported as vaft.code.efit.run_kinetic_chain, vaft.code.run_kinetic_chain.
run_kinetic_efit
function
source
run_kinetic_efit(inputs: KineticEFITInputs, config: KineticEFITConfig) -> KineticEFITResult
Descending PLASMA-scale sweep; keep the largest converging scale.
Also exported as vaft.code.efit.run_kinetic_efit, vaft.code.run_kinetic_efit.
scale_plasma
function
source
scale_plasma(kfile_text: str, scale: float) -> str
Rescale the PLASMA= value by scale (returns patched text).
Also exported as vaft.code.efit.scale_plasma, vaft.code.scale_plasma.
vaft.code.efit.legacy
Legacy VEST/OMFIT signal-processing and constraint-shaping helpers.
annotate_constraint_equilibrium
function
source
annotate_constraint_equilibrium(EQ, times)
Stamp the constraint equilibrium’s identity without erasing its provenance.
box_average
function
source
box_average(time, data, center: float, half_width: float, *, what: str = 'signal') -> float
The mean of the samples inside [center - half_width, center + half_width].
calculate_md_by_ods
function
source
calculate_md_by_ods(ods, filament_position=[], filament_fraction=[], method='vectorized')
correct_flux_loop
function
source
correct_flux_loop(ods, *, window=None)
In the inboard flux loop near the central solenoid, there is an issue where the uncertainty in the vacuum component of the total signal becomes larger than the plasma signal. To address this, a scaling factor vector is calculated by fitting the ratio between the measured values and the calculated values before plasma onset, aligning the measured data with the calculated values.
gauss_fit4
function
source
gauss_fit4(coef, x)
min_gauss_fit4
function
source
min_gauss_fit4(coef, x, y)
set_discharge_index
functionDeprecated usage
source
set_discharge_index(ods)
Set the time range higher than 20 kA and between 0.3 ~ 0.36 sec with manual tstep. If no Ip > 20 kA is found, return time range and ‘vacuum’; otherwise return time range and ‘plasma’.
smooth
function
source
smooth(array, span)
vest_Halpha_tstart_tend
functionDeprecatedDeprecated usage
source
vest_Halpha_tstart_tend(ods)
Deprecated H-alpha plasma window (0.3-0.36 s, min-normalised, legacy detector).
Deprecated: Deprecated H-alpha plasma window (0.3-0.36 s, min-normalised, legacy detector).
vest_rspv1
function
source
vest_rspv1(ods, plasma, rz)
vest_signal_onoffsetpeak
function
source
vest_signal_onoffsetpeak(time, data, tstart, tend, threshold)
Finds the onset, peak, and offset times of the signal within the specified time range by normalizing the signal and identifying the time window where the signal exceeds a threshold.
vfit_equilibrium_form_constraints
function
source
vfit_equilibrium_form_constraints(EQ, PF, MG, TF, times, constraints, average, *, bpol_probe_count=None)
vfit_signal_startend
function
source
vfit_signal_startend(time, data)
vaft.code.efit.linearization
Read and analyse EFIT’s opt-in response-matrix diagnostics.
analyze_efit_identifiability
function
source
analyze_efit_identifiability(problem: EFITLinearization | EFITLinearizationBlock | str | Path, config: IdentifiabilityConfig | None = None) -> IdentifiabilityReport
Analyse row-family information in a native EFIT response matrix.
Also exported as vaft.code.efit.analyze_efit_identifiability.
EFITLinearization
class
source
EFITLinearization(path: Path, sha256: str, schema_id: str, schema_version: int, source_revision: str, executable_sha256: str, matrix_state: str, shot: int, time_ms: float, jtime: int | None, outer_iteration: int | None, total_iteration: int | None, ivesel: int | None, ip_measured: float | None, ip_reconstructed: float | None, vessel_current_sum: float | None, chipasma: float | None, main: EFITLinearizationBlock, external_current: EFITLinearizationBlock | None, final_brsp: np.ndarray, attributes: Mapping[str, Any] = <factory>) -> None
Validated contents of one efit_response_diagnostics_v1 sidecar.
Also exported as vaft.code.efit.EFITLinearization.
21 fields · 2 members
path: Pathsha256: strschema_id: strschema_version: intsource_revision: strexecutable_sha256: strmatrix_state: strshot: inttime_ms: floatjtime: int | Noneouter_iteration: int | Nonetotal_iteration: int | Noneivesel: int | Noneip_measured: float | Noneip_reconstructed: float | Nonevessel_current_sum: float | Nonechipasma: float | Nonemain: EFITLinearizationBlockexternal_current: EFITLinearizationBlock | Nonefinal_brsp: np.ndarrayattributes: Mapping[str, Any]time_secondsproperty sourceblockmethod source
EFITLinearizationBlock
class
source
EFITLinearizationBlock(name: str, weighted_a: np.ndarray, weighted_rhs: np.ndarray, solver_a: np.ndarray, solver_rhs: np.ndarray, solver_exact_c: np.ndarray, solver_exact_d: np.ndarray, exact_c: np.ndarray, exact_d: np.ndarray, solver_solution: np.ndarray, physical_solution: np.ndarray, column_scale: np.ndarray, singular_values: np.ndarray, right_singular_vectors: np.ndarray, retained_mask: np.ndarray, row_family_id: np.ndarray, row_family: tuple[str, ...], row_kind: tuple[str, ...], row_channel: np.ndarray, row_statistical: np.ndarray, row_measurement: np.ndarray, row_reconstruction: np.ndarray, row_physical_residual: np.ndarray, row_uncertainty: np.ndarray, row_submitted_fwt: np.ndarray, row_processed_weight: np.ndarray, row_solver_weighted_residual: np.ndarray, parameter_name: tuple[str, ...], parameter_role_id: np.ndarray, parameter_role: tuple[str, ...], parameter_index: np.ndarray, parameter_units: tuple[str, ...], validation: LinearSolveValidation, solver_method: str = '', reduced_solve: EFITReducedLinearSolve | None = None, outer_iteration: int | None = None, total_iteration: int | None = None, status: int | None = None, condin: float | None = None, condno: float | None = None) -> None
One response solve exported by EFIT in both physical and solver units.
Also exported as vaft.code.efit.EFITLinearizationBlock.
40 fields · 4 members
name: strweighted_a: np.ndarrayweighted_rhs: np.ndarraysolver_a: np.ndarraysolver_rhs: np.ndarraysolver_exact_c: np.ndarraysolver_exact_d: np.ndarrayexact_c: np.ndarrayexact_d: np.ndarraysolver_solution: np.ndarrayphysical_solution: np.ndarraycolumn_scale: np.ndarraysingular_values: np.ndarrayright_singular_vectors: np.ndarrayretained_mask: np.ndarrayrow_family_id: np.ndarrayrow_family: tuple[str, ...]row_kind: tuple[str, ...]row_channel: np.ndarrayrow_statistical: np.ndarrayrow_measurement: np.ndarrayrow_reconstruction: np.ndarrayrow_physical_residual: np.ndarrayrow_uncertainty: np.ndarrayrow_submitted_fwt: np.ndarrayrow_processed_weight: np.ndarrayrow_solver_weighted_residual: np.ndarrayparameter_name: tuple[str, ...]parameter_role_id: np.ndarrayparameter_role: tuple[str, ...]parameter_index: np.ndarrayparameter_units: tuple[str, ...]validation: LinearSolveValidationsolver_method: strreduced_solve: EFITReducedLinearSolve | Noneouter_iteration: int | Nonetotal_iteration: int | Nonestatus: int | Nonecondin: float | Nonecondno: float | Nonenrowproperty sourcencolproperty sourcenexactproperty sourcesolver_residualproperty — Residual paired with the exported linear solve, never final BRSP. source
EFITLinearizationError
class
source
Raised when a response sidecar is incomplete or internally invalid.
Also exported as vaft.code.efit.EFITLinearizationError.
FAMILY_IDS
data
FAMILY_IDS = <builtins.mappingproxy>
FamilyInformation
class
source
FamilyInformation(family: str, row_count: int, diagnostic_chi2: float | None, solver_objective: float, solver_objective_share: float | None, rank_gain: tuple[int, ...], weak_subspace_fraction: float, maximum_weak_singular_lift: float, curvature_inverse_trace_reduction: float, classifications: tuple[str, ...]) -> None
Also exported as vaft.code.efit.FamilyInformation.
10 fields
family: strrow_count: intdiagnostic_chi2: float | Nonesolver_objective: floatsolver_objective_share: float | Nonerank_gain: tuple[int, ...]weak_subspace_fraction: floatmaximum_weak_singular_lift: floatcurvature_inverse_trace_reduction: floatclassifications: tuple[str, ...]
IdentifiabilityConfig
class
source
IdentifiabilityConfig(block: str = 'main', condin: float | None = None, cutoff_multipliers: tuple[float, ...] = (0.1, 1.0, 10.0), resolved_multiple: float = 10.0, unresolved_multiple: float = 0.1, independent_norm_fraction: float = 0.1, reinforcing_weak_lift: float = 10.0, reinforcing_trace_reduction: float = 0.2, overwhelmed_objective_share: float = 0.01, core_families: tuple[str, ...] = ('plasma_current', 'pf_current', 'pf_relation'), nonlinear_material_response: frozenset[str] = frozenset({}), structural_effects: frozenset[str] = frozenset({}), accounting_confounded: frozenset[str] = frozenset({})) -> None
Numerical policy for conditional information classification.
Also exported as vaft.code.efit.IdentifiabilityConfig.
13 fields
block: strcondin: float | Nonecutoff_multipliers: tuple[float, ...]resolved_multiple: floatunresolved_multiple: floatindependent_norm_fraction: floatreinforcing_weak_lift: floatreinforcing_trace_reduction: floatoverwhelmed_objective_share: floatcore_families: tuple[str, ...]nonlinear_material_response: frozenset[str]structural_effects: frozenset[str]accounting_confounded: frozenset[str]
IdentifiabilityReport
class
source
IdentifiabilityReport(block: str, condin: float, cutoff_multipliers: tuple[float, ...], cutoffs: tuple[float, ...], nominal_cutoff: float, parameter_scale: np.ndarray, null_space_basis: np.ndarray, gauss_newton_curvature: np.ndarray, scaled_projected_curvature: np.ndarray, exact_constraint_rank: int, singular_values: np.ndarray, ranks: tuple[int, ...], nullity: int, modes: tuple[ModeInformation, ...], maximum_family_share_sum_error: float, families: Mapping[str, FamilyInformation], subsets: Mapping[str, SubsetInformation], row_audit: tuple[RowInformation, ...], ip_accounting: IpAccounting | None) -> None
Local response information with sensitivity to EFIT’s rank cutoff.
Also exported as vaft.code.efit.IdentifiabilityReport.
19 fields · 1 members
block: strcondin: floatcutoff_multipliers: tuple[float, ...]cutoffs: tuple[float, ...]nominal_cutoff: floatparameter_scale: np.ndarraynull_space_basis: np.ndarraygauss_newton_curvature: np.ndarrayscaled_projected_curvature: np.ndarrayexact_constraint_rank: intsingular_values: np.ndarrayranks: tuple[int, ...]nullity: intmodes: tuple[ModeInformation, ...]maximum_family_share_sum_error: floatfamilies: Mapping[str, FamilyInformation]subsets: Mapping[str, SubsetInformation]row_audit: tuple[RowInformation, ...]ip_accounting: IpAccounting | Noneto_dictmethod — Return a JSON-compatible representation for workflow artifacts. source
IpAccounting
class
source
IpAccounting(measured: float | None, reconstructed: float | None, solve_residual: float | None, vessel_current_sum: float | None, predicted_vcurrt_chi2: float | None, reported_chipasma: float | None) -> None
Also exported as vaft.code.efit.IpAccounting.
6 fields
measured: float | Nonereconstructed: float | Nonesolve_residual: float | Nonevessel_current_sum: float | Nonepredicted_vcurrt_chi2: float | Nonereported_chipasma: float | None
LinearSolveValidation
class
source
LinearSolveValidation(column_scaling_relative_error: float, solution_scaling_relative_error: float, singular_value_relative_error: float | None, solver_reproduction_relative_error: float | None, exact_constraint_residual_norm: float | None, exact_constraint_tolerance: float | None) -> None
Numerical reproduction checks performed while reading a sidecar.
Also exported as vaft.code.efit.LinearSolveValidation.
6 fields
column_scaling_relative_error: floatsolution_scaling_relative_error: floatsingular_value_relative_error: float | Nonesolver_reproduction_relative_error: float | Noneexact_constraint_residual_norm: float | Noneexact_constraint_tolerance: float | None
ModeInformation
class
source
ModeInformation(index: int, singular_value: float, state: str, free_direction: np.ndarray, scaled_parameter_direction: np.ndarray, physical_parameter_direction: np.ndarray, family_shares: Mapping[str, float], parameter_role_shares: Mapping[str, float]) -> None
Also exported as vaft.code.efit.ModeInformation.
8 fields
index: intsingular_value: floatstate: strfree_direction: np.ndarrayscaled_parameter_direction: np.ndarrayphysical_parameter_direction: np.ndarrayfamily_shares: Mapping[str, float]parameter_role_shares: Mapping[str, float]
PARAMETER_ROLE_IDS
data
PARAMETER_ROLE_IDS = <builtins.mappingproxy>
read_efit_linearization
function
source
read_efit_linearization(path: str | Path) -> EFITLinearization
Load and structurally validate one native EFIT response sidecar.
Also exported as vaft.code.efit.read_efit_linearization.
RowInformation
class
source
RowInformation(index: int, family: str, kind: str, channel: int, statistical: bool, physical_residual: float | None, uncertainty: float | None, submitted_fwt: float | None, processed_weight: float | None, diagnostic_chi2: float | None, solver_objective: float) -> None
Also exported as vaft.code.efit.RowInformation.
11 fields
index: intfamily: strkind: strchannel: intstatistical: boolphysical_residual: float | Noneuncertainty: float | Nonesubmitted_fwt: float | Noneprocessed_weight: float | Nonediagnostic_chi2: float | Nonesolver_objective: float
SCHEMA_ID
data
SCHEMA_ID = 'efit_response_diagnostics_v1'
SCHEMA_VERSION
data
SCHEMA_VERSION = 1
SubsetInformation
class
source
SubsetInformation(name: str, families: tuple[str, ...], row_count: int, singular_values: np.ndarray, ranks: tuple[int, ...], nullity: int, curvature_inverse_trace: float, maximum_principal_angle_degrees: float | None) -> None
Also exported as vaft.code.efit.SubsetInformation.
8 fields
name: strfamilies: tuple[str, ...]row_count: intsingular_values: np.ndarrayranks: tuple[int, ...]nullity: intcurvature_inverse_trace: floatmaximum_principal_angle_degrees: float | None
vaft.code.efit.magnetic
Magnetic (routine) EFIT adapter: config, prepare/run/collect, gfile conversion.
collect_efit_outputs
function
source
collect_efit_outputs(workdir: str | Path, config: EFITConfig | None = None, *, returncode: int | None = None, runtime_status: str = 'collected', runtime_reason: str = '', executable: str | Path | None = None, expected_kfiles: Sequence[str | Path] = (), validation_config: EFITValidationConfig | None = None, constraints_ods: Any = None, diagnostics_dir: str | Path | None = None, requested_diagnostics: bool = False, restart_file: str | Path | None = None, restart_pre_run_fingerprint: tuple[int, int, int, int, str] | None = None, executed_kfiles: Sequence[str | Path] = (), direction_identity: Mapping[str, str] | None = None, restart_control_sha256: str | None = None, pre_run_output_fingerprints: Mapping[str, tuple[int, int, int, int, str]] | None = None, configuration: Mapping[str, Any] | None = None) -> EFITResult
Collect EFIT files and assign independent status to every attempted slice.
Also exported as vaft.code.collect_efit_outputs, vaft.code.efit.collect_efit_outputs.
EFIT_EXEC_ENV
data
EFIT_EXEC_ENV = 'EFIT'
EFIT_HOME_ENV
data
EFIT_HOME_ENV = 'EFITHOME'
EFIT_HOME_EXECUTABLE
data
EFIT_HOME_EXECUTABLE = <pathlib.PosixPath>
EFITConfig
class
source
EFITConfig(executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), shot: Optional[int] = None, times: Optional[Sequence[float]] = None, constraint_options: Mapping[str, Any] = <factory>, profile_options: Mapping[str, Any] = <factory>, env: Mapping[str, str] = <factory>, args: Sequence[str] = (), timeout: Optional[float] = None, npprime: Optional[int] = None, nffprime: Optional[int] = None, stack_size_kb: Optional[int] = 32768, profile: EFITProfileConfig | None = None, initialization: EFITInitializationConfig = <factory>, numerics: EFITNumericsConfig = <factory>, constraints: EFITConstraintConfig = <factory>, provenance: Mapping[str, Any] = <factory>, ordering_state: Mapping[str, Any] = <factory>, export_linearization: bool = False, direction_constraint: Path | str | None = None, restart_from: Path | str | None = None, write_restart: bool = False, iteration_history: str = 'none', backend: Optional['ExecutionBackend'] = None) -> None
Python-first EFIT workflow configuration.
Also exported as vaft.code.EFITConfig, vaft.code.efit.EFITConfig.
24 fields · 1 members
executable: Optional[str]workdir: Path | strshot: Optional[int]times: Optional[Sequence[float]]constraint_options: Mapping[str, Any]profile_options: Mapping[str, Any]env: Mapping[str, str]args: Sequence[str]timeout: Optional[float]npprime: Optional[int]nffprime: Optional[int]stack_size_kb: Optional[int]profile: EFITProfileConfig | Noneinitialization: EFITInitializationConfignumerics: EFITNumericsConfigconstraints: EFITConstraintConfigprovenance: Mapping[str, Any]ordering_state: Mapping[str, Any]export_linearization: booldirection_constraint: Path | str | Nonerestart_from: Path | str | Nonewrite_restart: booliteration_history: strbackend: Optional['ExecutionBackend']scientific_configmethod — Return the fully resolved scientific configuration. source
EFITInputs
class
source
EFITInputs(workdir: Path, ods: Any = None, geqdsk: Any = None, kfiles: tuple[Path, ...] = (), files: tuple[Path, ...] = (), configuration: Mapping[str, Any] = <factory>, manifest: Path | None = None) -> None
Input bundle for an EFIT run.
Also exported as vaft.code.EFITInputs, vaft.code.efit.EFITInputs.
7 fields
workdir: Pathods: Anygeqdsk: Anykfiles: tuple[Path, ...]files: tuple[Path, ...]configuration: Mapping[str, Any]manifest: Path | None
EFITResult
class
source
EFITResult(returncode: Optional[int], workdir: Path, gfiles: tuple[Path, ...] = (), afiles: tuple[Path, ...] = (), mfiles: tuple[Path, ...] = (), kfiles: tuple[Path, ...] = (), logs: tuple[Path, ...] = (), stdout: str = '', stderr: str = '', geqdsk: tuple[Any, ...] = (), keqdsk: tuple[Any, ...] = (), meqdsk: tuple[Any, ...] = (), parse_errors: tuple[str, ...] = (), mapping_diagnostics: tuple[Mapping[str, Any], ...] = (), artifact_hashes: Mapping[str, str] = <factory>, ods: Any = None, status: str = 'completed', reason: str = '', slice_statuses: tuple[EFITSliceStatus, ...] = (), configuration: Mapping[str, Any] = <factory>, linearization_files: tuple[Path, ...] = (), linearizations: tuple[EFITLinearization, ...] = (), restart_file: Path | None = None, diagnostic_errors: tuple[str, ...] = (), iteration_history: EFITIterationHistory | None = None, iteration_history_file: Path | None = None) -> None
Collected EFIT run status, files, logs, and parsed equilibria.
Also exported as vaft.code.EFITResult, vaft.code.efit.EFITResult.
26 fields · 2 members
returncode: Optional[int]workdir: Pathgfiles: tuple[Path, ...]afiles: tuple[Path, ...]mfiles: tuple[Path, ...]kfiles: tuple[Path, ...]logs: tuple[Path, ...]stdout: strstderr: strgeqdsk: tuple[Any, ...]keqdsk: tuple[Any, ...]meqdsk: tuple[Any, ...]parse_errors: tuple[str, ...]mapping_diagnostics: tuple[Mapping[str, Any], ...]artifact_hashes: Mapping[str, str]ods: Anystatus: strreason: strslice_statuses: tuple[EFITSliceStatus, ...]configuration: Mapping[str, Any]linearization_files: tuple[Path, ...]linearizations: tuple[EFITLinearization, ...]restart_file: Path | Nonediagnostic_errors: tuple[str, ...]iteration_history: EFITIterationHistory | Noneiteration_history_file: Path | Noneokproperty sourceusableproperty — Whether at least one collected slice is scientifically usable. source
find_efit_executable
function
source
find_efit_executable(config: EFITConfig | None = None) -> Path | None
Return EFIT resolved from explicit config, $EFITHOME, or $EFIT.
Also exported as vaft.code.efit.find_efit_executable.
gfile_to_omas
function
source
gfile_to_omas(self, ods=None, time_index=0, profile_index=0, allow_derived_data=True)
translate gEQDSK class to OMAS data structure
Also exported as vaft.code.efit.gfile_to_omas, vaft.code.gfile_to_omas.
prepare_efit_inputs
function
source
prepare_efit_inputs(ods: Any, config: EFITConfig) -> EFITInputs
Prepare EFIT input files from an ODS and workflow configuration.
Also exported as vaft.code.efit.prepare_efit_inputs, vaft.code.prepare_efit_inputs.
resolved_efit_configuration
function
source
resolved_efit_configuration(config: EFITConfig) -> dict[str, Any]
Return the canonical JSON-compatible configuration for an EFIT run.
Also exported as vaft.code.efit.resolved_efit_configuration, vaft.code.resolved_efit_configuration.
run_efit
function
source
run_efit(inputs: EFITInputs, config: EFITConfig) -> EFITResult
Run EFIT with prepared inputs and collect produced outputs.
Also exported as vaft.code.efit.run_efit, vaft.code.run_efit.
unrecorded_efit_configuration
function
source
unrecorded_efit_configuration(config: EFITConfig) -> dict[str, Any]
The configuration record of a collection over k-files nobody recorded.
Also exported as vaft.code.efit.unrecorded_efit_configuration.
UNRECORDED_SCIENTIFIC_SHA256
data
UNRECORDED_SCIENTIFIC_SHA256 = 'unrecorded'
Also exported as vaft.code.efit.UNRECORDED_SCIENTIFIC_SHA256.
vaft.code.efit.presets
Named EFIT configurations a pipeline can select by name.
apply_sigma_floor
function
source
apply_sigma_floor(ods, fraction: float, families: Iterable[str] = ('bpol_probe', 'flux_loop')) -> list[dict[str, Any]]
Raise each fitted channel’s measured_error_upper to fraction x its family’s median |
m | . |
Also exported as vaft.code.efit.apply_sigma_floor.
DEFAULT_PRESET
data
DEFAULT_PRESET = 'statistical_891'
Also exported as vaft.code.efit.DEFAULT_PRESET.
efit_preset
function
source
efit_preset(name: str) -> EFITPreset
The preset called name; a ValueError names the known ones.
Also exported as vaft.code.efit.efit_preset.
EFITPreset
class
source
EFITPreset(name: str, description: str, scientific: EFITScientificConfig = <factory>) -> None
A named scientific configuration.
Also exported as vaft.code.efit.EFITPreset.
3 fields · 4 members
name: strdescription: strscientific: EFITScientificConfigsigma_floorproperty — The configuration’s relative sigma floor (constraints.sigma_floor). sourcefloor_familiesproperty sourceprepare_constraintsmethod — A copy ofodswith this preset’s sigma floor applied, and what it changed. sourcerecordmethod — What a stage writes to say this preset built its inputs. source
FLOOR_FAMILIES
data
FLOOR_FAMILIES = ('bpol_probe', 'flux_loop')
preset_of
function
source
preset_of(scientific: EFITScientificConfig) -> EFITPreset | None
The preset whose scientific configuration scientific is, if any.
Also exported as vaft.code.efit.preset_of.
PRESET_RECORD
data
PRESET_RECORD = 'efit_preset.json'
PRESETS
data
PRESETS = <builtins.dict>
Also exported as vaft.code.efit.PRESETS.
PSI_ONLY_MAX_ITERATIONS
data
PSI_ONLY_MAX_ITERATIONS = 514
PSI_ONLY_SAICON
data
PSI_ONLY_SAICON = 10000000000.0
vaft.code.efit.recovery
The Gaussian-profile recovery of rejected B-probe constraints, as a backend (issue #296).
family_of
function
source
family_of(index: int, families: ProbeFamilies) -> str | None
Which family a probe belongs to; the last family wins, as the legacy builder’s sequential assignment did (on VEST the families are disjoint).
gaussian_probe_recovery
function
source
gaussian_probe_recovery(EQ: Any, decisions: ChannelDecisions, *, mode: int, families: ProbeFamilies, geometry: Sequence[float] = (0.54, 0.5, 0.46, 0.42, 0.38, 0.34, 0.3, 0.26, 0.22, 0.16, 0.12, 0.08, 0.04, 0, -0.04, -0.08, -0.12, -0.16, -0.22, -0..., ip_floor: float = 15000.0, uncertainty: str = 'residual_rms') -> ChannelDecisions
Replace rejected (mode=1) or every (mode=2) probe reading by a family Gaussian fit.
Also exported as vaft.code.efit.gaussian_probe_recovery.
GAUSSIAN_PROVENANCE
data
GAUSSIAN_PROVENANCE = 'gaussian_fit4'
IP_FIT_FLOOR
data
IP_FIT_FLOOR = 15000.0
probe_families
function
source
probe_families(magnetics: Any, *, count: int) -> ProbeFamilies
The legacy family membership, from probe positions, clamped to count.
Also exported as vaft.code.efit.probe_families.
PROBE_Z_TABLE
data
PROBE_Z_TABLE = (0.54, 0.5, 0.46, 0.42, 0.38, 0.34, 0.3, 0.26, 0.22, 0.16, 0.12, 0.08, 0.04, 0, -0.04, -0.08, -0.12, -0.16, -0.22, -0...
ProbeFamilies
class
source
ProbeFamilies(inboard: np.ndarray, side: np.ndarray, outboard: np.ndarray)
Zero-based probe indexes per geometric family, ascending.
Also exported as vaft.code.efit.ProbeFamilies.
vaft.code.efit.slice_name
The one encoder/decoder for the time part of EFIT file names.
decode_time_suffix
function
source
decode_time_suffix(suffix: str) -> int
"00306" -> 306000, "00306_320" -> 306320; ValueError otherwise.
encode_time_suffix
function
source
encode_time_suffix(microseconds: int) -> str
306000 -> "00306", 306320 -> "00306_320".
file_name_microseconds
function
source
file_name_microseconds(name: str | Path) -> int | None
Microseconds encoded in an EFIT slice file name, None when there are none.
slice_file_name
function
source
slice_file_name(kind: str, shot: int | str, time_seconds: float) -> str
Name of the kind (k/g/a/m) file of one slice, no extension.
split_slice_file_name
function
source
split_slice_file_name(name: str | Path) -> tuple[str, int]
"g039915.00306_320" -> ("039915", 306320).
time_to_microseconds
function
source
time_to_microseconds(time_seconds: float) -> int
Slice time in seconds -> the integer microseconds the file name carries.
whole_millisecond_tstep
function
source
whole_millisecond_tstep(text: str) -> float
An argparse type for --tstep: seconds, a whole number of milliseconds.
vaft.code.efit.status
Structured, JSON-compatible EFIT slice status and validation.
apply_temporal_continuity
function
source
apply_temporal_continuity(statuses: Sequence[EFITSliceStatus], config: EFITValidationConfig | None = None) -> tuple[EFITSliceStatus, ...]
Mark axis jumps without discarding otherwise successful neighboring slices.
Also exported as vaft.code.apply_temporal_continuity, vaft.code.efit.apply_temporal_continuity.
EFIT_FAILURE_CODES
data
EFIT_FAILURE_CODES = ('runtime_error', 'timeout', 'nonzero_returncode', 'missing_kfile', 'missing_gfile', 'missing_afile', 'missing_mfile'...
Also exported as vaft.code.efit.EFIT_FAILURE_CODES.
EFITSliceStatus
class
source
EFITSliceStatus(shot: int, time: float, runtime_ok: bool, output_ok: bool, numerical_ok: bool, physical_ok: bool, overall_status: str, failure_codes: tuple[str, ...] = (), metrics: Mapping[str, float] = <factory>, provenance: Mapping[str, Any] = <factory>) -> None
Independent runtime, output, numerical, and physical status for one slice.
Also exported as vaft.code.EFITSliceStatus, vaft.code.efit.EFITSliceStatus.
10 fields · 3 members
shot: inttime: floatruntime_ok: booloutput_ok: boolnumerical_ok: boolphysical_ok: booloverall_status: strfailure_codes: tuple[str, ...]metrics: Mapping[str, float]provenance: Mapping[str, Any]usableproperty sourceto_dictmethod — Return a JSON-compatible representation. sourcefrom_dictclassmethod — Restore a status serialized byto_dict. source
EFITValidationConfig
class
source
EFITValidationConfig(require_afile: bool = False, require_mfile: bool = False, pressure_negative_tolerance: float = 0.0, stored_energy_negative_tolerance: float = 0.0, li_range: tuple[float, float] = (0.0, 10.0), beta_range: tuple[float, float] = (0.0, 10.0), q_absolute_range: tuple[float, float] = (0.0, 100.0), volume_range: tuple[float, float] = (0.0, 100.0), minimum_boundary_area: float = 1e-08, maximum_axis_step: float | None = 0.2, maximum_diagnostic_residual: float | None = None) -> None
Thresholds used to decide whether an EFIT slice is scientifically usable.
Also exported as vaft.code.EFITValidationConfig, vaft.code.efit.EFITValidationConfig.
11 fields
require_afile: boolrequire_mfile: boolpressure_negative_tolerance: floatstored_energy_negative_tolerance: floatli_range: tuple[float, float]beta_range: tuple[float, float]q_absolute_range: tuple[float, float]volume_range: tuple[float, float]minimum_boundary_area: floatmaximum_axis_step: float | Nonemaximum_diagnostic_residual: float | None
validate_efit_slice
function
source
validate_efit_slice(*, shot: int, time: float, runtime_status: str, returncode: int | None, kfile: str | Path | None, gfile: str | Path | None, afile: str | Path | None = None, mfile: str | Path | None = None, geqdsk: Mapping[str, Any] | None = None, parse_error: str | None = None, converged: bool | None = None, metrics: Mapping[str, float] | None = None, provenance: Mapping[str, Any] | None = None, config: EFITValidationConfig | None = None) -> EFITSliceStatus
Validate one EFIT attempt without conflating process and science status.
Also exported as vaft.code.efit.validate_efit_slice, vaft.code.validate_efit_slice.
vaft.code.efit.termination
What EFIT’s own log says about how each slice ended (issues #76, #171).
EFIT_LOG_PATTERNS
data
EFIT_LOG_PATTERNS = <builtins.dict>
Also exported as vaft.code.efit.EFIT_LOG_PATTERNS.
parse_slices
function
source
parse_slices(text: str) -> list[dict[str, Any]]
Per-slice termination evidence, in the order EFIT processed them.
Also exported as vaft.code.efit.parse_slices.
vaft.code.efit.toolchain
The EFIT toolchain: two executable roles, one root, one build lineage (issue #194).
BUILD_TREE_LAYOUT
data
BUILD_TREE_LAYOUT = <builtins.dict>
EFIT_HOME_ENV
data
EFIT_HOME_ENV = 'EFITHOME'
EFIT_LEGACY_EXEC_ENV
data
EFIT_LEGACY_EXEC_ENV = 'EFIT'
EFIT_ROLES
data
EFIT_ROLES = ('efit', 'efund')
executable_identity
function
source
executable_identity(path: str | os.PathLike[str], role: str) -> ExecutableIdentity
Checksum and, where recoverable, the source revision behind an executable.
Also exported as vaft.code.efit.executable_identity.
ExecutableIdentity
class
source
ExecutableIdentity(role: str, path: str, sha256: str, size: int, mtime: str, build_revision: str | None = None, build_root: str | None = None) -> None
What a table manifest or a run record says about one binary.
7 fields · 1 members
role: strpath: strsha256: strsize: intmtime: strbuild_revision: str | Nonebuild_root: str | Noneas_dictmethod source
INSTALLED_LAYOUT
data
INSTALLED_LAYOUT = <builtins.dict>
resolve_role
function
source
resolve_role(role: str, *, explicit: str | os.PathLike[str] | None = None, env: Mapping[str, str] | None = None) -> Path | None
One role’s executable: explicit path, then $EFITHOME in either layout.
resolve_toolchain
function
source
resolve_toolchain(*, efit_executable: str | os.PathLike[str] | None = None, efund_executable: str | os.PathLike[str] | None = None, env: Mapping[str, str] | None = None) -> dict[str, Path | None]
Both roles, resolved by the same rule; None for a role nothing configures.
Also exported as vaft.code.efit.resolve_toolchain.
toolchain_identities
function
source
toolchain_identities(resolved: Mapping[str, Path | None]) -> dict[str, dict[str, Any] | None]
Identities for every resolved role, None where a role is unconfigured.
unconfigured_reason
function
source
unconfigured_reason(role: str = 'efit') -> str
vaft.code.execution
Execution backends: how an adapter’s prepared command is actually run.
BACKEND_ENV
data
BACKEND_ENV = 'VAFT_EXECUTION_BACKEND'
BACKEND_NAMES
data
BACKEND_NAMES = ('local', 'slurm', 'remote')
default_backend
function
source
default_backend() -> ExecutionBackend
The backend $VAFT_EXECUTION_BACKEND selects.
execution_environment
function
source
execution_environment(request: ExecutionRequest, base: Optional[Mapping[str, str]] = None) -> dict[str, str]
The full environment a local launch of request receives.
ExecutionBackend
class
source
ExecutionBackend(*args, **kwargs)
Anything that can run an ExecutionRequest to completion.
Also exported as vaft.code.ExecutionBackend.
1 members
runmethod — Run the request and report how it ended. source
ExecutionRequest
class
source
ExecutionRequest(command: Sequence[str], workdir: Path, env: Mapping[str, str] = <factory>, stdin: Optional[str] = None, timeout: Optional[float] = None, log_path: Optional[Path] = None, resources: ResourceRequest = <factory>, label: str = '') -> None
One program launch, fully described.
Also exported as vaft.code.ExecutionRequest.
8 fields
command: Sequence[str]workdir: Pathenv: Mapping[str, str]stdin: Optional[str]timeout: Optional[float]log_path: Optional[Path]resources: ResourceRequestlabel: str
ExecutionResult
class
source
ExecutionResult(returncode: Optional[int], stdout: str = '', stderr: str = '', timed_out: bool = False, elapsed_s: float = 0.0, launcher: tuple[str, ...] = (), log_path: Optional[Path] = None, job_id: Optional[str] = None, runtime_status: str = '', run_s: Optional[float] = None, peak_rss_mb: Optional[float] = None, waited_for: str = '') -> None
What a backend observed about one launch.
Also exported as vaft.code.ExecutionResult.
12 fields
returncode: Optional[int]stdout: strstderr: strtimed_out: boolelapsed_s: floatlauncher: tuple[str, ...]log_path: Optional[Path]job_id: Optional[str]runtime_status: strrun_s: Optional[float]peak_rss_mb: Optional[float]waited_for: str
LocalBackend
class
source
LocalBackend(*, reserve_mb: Optional[float] = None, memory_limit_mb: Optional[float] = None, admission_wait_s: Optional[float] = 3600.0, floor_mb: float = 4096.0, poll_interval_s: float = 2.0, ledger_dir: Optional[Path] = None) -> None
Run the command as a child process of the current Python process.
Also exported as vaft.code.LocalBackend.
1 members
runmethod source
resolve_backend
function
source
resolve_backend(config: Any = None) -> ExecutionBackend
The backend config names, else default_backend.
Also exported as vaft.code.resolve_backend.
ResourceRequest
class
source
ResourceRequest(ntasks: int = 1, threads_per_task: Optional[int] = None, memory_mb: Optional[int] = None) -> None
Compute resources one execution asks for.
Also exported as vaft.code.ResourceRequest.
3 fields
ntasks: intthreads_per_task: Optional[int]memory_mb: Optional[int]
RUNTIME_COMPLETED
data
RUNTIME_COMPLETED = 'completed'
RUNTIME_MEMORY_LIMIT
data
RUNTIME_MEMORY_LIMIT = 'memory_limit'
RUNTIME_QUEUE_TIMEOUT
data
RUNTIME_QUEUE_TIMEOUT = 'queue_timeout'
RUNTIME_STATUSES
data
RUNTIME_STATUSES = ('completed', 'timeout', 'queue_timeout', 'memory_limit')
RUNTIME_TIMEOUT
data
RUNTIME_TIMEOUT = 'timeout'
THREAD_ENV_VARIABLES
data
THREAD_ENV_VARIABLES = ('OMP_NUM_THREADS', 'MKL_NUM_THREADS', 'OPENBLAS_NUM_THREADS', 'VECLIB_MAXIMUM_THREADS', 'NUMEXPR_NUM_THREADS')
timeout_reason
function
source
timeout_reason(program: str, execution: ExecutionResult, timeout: Optional[float]) -> str
The one-line reason an adapter gives for a timed-out execution.
vaft.code.flare
FLARE interoperability: the equilibrium handshake.
BRZPHI_IMAGINARY_COLUMNS
data
BRZPHI_IMAGINARY_COLUMNS = (4, 6, 8)
flare_equilibrium_scales
function
source
flare_equilibrium_scales(equilibrium: Any, *, clockwise_phi: bool | None = None, source_cocos: int | None = None) -> FlareEquilibriumScales
Derive scale_Ip and scale_Bt for a GEQDSK FLARE is to trace.
flare_executable
function
source
flare_executable(home: str | os.PathLike[str] | None = None) -> Path
Locate the flare driver beneath its installation root.
FLARE_TASKS
data
FLARE_TASKS = ('run', 'equi2d_autoconf', 'equi3d_autoconf', 'find_resonances', 'footprint_parameters', 'geqdsk', 'mgen', 'poincare_...
FlareConfig
class
source
FlareConfig(executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), processes: Optional[int] = None, env: Mapping[str, str] = <factory>, args: Sequence[str] = (), timeout: Optional[float] = None, backend: Optional['ExecutionBackend'] = None) -> None
Where FLARE is and how to invoke it.
7 fields
executable: Optional[str]workdir: Path | strprocesses: Optional[int]env: Mapping[str, str]args: Sequence[str]timeout: Optional[float]backend: Optional['ExecutionBackend']
FlareEquilibriumScales
class
source
FlareEquilibriumScales(scale_ip: int, scale_bt: int, source_cocos: int, target_cocos: int, psi_per_radian: bool) -> None
The two multipliers FLARE’s control file needs, and where they came from.
5 fields
scale_ip: intscale_bt: intsource_cocos: inttarget_cocos: intpsi_per_radian: bool
FlareResult
class
source
FlareResult(returncode: Optional[int], workdir: Path, task: str, command: tuple[str, ...] = (), stdout: str = '', stderr: str = '', runtime_status: str = 'completed', elapsed_s: Optional[float] = None) -> None
One FLARE invocation: what it was asked, and what came back.
8 fields · 1 members
returncode: Optional[int]workdir: Pathtask: strcommand: tuple[str, ...]stdout: strstderr: strruntime_status: strelapsed_s: Optional[float]okproperty source
run_flare
function
source
run_flare(task: str, config: FlareConfig | None = None, *, home: str | os.PathLike[str] | None = None, extra_args: Sequence[str] = ()) -> FlareResult
Run one FLARE subcommand in a working directory.
write_helicity_flipped_field
function
source
write_helicity_flipped_field(source: str | os.PathLike[str], destination: str | os.PathLike[str] | None = None) -> Path
Write the complex conjugate of a GPEC BRZPHI file.
vaft.code.formalism
The plasma-formalism provenance record of a run (issue #1727, under #1723).
AXES
data
AXES = <builtins.mappingproxy>
BULK_DESCRIPTIONS
data
BULK_DESCRIPTIONS = ('fluid', 'hybrid', 'kinetic', 'particle', 'reduced')
DISTRIBUTION_FORMULATIONS
data
DISTRIBUTION_FORMULATIONS = ('delta_f', 'full_f')
FIELD_MODELS
data
FIELD_MODELS = ('mhd_displacement', 'electrostatic', 'electromagnetic', 'prescribed')
FLUID_MODELS
data
FLUID_MODELS = ('ideal_mhd', 'resistive_mhd', 'extended_mhd')
KINETIC_COUPLINGS
data
KINETIC_COUPLINGS = ('energy', 'pressure', 'current', 'closure', 'sources')
KINETIC_EQUATIONS
data
KINETIC_EQUATIONS = ('drift_kinetic', 'gyrokinetic', 'fokker_planck')
ORBIT_REPRESENTATIONS
data
ORBIT_REPRESENTATIONS = ('full_orbit', 'guiding_center', 'gyrocenter', 'bounce_averaged')
PlasmaFormalism
class
source
PlasmaFormalism(scientific_operation: str, bulk_description: str, fluid_model: str | None = None, kinetic_equation: str | None = None, kinetic_coupling: str | None = None, kinetic_population: tuple[str, ...] | None = None, distribution_formulation: str | None = None, orbit_representation: str | None = None, spatial_domain: str | None = None, topology_domain: str | None = None, regime: str | None = None, field_model: str | None = None, derived_from: str | None = None, solver: str | None = None, extensions: Mapping[str, Any] = <factory>) -> None
The physical formulation one run used, as factorized controlled fields.
Also exported as vaft.code.PlasmaFormalism.
15 fields · 3 members
scientific_operation: strbulk_description: strfluid_model: str | Nonekinetic_equation: str | Nonekinetic_coupling: str | Nonekinetic_population: tuple[str, ...] | Nonedistribution_formulation: str | Noneorbit_representation: str | Nonespatial_domain: str | Nonetopology_domain: str | Noneregime: str | Nonefield_model: str | Nonederived_from: str | Nonesolver: str | Noneextensions: Mapping[str, Any]as_dictmethod — A stable, JSON-ready dict: every field present,Nonekept, versioned. sourceto_jsonmethod —as_dictas canonical JSON (sorted keys), for hashing and storage. sourcefrom_dictclassmethod — Rebuild a record fromas_dictoutput; any other schema version is refused. source
REGIMES
data
REGIMES = ('static', 'linear', 'nonlinear', 'quasilinear', 'steady_state', 'time_dependent')
SCHEMA_VERSION
data
SCHEMA_VERSION = 1
SCIENTIFIC_OPERATIONS
data
SCIENTIFIC_OPERATIONS = ('equilibrium', 'ideal_stability', 'resistive_stability', 'perturbed_equilibrium', 'toroidal_torque', 'neoclassical_t...
SPATIAL_DOMAINS
data
SPATIAL_DOMAINS = ('local', 'radially_global', 'whole_volume')
TOPOLOGY_DOMAINS
data
TOPOLOGY_DOMAINS = ('closed_flux_surface', 'open_field_line', 'across_separatrix')
UNKNOWN
data
UNKNOWN = 'unknown'
vaft.code.gacode
Adapters for the GACODE suite: shared runtime, profiles, and NEO.
available_platforms
function
source
available_platforms(home: Path) -> tuple[str, ...]
Platform tags this installation carries, from platform/build.
find_gacode_executable
function
source
find_gacode_executable(config: GACODEConfig | None = None, code: str = 'neo') -> Path | None
Resolve one suite member’s launcher, or None when unconfigured.
Also exported as vaft.code.find_gacode_executable.
GACODE_COMPATIBILITY_ENVS
data
GACODE_COMPATIBILITY_ENVS = ('GACODE_ROOT',)
gacode_environment
function
source
gacode_environment(config: GACODEConfig | None = None, code: str = 'neo') -> dict[str, str]
Build the environment a GACODE launcher needs.
Also exported as vaft.code.gacode_environment.
gacode_home
function
source
gacode_home(config: GACODEConfig | None = None) -> Path | None
Resolve the installation root, or None when nothing is configured.
Also exported as vaft.code.gacode_home.
GACODE_HOME_ENV
data
GACODE_HOME_ENV = 'GACODEHOME'
gacode_platform
function
source
gacode_platform(config: GACODEConfig | None = None, *, home: Path | None = None) -> str
Resolve the platform tag, refusing to guess one.
Also exported as vaft.code.gacode_platform.
GACODE_PLATFORM_ENV
data
GACODE_PLATFORM_ENV = 'GACODE_PLATFORM'
GACODE_ROOT_ENV
data
GACODE_ROOT_ENV = 'GACODE_ROOT'
GACODEConfig
class
source
GACODEConfig(executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), args: Sequence[str] = (), env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, backend: Optional['ExecutionBackend'] = None, home: Optional[str] = None, platform: Optional[str] = None, n_mpi: int = 1, n_omp: int = 1, memory_mb: Optional[int] = None) -> None
Runtime configuration shared by every GACODE backend.
Also exported as vaft.code.GACODEConfig.
11 fields
executable: Optional[str]workdir: Path | strargs: Sequence[str]env: Mapping[str, str]timeout: Optional[float]backend: Optional['ExecutionBackend']home: Optional[str]platform: Optional[str]n_mpi: intn_omp: intmemory_mb: Optional[int]
GACODERun
class
source
GACODERun(returncode: Optional[int], log: Path, runtime_status: str = 'completed', elapsed_s: Optional[float] = None) -> 'GACODERun'
What run_gacode returns: unpacks as (returncode, log).
launcher_relative_path
function
source
launcher_relative_path(code: str) -> Path
Where a suite member’s launcher sits beneath the installation root.
require_gacode_executable
function
source
require_gacode_executable(config: GACODEConfig | None = None, code: str = 'neo') -> Path
Resolve one launcher, raising an actionable error when unconfigured.
run_gacode
function
source
run_gacode(executable: Path, arguments: Sequence[str], *, cwd: Path, log_path: Path, config: GACODEConfig | None = None, code: str = 'neo') -> GACODERun
Run a GACODE launcher, capturing merged stdout and stderr to a log.
SUITE_CODES
data
SUITE_CODES = ('neo', 'tglf', 'cgyro')
SUPPORTED_CODES
data
SUPPORTED_CODES = frozenset({'cgyro', 'neo', 'tglf'})
vaft.code.gacode.cgyro
CGYRO: the GACODE suite’s local delta-f continuum gyrokinetic solver (#1354).
CGYROConfig
class
source
CGYROConfig(executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), args: Sequence[str] = (), env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, backend: Optional['ExecutionBackend'] = None, home: Optional[str] = None, platform: Optional[str] = None, n_mpi: int = 1, n_omp: int = 1, memory_mb: Optional[int] = None, n_energy: int = 8, n_xi: int = 24, n_theta: int = 32, n_radial: int = 8, n_toroidal: int = 1, ky: float = 0.3, box_size: int = 1, nonlinear: bool = False, field_model: str = 'es', collision_model: int = 4, delta_t: float = 0.01, delta_t_method: int = 1, max_time: float = 200.0, freq_tol: float = 0.001, print_step: int = 100, restart: bool = False, extra_parameters: Mapping[str, Any] = <factory>) -> None
One CGYRO run’s settings: numerics and model choices, never plasma state.
28 fields · 3 members
executable: Optional[str]workdir: Path | strargs: Sequence[str]env: Mapping[str, str]timeout: Optional[float]backend: Optional['ExecutionBackend']home: Optional[str]platform: Optional[str]n_mpi: intn_omp: intmemory_mb: Optional[int]n_energy: intn_xi: intn_theta: intn_radial: intn_toroidal: intky: floatbox_size: intnonlinear: boolfield_model: strcollision_model: intdelta_t: floatdelta_t_method: intmax_time: floatfreq_tol: floatprint_step: intrestart: boolextra_parameters: Mapping[str, Any]n_fieldproperty sourceregimeproperty sourceresolutionmethod — The numerical settings a result depends on, for provenance and convergence. source
CGYROResult
class
source
CGYROResult(returncode: Optional[int], workdir: Path, stdout: str = '', stderr: str = '', logs: tuple[Path, ...] = (), outputs: Mapping[str, tuple[Path, ...]] = <factory>, parsed: Any = None, runtime_status: str = 'completed', elapsed_s: Optional[float] = None, outputs_native: Optional[Any] = None, provenance: Mapping[str, Any] = <factory>) -> None
A CGYRO run: exit status, files, native output, and two separate verdicts.
11 fields · 3 members
returncode: Optional[int]workdir: Pathstdout: strstderr: strlogs: tuple[Path, ...]outputs: Mapping[str, tuple[Path, ...]]parsed: Anyruntime_status: strelapsed_s: Optional[float]outputs_native: Optional[Any]provenance: Mapping[str, Any]executedproperty sourceokproperty sourcequalifiedproperty source
FIELD_MODELS
data
FIELD_MODELS = <builtins.dict>
formalism
function
source
formalism(config: Optional[CGYROConfig] = None, *, solver_version: Optional[str] = None, parameters: Optional[Mapping[str, Any]] = None) -> dict[str, Any]
The #1353 formalism record of a CGYRO run.
MAX_SPECIES
data
MAX_SPECIES = 11
plasma_formalism
function
source
plasma_formalism(config: Optional[CGYROConfig] = None, *, parameters: Optional[Mapping[str, Any]] = None)
The solver-neutral #1727 record of a CGYRO run (vaft.code.formalism.PlasmaFormalism).
stage_cgyro_case
function
source
stage_cgyro_case(local: CGYROInput, workdir: str | Path, config: Optional[CGYROConfig] = None, *, state_key: Optional[Mapping[str, Any]] = None, profile: Optional[GACODEProfile] = None) -> CGYROInputs
Write input.cgyro for an already-projected local input.
TGLF_FIELD_MODEL
data
TGLF_FIELD_MODEL = <builtins.dict>
vaft.code.gacode.cgyro.fields
Memory-mapped native CGYRO fields, audited against pygacode b493397.
FieldHistory
class
source
FieldHistory(raw: np.ndarray, records: np.ndarray, theta_indices: np.ndarray, time: np.ndarray, theta: np.ndarray, kx: np.ndarray, ky: np.ndarray, radial_start: int, metadata: Mapping[str, Any]) -> None
Lazy native field with explicit selected raw records and saved theta grid.
Also exported as vaft.code.gacode.cgyro.FieldHistory.
9 fields · 1 members
raw: numpy.ndarrayrecords: numpy.ndarraytheta_indices: numpy.ndarraytime: numpy.ndarraytheta: numpy.ndarraykx: numpy.ndarrayky: numpy.ndarrayradial_start: intmetadata: collections.abc.Mapping[str, typing.Any]readmethod — Read (kx, ky, selected time) at one saved theta; no interpolated angles. source
read_field_history
function
source
read_field_history(directory, *, field='phi', time_window=None, stride=1, theta_indices=None) -> FieldHistory
Open a native field without loading flux histories or the whole field.
Also exported as vaft.code.gacode.cgyro.read_field_history.
vaft.code.gacode.cgyro.inputs
Project a GACODE profile onto CGYRO’s local input, and write input.cgyro.
cgyro_input_from_tglf
function
source
cgyro_input_from_tglf(local: TGLFInput) -> CGYROInput
Translate a TGLF local input into CGYRO’s keys. Renaming only, no new physics.
Also exported as vaft.code.gacode.cgyro.cgyro_input_from_tglf.
cgyro_parameters
function
source
cgyro_parameters(local: CGYROInput, config: Optional[CGYROConfig] = None) -> dict[str, Any]
The KEY=VALUE settings this local input and configuration mean.
Also exported as vaft.code.gacode.cgyro.cgyro_parameters.
CGYROInput
class
source
CGYROInput(r_over_a: float, geometry: Mapping[str, float], species: Mapping[str, np.ndarray], names: Sequence[str], betae_unit: float, nu_ee: float, lambda_star: float, ipccw: float, btccw: float, tglf: TGLFInput, provenance: Mapping[str, Mapping[str, Any]] = <factory>) -> None
CGYRO’s local input at one flux surface, in CGYRO’s PROFILE_MODEL=1 terms.
Also exported as vaft.code.gacode.cgyro.CGYROInput.
11 fields · 4 members
r_over_a: floatgeometry: Mapping[str, float]species: Mapping[str, np.ndarray]names: Sequence[str]betae_unit: floatnu_ee: floatlambda_star: floatipccw: floatbtccw: floattglf: TGLFInputprovenance: Mapping[str, Mapping[str, Any]]n_speciesproperty sourcenormalisationproperty sourcez_effproperty —sum(n_i Z_i^2)/n_eover the species list – what CGYRO computes. sourcemissingmethod — Names recorded as unavailable, carried over from the TGLF projection. source
CGYROInputs
class
source
CGYROInputs(workdir: Path, files: tuple[Path, ...] = (), ods: Any = None, local: Optional[CGYROInput] = None, input_cgyro: Optional[Path] = None, parameters: Mapping[str, Any] = <factory>, provenance: Mapping[str, Any] = <factory>) -> None
A staged CGYRO case: the directory, input.cgyro, and what made it.
Also exported as vaft.code.gacode.cgyro.CGYROInputs.
7 fields
workdir: Pathfiles: tuple[Path, ...]ods: Anylocal: Optional[CGYROInput]input_cgyro: Optional[Path]parameters: Mapping[str, Any]provenance: Mapping[str, Any]
compare_with_oracle
function
source
compare_with_oracle(local: CGYROInput, equilibrium: Mapping[str, Any]) -> dict[str, dict[str, Any]]
Compare a translation with CGYRO’s own PROFILE_MODEL=2 projection.
Also exported as vaft.code.gacode.cgyro.compare_with_oracle.
input_sha256
function
source
input_sha256(path: str | Path) -> str
The hash a run is identified by: of the file CGYRO reads, not of its inputs.
Also exported as vaft.code.gacode.cgyro.input_sha256.
prepare_cgyro_case
function
source
prepare_cgyro_case(profile: GACODEProfile, r_over_a: float, workdir: str | Path, config: Optional[CGYROConfig] = None, *, state_key: Optional[Mapping[str, Any]] = None) -> CGYROInputs
Stage input.cgyro for one surface in workdir.
Also exported as vaft.code.gacode.cgyro.prepare_cgyro_case.
prepare_cgyro_input
function
source
prepare_cgyro_input(profile: GACODEProfile, r_over_a: float, *, config: Optional[CGYROConfig] = None) -> CGYROInput
Project profile onto CGYRO’s local input at r/a.
Also exported as vaft.code.gacode.cgyro.prepare_cgyro_input.
write_input_cgyro
function
source
write_input_cgyro(parameters: Mapping[str, Any], path: str | Path) -> Path
Write an input.cgyro, one KEY=VALUE per line.
Also exported as vaft.code.gacode.cgyro.write_input_cgyro.
vaft.code.gacode.cgyro.locality
Locality QA for local (flux-tube) CGYRO runs: is the turbulence small enough? (#1354)
BOX_THRESHOLDS
data
BOX_THRESHOLDS = <builtins.dict>
Also exported as vaft.code.gacode.cgyro.BOX_THRESHOLDS.
locality_report
function
source
locality_report(local: Any, outputs: Any = None, *, window: Optional[tuple[float, float]] = None) -> dict[str, Any]
Locality and box-adequacy QA for one CGYRO run.
Also exported as vaft.code.gacode.cgyro.locality_report.
LOCALITY_THRESHOLDS
data
LOCALITY_THRESHOLDS = <builtins.dict>
Also exported as vaft.code.gacode.cgyro.LOCALITY_THRESHOLDS.
radial_correlation_length
function
source
radial_correlation_length(outputs: Any, window: Optional[tuple[float, float]] = None) -> dict[str, Any]
Radial correlation length of the potential, in rho_s, from kxky_phi.
Also exported as vaft.code.gacode.cgyro.radial_correlation_length.
scale_lengths
function
source
scale_lengths(local: Any) -> dict[str, Optional[float]]
Equilibrium/profile scale lengths at the surface, in units of the minor radius.
Also exported as vaft.code.gacode.cgyro.scale_lengths.
vaft.code.gacode.cgyro.outputs
Collect one CGYRO run into a solver-native container.
CgyroOutputs
class
source
CgyroOutputs(directory: str, grid: Optional[dict[str, Any]] = None, equilibrium: Optional[dict[str, Any]] = None, time: Optional[np.ndarray] = None, time_error: Optional[np.ndarray] = None, frequency: Optional[np.ndarray] = None, growth_rate: Optional[np.ndarray] = None, ion_direction: Optional[int] = None, ballooning: dict[str, np.ndarray] = <factory>, flux: Optional[np.ndarray] = None, info: tuple[str, ...] = (), errors: tuple[str, ...] = (), exit_message: Optional[str] = None, version: Optional[dict[str, Any]] = None, files: tuple[str, ...] = (), record_index: Optional[np.ndarray] = None) -> None
One CGYRO run, in CGYRO’s own terms.
Also exported as vaft.code.gacode.cgyro.CgyroOutputs.
16 fields · 19 members
directory: strgrid: Optional[dict[str, Any]]equilibrium: Optional[dict[str, Any]]time: Optional[np.ndarray]time_error: Optional[np.ndarray]frequency: Optional[np.ndarray]growth_rate: Optional[np.ndarray]ion_direction: Optional[int]ballooning: dict[str, np.ndarray]flux: Optional[np.ndarray]info: tuple[str, ...]errors: tuple[str, ...]exit_message: Optional[str]version: Optional[dict[str, Any]]files: tuple[str, ...]record_index: Optional[np.ndarray]gyrokinetic_normalized_timeproperty — Native elapsed time, unchanged and restart-aligned liketime. sourcetime_normalizationproperty — Verified SI scales from native output; unavailable scales raise ValueError. sourcegyrokinetic_elapsed_time_sproperty — Elapsed seconds from the solver origin, never a discharge timestamp. sourcekyproperty —|k_y rho_s|per toroidal mode. sourcenonlinearproperty sourcefinal_frequencyproperty — Nativeomegaat the last print step, per toroidal mode. sourcefinal_growth_rateproperty sourcefrequency_ion_negativeproperty — Finalomegawith the ion diamagnetic direction negative, as TGLF writes it. sourceconvergedproperty — CGYRO’s linear frequency metFREQ_TOLbeforeMAX_TIME. sourcedecayedproperty — The field decayed below CGYRO’s 1e-12 floor and the run stopped. sourcesolvedproperty — No error, a finished kernel, and finite physics at the end of the run. sourceflux_time_tracemethod —(n_species, 3, n_time): fluxes summed over fields and toroidal modes. sourcetime_average_fluxmethod —(n_species, 3)time average over[t0, t1]ina/c_s. sourcealign_recordsmethod — A raw time-history array (time on the last axis) aligned totime. sourcemissingmethod sourceto_dictmethod sourcefrom_dictclassmethod sourcewrite_jsonmethod sourceread_jsonclassmethod source
collect_cgyro_outputs
function
source
collect_cgyro_outputs(workdir: str | Path) -> Optional[CgyroOutputs]
Parse everything CGYRO wrote in workdir; None when it wrote nothing.
Also exported as vaft.code.gacode.cgyro.collect_cgyro_outputs.
FIELD_NAMES
data
FIELD_NAMES = ('phi', 'a_parallel', 'b_parallel')
Also exported as vaft.code.gacode.cgyro.FIELD_NAMES.
FLUX_MOMENTS
data
FLUX_MOMENTS = ('particle', 'energy', 'momentum')
Also exported as vaft.code.gacode.cgyro.FLUX_MOMENTS.
FREQUENCY_SIGN_CONVENTION
data
FREQUENCY_SIGN_CONVENTION = 'ion_diamagnetic_negative'
Also exported as vaft.code.gacode.cgyro.FREQUENCY_SIGN_CONVENTION.
parse_equilibrium
function
source
parse_equilibrium(path: str | Path, n_species: int) -> Optional[dict[str, Any]]
out.cgyro.equilibrium, unpacked in pygacode’s order.
parse_grids
function
source
parse_grids(path: str | Path) -> Optional[dict[str, Any]]
out.cgyro.grids, unpacked in pygacode’s order.
SCHEMA
data
SCHEMA = 'vaft.code.gacode.cgyro.CgyroOutputs'
Also exported as vaft.code.gacode.cgyro.SCHEMA.
SCHEMA_VERSION
data
SCHEMA_VERSION = 1
Also exported as vaft.code.gacode.cgyro.SCHEMA_VERSION.
vaft.code.gacode.cgyro.runner
Execute CGYRO and collect its native result.
CGYROExecutionError
class
source
CGYRO ran and did not produce a usable result.
Also exported as vaft.code.gacode.cgyro.CGYROExecutionError.
gacode_revision
function
source
gacode_revision(config: Optional[CGYROConfig] = None) -> Optional[str]
The GACODE source commit, from the installation’s own git checkout.
Also exported as vaft.code.gacode.cgyro.gacode_revision.
local_ordering_state
function
source
local_ordering_state(local) -> dict[str, float]
The ordering quantities a CGYRO local input fixes by itself (#1823).
Also exported as vaft.code.gacode.cgyro.local_ordering_state.
read_cgyro_case
function
source
read_cgyro_case(workdir: str | Path) -> Optional[CgyroOutputs]
Read a finished run directory without re-running it.
Also exported as vaft.code.gacode.cgyro.read_cgyro_case.
run_cgyro
function
source
run_cgyro(inputs: CGYROInputs, config: Optional[CGYROConfig] = None, *, check: bool = True, state_key: Optional[Mapping[str, Any]] = None, ordering_state: Optional[Mapping[str, Any]] = None) -> CGYROResult
Run CGYRO on an already-staged case and parse everything it wrote.
Also exported as vaft.code.gacode.cgyro.run_cgyro.
run_cgyro_case
function
source
run_cgyro_case(profile: GACODEProfile, r_over_a: float, workdir: str | Path, config: Optional[CGYROConfig] = None, *, check: bool = True, state_key: Optional[Mapping[str, Any]] = None, ordering_state: Optional[Mapping[str, Any]] = None) -> CGYROResult
Stage and run one CGYRO case at one flux surface: the one-call path.
Also exported as vaft.code.gacode.cgyro.run_cgyro_case.
vaft.code.gacode.cgyro.time
CGYRO elapsed-time coordinates, separate from the input discharge timestamp.
CgyroTimeNormalization
class
source
CgyroTimeNormalization(reference_length_m: float, electron_temperature_j: float, reference_mass_kg: float, sound_speed_m_s: float, source: str) -> None
Verified per-run SI reference scales; the mass convention is deuterium.
Also exported as vaft.code.gacode.cgyro.CgyroTimeNormalization.
5 fields · 5 members
reference_length_m: floatelectron_temperature_j: floatreference_mass_kg: floatsound_speed_m_s: floatsource: strfrom_equilibriumclassmethod — Read native a_meters, temp_norm [keV], mass_norm [1e-27 kg], vth_norm [m/s]. sourcefrom_normalisationclassmethod — Use an explicit TGLFNormalisation shared with the CGYRO local input. sourcefrom_metadataclassmethod — Restore available serialized scales, rejecting a contradictory saved factor. sourcegyrokinetic_time_scale_sproperty — One native a/c_s unit in seconds. sourcemetadatamethod — Serializable reference scales and temporal-domain provenance. source
gyrokinetic_elapsed_time_s
function
source
gyrokinetic_elapsed_time_s(time, normalization)
Convert CGYRO normalized elapsed time to seconds, preserving the solver origin.
Also exported as vaft.code.gacode.cgyro.gyrokinetic_elapsed_time_s.
gyrokinetic_normalized_time
function
source
gyrokinetic_normalized_time(elapsed_time_s, normalization)
Convert elapsed seconds to CGYRO t*c_s/a; discharge timestamps are not inputs.
Also exported as vaft.code.gacode.cgyro.gyrokinetic_normalized_time.
gyrokinetic_time_scale_s
function
source
gyrokinetic_time_scale_s(source)
Return the verified native a/c_s time scale [s]; missing scales raise ValueError.
Also exported as vaft.code.gacode.cgyro.gyrokinetic_time_scale_s.
vaft.code.gacode.inputs
Convert an IMAS/OMAS scientific state into a GACODE profile set.
GACODEInputs
class
source
GACODEInputs(workdir: Path, files: tuple[Path, ...] = (), ods: Any = None, profile: Optional[GACODEProfile] = None, input_gacode: Optional[Path] = None, provenance: Mapping[str, Any] = <factory>) -> None
A staged GACODE case: the typed profile and the file written from it.
6 fields
workdir: Pathfiles: tuple[Path, ...]ods: Anyprofile: Optional[GACODEProfile]input_gacode: Optional[Path]provenance: Mapping[str, Any]
IMPURITIES
data
IMPURITIES = <builtins.dict>
impurity_fractions
function
source
impurity_fractions(z_eff: float, z_impurity: float) -> tuple[float, float]
(n_main/n_e, n_imp/n_e) for one hydrogenic ion and one impurity.
prepare_gacode_inputs
function
source
prepare_gacode_inputs(ods: Any, workdir: str | Path, **kwargs: Any) -> GACODEInputs
Convert an ODS and stage input.gacode in workdir.
prepare_gacode_profile
function
source
prepare_gacode_profile(ods: Any, *, time: Optional[float] = None, time_index: Optional[int] = None, tolerance: Optional[float] = None, rho_max: Optional[float] = None, z_eff: Optional[float] = None, impurity: Optional[str] = None, shot: Optional[int] = None) -> GACODEProfile
Project an ODS equilibrium and core_profiles onto a GACODE profile set.
ProfileConversionError
class
source
The canonical state cannot be projected onto a GACODE profile set.
vaft.code.gacode.neo
NEO: the GACODE suite’s drift-kinetic neoclassical solver.
NEO_DEFAULTS
data
NEO_DEFAULTS = <builtins.dict>
NEOConfig
class
source
NEOConfig(executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), args: Sequence[str] = (), env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, backend: Optional['ExecutionBackend'] = None, home: Optional[str] = None, platform: Optional[str] = None, n_mpi: int = 1, n_omp: int = 1, memory_mb: Optional[int] = None, n_energy: int = 6, n_xi: int = 17, n_theta: int = 17, n_radial: int = 1, rmin_over_a: float = 0.5, rmin_over_a_2: float = 0.6, collision_model: int = 4, profile_model: int = 2, profile_erad0_model: int = 1, rotation_model: int = 1, spitzer_model: int = 0, equilibrium_model: int = 0, ipccw: int = -1, btccw: int = -1, n_species: Optional[int] = None, extra_parameters: Mapping[str, Any] = <factory>) -> None
A NEO run’s numerical settings, on top of the shared GACODE runtime.
27 fields
executable: Optional[str]workdir: Path | strargs: Sequence[str]env: Mapping[str, str]timeout: Optional[float]backend: Optional['ExecutionBackend']home: Optional[str]platform: Optional[str]n_mpi: intn_omp: intmemory_mb: Optional[int]n_energy: intn_xi: intn_theta: intn_radial: intrmin_over_a: floatrmin_over_a_2: floatcollision_model: intprofile_model: intprofile_erad0_model: introtation_model: intspitzer_model: intequilibrium_model: intipccw: intbtccw: intn_species: Optional[int]extra_parameters: Mapping[str, Any]
NEOResult
class
source
NEOResult(returncode: Optional[int], workdir: Path, stdout: str = '', stderr: str = '', logs: tuple[Path, ...] = (), outputs: Mapping[str, tuple[Path, ...]] = <factory>, parsed: Any = None, runtime_status: str = 'completed', elapsed_s: Optional[float] = None, outputs_native: Optional[Any] = None, provenance: Mapping[str, Any] = <factory>) -> None
A NEO run: its exit status, its files, and its native output.
11 fields · 1 members
returncode: Optional[int]workdir: Pathstdout: strstderr: strlogs: tuple[Path, ...]outputs: Mapping[str, tuple[Path, ...]]parsed: Anyruntime_status: strelapsed_s: Optional[float]outputs_native: Optional[Any]provenance: Mapping[str, Any]okproperty source
plasma_formalism
function
source
plasma_formalism(config: Optional[NEOConfig] = None, *, parameters: Optional[Mapping[str, Any]] = None)
The #1727 record of a NEO run (vaft.code.formalism.PlasmaFormalism, #1735).
vaft.code.gacode.neo.inputs
Generate input.neo and stage a NEO case.
conductivity_parameters
function
source
conductivity_parameters(config: NEOConfig, profile: Optional[GACODEProfile] = None) -> dict[str, Any]
The settings that turn a transport case into a conductivity case.
Also exported as vaft.code.gacode.neo.conductivity_parameters.
neo_parameters
function
source
neo_parameters(config: NEOConfig, profile: Optional[GACODEProfile] = None) -> dict[str, Any]
The KEY=VALUE settings this configuration means.
Also exported as vaft.code.gacode.neo.neo_parameters.
NEOInputs
class
source
NEOInputs(workdir: Path, files: tuple[Path, ...] = (), ods: Any = None, profile: Optional[GACODEProfile] = None, input_neo: Optional[Path] = None, input_gacode: Optional[Path] = None, parameters: Mapping[str, Any] = <factory>, provenance: Mapping[str, Any] = <factory>) -> None
A staged NEO case: the directory, the files in it, and what made them.
Also exported as vaft.code.gacode.neo.NEOInputs.
8 fields
workdir: Pathfiles: tuple[Path, ...]ods: Anyprofile: Optional[GACODEProfile]input_neo: Optional[Path]input_gacode: Optional[Path]parameters: Mapping[str, Any]provenance: Mapping[str, Any]
prepare_neo_case
function
source
prepare_neo_case(profile: GACODEProfile, workdir: str | Path, config: Optional[NEOConfig] = None) -> NEOInputs
Stage input.gacode and input.neo in workdir.
Also exported as vaft.code.gacode.neo.prepare_neo_case.
prepare_neo_conductivity_case
function
source
prepare_neo_conductivity_case(profile: GACODEProfile, workdir: str | Path, config: Optional[NEOConfig] = None) -> NEOInputs
Stage the gradient-free companion run that yields a conductivity.
Also exported as vaft.code.gacode.neo.prepare_neo_conductivity_case.
write_input_neo
function
source
write_input_neo(parameters: Mapping[str, Any], path: str | Path) -> Path
Write an input.neo file, one KEY=VALUE per line.
Also exported as vaft.code.gacode.neo.write_input_neo.
vaft.code.gacode.neo.outputs
Parse a NEO run directory into a complete, solver-native result.
collect_neo_outputs
function
source
collect_neo_outputs(workdir: str | Path) -> Optional[NeoOutputs]
Read a NEO run directory without re-running it.
Also exported as vaft.code.gacode.neo.collect_neo_outputs.
NeoGrid
class
source
NeoGrid(n_species: int, n_energy: int, n_xi: int, n_theta: int, theta: np.ndarray, n_radial: int, r_over_a: np.ndarray) -> None
The discretisation NEO actually used.
Also exported as vaft.code.gacode.neo.NeoGrid.
7 fields
n_species: intn_energy: intn_xi: intn_theta: inttheta: np.ndarrayn_radial: intr_over_a: np.ndarray
NeoNormalisation
class
source
NeoNormalisation(r_over_a: np.ndarray, a_meters: np.ndarray, mass_deuterium: np.ndarray, density_norm: np.ndarray, temperature_norm: np.ndarray, velocity_norm_times_a: np.ndarray, b_unit: np.ndarray) -> None
out.neo.expnorm: everything needed to put NEO’s output into SI.
Also exported as vaft.code.gacode.neo.NeoNormalisation.
7 fields
r_over_a: np.ndarraya_meters: np.ndarraymass_deuterium: np.ndarraydensity_norm: np.ndarraytemperature_norm: np.ndarrayvelocity_norm_times_a: np.ndarrayb_unit: np.ndarray
NeoOutputs
class
source
NeoOutputs(directory: str, grid: Optional[NeoGrid] = None, species_mass: Optional[np.ndarray] = None, species_charge: Optional[np.ndarray] = None, normalisation: Optional[NeoNormalisation] = None, coordinates: Optional[Mapping[str, np.ndarray]] = None, equilibrium: Optional[Mapping[str, np.ndarray]] = None, transport: Optional[Mapping[str, np.ndarray]] = None, transport_gyroviscous: Optional[Mapping[str, np.ndarray]] = None, transport_experimental: Optional[Mapping[str, np.ndarray]] = None, transport_gyrobohm: Optional[Mapping[str, np.ndarray]] = None, theory: Optional[Mapping[str, np.ndarray]] = None, rotation: Optional[Mapping[str, np.ndarray]] = None, geometry: Optional[Mapping[str, float]] = None, spitzer: Optional[Mapping[str, np.ndarray]] = None, precision: Optional[float] = None, version: Optional[Mapping[str, str]] = None, errors: tuple[str, ...] = (), files: tuple[str, ...] = ()) -> None
One NEO run, in NEO’s own terms.
Also exported as vaft.code.gacode.neo.NeoOutputs.
19 fields · 12 members
directory: strgrid: Optional[NeoGrid]species_mass: Optional[np.ndarray]species_charge: Optional[np.ndarray]normalisation: Optional[NeoNormalisation]coordinates: Optional[Mapping[str, np.ndarray]]equilibrium: Optional[Mapping[str, np.ndarray]]transport: Optional[Mapping[str, np.ndarray]]transport_gyroviscous: Optional[Mapping[str, np.ndarray]]transport_experimental: Optional[Mapping[str, np.ndarray]]transport_gyrobohm: Optional[Mapping[str, np.ndarray]]theory: Optional[Mapping[str, np.ndarray]]rotation: Optional[Mapping[str, np.ndarray]]geometry: Optional[Mapping[str, float]]spitzer: Optional[Mapping[str, np.ndarray]]precision: Optional[float]version: Optional[Mapping[str, str]]errors: tuple[str, ...]files: tuple[str, ...]n_speciesproperty sourcebootstrap_currentproperty — NEO’s own drift-kinetic<j_par B>, normalised. sourceeffective_chargeproperty —Z_effas this run’s own species list implies it, per radius. sourceion_density_fractionproperty —sum(n_i)/n_efrom this run’s species list, per radius. sourcetrapped_fractionproperty — The trapped fraction NEO computed from the surface geometry. sourcesolvedproperty — Whether NEO completed the problem it was asked to solve. sourcedescribemethod — What a transported quantity means and how it is normalised. sourcemissingmethod — Products this run did not write, so absent never reads as zero. sourceto_dictmethod — A JSON-ready payload thatfrom_dictreads back exactly. sourcefrom_dictclassmethod sourcewrite_jsonmethod sourceread_jsonclassmethod source
SCHEMA
data
SCHEMA = 'vaft.code.gacode.neo.NeoOutputs'
Also exported as vaft.code.gacode.neo.SCHEMA.
SCHEMA_VERSION
data
SCHEMA_VERSION = 1
Also exported as vaft.code.gacode.neo.SCHEMA_VERSION.
THEORY_SCALARS
data
THEORY_SCALARS = ('hinton_hazeltine_particle_flux', 'hinton_hazeltine_ion_energy_flux', 'hinton_hazeltine_electron_energy_flux', 'hint...
Also exported as vaft.code.gacode.neo.THEORY_SCALARS.
vaft.code.gacode.neo.runner
Execute NEO and collect its native result.
NEOExecutionError
class
source
NEO ran and did not produce a usable result.
Also exported as vaft.code.gacode.neo.NEOExecutionError.
read_neo_case
function
source
read_neo_case(workdir: str | Path) -> Optional[NeoOutputs]
Read a finished run directory without re-running it.
Also exported as vaft.code.gacode.neo.read_neo_case.
run_neo
function
source
run_neo(inputs: NEOInputs, config: Optional[NEOConfig] = None, *, check: bool = True) -> NEOResult
Run NEO on an already-staged case and parse everything it wrote.
Also exported as vaft.code.gacode.neo.run_neo.
run_neo_case
function
source
run_neo_case(profile: GACODEProfile, workdir: str | Path, config: Optional[NEOConfig] = None, *, check: bool = True) -> NEOResult
Stage and run one NEO case: the one-call path.
Also exported as vaft.code.gacode.neo.run_neo_case.
run_neo_conductivity_case
function
source
run_neo_conductivity_case(profile: GACODEProfile, workdir: str | Path, config: Optional[NEOConfig] = None, *, check: bool = True) -> NEOResult
Stage and run the gradient-free companion case that yields a conductivity.
Also exported as vaft.code.gacode.neo.run_neo_conductivity_case.
run_neo_pair
function
source
run_neo_pair(profile: GACODEProfile, workdir: str | Path, config: Optional[NEOConfig] = None, *, check: bool = True) -> tuple[NEOResult, NEOResult]
Both runs of one case: transport, then conductivity.
Also exported as vaft.code.gacode.neo.run_neo_pair.
vaft.code.gacode.output_audit
Derivability/retention view over existing native dataclasses and mapping audits.
mapping_transformations
function
source
mapping_transformations()
Expose the existing leaf-level mapping evidence without replacing its registry.
output_audit
function
source
output_audit()
List every parsed output, class, interpretation, retention and plot route.
vaft.code.gacode.result_identity
Compact scientific identity for solver collections and local runs (#2026).
collection_record
function
source
collection_record(solver, surfaces, *, state_identity=None, realization_id=None, configuration=None, windows=None)
digest
function
source
digest(value)
encode
function
source
encode(record, existing=None)
input_value_status
function
source
input_value_status(effective, requested, provenance)
Distinguish physical evidence from the effective numeric solver input.
parameters
function
source
parameters(text)
Decode our XML envelope, including OMAS-decoded dictionary representations.
plain
function
source
plain(value)
prepare_target
function
source
prepare_target(ods, record, time, time_index)
Resolve collection/time, rejecting ambiguous replacement before any write.
preserve_time_semantics
function
source
preserve_time_semantics(ods)
Use heterogeneous IDS time when per-model stored slice coordinates differ.
read_native_input
function
source
read_native_input(directory, solver)
Read generated value/KEY records or requested KEY=VALUE syntax.
vaft.code.gacode.tglf
TGLF: the GACODE suite’s quasilinear turbulent-transport model.
MAX_SPECIES
data
MAX_SPECIES = 7
plasma_formalism
function
source
plasma_formalism(config: Optional[TGLFConfig] = None, *, parameters: Optional[Mapping[str, Any]] = None)
The #1727 record of a TGLF run (vaft.code.formalism.PlasmaFormalism, #1735).
TGLF_DEFAULT_SCALARS
data
TGLF_DEFAULT_SCALARS = <builtins.dict>
TGLF_DEFAULT_SPECIES
data
TGLF_DEFAULT_SPECIES = <builtins.dict>
TGLFConfig
class
source
TGLFConfig(executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), args: Sequence[str] = (), env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, backend: Optional['ExecutionBackend'] = None, home: Optional[str] = None, platform: Optional[str] = None, n_mpi: int = 1, n_omp: int = 1, memory_mb: Optional[int] = None, sat_rule: int = 0, use_transport_model: bool = True, geometry_flag: int = 1, use_bper: bool = False, use_bpar: bool = False, n_species: Optional[int] = None, extra_parameters: Mapping[str, Any] = <factory>) -> None
One TGLF run’s settings.
18 fields
executable: Optional[str]workdir: Path | strargs: Sequence[str]env: Mapping[str, str]timeout: Optional[float]backend: Optional['ExecutionBackend']home: Optional[str]platform: Optional[str]n_mpi: intn_omp: intmemory_mb: Optional[int]sat_rule: intuse_transport_model: boolgeometry_flag: intuse_bper: booluse_bpar: booln_species: Optional[int]extra_parameters: Mapping[str, Any]
TGLFResult
class
source
TGLFResult(returncode: Optional[int], workdir: Path, stdout: str = '', stderr: str = '', logs: tuple[Path, ...] = (), outputs: Mapping[str, tuple[Path, ...]] = <factory>, parsed: Any = None, runtime_status: str = 'completed', elapsed_s: Optional[float] = None, outputs_native: Optional[Any] = None, provenance: Mapping[str, Any] = <factory>) -> None
A TGLF run: its exit status, its files, and its native output.
11 fields · 1 members
returncode: Optional[int]workdir: Pathstdout: strstderr: strlogs: tuple[Path, ...]outputs: Mapping[str, tuple[Path, ...]]parsed: Anyruntime_status: strelapsed_s: Optional[float]outputs_native: Optional[Any]provenance: Mapping[str, Any]okproperty source
vaft.code.gacode.tglf.inputs
Project a GACODE profile onto TGLF’s local input, and write input.tglf.
bound_deriv
function
source
bound_deriv(values: Any, radius: Any) -> np.ndarray
GACODE’s three-point Lagrange derivative on a possibly unequal grid.
Also exported as vaft.code.gacode.tglf.bound_deriv.
LocalConversionError
class
source
The profile cannot be projected onto a local TGLF input.
Also exported as vaft.code.gacode.cgyro.LocalConversionError, vaft.code.gacode.cgyro.inputs.LocalConversionError, vaft.code.gacode.tglf.LocalConversionError.
prepare_tglf_case
function
source
prepare_tglf_case(profile: GACODEProfile, rho: float, workdir: str | Path, config: Optional[TGLFConfig] = None) -> TGLFInputs
Stage input.tglf for one surface in workdir.
Also exported as vaft.code.gacode.tglf.prepare_tglf_case.
prepare_tglf_input
function
source
prepare_tglf_input(profile: GACODEProfile, rho: float, *, config: Optional[TGLFConfig] = None) -> TGLFInput
Project profile onto TGLF’s local input at r/a = rho.
Also exported as vaft.code.gacode.tglf.prepare_tglf_input.
read_local_input
function
source
read_local_input(directory, *, normalisation, names, provenance=None)
Restore a native local input with caller-retained SI scales and species names.
Also exported as vaft.code.gacode.tglf.read_local_input.
tglf_parameters
function
source
tglf_parameters(local: TGLFInput, config: Optional[TGLFConfig] = None) -> dict[str, Any]
The KEY=VALUE settings this local input and configuration mean.
Also exported as vaft.code.gacode.tglf.tglf_parameters.
TGLFInput
class
source
TGLFInput(rho: float, rmin_loc: float, rmaj_loc: float, drmajdx_loc: float, zmaj_loc: float, dzmajdx_loc: float, q_loc: float, q_prime_loc: float, p_prime_loc: float, kappa_loc: float, s_kappa_loc: float, delta_loc: float, s_delta_loc: float, zeta_loc: float, s_zeta_loc: float, zs: np.ndarray, mass: np.ndarray, as_: np.ndarray, taus: np.ndarray, rlns: np.ndarray, rlts: np.ndarray, betae: float, xnue: float, zeff: float, debye: float, sign_bt: float, sign_it: float, vexb_shear: Optional[float] = None, names: Sequence[str] = (), normalisation: Optional['TGLFNormalisation'] = None, provenance: Mapping[str, Mapping[str, Any]] = <factory>) -> None
TGLF’s local input at one flux surface.
Also exported as vaft.code.gacode.tglf.TGLFInput.
31 fields · 3 members
rho: floatrmin_loc: floatrmaj_loc: floatdrmajdx_loc: floatzmaj_loc: floatdzmajdx_loc: floatq_loc: floatq_prime_loc: floatp_prime_loc: floatkappa_loc: floats_kappa_loc: floatdelta_loc: floats_delta_loc: floatzeta_loc: floats_zeta_loc: floatzs: np.ndarraymass: np.ndarrayas_: np.ndarraytaus: np.ndarrayrlns: np.ndarrayrlts: np.ndarraybetae: floatxnue: floatzeff: floatdebye: floatsign_bt: floatsign_it: floatvexb_shear: Optional[float]names: Sequence[str]normalisation: Optional['TGLFNormalisation']provenance: Mapping[str, Mapping[str, Any]]n_speciesproperty sourcemissingmethod — Names this input records as unavailable, in provenance order. sourcecheck_tglf_requirementsmethod — Quantities TGLF needs that this input does not carry. source
TGLFInputs
class
source
TGLFInputs(workdir: Path, files: tuple[Path, ...] = (), ods: Any = None, local: Optional[TGLFInput] = None, input_tglf: Optional[Path] = None, parameters: Mapping[str, Any] = <factory>, provenance: Mapping[str, Any] = <factory>) -> None
A staged TGLF case: the directory, the file in it, and what made it.
Also exported as vaft.code.gacode.tglf.TGLFInputs.
7 fields
workdir: Pathfiles: tuple[Path, ...]ods: Anylocal: Optional[TGLFInput]input_tglf: Optional[Path]parameters: Mapping[str, Any]provenance: Mapping[str, Any]
TGLFNormalisation
class
source
TGLFNormalisation(electron_density: float, electron_temperature: float, sound_speed: float, gyroradius: float, minor_radius: float, b_unit: float) -> None
The SI scales of one TGLF surface, and the gyro-Bohm units they define.
Also exported as vaft.code.gacode.tglf.TGLFNormalisation.
6 fields · 4 members
electron_density: floatelectron_temperature: floatsound_speed: floatgyroradius: floatminor_radius: floatb_unit: floatparticle_fluxproperty —Gamma_GB[m^-2 s^-1]. sourceenergy_fluxproperty —Q_GB[W m^-2]. sourcemomentum_fluxproperty —Pi_GB[J m^-2], which is TGYRO’s own label for it. sourceexchange_powerproperty —S_GB[W m^-3]: a power density, which is why it has no flux home. source
write_input_tglf
function
source
write_input_tglf(parameters: Mapping[str, Any], path: str | Path) -> Path
Write an input.tglf, one KEY=VALUE per line.
Also exported as vaft.code.gacode.tglf.write_input_tglf.
vaft.code.gacode.tglf.outputs
Collect one TGLF run into a solver-native container.
collect_tglf_outputs
function
source
collect_tglf_outputs(workdir: str | Path) -> Optional[TglfOutputs]
Read a finished TGLF directory, or None when it holds no TGLF output.
Also exported as vaft.code.gacode.tglf.collect_tglf_outputs.
FIELD_SPECTRUM_COLUMNS
data
FIELD_SPECTRUM_COLUMNS = ('vector', 'phi', 'a_par', 'b_par')
FLUX_SPECTRUM_FIELDS
data
FLUX_SPECTRUM_FIELDS = ('phi', 'a_par', 'b_par')
FLUX_SPECTRUM_QUANTITIES
data
FLUX_SPECTRUM_QUANTITIES = ('particle', 'energy', 'toroidal_stress', 'parallel_stress', 'exchange')
GBFLUX_QUANTITIES
data
GBFLUX_QUANTITIES = ('particle', 'energy', 'momentum', 'exchange')
Also exported as vaft.code.gacode.tglf.GBFLUX_QUANTITIES.
INTENSITY_MOMENTS
data
INTENSITY_MOMENTS = ('density', 'temperature', 'parallel_velocity', 'parallel_energy')
SCHEMA
data
SCHEMA = 'vaft.code.gacode.tglf.TglfOutputs'
Also exported as vaft.code.gacode.tglf.SCHEMA.
SCHEMA_VERSION
data
SCHEMA_VERSION = 4
Also exported as vaft.code.gacode.tglf.SCHEMA_VERSION.
TglfOutputs
class
source
TglfOutputs(directory: str, gbflux: Optional[Mapping[str, np.ndarray]] = None, ky_spectrum: Optional[np.ndarray] = None, eigenvalue_spectrum: Optional[np.ndarray] = None, sum_flux_spectrum: Optional[np.ndarray] = None, field_spectrum: Optional[np.ndarray] = None, intensity_spectrum: Optional[np.ndarray] = None, density_spectrum: Optional[np.ndarray] = None, temperature_spectrum: Optional[np.ndarray] = None, nete_crossphase_spectrum: Optional[np.ndarray] = None, nsts_crossphase_spectrum: Optional[np.ndarray] = None, ql_flux_spectrum: Optional[np.ndarray] = None, ql_intensity_spectrum: Optional[np.ndarray] = None, width_spectrum: Optional[np.ndarray] = None, spectral_shift_spectrum: Optional[np.ndarray] = None, ave_p0_spectrum: Optional[np.ndarray] = None, saturation_parameters: Optional[Mapping[str, Any]] = None, spectral_species: Optional[tuple[int, ...]] = None, grid: Optional[Mapping[str, int]] = None, precision: Optional[float] = None, version: Optional[Mapping[str, str]] = None, errors: tuple[str, ...] = (), files: tuple[str, ...] = ()) -> None
One TGLF run, in TGLF’s own terms.
Also exported as vaft.code.gacode.tglf.TglfOutputs.
23 fields · 11 members
directory: strgbflux: Optional[Mapping[str, np.ndarray]]ky_spectrum: Optional[np.ndarray]eigenvalue_spectrum: Optional[np.ndarray]sum_flux_spectrum: Optional[np.ndarray]field_spectrum: Optional[np.ndarray]intensity_spectrum: Optional[np.ndarray]density_spectrum: Optional[np.ndarray]temperature_spectrum: Optional[np.ndarray]nete_crossphase_spectrum: Optional[np.ndarray]nsts_crossphase_spectrum: Optional[np.ndarray]ql_flux_spectrum: Optional[np.ndarray]ql_intensity_spectrum: Optional[np.ndarray]width_spectrum: Optional[np.ndarray]spectral_shift_spectrum: Optional[np.ndarray]ave_p0_spectrum: Optional[np.ndarray]saturation_parameters: Optional[Mapping[str, Any]]spectral_species: Optional[tuple[int, ...]]grid: Optional[Mapping[str, int]]precision: Optional[float]version: Optional[Mapping[str, str]]errors: tuple[str, ...]files: tuple[str, ...]n_speciesproperty sourceenergy_fluxproperty — Gyro-Bohm normalised energy flux per species, electrons first. sourceparticle_fluxproperty sourcegrowth_rateproperty — Linear growth rate(ky, mode)inc_s/a, from the eigenvalue spectrum. sourcefrequencyproperty — Real frequency(ky, mode)inc_s/a; TGLF’s sign convention, unlabelled. sourcesolvedproperty — Whether TGLF completed the problem it was asked to solve. sourcemissingmethod — Fields this run did not produce, in declaration order. sourceto_dictmethod sourcefrom_dictclassmethod sourcewrite_jsonmethod sourceread_jsonclassmethod source
vaft.code.gacode.tglf.runner
Execute TGLF and collect its native result.
read_tglf_case
function
source
read_tglf_case(workdir: str | Path) -> Optional[TglfOutputs]
Read a finished run directory without re-running it.
Also exported as vaft.code.gacode.tglf.read_tglf_case.
run_tglf
function
source
run_tglf(inputs: TGLFInputs, config: Optional[TGLFConfig] = None, *, check: bool = True) -> TGLFResult
Run TGLF on an already-staged case and parse everything it wrote.
Also exported as vaft.code.gacode.tglf.run_tglf.
run_tglf_case
function
source
run_tglf_case(profile: GACODEProfile, rho: float, workdir: str | Path, config: Optional[TGLFConfig] = None, *, check: bool = True) -> TGLFResult
Stage and run one TGLF case at one flux surface: the one-call path.
Also exported as vaft.code.gacode.tglf.run_tglf_case.
TGLFExecutionError
class
source
TGLF ran and did not produce a usable result.
Also exported as vaft.code.gacode.tglf.TGLFExecutionError.
vaft.code.gacode.tglf.spectral
Quasilinear flux decomposition of one TGLF run, validated against TGLF’s own output (#1900).
closure_split
function
source
closure_split(a: Any, b: Any, *, kygrid_model: int = 1, linear_rtol: float = 1e-09) -> ClosureSplit
Split flux(b) - flux(a) into intensity and amplitude-factor terms (ClosureSplit).
ClosureSplit
class
source
ClosureSplit(status: str, reason: str = '', linear_max_rel_diff: Optional[float] = None, total: Optional[np.ndarray] = None, intensity_term: Optional[np.ndarray] = None, qla_term: Optional[np.ndarray] = None) -> None
Exact two-term split of the flux change b - a between two runs with equal linear physics.
6 fields
status: strreason: strlinear_max_rel_diff: Optional[float]total: Optional[np.ndarray]intensity_term: Optional[np.ndarray]qla_term: Optional[np.ndarray]
flux_decomposition
function
source
flux_decomposition(native: Any, *, kygrid_model: int = 1, tolerance: float = 1e-06) -> FluxDecomposition
Factor a TGLF run’s flux into W * phi * QLA and check the rebuild (module docstring).
FluxDecomposition
class
source
FluxDecomposition(status: str, reason: str = '', relative_error: Optional[float] = None, tolerance: float = 1e-06, sat_rule: Optional[int] = None, kygrid_model: Optional[int] = None, ky: Optional[np.ndarray] = None, weight: Optional[np.ndarray] = None, intensity: Optional[np.ndarray] = None, qla: Optional[np.ndarray] = None, x: Optional[np.ndarray] = None, flux: Optional[np.ndarray] = None, ky_weights: Optional[np.ndarray] = None) -> None
The factors of one TGLF run’s saturated flux, or why they are withheld.
13 fields · 2 members
status: strreason: strrelative_error: Optional[float]tolerance: floatsat_rule: Optional[int]kygrid_model: Optional[int]ky: Optional[np.ndarray]weight: Optional[np.ndarray]intensity: Optional[np.ndarray]qla: Optional[np.ndarray]x: Optional[np.ndarray]flux: Optional[np.ndarray]ky_weights: Optional[np.ndarray]validatedproperty sourceintegratedmethod —(species, field, 5)ky-integrated, mode-summed totals offlux(default: own). source
ky_integration_weights
function
source
ky_integration_weights(ky: np.ndarray, kygrid_model: int = 1) -> np.ndarray
(2, ky) weights (dky0, dky1) of write_tglf_sum_flux_spectrum.
LINEAR_RTOL
data
LINEAR_RTOL = 1e-09
QLA_OTHER
data
QLA_OTHER = 1.6
RECONSTRUCTION_RTOL
data
RECONSTRUCTION_RTOL = 1e-06
sat3_qla_factors
function
source
sat3_qla_factors(native: Any) -> Optional[tuple[np.ndarray, np.ndarray]]
(QLA, x) for a SAT_RULE 3 run: QLA shaped (5, mode), x shaped (mode,).
vaft.code.gacode.tglf.surrogate
TGLF-NN: an accelerated backend for the local TGLF contract.
DOMAIN_MEASURE
data
DOMAIN_MEASURE = "standard-deviation distance from the model's training mean (xm/xsigma)"
DomainAudit
class
source
DomainAudit(model: str, z_scores: Mapping[str, float], threshold: float, violations: tuple[str, ...], max_abs_z: float, assumed: tuple[str, ...] = (), measure: str = "standard-deviation distance from the model's training mean (xm/xsigma)", bounds_available: bool = False) -> None
How far a local input sits from what the model was trained on.
ModelContractError
class
source
The model asks for inputs this local state cannot supply.
ModelIdentity
class
source
ModelIdentity(name: str, directory: str, members: tuple[str, ...], sha256: Mapping[str, str], resolved_by: str, format: str = 'onnx', sat_rule: Optional[int] = None, electromagnetic: Optional[bool] = None, devices: tuple[str, ...] = (), tags: tuple[str, ...] = (), upstream_version: Optional[str] = None, alternatives: tuple[str, ...] = (), physics_source: str = 'parsed from the upstream model name') -> None
Which model this is, where it came from, and what physics it claims.
13 fields · 1 members
name: strdirectory: strmembers: tuple[str, ...]sha256: Mapping[str, str]resolved_by: strformat: strsat_rule: Optional[int]electromagnetic: Optional[bool]devices: tuple[str, ...]tags: tuple[str, ...]upstream_version: Optional[str]alternatives: tuple[str, ...]physics_source: strensemble_sizeproperty source
ModelResolutionError
class
source
No model artifact could be found, or the search was ambiguous.
SurrogateError
class
source
Base for every refusal this backend makes.
SurrogateMetadata
class
source
SurrogateMetadata(xnames: tuple[str, ...], ynames: tuple[str, ...], xm: np.ndarray, xsigma: np.ndarray, ym: np.ndarray, ysigma: np.ndarray) -> None
The normalisation contract shipped beside an ONNX ensemble.
6 fields · 1 members
xnames: tuple[str, ...]ynames: tuple[str, ...]xm: np.ndarrayxsigma: np.ndarrayym: np.ndarrayysigma: np.ndarrayrequires_base_model_outputsproperty — Input channels that are another model’s outputs. source
SurrogatePrediction
class
source
SurrogatePrediction(outputs: Mapping[str, float], uncertainty: Mapping[str, float], model: ModelIdentity, domain: DomainAudit, features: Mapping[str, float], provenance: Mapping[str, Any] = <factory>) -> None
One surrogate evaluation, with the grounds for trusting it or not.
6 fields · 2 members
outputs: Mapping[str, float]uncertainty: Mapping[str, float]model: ModelIdentitydomain: DomainAuditfeatures: Mapping[str, float]provenance: Mapping[str, Any]qualifiedproperty — Whether this prediction rests on an input the model was trained for. sourcerelative_spreadmethod — Ensemble spread as a fraction of the mean, per channel. source
TrainingDomainError
class
source
TrainingDomainError(message: str, audit: 'DomainAudit') -> None
The input lies outside the model’s training distribution and was refused.
vaft.code.gacode.tglf.surrogate.domain
Project a local TGLF input into a model’s feature space, and say where it lands.
audit_features
function
source
audit_features(values: np.ndarray, assumed: Sequence[str], identity: ModelIdentity, metadata: SurrogateMetadata, *, threshold: float = 3.0) -> DomainAudit
audit_training_domain for a feature vector that is already built.
Also exported as vaft.code.gacode.tglf.surrogate.audit_features.
audit_training_domain
function
source
audit_training_domain(local: TGLFInput, identity: ModelIdentity, metadata: SurrogateMetadata, *, config: Optional[TGLFConfig] = None, threshold: float = 3.0) -> DomainAudit
Where local sits relative to the model’s training distribution.
Also exported as vaft.code.gacode.tglf.surrogate.audit_training_domain.
build_features
function
source
build_features(local: TGLFInput, metadata: SurrogateMetadata, *, config: Optional[TGLFConfig] = None) -> tuple[np.ndarray, tuple[str, ...]]
The model’s input vector for local, and which entries rest on a default.
Also exported as vaft.code.gacode.tglf.surrogate.build_features.
DEFAULT_DOMAIN_THRESHOLD
data
DEFAULT_DOMAIN_THRESHOLD = 3.0
Also exported as vaft.code.gacode.tglf.surrogate.DEFAULT_DOMAIN_THRESHOLD.
vaft.code.gacode.tglf.surrogate.inference
Run a TGLF-NN ensemble on a local TGLF input.
ensemble_predict
function
source
ensemble_predict(features: np.ndarray, identity: ModelIdentity, metadata: SurrogateMetadata) -> tuple[dict[str, float], dict[str, float]]
Mean and standard deviation over the ensemble, per output channel.
Also exported as vaft.code.gacode.tglf.surrogate.ensemble_predict.
run_surrogate
function
source
run_surrogate(local: TGLFInput, model: str | Path, *, model_dir: Optional[str | Path] = None, env: Optional[Mapping[str, str]] = None, config: Optional[TGLFConfig] = None, threshold: float = 3.0, allow_extrapolation: bool = False) -> SurrogatePrediction
Predict the gyro-Bohm fluxes at local with the TGLF-NN family model.
Also exported as vaft.code.gacode.tglf.surrogate.run_surrogate.
vaft.code.gacode.tglf.surrogate.resolver
Find a TGLF-NN model artifact without vendoring one, and without the network.
available_models
function
source
available_models(*, model_dir: Optional[str | Path] = None, env: Optional[Mapping[str, str]] = None) -> dict[str, Path]
Model families found right now, name to the directory that wins the search.
Also exported as vaft.code.gacode.tglf.surrogate.available_models.
KNOWN_DEVICES
data
KNOWN_DEVICES = frozenset({'d3d', 'd3dedge', 'd3dnearedge', 'fpp', 'iter', 'mastu', 'nstx', 'stfpp', 'ukstep'})
Also exported as vaft.code.gacode.tglf.surrogate.KNOWN_DEVICES.
load_metadata
function
source
load_metadata(identity: ModelIdentity) -> SurrogateMetadata
Read the normalisation contract shipped beside the ensemble.
Also exported as vaft.code.gacode.tglf.surrogate.load_metadata.
METADATA_FILES
data
METADATA_FILES = ('xnames.txt', 'ynames.txt', 'xm.txt', 'xsigma.txt', 'ym.txt', 'ysigma.txt')
Also exported as vaft.code.gacode.tglf.surrogate.METADATA_FILES.
MODELS_COMPATIBILITY_ENVS
data
MODELS_COMPATIBILITY_ENVS = ('TURBULENTTRANSPORT_ROOT',)
Also exported as vaft.code.gacode.tglf.surrogate.MODELS_COMPATIBILITY_ENVS.
MODELS_HOME_ENV
data
MODELS_HOME_ENV = 'TURBULENTTRANSPORTHOME'
Also exported as vaft.code.gacode.tglf.surrogate.MODELS_HOME_ENV.
parse_model_name
function
source
parse_model_name(name: str) -> dict
What the upstream family name states about the model’s physics.
Also exported as vaft.code.gacode.tglf.surrogate.parse_model_name.
resolve_model
function
source
resolve_model(model: str | Path, *, model_dir: Optional[str | Path] = None, env: Optional[Mapping[str, str]] = None) -> ModelIdentity
Locate model and record what was found.
Also exported as vaft.code.gacode.tglf.surrogate.resolve_model.
vaft.code.genray.config
Configuration, input and result objects for the GENRAY EC ray-tracing adapter (#264).
GENRAY_HOME_ENV
data
GENRAY_HOME_ENV = 'GENRAYHOME'
Also exported as vaft.code.genray.GENRAY_HOME_ENV.
GENRAY_HOME_EXECUTABLE
data
GENRAY_HOME_EXECUTABLE = <pathlib.PosixPath>
Also exported as vaft.code.genray.GENRAY_HOME_EXECUTABLE.
GENRAYConfig
class
source
GENRAYConfig(mode: str, time: float, time_tolerance: float = 0.0005, beam_index: int = 0, harmonic: int = 1, power_w: Optional[float] = None, zeff: Optional[float] = None, minimum_temperature_ev: Optional[float] = None, n_rho: int = 41, max_steps: int = 10000, max_reflections: int = 1, namelist_overrides: Mapping[str, Mapping[str, Any]] = <factory>, executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, backend: Optional['ExecutionBackend'] = None) -> None
Runtime configuration for one GENRAY EC run.
Also exported as vaft.code.GENRAYConfig, vaft.code.genray.GENRAYConfig.
17 fields · 1 members
mode: strtime: floattime_tolerance: floatbeam_index: intharmonic: intpower_w: Optional[float]zeff: Optional[float]minimum_temperature_ev: Optional[float]n_rho: intmax_steps: intmax_reflections: intnamelist_overrides: Mapping[str, Mapping[str, Any]]executable: Optional[str]workdir: Path | strenv: Mapping[str, str]timeout: Optional[float]backend: Optional['ExecutionBackend']ioxmproperty source
GENRAYInputs
class
source
GENRAYInputs(workdir: Path, genray_in: Path, eqdsk: Path, provenance: dict[str, Any], files: tuple[Path, ...] = ()) -> None
A materialised GENRAY case: the working directory and what VAFT put in it.
Also exported as vaft.code.GENRAYInputs, vaft.code.genray.GENRAYInputs.
5 fields
workdir: Pathgenray_in: Patheqdsk: Pathprovenance: dict[str, Any]files: tuple[Path, ...]
GENRAYResult
class
source
GENRAYResult(returncode: Optional[int], workdir: Path, stdout: str = '', stderr: str = '', netcdf: Optional[Path] = None, parsed: Any = None, provenance: dict[str, Any] = <factory>, runtime_status: str = 'completed', elapsed_s: Optional[float] = None) -> None
Outcome of one GENRAY run.
Also exported as vaft.code.GENRAYResult, vaft.code.genray.GENRAYResult.
9 fields · 1 members
returncode: Optional[int]workdir: Pathstdout: strstderr: strnetcdf: Optional[Path]parsed: Anyprovenance: dict[str, Any]runtime_status: strelapsed_s: Optional[float]okproperty — Exit 0, agenray.nc, every total present and at least one ray in the plasma. source
vaft.code.genray.inputs
Materialise a GENRAY EC case from IMAS ec_launchers, equilibrium and core_profiles.
eccone_angles
function
source
eccone_angles(steering_angle_pol: float, steering_angle_tor: float) -> tuple[float, float]
GENRAY (alfast, betast) [degree] from the IMAS steering angles [rad].
Also exported as vaft.code.genray.eccone_angles.
EQDSK_NAME
data
EQDSK_NAME = 'equilib.dat'
GENRAY_INPUT_NAME
data
GENRAY_INPUT_NAME = 'genray.dat'
genray_namelists
function
source
genray_namelists(launcher: Mapping[str, Any], profiles: Mapping[str, Any], config: GENRAYConfig) -> dict[str, dict[str, Any]]
The namelist groups VAFT sets; everything else keeps GENRAY’s default_in.
Also exported as vaft.code.genray.genray_namelists.
prepare_genray_inputs
function
source
prepare_genray_inputs(ods: Any, config: GENRAYConfig, workdir: str | Path | None = None) -> GENRAYInputs
Write genray.dat, equilib.dat and the provenance record for one case.
Also exported as vaft.code.genray.prepare_genray_inputs, vaft.code.prepare_genray_inputs.
PROVENANCE_NAME
data
PROVENANCE_NAME = 'vaft_genray_inputs.json'
render_namelists
function
source
render_namelists(groups: Mapping[str, Mapping[str, Any]]) -> str
Deterministic &group ... &end text, in the order given.
Also exported as vaft.code.genray.render_namelists.
vaft.code.genray.outputs
Read GENRAY’s genray.nc and map the rays into the IMAS waves IDS.
collect_genray_outputs
function
source
collect_genray_outputs(workdir: str | Path) -> Path | None
The genray.nc GENRAY wrote into workdir, if any.
Also exported as vaft.code.genray.collect_genray_outputs.
EC_WAVE_TYPE
data
EC_WAVE_TYPE = <builtins.dict>
Also exported as vaft.code.genray.EC_WAVE_TYPE.
genray_to_waves
function
source
genray_to_waves(parsed: Mapping[str, Any], ods: Any, *, time: float, beam_name: str = '', provenance: Mapping[str, Any] | None = None, coherent_wave_index: int = 0) -> Any
Write parsed GENRAY rays into waves.coherent_wave[index].beam_tracing[0].
Also exported as vaft.code.genray.genray_to_waves, vaft.code.genray_to_waves.
RAY_STOP_REASONS
data
RAY_STOP_REASONS = <builtins.dict>
read_genray_netcdf
function
source
read_genray_netcdf(path: str | Path) -> dict[str, Any]
The per-ray arrays and totals of genray.nc, in SI, trimmed to each ray’s length.
Also exported as vaft.code.genray.read_genray_netcdf.
vaft.code.genray.runner
Run GENRAY on a prepared case and map its rays into waves.
find_genray_executable
function
source
find_genray_executable(config: GENRAYConfig | None = None) -> Path
config.executable if given, else $GENRAYHOME/bin/xgenray.
Also exported as vaft.code.find_genray_executable, vaft.code.genray.find_genray_executable.
run
function
source
run(ods: Any, config: GENRAYConfig, *, workdir: str | Path | None = None, output: Any = None) -> GENRAYResult
Prepare, run and map one EC case: ec_launchers + equilibrium + core_profiles -> waves.
Also exported as vaft.code.genray.run.
run_genray
function
source
run_genray(inputs: GENRAYInputs, config: GENRAYConfig) -> GENRAYResult
Execute GENRAY in inputs.workdir and parse genray.nc if it was written.
Also exported as vaft.code.genray.run_genray, vaft.code.run_genray.
vaft.code.gpec
Python-first adapter for the GPEC code suite.
audit_coil_field_phase
function
source
audit_coil_field_phase(coil_in: str | Path, coil_brzphi: str | Path, *, n_tor: int | None = None, coil_data_dir: str | Path | None = None, sample_points: int = 12, phi_samples: int = 48, region: int | None = None) -> CoilPhaseAudit
Audit a GPEC coil-field harmonic against Biot-Savart on its own coils.
BRZPHI_COMPONENTS
data
BRZPHI_COMPONENTS = ('b_r', 'b_z', 'b_phi')
BrzphiHarmonics
class
source
BrzphiHarmonics(points_rz: np.ndarray, values: np.ndarray, region: np.ndarray, n_tor: int | None, modes: tuple[int, ...], path: str) -> None
One *BRZPHI file’s complex field on its (R, Z) grid.
6 fields
points_rz: np.ndarrayvalues: np.ndarrayregion: np.ndarrayn_tor: int | Nonemodes: tuple[int, ...]path: str
coil_filaments_from_coil_in
function
source
coil_filaments_from_coil_in(path: str | Path, *, coil_data_dir: str | Path | None = None) -> GpecCoilFilaments
Read a GPEC coil.in and its .dat files as energised filaments.
CoilInputSpec
class
source
CoilInputSpec(name: str, currents_a: tuple[float, ...]) -> None
One activated coil set for a GPEC run: canonical name plus sector currents (A).
2 fields · 1 members
name: strcurrents_a: tuple[float, ...]from_excitationclassmethod source
CoilPhaseAudit
class
source
CoilPhaseAudit(audit: 'ToroidalPhaseAudit', n_tor: int, coil_in: str, coil_brzphi: str, machine: str, coil_names: tuple[str, ...], source_files: tuple[str, ...]) -> None
A ToroidalPhaseAudit with the GPEC files it was measured on.
7 fields
audit: 'ToroidalPhaseAudit'n_tor: intcoil_in: strcoil_brzphi: strmachine: strcoil_names: tuple[str, ...]source_files: tuple[str, ...]
collect_gpec_suite_outputs
function
source
collect_gpec_suite_outputs(workdir: Path | str) -> dict[str, tuple[Path, ...]]
Collect known GPEC-suite outputs under a prepared case directory.
Also exported as vaft.code.collect_gpec_suite_outputs.
DCON_PRODUCTS_FOR_GPEC
data
DCON_PRODUCTS_FOR_GPEC = <builtins.tuple>
dcon_scan_row
function
source
dcon_scan_row(result: DconOutput, *, shot: Optional[int] = None, time_ms: Optional[float] = None) -> dict[str, Any]
Flatten one DCON run into a row keyed by SCAN_COLUMNS.
DconCoordinates
class
source
DconCoordinates(jacobian: str = '', power_bp: Optional[float] = None, power_b: Optional[float] = None, power_r: Optional[float] = None, mpsi: Optional[int] = None, mtheta: Optional[int] = None) -> None
The flux coordinate system and grid DCON mapped the equilibrium onto.
DconEdgeScan
class
source
DconEdgeScan(psi_n: np.ndarray, q: np.ndarray, dW: np.ndarray) -> None
DCON’s edge scan: the least-stable total energy against edge safety factor.
3 fields · 5 members
psi_n: np.ndarrayq: np.ndarraydW: np.ndarrayfrom_datasetclassmethod sourcepeak_search_startmethod — Index of the first entry DCON’s peak search looks at. sourceq_edge_startmethod — DCON’sqedgestart = INT(q(psiedge)), recovered exactly from the scan. sourceto_dictmethod sourcefrom_dictclassmethod source
DconEigenfunction
class
source
DconEigenfunction(m: np.ndarray, psi: np.ndarray, rho: np.ndarray, q: np.ndarray, xi_psi_real: np.ndarray, xi_psi_imag: np.ndarray, v4_real: np.ndarray, v4_imag: np.ndarray) -> None
Per-poloidal-harmonic normal-displacement eigenfunction from solutions.bin.
8 fields · 4 members
m: np.ndarraypsi: np.ndarrayrho: np.ndarrayq: np.ndarrayxi_psi_real: np.ndarrayxi_psi_imag: np.ndarrayv4_real: np.ndarrayv4_imag: np.ndarrayamplitudeproperty —|xi . grad(psi)|per (harmonic, step), preserving the NaN padding. sourceb_normalmethod — Normal perturbed field per (harmonic, step), complex. sourceto_dictmethod sourcefrom_dictclassmethod source
DconEquilibrium
class
source
DconEquilibrium(amean: Optional[float] = None, rmean: Optional[float] = None, aratio: Optional[float] = None, kappa: Optional[float] = None, delta1: Optional[float] = None, delta2: Optional[float] = None, ro: Optional[float] = None, zo: Optional[float] = None, psio: Optional[float] = None, psilow: Optional[float] = None, q0: Optional[float] = None, qmin: Optional[float] = None, qmax: Optional[float] = None, qa: Optional[float] = None, q95: Optional[float] = None, crnt: Optional[float] = None, bt0: Optional[float] = None, betat: Optional[float] = None, betan: Optional[float] = None, betap1: Optional[float] = None, betap2: Optional[float] = None, betap3: Optional[float] = None, li1: Optional[float] = None, li2: Optional[float] = None, li3: Optional[float] = None) -> None
Equilibrium scalars DCON computed from the g-file, from the netCDF globals.
25 fields · 3 members
amean: Optional[float]rmean: Optional[float]aratio: Optional[float]kappa: Optional[float]delta1: Optional[float]delta2: Optional[float]ro: Optional[float]zo: Optional[float]psio: Optional[float]psilow: Optional[float]q0: Optional[float]qmin: Optional[float]qmax: Optional[float]qa: Optional[float]q95: Optional[float]crnt: Optional[float]bt0: Optional[float]betat: Optional[float]betan: Optional[float]betap1: Optional[float]betap2: Optional[float]betap3: Optional[float]li1: Optional[float]li2: Optional[float]li3: Optional[float]from_attrsclassmethod — Build from a dataset’s global attributes, orNoneif it carries none of them. sourceto_dictmethod sourcefrom_dictclassmethod source
DconEvaluation
class
source
DconEvaluation(mer_flag: Optional[bool] = None, bal_flag: Optional[bool] = None, thmax0: Optional[float] = None, psiedge: Optional[float] = None, vac_flag: Optional[bool] = None, nperq_edge: Optional[int] = None, source: str = '') -> None
Which local-stability criteria this DCON run was asked to evaluate.
7 fields · 6 members
mer_flag: Optional[bool]bal_flag: Optional[bool]thmax0: Optional[float]psiedge: Optional[float]vac_flag: Optional[bool]nperq_edge: Optional[int]source: strmercierproperty — Whetherdi/drmay be read as physics. sourceballooningproperty — Whetherca1may be read as physics. sourcerequested_psiedgeproperty — Thepsiedgethe run asked for, with DCON’s default filled in. sourcefrom_run_dirclassmethod sourceto_dictmethod sourcefrom_dictclassmethod source
DCONOptions
class
source
DCONOptions(sas_flag: bool = False, qhigh: float = 20.2, psiedge: float = 1.0, mer_flag: bool = True, bal_flag: bool = False, thmax0: float = 1.0, con_flag: Optional[bool] = None) -> None
DCON-specific namelist overrides.
7 fields
sas_flag: boolqhigh: floatpsiedge: floatmer_flag: boolbal_flag: boolthmax0: floatcon_flag: Optional[bool]
DconOutput
class
source
DconOutput(n_tor: int, mlow: int, mhigh: int, mpert: int, mband: int, psi_n: Optional[np.ndarray] = None, m: Optional[np.ndarray] = None, mode: Optional[np.ndarray] = None, W_p_eigenvalue: Optional[np.ndarray] = None, W_v_eigenvalue: Optional[np.ndarray] = None, W_t_eigenvalue: Optional[np.ndarray] = None, W_p_eigenvector: Optional[np.ndarray] = None, W_v_eigenvector: Optional[np.ndarray] = None, W_t_eigenvector: Optional[np.ndarray] = None, W_t: Optional[np.ndarray] = None, di: Optional[np.ndarray] = None, dr: Optional[np.ndarray] = None, ca1: Optional[np.ndarray] = None, ca1_evaluated: Optional[np.ndarray] = None, evaluation: Optional['DconEvaluation'] = None, qlim: Optional[float] = None, psilim: Optional[float] = None, f: Optional[np.ndarray] = None, mu0p: Optional[np.ndarray] = None, dvdpsi: Optional[np.ndarray] = None, q: Optional[np.ndarray] = None, equilibrium: Optional[DconEquilibrium] = None, coordinates: Optional[DconCoordinates] = None, edge_scan: Optional[DconEdgeScan] = None, eigenfunction: Optional[DconEigenfunction] = None, metadata: dict[str, Any] = <factory>) -> None
Typed container over one DCON run’s native output (one n_tor).
31 fields · 10 members
n_tor: intmlow: intmhigh: intmpert: intmband: intpsi_n: Optional[np.ndarray]m: Optional[np.ndarray]mode: Optional[np.ndarray]W_p_eigenvalue: Optional[np.ndarray]W_v_eigenvalue: Optional[np.ndarray]W_t_eigenvalue: Optional[np.ndarray]W_p_eigenvector: Optional[np.ndarray]W_v_eigenvector: Optional[np.ndarray]W_t_eigenvector: Optional[np.ndarray]W_t: Optional[np.ndarray]di: Optional[np.ndarray]dr: Optional[np.ndarray]ca1: Optional[np.ndarray]ca1_evaluated: Optional[np.ndarray]evaluation: Optional['DconEvaluation']qlim: Optional[float]psilim: Optional[float]f: Optional[np.ndarray]mu0p: Optional[np.ndarray]dvdpsi: Optional[np.ndarray]q: Optional[np.ndarray]equilibrium: Optional[DconEquilibrium]coordinates: Optional[DconCoordinates]edge_scan: Optional[DconEdgeScan]eigenfunction: Optional[DconEigenfunction]metadata: dict[str, Any]plasma1property — Least-stable plasma-response energy eigenvalue (dcon/free.f’splasma1). sourcevacuum1property sourcetotal1property — Least-stable total-energy eigenvalue –dcon/free.f’stotal1, theW_t_eigenvalueentry labelled by mode 1. sourceedge_treatmentproperty — Which of DCON’s two edge solutions this output describes. sourcem_pol_dominantproperty — The poloidal mode number carrying the largest peak|xi . grad(psi)|. sourcestable_free_boundaryproperty — Free-boundary stability fromsign(Re(total1))(dcon/dcon.f:306-314). sourceto_dictmethod sourcefrom_dictclassmethod sourcewrite_jsonmethod sourceread_jsonclassmethod source
emit_coil_dat
function
source
emit_coil_dat(coil_set: CoilSet3D, path: Path) -> Path
Write a GPEC .dat (header GPEC_COIL_DAT_HEADER) from the arrays.
find_gpec_executable
function
source
find_gpec_executable(program: str, config: 'GPECSuiteConfig | None' = None) -> Path | None
Resolve one GPEC-suite program, or None when it is not installed.
Also exported as vaft.code.find_gpec_executable.
format_gfile_header_for_gpec
function
source
format_gfile_header_for_gpec(header_line: str, shot: int | None = None, time_ms: float | int | str | None = None) -> str
Format a GEQDSK header for GPEC’s fixed-column EFIT reader.
Also exported as vaft.code.format_gfile_header_for_gpec.
GPEC_HOME_ENV
data
GPEC_HOME_ENV = 'GPECHOME'
GpecAsciiOutput
class
source
GpecAsciiOutput(kind: str, description: str = '', version: str = '', notes: tuple[str, ...] = (), attrs: dict[str, Any] = <factory>, sections: tuple[GpecAsciiSection, ...] = (), unparsed: tuple[tuple[int, str], ...] = (), path: str = '') -> None
One GPEC ASCII output file.
8 fields · 3 members
kind: strdescription: strversion: strnotes: tuple[str, ...]attrs: dict[str, Any]sections: tuple[GpecAsciiSection, ...]unparsed: tuple[tuple[int, str], ...]path: strtitlesproperty sourcesectionmethod — The first section with this exact title. sourcesections_namedmethod — Every section with this title –gpec_responserepeats “Eigenvectors”. source
GpecAsciiSection
class
source
GpecAsciiSection(title: str, tables: tuple[GpecAsciiTable, ...] = (), legend: tuple[str, ...] = ()) -> None
A titled group of blocks, with the free text GPEC printed under the title.
3 fields · 1 members
title: strtables: tuple[GpecAsciiTable, ...]legend: tuple[str, ...]tableproperty — The only block, for the sections that have exactly one. source
GpecAsciiTable
class
source
GpecAsciiTable(columns: tuple[str, ...], data: np.ndarray, header: dict[str, Any] = <factory>) -> None
One block: its scalars, its column names, and its rows.
3 fields · 4 members
columns: tuple[str, ...]data: np.ndarrayheader: dict[str, Any]columnmethod — One column by its file name. sourcecomplex_columnmethod —real(name)andimag(name)combined, without reinterpreting them. sourcecomplex_namesproperty — Names that appear as areal/imagcolumn pair. sourceto_dictmethod — Columns as a name -> array mapping, in file order. source
GPECCaseInputs
class
source
GPECCaseInputs(shot: int, time_ms: int | str | None, geqdsk: Path, workdir: Path, coil_in: Path | None = None, dcon_workdir: Path | None = None) -> None
Materialized inputs for one shot/time GPEC-suite case.
Also exported as vaft.code.GPECCaseInputs.
6 fields
shot: inttime_ms: int | str | Nonegeqdsk: Pathworkdir: Pathcoil_in: Path | Nonedcon_workdir: Path | None
GpecCoilFilaments
class
source
GpecCoilFilaments(loops_xyz: tuple[np.ndarray, ...], currents_a: np.ndarray, coil_names: tuple[str, ...], machine: str, source_files: tuple[Path, ...]) -> None
The energised filaments of a GPEC run, ready for a Biot-Savart evaluation.
5 fields
loops_xyz: tuple[np.ndarray, ...]currents_a: np.ndarraycoil_names: tuple[str, ...]machine: strsource_files: tuple[Path, ...]
GpecControlOutput
class
source
GpecControlOutput(n_tor: int, machine: str, shot: int, time: float, version: str, jacobian: str, helicity: int, energy_vacuum: float, energy_surface: float, energy_plasma: float, m: Optional[np.ndarray] = None, theta: Optional[np.ndarray] = None, psi_n_rational: Optional[np.ndarray] = None, q_rational: Optional[np.ndarray] = None, m_rational: Optional[np.ndarray] = None, R: Optional[np.ndarray] = None, z: Optional[np.ndarray] = None, Phi: Optional[np.ndarray] = None, Phi_x: Optional[np.ndarray] = None, b_n: Optional[np.ndarray] = None, b_n_x: Optional[np.ndarray] = None, xi_n: Optional[np.ndarray] = None, xi_n_fun: Optional[np.ndarray] = None, b_n_fun: Optional[np.ndarray] = None, coil_names: tuple[str, ...] = (), Phi_coil: Optional[np.ndarray] = None, extras: dict[str, np.ndarray] = <factory>, attrs: dict[str, Any] = <factory>) -> None
Control-surface output (gpec_control_output_n<mode>.nc).
28 fields · 1 members
n_tor: intmachine: strshot: inttime: floatversion: strjacobian: strhelicity: intenergy_vacuum: floatenergy_surface: floatenergy_plasma: floatm: Optional[np.ndarray]theta: Optional[np.ndarray]psi_n_rational: Optional[np.ndarray]q_rational: Optional[np.ndarray]m_rational: Optional[np.ndarray]R: Optional[np.ndarray]z: Optional[np.ndarray]Phi: Optional[np.ndarray]Phi_x: Optional[np.ndarray]b_n: Optional[np.ndarray]b_n_x: Optional[np.ndarray]xi_n: Optional[np.ndarray]xi_n_fun: Optional[np.ndarray]b_n_fun: Optional[np.ndarray]coil_names: tuple[str, ...]Phi_coil: Optional[np.ndarray]extras: dict[str, np.ndarray]attrs: dict[str, Any]energy_totalproperty — Sum of the vacuum/surface/plasma perturbed-energy attributes [J]. source
GpecCylindricalOutput
class
source
GpecCylindricalOutput(n_tor: int, R: np.ndarray, z: np.ndarray, l: Optional[np.ndarray] = None, b_r_equil: Optional[np.ndarray] = None, b_z_equil: Optional[np.ndarray] = None, b_t_equil: Optional[np.ndarray] = None, b_r: Optional[np.ndarray] = None, b_z: Optional[np.ndarray] = None, b_t: Optional[np.ndarray] = None, b_r_plasma: Optional[np.ndarray] = None, b_z_plasma: Optional[np.ndarray] = None, b_t_plasma: Optional[np.ndarray] = None, A_r: Optional[np.ndarray] = None, A_z: Optional[np.ndarray] = None, A_t: Optional[np.ndarray] = None, xi_r: Optional[np.ndarray] = None, xi_z: Optional[np.ndarray] = None, xi_t: Optional[np.ndarray] = None, units: dict[str, str] = <factory>, attrs: dict[str, Any] = <factory>) -> None
Cylindrical-grid output (gpec_cylindrical_output_n<mode>.nc).
21 fields
n_tor: intR: np.ndarrayz: np.ndarrayl: Optional[np.ndarray]b_r_equil: Optional[np.ndarray]b_z_equil: Optional[np.ndarray]b_t_equil: Optional[np.ndarray]b_r: Optional[np.ndarray]b_z: Optional[np.ndarray]b_t: Optional[np.ndarray]b_r_plasma: Optional[np.ndarray]b_z_plasma: Optional[np.ndarray]b_t_plasma: Optional[np.ndarray]A_r: Optional[np.ndarray]A_z: Optional[np.ndarray]A_t: Optional[np.ndarray]xi_r: Optional[np.ndarray]xi_z: Optional[np.ndarray]xi_t: Optional[np.ndarray]units: dict[str, str]attrs: dict[str, Any]
GpecIdealResult
class
source
GpecIdealResult(control: GpecControlOutput, cylindrical: Optional[GpecCylindricalOutput] = None, source_paths: dict[str, str] = <factory>) -> None
One ideal-GPEC run’s native output set for a single toroidal mode.
3 fields · 4 members
control: GpecControlOutputcylindrical: Optional[GpecCylindricalOutput]source_paths: dict[str, str]n_torproperty sourcefrom_netcdfclassmethod — Read a run directory’s control (required), cylindrical and profile files. sourceto_dictmethod — JSON-safe transcript of the control output plus source provenance. sourcewrite_jsonmethod source
GPECModuleRun
class
source
GPECModuleRun(module: str, mode: int, workdir: Path, returncode: Optional[int] = None, status: str = 'prepared', reason: str = '', logs: tuple[Path, ...] = (), outputs: tuple[Path, ...] = (), commands: tuple[str, ...] = (), missing_optional_outputs: tuple[str, ...] = (), plasma_formalism: Optional[Mapping[str, Any]] = None, ordering_check: Optional[Mapping[str, Any]] = None) -> None
Status for one module/mode directory.
Also exported as vaft.code.GPECModuleRun.
12 fields · 2 members
module: strmode: intworkdir: Pathreturncode: Optional[int]status: strreason: strlogs: tuple[Path, ...]outputs: tuple[Path, ...]commands: tuple[str, ...]missing_optional_outputs: tuple[str, ...]plasma_formalism: Optional[Mapping[str, Any]]ordering_check: Optional[Mapping[str, Any]]formalismproperty — Thevaft.code.formalism.PlasmaFormalismof this run, orNone. sourceokproperty — Whether this cell produced a usable result. source
GpecProfileOutput
class
source
GpecProfileOutput(n_tor: int, machine: str = '', shot: int = 0, time: float = 0.0, version: str = '', helicity: Optional[float] = None, psi_n: Optional[np.ndarray] = None, psi_n_rational: Optional[np.ndarray] = None, theta_dcon: Optional[np.ndarray] = None, m_out: Optional[np.ndarray] = None, m_pest: Optional[np.ndarray] = None, q_rational: Optional[np.ndarray] = None, dqdpsi_n_rational: Optional[np.ndarray] = None, area_rational: Optional[np.ndarray] = None, Phi_res: Optional[np.ndarray] = None, Phi_res_v: Optional[np.ndarray] = None, Phi_res_crit: Optional[np.ndarray] = None, Phi_res_crit_callen: Optional[np.ndarray] = None, Delta: Optional[np.ndarray] = None, B_pen: Optional[np.ndarray] = None, I_res: Optional[np.ndarray] = None, w_isl: Optional[np.ndarray] = None, w_isl_v: Optional[np.ndarray] = None, w_isl_v_crit: Optional[np.ndarray] = None, K_isl: Optional[np.ndarray] = None, K_isl_v: Optional[np.ndarray] = None, q: Optional[np.ndarray] = None, rmean_n: Optional[np.ndarray] = None, dvdpsi_n: Optional[np.ndarray] = None, R: Optional[np.ndarray] = None, z: Optional[np.ndarray] = None, B: Optional[np.ndarray] = None, R_n: Optional[np.ndarray] = None, z_n: Optional[np.ndarray] = None, b_n: Optional[np.ndarray] = None, b_n_fun: Optional[np.ndarray] = None, xi_n: Optional[np.ndarray] = None, xi_n_fun: Optional[np.ndarray] = None, extras: dict[str, np.ndarray] = <factory>, units: dict[str, str] = <factory>, jacobians: dict[str, str] = <factory>, dims: dict[str, tuple[str, ...]] = <factory>, attrs: dict[str, Any] = <factory>) -> None
Profile output (gpec_profile_output_n<mode>.nc).
43 fields · 3 members
n_tor: intmachine: strshot: inttime: floatversion: strhelicity: Optional[float]psi_n: Optional[np.ndarray]psi_n_rational: Optional[np.ndarray]theta_dcon: Optional[np.ndarray]m_out: Optional[np.ndarray]m_pest: Optional[np.ndarray]q_rational: Optional[np.ndarray]dqdpsi_n_rational: Optional[np.ndarray]area_rational: Optional[np.ndarray]Phi_res: Optional[np.ndarray]Phi_res_v: Optional[np.ndarray]Phi_res_crit: Optional[np.ndarray]Phi_res_crit_callen: Optional[np.ndarray]Delta: Optional[np.ndarray]B_pen: Optional[np.ndarray]I_res: Optional[np.ndarray]w_isl: Optional[np.ndarray]w_isl_v: Optional[np.ndarray]w_isl_v_crit: Optional[np.ndarray]K_isl: Optional[np.ndarray]K_isl_v: Optional[np.ndarray]q: Optional[np.ndarray]rmean_n: Optional[np.ndarray]dvdpsi_n: Optional[np.ndarray]R: Optional[np.ndarray]z: Optional[np.ndarray]B: Optional[np.ndarray]R_n: Optional[np.ndarray]z_n: Optional[np.ndarray]b_n: Optional[np.ndarray]b_n_fun: Optional[np.ndarray]xi_n: Optional[np.ndarray]xi_n_fun: Optional[np.ndarray]extras: dict[str, np.ndarray]units: dict[str, str]jacobians: dict[str, str]dims: dict[str, tuple[str, ...]]attrs: dict[str, Any]n_rationalproperty — Number of rational surfaces in the file. sourcem_rationalproperty — Resonant poloidal mode numbern * qat each rational surface. sourceresonant_tablemethod — The rational-surface quantities present, as one aligned mapping. source
GPECSuiteConfig
class
source
GPECSuiteConfig(gpec_home: Path | str | None = None, executable_dir: Path | str | None = None, modules: Sequence[str] = ('dcon', 'rdcon', 'stride', 'gpec'), modes: Sequence[int] = (1, 2), run_mode: str = 'run_if_available', templates_dir: Path | str | None = None, coil_data_dir: Path | str | None = None, psilow: float = 0.01, psihigh: float = 0.994, verify_outputs: bool = False, timeout: Optional[float] = 1200.0, env: Mapping[str, str] = <factory>, ordering_state: Mapping[str, Any] = <factory>, dcon: DCONOptions = <factory>, rdcon: RDCONOptions = <factory>, stride: STRIDEOptions = <factory>, gpec: IdealGPECOptions = <factory>, backend: Optional['ExecutionBackend'] = None) -> None
Runtime and VEST-default configuration for the GPEC suite.
Also exported as vaft.code.GPECSuiteConfig.
18 fields
gpec_home: Path | str | Noneexecutable_dir: Path | str | Nonemodules: Sequence[str]modes: Sequence[int]run_mode: strtemplates_dir: Path | str | Nonecoil_data_dir: Path | str | Nonepsilow: floatpsihigh: floatverify_outputs: booltimeout: Optional[float]env: Mapping[str, str]ordering_state: Mapping[str, Any]dcon: DCONOptionsrdcon: RDCONOptionsstride: STRIDEOptionsgpec: IdealGPECOptionsbackend: Optional['ExecutionBackend']
GPECSuiteResult
class
source
GPECSuiteResult(returncode: Optional[int], workdir: Path, shot: int | None = None, time_ms: int | str | None = None, records: tuple[GPECModuleRun, ...] = (), logs: tuple[Path, ...] = (), outputs: Mapping[str, tuple[Path, ...]] = <factory>, stdout: str = '', stderr: str = '', parsed: Any = None, input_equilibrium_sha256: str = '') -> None
Suite status, records, and collected artifacts.
Also exported as vaft.code.GPECSuiteResult.
11 fields · 1 members
returncode: Optional[int]workdir: Pathshot: int | Nonetime_ms: int | str | Nonerecords: tuple[GPECModuleRun, ...]logs: tuple[Path, ...]outputs: Mapping[str, tuple[Path, ...]]stdout: strstderr: strparsed: Anyinput_equilibrium_sha256: strokproperty source
IdealGPECOptions
class
source
IdealGPECOptions(coil_flag: bool = True, ascii_flag: Optional[bool] = None, xclebsch_flag: Optional[bool] = None, coil_specs: Optional[Sequence['CoilInputSpec']] = None, machine: str = 'vest', coil_config: Optional[Mapping[str, 'CoilSet3D']] = None, ip_direction: Optional[str] = None, bt_direction: Optional[str] = None, singthresh_flag: bool = False, singthresh_callen_flag: bool = False, singthresh_slayer_flag: bool = False, singthresh_slayer_inpr: Optional[float] = None, singthresh_slayer_inpr_prof: Optional[Sequence[float]] = None) -> None
Ideal-GPEC-specific namelist overrides.
13 fields · 4 members
coil_flag: boolascii_flag: Optional[bool]xclebsch_flag: Optional[bool]coil_specs: Optional[Sequence['CoilInputSpec']]machine: strcoil_config: Optional[Mapping[str, 'CoilSet3D']]ip_direction: Optional[str]bt_direction: Optional[str]singthresh_flag: boolsingthresh_callen_flag: boolsingthresh_slayer_flag: boolsingthresh_slayer_inpr: Optional[float]singthresh_slayer_inpr_prof: Optional[Sequence[float]]writes_pentrc_inputproperty — Whether this run will leave the ASCII displacement PENTRC reads. sourcewants_callen_thresholdproperty — Whether this run will compute Callen’s critical width [-]. sourcewants_slayer_thresholdproperty — Whether this run will compute SLAYER’s critical resonant field [-]. sourcewants_any_thresholdproperty — Whether either threshold is requested, and so kinetic profiles are needed [-]. source
JACOBIAN_NAMES
data
JACOBIAN_NAMES = ('hamada', 'pest', 'equal_arc', 'boozer', 'park', 'polar', 'other')
ordering_state_for_case
function
source
ordering_state_for_case(geqdsk: Path | str, *, time_s: float | None = None, ods: Any = None, z_eff: float | None = None, plasma_onset: float | None = None) -> tuple[dict[str, Any], dict[str, Any]]
Ordering quantities of one case, and how they were obtained.
PENTRC_COLLISION_OPERATORS
data
PENTRC_COLLISION_OPERATORS = <builtins.mappingproxy>
PENTRC_IMPURITY_SPECIES
data
PENTRC_IMPURITY_SPECIES = <builtins.mappingproxy>
PENTRC_ION_SPECIES
data
PENTRC_ION_SPECIES = <builtins.mappingproxy>
PENTRC_MODULE
data
PENTRC_MODULE = 'pentrc'
pentrc_output_name
function
source
pentrc_output_name(mode: int) -> str
PENTRC’s netCDF output for one toroidal mode (pentrc/torque.F90:1905).
PENTRCOptions
class
source
PENTRCOptions(methods: Sequence[str], main_ion: str, impurity: str, collision_operator: str, bounce_harmonics: int = 6, moment: str = 'pressure', electron: bool = False, psi_limits: Optional[tuple[float, float]] = None, grids: Sequence[str] = ('dynamic',), artificial_factors: Optional[Mapping[str, float]] = None, data_dir: str = 'default', threads: int = 0, output_ascii: bool = False, output_netcdf: bool = True) -> None
What one PENTRC run computes, and for which plasma.
14 fields · 1 members
methods: Sequence[str]main_ion: strimpurity: strcollision_operator: strbounce_harmonics: intmoment: strelectron: boolpsi_limits: Optional[tuple[float, float]]grids: Sequence[str]artificial_factors: Optional[Mapping[str, float]]data_dir: strthreads: intoutput_ascii: booloutput_netcdf: boolspecies_namelistproperty — The fourpentrc.inspecies keys this selection resolves to [u, e]. source
peq_jacobian
function
source
peq_jacobian(path: Path | str) -> str
The Jacobian a gpec_xclebsch_n<n>.out was decomposed in, as jac_in.
peq_toroidal_angle
function
source
peq_toroidal_angle(run_dir: Path | str) -> int
tmag_in for the displacement in run_dir, read off its own gpec.in.
Pest3MatchingOutput
class
source
Pest3MatchingOutput(solver: str, n_tor: int, mlow: int, mhigh: int, mpert: int, mband: int, m: Optional[np.ndarray] = None, psi_n_rational: Optional[np.ndarray] = None, q_rational: Optional[np.ndarray] = None, A_prime: Optional[np.ndarray] = None, B_prime: Optional[np.ndarray] = None, Gamma_prime: Optional[np.ndarray] = None, Delta_prime: Optional[np.ndarray] = None, Delta: Optional[np.ndarray] = None, nzero: Optional[int] = None, plasma1: Optional[complex] = None, vacuum1: Optional[complex] = None, total1: Optional[complex] = None, metadata: dict[str, Any] = <factory>, psi_n: Optional[np.ndarray] = None, q: Optional[np.ndarray] = None, di: Optional[np.ndarray] = None, dr: Optional[np.ndarray] = None, h: Optional[np.ndarray] = None, ca1: Optional[np.ndarray] = None) -> None
Typed container over one RDCON or STRIDE run’s PEST3 matching output (one n_tor).
25 fields · 8 members
solver: strn_tor: intmlow: intmhigh: intmpert: intmband: intm: Optional[np.ndarray]psi_n_rational: Optional[np.ndarray]q_rational: Optional[np.ndarray]A_prime: Optional[np.ndarray]B_prime: Optional[np.ndarray]Gamma_prime: Optional[np.ndarray]Delta_prime: Optional[np.ndarray]Delta: Optional[np.ndarray]nzero: Optional[int]plasma1: Optional[complex]vacuum1: Optional[complex]total1: Optional[complex]metadata: dict[str, Any]psi_n: Optional[np.ndarray]q: Optional[np.ndarray]di: Optional[np.ndarray]dr: Optional[np.ndarray]h: Optional[np.ndarray]ca1: Optional[np.ndarray]msingproperty sourcedelta_prime_diagonalmethod — The single-surface (diagonal) classical Delta-prime per rational surface. sourcerational_surface_stabilitymethod — One row per rational surface: diagonal Delta-prime and the local criteria there. sourcestableproperty — Free-boundary-style stability fromsign(Re(total1)), when available. sourceto_dictmethod sourcefrom_dictclassmethod sourcewrite_jsonmethod sourceread_jsonclassmethod source
prepare_gpec_suite_case
function
source
prepare_gpec_suite_case(inputs: GPECCaseInputs, config: GPECSuiteConfig | None = None) -> GPECSuiteResult
Create VEST GPEC-suite input directories for one shot/time GEQDSK.
Also exported as vaft.code.prepare_gpec_suite_case.
prepare_pentrc_run
function
source
prepare_pentrc_run(run_dir: Path | str, *, mode: int, options: PENTRCOptions, kinetic_file: Path | str, config: GPECSuiteConfig | None = None) -> Path
Write pentrc.in into a completed ideal-GPEC cell, and return it.
PRIOR_PENTRC_INPUT
data
PRIOR_PENTRC_INPUT = 'pentrc_prior.in'
RDCONOptions
class
source
RDCONOptions(t_e: Optional[Sequence[float]] = None, n_e: Optional[Sequence[float]] = None, psi_norm: Optional[Sequence[float]] = None, ion_mass_amu: float = 1.0, z_eff: Optional[float] = None, ln_lambda: Optional[float] = None) -> None
RDCON-specific namelist overrides.
6 fields · 1 members
t_e: Optional[Sequence[float]]n_e: Optional[Sequence[float]]psi_norm: Optional[Sequence[float]]ion_mass_amu: floatz_eff: Optional[float]ln_lambda: Optional[float]has_kinetic_profilesproperty source
read_brzphi_harmonics
function
source
read_brzphi_harmonics(path: str | Path, *, region: int | None = None) -> BrzphiHarmonics
Read a gpec_*brzphi_n*.out as points and complex field values.
read_coil_control
function
source
read_coil_control(path: str | Path) -> dict[str, str]
The scalar &COIL_CONTROL entries of a GPEC coil.in, as written.
read_coil_in
function
source
read_coil_in(path: str | Path) -> tuple[CoilInputSpec, ...]
Read the activated coil sets and sector currents from a GPEC coil.in.
read_dcon_output
function
source
read_dcon_output(run_dir: str | Path, *, mode: int) -> DconOutput
Build a DconOutput from one completed DCON run directory.
read_dcon_scan
function
source
read_dcon_scan(workdir: str | Path, *, modes: Sequence[int] = (1,), shot: Optional[int] = None) -> list[dict[str, Any]]
Harvest one row per DCON run under a prepared case directory.
read_gpec_ascii
function
source
read_gpec_ascii(path: str | Path) -> GpecAsciiOutput
Read any of GPEC’s sectioned ASCII outputs.
read_gpec_netcdf
function
source
read_gpec_netcdf(run_dir: str | Path, mode: int | None = None) -> GpecIdealResult
Read one ideal-GPEC run directory into a GpecIdealResult.
read_gpec_profile_output
function
source
read_gpec_profile_output(path: str | Path) -> GpecProfileOutput
Read one gpec_profile_output_n<mode>.nc file.
read_gpec_response
function
source
read_gpec_response(path: str | Path) -> GpecAsciiOutput
Read gpec_response_n*.out or gpec_response_fun_n*.out.
read_gpec_singcoup
function
source
read_gpec_singcoup(path: str | Path) -> GpecAsciiOutput
Read gpec_singcoup_matrix_n*.out or gpec_singcoup_svd_n*.out.
read_namelist_group
function
source
read_namelist_group(path: Path | str, group: str) -> dict[str, str]
The scalar assignments of one Fortran namelist group, as the file writes them.
read_pest3_matching_output
function
source
read_pest3_matching_output(run_dir: str | Path, *, solver: str, mode: int) -> Pest3MatchingOutput
Build a Pest3MatchingOutput from a completed RDCON or STRIDE run.
read_resonant_table
function
source
read_resonant_table(path: str | Path) -> dict[str, np.ndarray]
Just the rational-surface block of a profile file.
read_solutions_bin
function
source
read_solutions_bin(path: str | Path, *, mlow: int) -> DconEigenfunction
Parse solutions.bin and label its blocks by true poloidal mode number.
resolve_coil_inputs
function
source
resolve_coil_inputs(machine: str, coil_config: Mapping[str, CoilSet3D] | Vest3DCoilConfig | None, ip_direction: str | None, bt_direction: str | None, names: Sequence[str]) -> tuple[Mapping[str, CoilSet3D], str, str]
Resolve geometry and direction words for machine; refuse to guess.
run_gpec_suite_case
function
source
run_gpec_suite_case(inputs: GPECCaseInputs, config: GPECSuiteConfig | None = None, *, prepare: bool = True) -> GPECSuiteResult
Prepare and optionally run all configured VEST GPEC-suite modules.
Also exported as vaft.code.run_gpec_suite_case.
run_pentrc
function
source
run_pentrc(run_dir: Path | str, *, mode: int, options: PENTRCOptions, kinetic_file: Path | str, config: GPECSuiteConfig | None = None, allow_unbounded_runtime: bool = False) -> GPECModuleRun
Prepare and run PENTRC in a completed ideal-GPEC cell.
SCAN_COLUMNS
data
SCAN_COLUMNS = ('shot', 'time_ms', 'n_tor', 'q0', 'qmin', 'qmax', 'qa', 'q95', 'qlim', 'betan', 'betat', 'betap1', 'betap3', 'li1', ...
scan_pentrc_log
function
source
scan_pentrc_log(path: Path | str) -> tuple[str | None, int]
The first fatal line in a PENTRC log, and how many non-convergence lines.
stage_coil_data
function
source
stage_coil_data(coil_sets: Sequence[CoilSet3D], data_dir: Path, *, machine: str) -> tuple[Path, ...]
Stage each set as <data_dir>/<machine>_<coil_name>.dat.
stage_dcon_products
function
source
stage_dcon_products(dcon_dir: Path, run_dir: Path) -> tuple[Path, ...]
Put DCON’s products where ideal GPEC will look for them, and say which.
STRIDEOptions
class
source
STRIDEOptions() -> None
STRIDE-specific namelist overrides (none exposed yet – packaged defaults only).
THRESHOLD_PENTRC_INPUT
data
THRESHOLD_PENTRC_INPUT = 'pentrc_threshold.in'
validate_dcon_result
function
source
validate_dcon_result(dcon_dir: Path | str, mode: int, *, verify_outputs: bool = False) -> list[str]
Describe what makes dcon_dir unusable as an ideal-GPEC prerequisite.
validate_pentrc_inputs
function
source
validate_pentrc_inputs(run_dir: Path | str, mode: int) -> list[str]
Describe what stops PENTRC running in run_dir.
validate_threshold_inputs
function
source
validate_threshold_inputs(run_dir: Path | str, dcon_dir: Path | str | None = None) -> list[str]
Describe what stops run_dir computing a penetration threshold.
write_coil_in
function
source
write_coil_in(template_path: Path, out_path: Path, *, data_dir: Path, specs: Sequence[CoilInputSpec], machine: str, coil_config: Mapping[str, CoilSet3D] | None = None, ip_direction: str | None = None, bt_direction: str | None = None) -> Path
Write a GPEC coil.in activating exactly specs for machine.
write_threshold_pentrc_input
function
source
write_threshold_pentrc_input(run_dir: Path | str, *, options: PENTRCOptions, kinetic_file: Path | str, config: GPECSuiteConfig | None = None) -> Path
Write the pentrc.in ideal GPEC reads for a penetration threshold.
vaft.code.mitim.availability
Is a usable MITIM installation configured? (#1588 section 3).
mitim_availability
function
source
mitim_availability(config: MITIMConfig | None = None, *, timeout: float = 300.0) -> MITIMAvailability
Probe the configured MITIM interpreter and the GACODE build it would use.
Also exported as vaft.code.mitim.mitim_availability.
MITIMAvailability
class
source
MITIMAvailability(status: str, detail: str = '', python: Optional[str] = None, python_version: Optional[str] = None, version: Optional[str] = None, revision: Optional[str] = None, root: Optional[str] = None, portals: bool = False, gacode_root: Optional[str] = None, gacode_platform: Optional[str] = None, gacode_revision: Optional[str] = None, supported_versions: tuple[str, ...] = ('5.3.0',)) -> None
What the probe found. status is one of STATUSES.
Also exported as vaft.code.mitim.MITIMAvailability.
12 fields · 2 members
status: strdetail: strpython: Optional[str]python_version: Optional[str]version: Optional[str]revision: Optional[str]root: Optional[str]portals: boolgacode_root: Optional[str]gacode_platform: Optional[str]gacode_revision: Optional[str]supported_versions: tuple[str, ...]readyproperty sourceas_dictmethod source
PROBE
data
PROBE = '\nimport json, platform, subprocess, sys\nout = {"python": sys.executable, "python_version": platform.python_version...
STATUSES
data
STATUSES = ('configuration_missing', 'probe_timeout', 'not_installed', 'unsupported_version', 'portals_unavailable', 'gacode_una...
Also exported as vaft.code.mitim.STATUSES.
vaft.code.mitim.compare
Compare MITIM’s TGLF local inputs with VAFT’s, key by key (#1588 stage A2).
compare_neo_fluxes
function
source
compare_neo_fluxes(vaft_transport: Mapping[str, Any], mitim_by_r_over_a: Mapping[float, Mapping[str, Any]], *, rtol: float = 0.001, atol: float = 0.0, vaft_charges: Iterable[float] | None = None, mitim_charges: Mapping[float, Iterable[float]] | None = None) -> list[dict[str, Any]]
Per (r/a, channel, species) rows comparing a VAFT profile run with MITIM runs.
Also exported as vaft.code.mitim.compare_neo_fluxes.
compare_tglf_inputs
function
source
compare_tglf_inputs(vaft: Mapping[str, Any], mitim: Mapping[str, Any], *, rtol: float = 0.001, atol: float = 1e-06, keys: Iterable[str] | None = None, effective: bool = True) -> list[dict[str, Any]]
One row per key present in either input.
Also exported as vaft.code.mitim.compare_tglf_inputs.
effective_tglf_controls
function
source
effective_tglf_controls(parameters: Mapping[str, Any]) -> dict[str, Any]
The controls TGLF actually runs with, after its own start-up presets.
Also exported as vaft.code.mitim.effective_tglf_controls.
neo_input_charges
function
source
neo_input_charges(input_neo: Mapping[str, Any]) -> list[float]
Z_1 .. Z_N_SPECIES of an input.neo, in NEO’s species order.
Also exported as vaft.code.mitim.neo_input_charges.
neo_local_to_profile_normalisation
function
source
neo_local_to_profile_normalisation(transport: Mapping[str, Any], input_neo: Mapping[str, Any], *, reference_mass_1: float | None = None) -> dict[str, Any]
Re-express a local-mode NEO result in profile mode’s normalisation.
Also exported as vaft.code.mitim.neo_local_to_profile_normalisation.
PHYSICS_KEYS
data
PHYSICS_KEYS = <re.Pattern>
read_input_neo
function
source
read_input_neo(path: str | Path) -> dict[str, Any]
KEY = VALUE lines of an input.neo (same syntax as input.tglf).
Also exported as vaft.code.mitim.read_input_neo.
read_input_tglf
function
source
read_input_tglf(path: str | Path) -> dict[str, Any]
KEY=VALUE lines of an input.tglf; comments (#) and blanks skipped.
Also exported as vaft.code.mitim.read_input_tglf.
vaft.code.mitim.config
Configuration and result objects for the MITIM-fusion adapter (#1588 stage A1).
MITIM_CODES
data
MITIM_CODES = ('trxpl', 'profiles_gen', 'tgyro', 'tglf', 'neo', 'cgyro', 'qualikiz', 'gx', 'astra', 'eq', 'scruncher', 'ntcc', 'get...
MITIM_PYTHON_ENV
data
MITIM_PYTHON_ENV = 'VAFT_MITIM_PYTHON'
Also exported as vaft.code.mitim.MITIM_PYTHON_ENV.
mitim_user_config
function
source
mitim_user_config(config: MITIMConfig, workdir: str | Path, *, username: str | None = None) -> dict
The $MITIM_CONFIG document for one run.
Also exported as vaft.code.mitim.mitim_user_config.
MITIMConfig
class
source
MITIMConfig(python: Optional[str] = None, gacode: Optional['GACODEConfig'] = None, cores: int = 1, timeout: Optional[float] = None, backend: Optional['ExecutionBackend'] = None, env: Mapping[str, str] = <factory>, verbose_level: int = 1) -> None
Runtime configuration for one MITIM-driven run.
Also exported as vaft.code.mitim.MITIMConfig.
7 fields · 1 members
python: Optional[str]gacode: Optional['GACODEConfig']cores: inttimeout: Optional[float]backend: Optional['ExecutionBackend']env: Mapping[str, str]verbose_level: intinterpretermethod — The configured MITIM interpreter, or None when neither source names one. source
MITIMResult
class
source
MITIMResult(returncode: Optional[int], workdir: Path, stdout: str = '', stderr: str = '', runtime_status: str = 'completed', elapsed_s: Optional[float] = None, result: Optional[Mapping[str, Any]] = None, record: Mapping[str, Any] = <factory>) -> None
One MITIM driver run.
Also exported as vaft.code.mitim.MITIMResult.
8 fields · 1 members
returncode: Optional[int]workdir: Pathstdout: strstderr: strruntime_status: strelapsed_s: Optional[float]result: Optional[Mapping[str, Any]]record: Mapping[str, Any]okproperty — The driver exited 0 and reported success inresult.json. source
SUPPORTED_MITIM_VERSIONS
data
SUPPORTED_MITIM_VERSIONS = ('5.3.0',)
Also exported as vaft.code.mitim.SUPPORTED_MITIM_VERSIONS.
VAFT_MACHINE
data
VAFT_MACHINE = 'vaft_local'
Also exported as vaft.code.mitim.VAFT_MACHINE.
vaft.code.mitim.coordinates
The radial coordinate bridge between VAFT and MITIM (#1588 stage A2).
r_over_a_at
function
source
r_over_a_at(profile: Any, rho_tor_norm: Any) -> np.ndarray
r/a of the surfaces at rho_tor_norm of profile [-].
Also exported as vaft.code.mitim.r_over_a_at.
rho_tor_norm_at
function
source
rho_tor_norm_at(profile: Any, r_over_a: Any) -> np.ndarray
rho_tor_norm of the surfaces at r/a (rmin/rmin[-1]) of profile [-].
Also exported as vaft.code.mitim.rho_tor_norm_at.
vaft.code.mitim.drivers.neo_smoke
MITIM NEOtools at a few radii on one input.gacode: the stage-A1 smoke capability.
vaft.code.mitim.drivers.portals_closed_loop
PORTALS/powertorch synthetic closed loop with a manufactured source (#1588 C1).
vaft.code.mitim.drivers.portals_tglf_closed_loop
PORTALS (TGLF + NEO) synthetic closed loop with a manufactured source (#1588 C1b).
vaft.code.mitim.drivers.tglf_local_inputs
MITIM’s own TGLF local inputs at exact r/a, written but not run (#1588 A2).
vaft.code.mitim.drivers.tglf_run
MITIM TGLFtools run at given rho_tor_norm, outputs regrouped per radius (#1588 A2).
main
function
source
main(argument_file)
split_by_radius
function
source
split_by_radius(source, target, marker='out.tglf.gbflux')
Copy each radius’s files, unsuffixed, into target/rho_<value>/.
vaft.code.mitim.portals
PORTALS/powertorch synthetic closed loop (#1588 stage C1).
closed_loop_report
function
source
closed_loop_report(result: dict, perturbation: float) -> ClosedLoopReport
Reduce a driver result.json to ClosedLoopReport.
Also exported as vaft.code.mitim.closed_loop_report.
ClosedLoopReport
class
source
ClosedLoopReport(r_over_a: tuple[float, ...], manufacture_error: float, recovery_error: float, final_flux_error: float, sign_ok: bool) -> None
What a closed loop established, from the driver’s result.json.
Also exported as vaft.code.mitim.ClosedLoopReport.
5 fields
r_over_a: tuple[float, ...]manufacture_error: floatrecovery_error: floatfinal_flux_error: floatsign_ok: bool
NO_EARLY_STOP
data
NO_EARLY_STOP = <builtins.dict>
run_portals_closed_loop
function
source
run_portals_closed_loop(profile: Any, r_over_a, workdir: str | Path, config: MITIMConfig | None = None, *, model: str = 'analytic', chi_e: float = 1.0, chi_i: float = 1.0, perturbation: float = 0.3, tglf_code_settings: str = 'SAT3', tglf_extra_options: Optional[dict] = None, neo_extra_options: Optional[dict] = None, initial_training: int = 5, maximum_iterations: int = 10, stopping_criteria_parameters: Optional[dict] = None, availability: Optional[MITIMAvailability] = None) -> tuple[MITIMResult, Optional[ClosedLoopReport]]
Manufacture a flux-matched problem from profile and check MITIM recovers it.
Also exported as vaft.code.mitim.run_portals_closed_loop.
vaft.code.mitim.runner
Launch a MITIM driver script in the isolated MITIM interpreter (#1588 stage A1).
mitim_tglf_local_inputs
function
source
mitim_tglf_local_inputs(profile: Any, r_over_a, workdir: str | Path, config: MITIMConfig | None = None, *, code_settings: str = 'SAT3', availability: Optional[MITIMAvailability] = None) -> tuple[MITIMResult, dict[float, dict]]
MITIM’s own TGLF local inputs for profile at exactly these r/a, not run.
Also exported as vaft.code.mitim.mitim_tglf_local_inputs.
run_mitim_driver
function
source
run_mitim_driver(driver: str, arguments: Mapping[str, Any], workdir: str | Path, config: MITIMConfig | None = None, *, availability: Optional[MITIMAvailability] = None) -> MITIMResult
Run one packaged driver (vaft/code/mitim/drivers/<driver>.py) in workdir.
Also exported as vaft.code.mitim.run_mitim_driver.
run_mitim_neo
function
source
run_mitim_neo(profile: Any, r_over_a, workdir: str | Path, config: MITIMConfig | None = None, *, code_settings: Optional[str] = None, extra_options: Optional[Mapping[str, Any]] = None, availability: Optional[MITIMAvailability] = None) -> tuple[MITIMResult, dict[float, Any], dict[float, dict]]
Run NEO through MITIM (local mode, one radius each) at VAFT’s r/a.
Also exported as vaft.code.mitim.run_mitim_neo.
run_mitim_tglf
function
source
run_mitim_tglf(profile: Any, r_over_a, workdir: str | Path, config: MITIMConfig | None = None, *, code_settings: str = 'SAT3', extra_options: Optional[Mapping[str, Any]] = None, availability: Optional[MITIMAvailability] = None) -> tuple[MITIMResult, dict[float, Any]]
Run TGLF through MITIM at VAFT’s r/a surfaces and read the results with VAFT.
Also exported as vaft.code.mitim.run_mitim_tglf.
run_neo_smoke
function
source
run_neo_smoke(profile: Any, rho_tor_norm, workdir: str | Path, config: MITIMConfig | None = None, *, code_settings: Optional[str] = None, availability: Optional[MITIMAvailability] = None) -> tuple[MITIMResult, list]
The stage-A1 smoke capability: MITIM NEOtools on VAFT’s own input.gacode.
Also exported as vaft.code.mitim.run_neo_smoke.
vaft.code.nice.config
Typed configuration and result objects for the NICE reconstruction adapter.
NiceConfig
class
source
NiceConfig(executable: Optional[str] = None, nice_home: Optional[Path | str] = None, source_revision: Optional[str] = None, vaft_revision: Optional[str] = None, input_snapshot_hash: Optional[str] = None, build_options: Mapping[str, Any] = <factory>, profile_basis: Mapping[str, Any] = <factory>, solver_tolerances: Mapping[str, Any] = <factory>, initialization_method: str = 'from_scratch', workdir: Path | str = PosixPath('.'), parameter_file: Optional[Path | str] = None, env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, arguments: tuple[str, ...] = (), shot: Optional[int] = None, time: Optional[float] = None, time_index: Optional[int] = None, cocos_in: int = 11, cocos_out: int = 11, major_radius: float = 0.4, include_plasma_current: bool = True, include_flux_loops: bool = True, include_bpol_probes: bool = True, include_diamagnetic_flux: bool = False, disabled_channels: tuple[str, ...] = (), diagnostic_source: str = 'magnetics', correct_active_response: bool = False, flux_loop_input_sign: float = -1.0, default_bpol_uncertainty: float = 0.001, default_flux_uncertainty: float = 0.0001, default_ip_uncertainty: float = 1000.0, default_diamagnetic_uncertainty: float = 0.0001, passive_currents: Optional[tuple[float, ...]] = None, passive_current_mode: str = 'diagnostic_subtraction', backend: Optional['ExecutionBackend'] = None) -> None
Configuration for one standalone NICE magnetic reconstruction.
Also exported as vaft.code.NiceConfig, vaft.code.nice.NiceConfig.
35 fields
executable: Optional[str]nice_home: Optional[Path | str]source_revision: Optional[str]vaft_revision: Optional[str]input_snapshot_hash: Optional[str]build_options: Mapping[str, Any]profile_basis: Mapping[str, Any]solver_tolerances: Mapping[str, Any]initialization_method: strworkdir: Path | strparameter_file: Optional[Path | str]env: Mapping[str, str]timeout: Optional[float]arguments: tuple[str, ...]shot: Optional[int]time: Optional[float]time_index: Optional[int]cocos_in: intcocos_out: intmajor_radius: floatinclude_plasma_current: boolinclude_flux_loops: boolinclude_bpol_probes: boolinclude_diamagnetic_flux: booldisabled_channels: tuple[str, ...]diagnostic_source: strcorrect_active_response: boolflux_loop_input_sign: floatdefault_bpol_uncertainty: floatdefault_flux_uncertainty: floatdefault_ip_uncertainty: floatdefault_diamagnetic_uncertainty: floatpassive_currents: Optional[tuple[float, ...]]passive_current_mode: strbackend: Optional['ExecutionBackend']
NiceDiagnostic
class
source
NiceDiagnostic(family: str, ods_path: str, identifier: str, geometry: Mapping[str, Any], value: float, uncertainty: float, normalization: float, enabled: bool, reason: str = '', original_value: Optional[float] = None, conditioned_value: Optional[float] = None, weight: float = 1.0, passive_response: float = 0.0, active_response_correction: float = 0.0, original_uncertainty: Optional[float] = None, original_enabled: Optional[bool] = None) -> None
Also exported as vaft.code.NiceDiagnostic, vaft.code.nice.NiceDiagnostic.
16 fields
family: strods_path: stridentifier: strgeometry: Mapping[str, Any]value: floatuncertainty: floatnormalization: floatenabled: boolreason: stroriginal_value: Optional[float]conditioned_value: Optional[float]weight: floatpassive_response: floatactive_response_correction: floatoriginal_uncertainty: Optional[float]original_enabled: Optional[bool]
NiceInputs
class
source
NiceInputs(workdir: Path, input_dir: Path, output_dir: Path, shot: int, time: float, geometry: Mapping[str, Any], diagnostics: tuple[NiceDiagnostic, ...], passive_currents: tuple[float, ...], manifest: Mapping[str, Any], manifest_file: Path, files: tuple[Path, ...] = (), ods: Any = None) -> None
Also exported as vaft.code.NiceInputs, vaft.code.nice.NiceInputs.
12 fields
workdir: Pathinput_dir: Pathoutput_dir: Pathshot: inttime: floatgeometry: Mapping[str, Any]diagnostics: tuple[NiceDiagnostic, ...]passive_currents: tuple[float, ...]manifest: Mapping[str, Any]manifest_file: Pathfiles: tuple[Path, ...]ods: Any
NiceResult
class
source
NiceResult(returncode: Optional[int], workdir: Path, process_succeeded: bool = False, converged: Optional[bool] = None, scientifically_usable: Optional[bool] = None, termination_reason: str = '', nonlinear_iterations: Optional[int] = None, objective: Mapping[str, Any] = <factory>, iteration_history: tuple[Mapping[str, Any], ...] = (), diagnostic_residuals: tuple[Mapping[str, Any], ...] = (), output_files: tuple[Path, ...] = (), logs: tuple[Path, ...] = (), stdout: str = '', stderr: str = '', parsing_errors: tuple[str, ...] = (), provenance: Mapping[str, Any] = <factory>, ods: Any = None, runtime_status: str = 'completed', elapsed_s: Optional[float] = None) -> None
Also exported as vaft.code.NiceResult, vaft.code.nice.NiceResult.
19 fields · 1 members
returncode: Optional[int]workdir: Pathprocess_succeeded: boolconverged: Optional[bool]scientifically_usable: Optional[bool]termination_reason: strnonlinear_iterations: Optional[int]objective: Mapping[str, Any]iteration_history: tuple[Mapping[str, Any], ...]diagnostic_residuals: tuple[Mapping[str, Any], ...]output_files: tuple[Path, ...]logs: tuple[Path, ...]stdout: strstderr: strparsing_errors: tuple[str, ...]provenance: Mapping[str, Any]ods: Anyruntime_status: strelapsed_s: Optional[float]okproperty source
vest_reference_parameter_file
function
source
vest_reference_parameter_file() -> Path
Packaged, revision-pinned VEST magnetic-reconstruction parameters.
Also exported as vaft.code.nice.vest_reference_parameter_file, vaft.code.vest_reference_parameter_file.
vaft.code.nice.diagnostics
Magnetic diagnostic extraction for NICE, independent of EFIT k-files.
diagnostics_from_ods
function
source
diagnostics_from_ods(ods: Any, time: float, config: NiceConfig) -> tuple[NiceDiagnostic, ...]
Return a complete, provenance-ready channel table for one slice.
Also exported as vaft.code.diagnostics_from_ods, vaft.code.nice.diagnostics_from_ods.
vaft.code.nice.geometry
Canonical ODS to NICE-native geometry conversion.
geometry_hash
function
source
geometry_hash(geometry: dict[str, Any]) -> str
Also exported as vaft.code.nice.geometry_hash.
nice_geometry_from_ods
function
source
nice_geometry_from_ods(ods: Any) -> dict[str, Any]
Map wall, PF-active and PF-passive directly from their canonical IDSs.
Also exported as vaft.code.nice.nice_geometry_from_ods, vaft.code.nice_geometry_from_ods.
validate_contour
function
source
validate_contour(r, z, geometry)
Reject intersections and reversed VacTH integration orientation.
vaft.code.nice.inputs
Prepare a standalone NICE native-input directory from a canonical ODS.
prepare_nice_inputs
function
source
prepare_nice_inputs(ods: Any, config: NiceConfig) -> NiceInputs
Write deterministic NICE text inputs without importing or executing NICE.
Also exported as vaft.code.nice.prepare_nice_inputs, vaft.code.prepare_nice_inputs.
vaft.code.nice.outputs
Collect NICE-native output and convert it to a canonical equilibrium ODS.
collect_nice_outputs
function
source
collect_nice_outputs(workdir: str | Path, config: Optional[NiceConfig] = None) -> NiceResult
Rebuild a NICE result from disk without importing or executing NICE.
Also exported as vaft.code.collect_nice_outputs, vaft.code.nice.collect_nice_outputs.
vaft.code.nice.response
Prescribed active-field correction for the pinned NICE filament model.
active_response
function
source
active_response(ods, geometry, diagnostics, time)
vaft.code.nice.runner
Standalone NICE process execution with reproducibility metadata.
NICE_HOME_ENV
data
NICE_HOME_ENV = 'NICEHOME'
resolve_nice_executable
function
source
resolve_nice_executable(config: NiceConfig) -> Path
Also exported as vaft.code.nice.resolve_nice_executable.
run_nice
function
source
run_nice(inputs: NiceInputs, config: NiceConfig) -> NiceResult
Execute NICE and then collect its native outputs.
Also exported as vaft.code.nice.run_nice, vaft.code.run_nice.
vaft.code.nice.study
Whole-window and matched-slice analysis helpers for NICE/EFIT studies.
assert_same_physical_channels
function
source
assert_same_physical_channels(left: Iterable[NiceDiagnostic], right: Iterable[NiceDiagnostic]) -> None
Also exported as vaft.code.nice.assert_same_physical_channels.
compare_diagnostic_residuals
function
source
compare_diagnostic_residuals(nice_residuals: Iterable[dict[str, Any]], efit_residuals: Iterable[dict[str, Any]]) -> list[dict[str, Any]]
Match residuals by physical channel, never by solver array position.
Also exported as vaft.code.nice.compare_diagnostic_residuals.
compare_equilibria
function
source
compare_equilibria(nice_ods: Any, efit_ods: Any, time: float) -> dict[str, Any]
Compare common physical quantities on the closest matched slice.
Also exported as vaft.code.nice.compare_equilibria.
constraint_family_configs
function
source
constraint_family_configs(base: NiceConfig) -> dict[str, NiceConfig]
The issue #666 family-addition cases (diamagnetics is provenance-only).
Also exported as vaft.code.nice.constraint_family_configs.
lcfs_rms_displacement
function
source
lcfs_rms_displacement(left_r, left_z, right_r, right_z) -> float
Orientation/starting-index invariant RMS LCFS point displacement [m].
Also exported as vaft.code.nice.lcfs_rms_displacement.
physical_channel_signature
function
source
physical_channel_signature(channels: Iterable[NiceDiagnostic]) -> tuple[tuple[Any, ...], ...]
Stable identity of a physical diagnostic set, excluding values/weights.
Also exported as vaft.code.nice.physical_channel_signature.
run_nice_window
function
source
run_nice_window(ods: Any, times: Sequence[float], config: NiceConfig) -> tuple[NiceResult, ...]
Run every requested time and retain explicit failure records.
Also exported as vaft.code.nice.run_nice_window.
summarize_window
function
source
summarize_window(times: Sequence[float], results: Sequence[NiceResult]) -> dict[str, Any]
Also exported as vaft.code.nice.summarize_window.
write_study_report
function
source
write_study_report(path: str | Path, payload: dict[str, Any]) -> Path
Write a deterministic, machine-readable report used by plotting/notebooks.
Also exported as vaft.code.nice.write_study_report.
write_window_report
function
source
write_window_report(output_dir: str | Path, shot: int, times: Sequence[float], results: Sequence[NiceResult], efit_ods: Any | None = None) -> dict[str, Path]
Generate the compact per-shot JSON summary and NICE/EFIT trace overlay.
Also exported as vaft.code.nice.write_window_report.
vaft.code.nice.validate_reference
Reproduce issue #666 against local clones: python -m vaft.code.nice.validate_reference.
vaft.code.nubeam
NUBEAM neutral-beam Monte Carlo adapter.
build_plasma_state
function
source
build_plasma_state(spec: PlasmaStateSpec, workdir: str | Path, config: Optional[NUBEAMConfig] = None) -> Path
Write spec into workdir as a Plasma State with vaft_plasma_state.
input_plasma_state_name
function
source
input_plasma_state_name(text: str) -> str
input_plasma_state from a &NUBEAM_FILES namelist.
NUBEAM_NAMELISTS
data
NUBEAM_NAMELISTS = ('nubeam_init.dat', 'nubeam_init_files.dat', 'nubeam_step.dat', 'nubeam_step_files.dat')
run_nubeam_ods
function
source
run_nubeam_ods(ods: Any, *, time: float, case_dir: str | Path, workdir: str | Path, beam_power_w: Sequence[float], beam_energy_kev: Sequence[float], config: Optional[NUBEAMConfig] = None, **spec_options: Any) -> NUBEAMResult
Run NUBEAM at one time from equilibrium and core_profiles.
stage_nubeam_namelists
function
source
stage_nubeam_namelists(case_dir: str | Path, *, workdir: str | Path, config: Optional[NUBEAMConfig] = None) -> StagedNamelists
Copy the NUBEAM namelists and one mdescr / sconfig pair into workdir.
StagedNamelists
class
source
StagedNamelists(workdir: Path, files: tuple[Path, ...], mdescr: Path, sconfig: Path, state_name: str) -> None
A run directory holding NUBEAM’s namelists and the machine description.
5 fields
workdir: Pathfiles: tuple[Path, ...]mdescr: Pathsconfig: Pathstate_name: str
vaft.code.nubeam.config
Configuration and the fixed-width path budget for the NUBEAM adapter.
NUBEAM_GENERATOR_EXECUTABLE
data
NUBEAM_GENERATOR_EXECUTABLE = <pathlib.PosixPath>
Also exported as vaft.code.nubeam.NUBEAM_GENERATOR_EXECUTABLE.
NUBEAM_HOME_ENV
data
NUBEAM_HOME_ENV = 'NUBEAMHOME'
Also exported as vaft.code.nubeam.NUBEAM_HOME_ENV.
NUBEAM_HOME_EXECUTABLE
data
NUBEAM_HOME_EXECUTABLE = <pathlib.PosixPath>
Also exported as vaft.code.nubeam.NUBEAM_HOME_EXECUTABLE.
NUBEAM_LONGEST_OUTPUT_SUFFIX
data
NUBEAM_LONGEST_OUTPUT_SUFFIX = '_debug_nbi_ptcl_state_cpu0_1.cdf'
Also exported as vaft.code.nubeam.NUBEAM_LONGEST_OUTPUT_SUFFIX.
NUBEAM_PATH_BUFFER_CHARS
data
NUBEAM_PATH_BUFFER_CHARS = 140
Also exported as vaft.code.nubeam.NUBEAM_PATH_BUFFER_CHARS.
NUBEAM_UPDATE_STATE_EXECUTABLE
data
NUBEAM_UPDATE_STATE_EXECUTABLE = <pathlib.PosixPath>
Also exported as vaft.code.nubeam.NUBEAM_UPDATE_STATE_EXECUTABLE.
NUBEAMConfig
class
source
NUBEAMConfig(executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), args: Sequence[str] = (), env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, backend: Optional['ExecutionBackend'] = None, runid: str = 'NUBEAM', repeat_count: str = '1x0.001', postproc: str = 'summary_test', frantic: bool = True, frantic_zones: int = 50, preact_dir: Optional[Path] = None, adas_dir: Optional[Path] = None, generator_executable: Optional[str] = None, update_state_executable: Optional[str] = None, nptcls: Optional[int] = None, path_buffer_chars: int = 140) -> None
Runtime configuration for a NUBEAM run.
Also exported as vaft.code.NUBEAMConfig, vaft.code.nubeam.NUBEAMConfig.
17 fields · 1 members
executable: Optional[str]workdir: Path | strargs: Sequence[str]env: Mapping[str, str]timeout: Optional[float]backend: Optional['ExecutionBackend']runid: strrepeat_count: strpostproc: strfrantic: boolfrantic_zones: intpreact_dir: Optional[Path]adas_dir: Optional[Path]generator_executable: Optional[str]update_state_executable: Optional[str]nptcls: Optional[int]path_buffer_chars: intworkdir_budgetproperty — Longest permissible work-directory path for this configuration. source
workdir_budget
function
source
workdir_budget(runid: str, *, buffer_chars: int = 140) -> int
Longest work-directory path NUBEAM can be handed for this run id.
Also exported as vaft.code.nubeam.workdir_budget.
vaft.code.nubeam.inputs
Staging of a NUBEAM run directory, and the inputf rewrite.
check_workdir_length
function
source
check_workdir_length(workdir: Path, config: NUBEAMConfig, runid: Optional[str] = None) -> None
Refuse a work directory NUBEAM would silently truncate.
Also exported as vaft.code.nubeam.check_workdir_length.
inputf_runid
function
source
inputf_runid(text: str) -> str
Run identifier declared by inputf.
Also exported as vaft.code.nubeam.inputf_runid.
inputf_state_filename
function
source
inputf_state_filename(text: str) -> str
Name of the Plasma State the case’s inputf asks for.
Also exported as vaft.code.nubeam.inputf_state_filename.
NUBEAMCase
class
source
NUBEAMCase(input_dir: Path, gfile: Path) -> None
A NUBEAM case: a directory of inputs and the equilibrium to run it on.
Also exported as vaft.code.nubeam.NUBEAMCase.
2 fields
input_dir: Pathgfile: Path
NUBEAMInputError
class
source
Raised when a NUBEAM run cannot be staged from the given inputs.
Also exported as vaft.code.nubeam.NUBEAMInputError.
NUBEAMInputs
class
source
NUBEAMInputs(workdir: Path, files: tuple[Path, ...] = (), ods: Any = None, inputf: Optional[Path] = None, gfile: Optional[Path] = None, plasma_state: Optional[Path] = None, runid: str = 'NUBEAM', manifests: tuple[Path, ...] = <factory>) -> None
A staged NUBEAM run directory.
Also exported as vaft.code.NUBEAMInputs, vaft.code.nubeam.NUBEAMInputs.
8 fields
workdir: Pathfiles: tuple[Path, ...]ods: Anyinputf: Optional[Path]gfile: Optional[Path]plasma_state: Optional[Path]runid: strmanifests: tuple[Path, ...]
packaged_vest_case
function
source
packaged_vest_case() -> NUBEAMCase
Return the VEST reference case stored in the repository.
Also exported as vaft.code.nubeam.packaged_vest_case.
PACKAGED_VEST_CASE_DIR
data
PACKAGED_VEST_CASE_DIR = 'nubeam/vest_case'
Also exported as vaft.code.nubeam.PACKAGED_VEST_CASE_DIR.
PACKAGED_VEST_CASE_GFILE
data
PACKAGED_VEST_CASE_GFILE = 'g020000.015100'
Also exported as vaft.code.nubeam.PACKAGED_VEST_CASE_GFILE.
prepare_nubeam_inputs
function
source
prepare_nubeam_inputs(input_dir: str | Path, *, gfile: str | Path, workdir: str | Path, config: Optional[NUBEAMConfig] = None) -> NUBEAMInputs
Stage a NUBEAM run directory from a case directory and an equilibrium.
Also exported as vaft.code.nubeam.prepare_nubeam_inputs, vaft.code.prepare_nubeam_inputs.
rewrite_inputf_equilibrium
function
source
rewrite_inputf_equilibrium(text: str, gfile_name: str) -> str
Return text with the inputf G-EQDSK line pointing at gfile_name.
Also exported as vaft.code.nubeam.rewrite_inputf_equilibrium.
vaft.code.nubeam.outputs
Native NUBEAM output containers and directory collection.
collect_nubeam_outputs
function
source
collect_nubeam_outputs(workdir: str | Path, config: Optional[NUBEAMConfig] = None, *, returncode: Optional[int] = None) -> NUBEAMResult
Read a NUBEAM run directory without re-running anything.
Also exported as vaft.code.collect_nubeam_outputs, vaft.code.nubeam.collect_nubeam_outputs.
LOST_PARTICLE_FIELDS
data
LOST_PARTICLE_FIELDS = ('time', 'beam', 'efrac', 'ptcl', 'rlost', 'zlost', 'energy', 'vfrac', 'lstype', 'spec')
Also exported as vaft.code.nubeam.LOST_PARTICLE_FIELDS.
NUBEAMBirthMarkers
class
source
NUBEAMBirthMarkers(path: Path, species: str, count: int, columns: Mapping[str, Any] = <factory>, step: Optional[int] = None) -> None
Deposition markers from <runid>_birth_cpu<n>_<k>.cdf_<step>.
Also exported as vaft.code.nubeam.NUBEAMBirthMarkers.
5 fields
path: Pathspecies: strcount: intcolumns: Mapping[str, Any]step: Optional[int]
NUBEAMFluxSurfaceAverages
class
source
NUBEAMFluxSurfaceAverages(f: Any, gm1: Any, gm5: Any) -> None
Flux-surface averages of the equilibrium NUBEAM ran on.
Also exported as vaft.code.nubeam.NUBEAMFluxSurfaceAverages.
3 fields · 1 members
f: Anygm1: Anygm5: Anyat_zone_centresmethod — The three averages midway between boundaries, where profiles live. source
NUBEAMLostParticles
class
source
NUBEAMLostParticles(path: Path, count: int, columns: Mapping[str, Any] = <factory>) -> None
Fast ions NUBEAM stopped following, one entry per lost marker.
Also exported as vaft.code.nubeam.NUBEAMLostParticles.
NUBEAMOutputs
class
source
NUBEAMOutputs(workdir: Path, runid: Optional[str] = None, state_changes: Optional[Path] = None, plasma_state: Optional[Path] = None, profiles: Mapping[str, Any] = <factory>, scalars: Mapping[str, Any] = <factory>, birth: Optional[NUBEAMBirthMarkers] = None, birth_steps: tuple[NUBEAMBirthMarkers, ...] = (), lost: Optional[NUBEAMLostParticles] = None, grid: Optional[NUBEAMRadialGrid] = None, flux_surface: Optional[NUBEAMFluxSurfaceAverages] = None, beam_conditions: Mapping[str, Any] = <factory>, power_balance: tuple[NUBEAMPowerBalance, ...] = (), interpolation_warnings: int = 0) -> None
Everything a completed NUBEAM run produced, in NUBEAM’s own terms.
Also exported as vaft.code.nubeam.NUBEAMOutputs.
14 fields · 1 members
workdir: Pathrunid: Optional[str]state_changes: Optional[Path]plasma_state: Optional[Path]profiles: Mapping[str, Any]scalars: Mapping[str, Any]birth: Optional[NUBEAMBirthMarkers]birth_steps: tuple[NUBEAMBirthMarkers, ...]lost: Optional[NUBEAMLostParticles]grid: Optional[NUBEAMRadialGrid]flux_surface: Optional[NUBEAMFluxSurfaceAverages]beam_conditions: Mapping[str, Any]power_balance: tuple[NUBEAMPowerBalance, ...]interpolation_warnings: intdescribemethod — Documented meaning of a profile, or a note that it is undocumented. source
NUBEAMPowerBalance
class
source
NUBEAMPowerBalance(species: str, entries: Mapping[str, float] = <factory>, residual: Optional[float] = None) -> None
NUBEAM’s own end-of-step power accounting for one fast ion species.
Also exported as vaft.code.nubeam.NUBEAMPowerBalance.
3 fields · 3 members
species: strentries: Mapping[str, float]residual: Optional[float]injectedproperty — Injected power [W], the quantity everything else is a fraction of. sourcesinksmethod — Loss and heating channels, as positive watts. sourcefractionsmethod — Each sink as a fraction of injected power, or{}if unknown. source
NUBEAMRadialGrid
class
source
NUBEAMRadialGrid(rho: Any, volume: Any, area: Any) -> None
The radial grid NUBEAM’s profiles live on, and the zone measures.
Also exported as vaft.code.nubeam.NUBEAMRadialGrid.
3 fields · 3 members
NUBEAMResult
class
source
NUBEAMResult(returncode: Optional[int], workdir: Path, stdout: str = '', stderr: str = '', logs: tuple[Path, ...] = (), outputs: Mapping[str, tuple[Path, ...]] = <factory>, parsed: Any = None, runtime_status: str = 'completed', elapsed_s: Optional[float] = None, outputs_native: Optional[NUBEAMOutputs] = None) -> None
Result bundle for a NUBEAM run.
Also exported as vaft.code.NUBEAMResult, vaft.code.nubeam.NUBEAMResult.
10 fields · 1 members
returncode: Optional[int]workdir: Pathstdout: strstderr: strlogs: tuple[Path, ...]outputs: Mapping[str, tuple[Path, ...]]parsed: Anyruntime_status: strelapsed_s: Optional[float]outputs_native: Optional[NUBEAMOutputs]okproperty source
parse_power_balance
function
source
parse_power_balance(text: str) -> tuple[NUBEAMPowerBalance, ...]
Read the power-accounting blocks out of a NUBEAM step log.
Also exported as vaft.code.nubeam.parse_power_balance.
PROFILE_DESCRIPTIONS
data
PROFILE_DESCRIPTIONS = <builtins.dict>
vaft.code.nubeam.plasma_state
Build NUBEAM’s input Plasma State with VAFT’s own generator.
check_spec_against_namelists
function
source
check_spec_against_namelists(spec: PlasmaStateSpec) -> None
Refuse a spec whose counts disagree with its mdescr / sconfig files.
count_beams
function
source
count_beams(path: str | Path) -> int
Number of beam sources an mdescr namelist declares (nbi_src_name).
GENERATOR_MAX_BEAMS
data
GENERATOR_MAX_BEAMS = 32
GENERATOR_MAX_GAS_SOURCES
data
GENERATOR_MAX_GAS_SOURCES = 16
GENERATOR_MAX_IONS
data
GENERATOR_MAX_IONS = 20
GENERATOR_MAX_POINTS
data
GENERATOR_MAX_POINTS = 2001
ion_densities_from_zeff
function
source
ion_densities_from_zeff(ne: Any, zeff: Any, charges: Sequence[int]) -> tuple[np.ndarray, ...]
Main-ion and impurity densities from ne and Zeff, for two species.
Also exported as vaft.code.nubeam.ion_densities_from_zeff.
legacy_case_spec
function
source
legacy_case_spec(workdir: str | Path, *, gfile: str | Path, inputf: str = 'inputf') -> PlasmaStateSpec
The spec for a staged legacy case directory (inputf + profiles).
Also exported as vaft.code.nubeam.legacy_case_spec.
LegacyProfiles
class
source
LegacyProfiles(profiles: PlasmaStateProfiles, beam_power_w: tuple[float, ...], beam_energy_kev: tuple[float, ...], edge_neutral_density: float, neutral_energy_kev: tuple[float, ...]) -> None
Contents of a legacy profiles file, as far as VAFT reads it.
5 fields
profiles: PlasmaStateProfilesbeam_power_w: tuple[float, ...]beam_energy_kev: tuple[float, ...]edge_neutral_density: floatneutral_energy_kev: tuple[float, ...]
PLASMA_STATE_NAMELIST
data
PLASMA_STATE_NAMELIST = 'vaft_plasma_state.nml'
Also exported as vaft.code.nubeam.PLASMA_STATE_NAMELIST.
PlasmaStateInputError
class
source
Raised when a Plasma State cannot be specified from the given data.
Also exported as vaft.code.nubeam.PlasmaStateInputError.
PlasmaStateProfiles
class
source
PlasmaStateProfiles(x: np.ndarray, ne: np.ndarray, te_kev: np.ndarray, ti_kev: np.ndarray, zeff: np.ndarray, ion_densities: tuple[np.ndarray, ...], coordinate: str = 'rho_tor', omegat: Optional[np.ndarray] = None) -> None
Kinetic profiles tabulated on one radial abscissa.
Also exported as vaft.code.nubeam.PlasmaStateProfiles.
8 fields
x: np.ndarrayne: np.ndarrayte_kev: np.ndarrayti_kev: np.ndarrayzeff: np.ndarrayion_densities: tuple[np.ndarray, ...]coordinate: stromegat: Optional[np.ndarray]
PlasmaStateSpec
class
source
PlasmaStateSpec(mdescr: Path, sconfig: Path, gfile: Path, profiles: PlasmaStateProfiles, beam_power_w: tuple[float, ...], beam_energy_kev: tuple[float, ...], t0: float = 0.0, t1: float = 0.0, runid: str = 'NUBEAM', output_name: str = 'NUBEAM.cdf', edge_neutral_density: float = 0.0, neutral_energy_kev: tuple[float, ...] = (), recycling: tuple[int, ...] = (), nrho: int = 101, nth_eq: int = 101, bdy_crat: float = 0.08, nmom: int = 64, limiter_from_geqdsk: bool = True, label: str = 'vaft_plasma_state') -> None
Everything the generator needs for one Plasma State.
Also exported as vaft.code.nubeam.PlasmaStateSpec.
19 fields
mdescr: Pathsconfig: Pathgfile: Pathprofiles: PlasmaStateProfilesbeam_power_w: tuple[float, ...]beam_energy_kev: tuple[float, ...]t0: floatt1: floatrunid: stroutput_name: stredge_neutral_density: floatneutral_energy_kev: tuple[float, ...]recycling: tuple[int, ...]nrho: intnth_eq: intbdy_crat: floatnmom: intlimiter_from_geqdsk: boollabel: str
PROFILE_COORDINATES
data
PROFILE_COORDINATES = ('rho_tor', 'sqrt_psi_n')
profiles_from_core_profiles
function
source
profiles_from_core_profiles(ods: Any, *, time: float, equilibrium_index: int, ion_charges: Sequence[int], ion_masses: Sequence[int], time_tolerance: float = 0.001, zeff: Optional[float] = None, n_points: int = 101, minimum_density: Optional[float] = None, minimum_temperature_ev: Optional[float] = None) -> tuple[PlasmaStateProfiles, dict[str, Any]]
Kinetic profiles from core_profiles on sqrt(psi_N), plus provenance.
Also exported as vaft.code.nubeam.profiles_from_core_profiles.
read_legacy_profiles
function
source
read_legacy_profiles(path: str | Path) -> LegacyProfiles
Read the profiles file of a legacy NUBEAM case directory.
Also exported as vaft.code.nubeam.read_legacy_profiles.
read_shot_configuration
function
source
read_shot_configuration(path: str | Path) -> ShotConfiguration
Thermal ion species and neutral gas sources declared by an sconfig file.
Also exported as vaft.code.nubeam.read_shot_configuration.
render_plasma_state_namelist
function
source
render_plasma_state_namelist(spec: PlasmaStateSpec, workdir: str | Path) -> str
The &vaft_plasma_state namelist for spec, run from workdir.
Also exported as vaft.code.nubeam.render_plasma_state_namelist.
ShotConfiguration
class
source
ShotConfiguration(ion_charge_numbers: tuple[int, ...], ion_mass_numbers: tuple[int, ...], gas_sources: tuple[str, ...]) -> None
The parts of an sconfig namelist the profiles must line up with.
3 fields
ion_charge_numbers: tuple[int, ...]ion_mass_numbers: tuple[int, ...]gas_sources: tuple[str, ...]
spec_from_ods
function
source
spec_from_ods(ods: Any, *, time: float, workdir: str | Path, mdescr: str | Path, sconfig: str | Path, beam_power_w: Sequence[float], beam_energy_kev: Sequence[float], time_tolerance: float = 0.001, duration: float = 0.0, zeff: Optional[float] = None, minimum_density: Optional[float] = None, minimum_temperature_ev: Optional[float] = None, edge_neutral_density: float = 0.0, neutral_energy_kev: Optional[Sequence[float]] = None, runid: str = 'NUBEAM', output_name: str = 'NUBEAM.cdf', **options: Any) -> tuple[PlasmaStateSpec, dict[str, Any]]
Spec for one time from equilibrium and core_profiles in ods.
Also exported as vaft.code.nubeam.spec_from_ods.
vaft.code.nubeam.runner
Executable discovery and process execution for NUBEAM.
find_nubeam_executable
function
source
find_nubeam_executable(config: Optional[NUBEAMConfig] = None) -> Optional[Path]
Resolve nubeam_comp_exec from explicit config or $NUBEAMHOME.
Also exported as vaft.code.find_nubeam_executable, vaft.code.nubeam.find_nubeam_executable.
find_plasma_state_generator
function
source
find_plasma_state_generator(config: Optional[NUBEAMConfig] = None) -> Optional[Path]
Resolve the Plasma State generator vaft_plasma_state.
Also exported as vaft.code.nubeam.find_plasma_state_generator.
find_update_state_executable
function
source
find_update_state_executable(config: Optional[NUBEAMConfig] = None) -> Optional[Path]
Resolve update_state, which merges NUBEAM’s changes into a state.
Also exported as vaft.code.nubeam.find_update_state_executable.
generate_plasma_state
function
source
generate_plasma_state(inputs: NUBEAMInputs, config: Optional[NUBEAMConfig] = None) -> Path
Build the Plasma State NUBEAM will read, for a staged legacy case.
Also exported as vaft.code.nubeam.generate_plasma_state.
nubeam_home
function
source
nubeam_home() -> Optional[Path]
The configured NUBEAM installation root, if any.
NUBEAMExecutionError
class
source
Raised when a NUBEAM stage does not complete normally.
Also exported as vaft.code.nubeam.NUBEAMExecutionError.
run_nubeam
function
source
run_nubeam(inputs: NUBEAMInputs, config: Optional[NUBEAMConfig] = None) -> NUBEAMResult
Run NUBEAM INIT then STEP against a staged Plasma State.
Also exported as vaft.code.nubeam.run_nubeam, vaft.code.run_nubeam.
run_nubeam_case
function
source
run_nubeam_case(input_dir: str | Path, *, gfile: str | Path, workdir: str | Path, config: Optional[NUBEAMConfig] = None) -> NUBEAMResult
Stage a case, build its Plasma State, and run NUBEAM over it.
Also exported as vaft.code.nubeam.run_nubeam_case, vaft.code.run_nubeam_case.
vaft.code.pentrc.outputs
Compatibility path for vaft.code.gpec._pentrc_output (#1883).
energy_profile
function
source
energy_profile(output: PentrcOutput, method: str, grid: str = 'lsode') -> tuple[np.ndarray, np.ndarray]
Radially accumulated perturbed potential energy.
Also exported as vaft.code.gpec.energy_profile, vaft.code.pentrc.energy_profile.
PentrcFormatError
class
source
The file is not a PENTRC output, or does not carry what was asked of it.
Also exported as vaft.code.PentrcFormatError, vaft.code.gpec.PentrcFormatError, vaft.code.pentrc.PentrcFormatError.
PentrcOutput
class
source
PentrcOutput(path: Path, n_tor: int, attrs: dict, _dataset: Any = None) -> None
One pentrc_output_n*.nc, read lazily and converted nowhere.
Also exported as vaft.code.PentrcOutput, vaft.code.gpec.PentrcOutput, vaft.code.pentrc.PentrcOutput.
3 fields · 9 members
path: Pathn_tor: intattrs: dictclosemethod — Release the underlying dataset. sourcedatasetproperty — The open xarray dataset. sourceavailablemethod — Every(method, grid)pair this run actually wrote, sorted. sourcepsi_normmethod — The radial grid one calculation was written on [-]. sourceprofile_psi_normmethod — Thepsi_ngrid the equilibrium and kinetic profiles sit on [-]. sourceprofilemethod — One equilibrium or kinetic profile, in PENTRC’s own units. sourcecomplex_quantitymethod — One(psi, ell)complex array, unsummed. sourcelong_namemethod — Thelong_namePENTRC gave one variable, or"". sourceellmethod — The integer bounce harmonics the run resolved [-]. source
PROFILE_VARIABLES
data
PROFILE_VARIABLES = <builtins.mappingproxy>
Also exported as vaft.code.gpec.PROFILE_VARIABLES, vaft.code.pentrc.PROFILE_VARIABLES.
read_pentrc_output
function
source
read_pentrc_output(path: str | Path) -> PentrcOutput
Open one PENTRC output file.
Also exported as vaft.code.gpec.read_pentrc_output, vaft.code.pentrc.read_pentrc_output, vaft.code.read_pentrc_output.
TORQUE_GRIDS
data
TORQUE_GRIDS = <builtins.mappingproxy>
Also exported as vaft.code.gpec.TORQUE_GRIDS, vaft.code.pentrc.TORQUE_GRIDS.
TORQUE_LONG_NAME
data
TORQUE_LONG_NAME = 'Integrated Toroidal Torque'
Also exported as vaft.code.gpec.TORQUE_LONG_NAME, vaft.code.pentrc.TORQUE_LONG_NAME.
TORQUE_METHODS
data
TORQUE_METHODS = <builtins.mappingproxy>
Also exported as vaft.code.gpec.TORQUE_METHODS, vaft.code.pentrc.TORQUE_METHODS.
torque_profile
function
source
torque_profile(output: PentrcOutput, method: str, grid: str = 'lsode') -> tuple[np.ndarray, np.ndarray]
Radially accumulated NTV torque, summed over the bounce harmonics.
Also exported as vaft.code.gpec.torque_profile, vaft.code.pentrc.torque_profile.
TORQUE_QUANTITIES
data
TORQUE_QUANTITIES = <builtins.mappingproxy>
Also exported as vaft.code.gpec.TORQUE_QUANTITIES, vaft.code.pentrc.TORQUE_QUANTITIES.
vaft.code.remote
Run external codes on a remote Slurm cluster over ssh.
FETCH_ALL
data
FETCH_ALL = 'all'
FETCH_NONE
data
FETCH_NONE = 'none'
RemoteHost
class
source
RemoteHost(host: str, work_root: str, user: Optional[str] = None, port: Optional[int] = None, identity_file: Optional[str] = None, ssh_options: tuple[str, ...] = (), path_maps: tuple[tuple[str, str], ...] = (), setup_lines: tuple[str, ...] = (), fetch: Union[str, tuple[str, ...]] = 'all', keep_remote: bool = True, rsync_options: tuple[str, ...] = (), ssh_executable: str = 'ssh', rsync_executable: str = 'rsync') -> None
An ssh-reachable host that runs Slurm, and how its paths line up with ours.
Also exported as vaft.code.RemoteHost.
13 fields · 10 members
host: strwork_root: struser: Optional[str]port: Optional[int]identity_file: Optional[str]ssh_options: tuple[str, ...]path_maps: tuple[tuple[str, str], ...]setup_lines: tuple[str, ...]fetch: Union[str, tuple[str, ...]]keep_remote: boolrsync_options: tuple[str, ...]ssh_executable: strrsync_executable: strtargetproperty —user@hostor justhost: the ssh and rsync destination. sourcessh_prefixmethod — The ssh command up to but not including the destination. sourcessh_argvmethod — Full argv to run one shell command on the host. sourcersync_prefixmethod — The rsync command up to but not including the paths. sourceremotemethod —pathas the host sees it; return a destination string for rsync. sourceremote_pathmethod —localunder the first matchingpath_mapspair, elseNone. sourcetranslatemethod — One command argument with any mapped path prefix rewritten. sourcetranslate_valuemethod — One environment value, treating it as a:-separated path list. sourceforwarded_environmentmethod —envwith submitting-machine-only names dropped and paths translated. sourcefrom_environmentclassmethod — Build a host fromVAFT_REMOTE_*variables. source
RemoteSlurmBackend
class
source
RemoteSlurmBackend(host: RemoteHost, *, partition: Optional[str] = None, account: Optional[str] = None, qos: Optional[str] = None, extra_args: Sequence[str] = (), max_wait: Optional[float] = None, poll_interval: float = 10.0, max_poll_interval: float = 60.0, backoff: float = 1.5, keep_scratch: bool = False) -> None
Run each request as a batch job on an ssh-reachable Slurm cluster.
Also exported as vaft.code.RemoteSlurmBackend.
UNFORWARDED_ENVIRONMENT
data
UNFORWARDED_ENVIRONMENT = ('PATH', 'LD_LIBRARY_PATH', 'LD_PRELOAD', 'LD_RUN_PATH', 'LIBRARY_PATH', 'DYLD_', 'CPATH', 'C_INCLUDE_PATH', 'CPLUS_I...
vaft.code.resources
In-process memory guard: RSS, the effective budget, and a clean stop before OOM.
cgroup_usage_mb
function
source
cgroup_usage_mb(directory: PathLike, kind: str = 'v2') -> Optional[float]
Non-reclaimable memory in use by a whole cgroup, in MiB (None when memory.stat cannot be read).
memory_budget
function
source
memory_budget(environ: Optional[Mapping[str, str]] = None, *, cgroup_root: Optional[PathLike] = None, proc_cgroup: Optional[PathLike] = None, meminfo: Optional[PathLike] = None) -> MemoryBudgetInfo
The effective memory limit of this process, in MiB, and its source.
Also exported as vaft.code.memory_budget.
MEMORY_BUDGET_ENV
data
MEMORY_BUDGET_ENV = 'VAFT_MEMORY_BUDGET_MB'
MEMORY_ENV_VARIABLES
data
MEMORY_ENV_VARIABLES = ('VAFT_MEMORY_BUDGET_MB', 'SLURM_MEM_PER_NODE', 'SLURM_MEM_PER_CPU', 'SLURM_CPUS_ON_NODE')
MemoryBudget
class
source
MemoryBudget(limit_mb: Optional[float] = None, fraction: float = 0.9, *, on_exceed: str = 'raise', interval_s: Optional[float] = None, source: Optional[str] = None, environ: Optional[Mapping[str, str]] = None) -> None
Stop cleanly before the process runs out of memory.
Also exported as vaft.code.MemoryBudget.
6 members
threshold_mbproperty —fraction x limit_mb, orNonewithout a limit. sourcesamplemethod — Read RSS now and fold it intopeak_mb; never raises. sourceusagemethod — The memory in use that the budget is compared against, in MiB (also folds RSS into the peaks). sourcestart_intervalmethod — Start a newinterval_peak_mbwindow; returns the one that ended. sourcecheckmethod — RaiseMemoryBudgetExceededif RSS is above the threshold. sourceas_dictmethod — JSON-ready summary for status records. source
MemoryBudgetExceeded
class
source
MemoryBudgetExceeded(rss_mb: float, threshold_mb: float, limit_mb: float, *, label: Any = None, source: Optional[str] = None, peak_mb: Optional[float] = None) -> None
Memory in use crossed fraction x limit inside a MemoryBudget.
Also exported as vaft.code.MemoryBudgetExceeded.
MemoryBudgetInfo
class
source
MemoryBudgetInfo(limit_mb: Optional[float], source: Optional[str], candidates: Mapping[str, float] = <factory>, usage_cgroup: Optional[str] = None, usage_kind: Optional[str] = None) -> None
The effective memory limit of this process and where it came from.
Also exported as vaft.code.MemoryBudgetInfo.
5 fields · 1 members
limit_mb: Optional[float]source: Optional[str]candidates: Mapping[str, float]usage_cgroup: Optional[str]usage_kind: Optional[str]as_dictmethod — JSON-ready form, for status records. source
peak_rss_mb
function
source
peak_rss_mb() -> Optional[float]
Peak resident set size of this process since it started, in MiB.
Also exported as vaft.code.peak_rss_mb.
rss_mb
function
source
rss_mb() -> Optional[float]
Current resident set size of this process, in MiB.
Also exported as vaft.code.rss_mb.
vaft.code.slurm
Run external codes as Slurm jobs through the shared execution contract (#1017).
exported_environment
function
source
exported_environment(overlay: Mapping[str, str], parent: Optional[Mapping[str, str]] = None) -> dict[str, str]
The part of overlay a job script must export itself.
LIVE_STATES
data
LIVE_STATES = frozenset({'COMPLETING', 'CONFIGURING', 'PENDING', 'REQUEUED', 'REQUEUE_FED', 'REQUEUE_HOLD', 'RESIZING', 'RESV_DEL_H...
SCRATCH_DIRECTORY
data
SCRATCH_DIRECTORY = '.vaft-slurm'
SlurmBackend
class
source
SlurmBackend(*, partition: Optional[str] = None, account: Optional[str] = None, qos: Optional[str] = None, extra_args: Sequence[str] = (), mode: str = 'auto', max_wait: Optional[float] = None, poll_interval: float = 10.0, step_grace: float = 30.0, keep_scratch: bool = False) -> None
Run each request as a Slurm job step (srun) or batch job (sbatch).
Also exported as vaft.code.SlurmBackend.
TIMEOUT_STATES
data
TIMEOUT_STATES = frozenset({'DEADLINE', 'TIMEOUT'})
walltime
function
source
walltime(seconds: float) -> str
--time value for seconds: whole minutes, rounded up, at least 1.
vaft.code.snakemake
init_snakemake_logger
function
source
init_snakemake_logger(snakemake, *, name: str = 'vaft', std_opt: bool = True) -> logging.Logger
Create (or reuse) a logger that writes to both console and the rule’s log file. Parameters ———- snakemake : object Snakemake-injected object available inside script: files. name : str Logger name (default “vaft”). std_opt : bool If True → redirect sys.stdout → logger at INFO level, redirect sys.stderr → logger at ERROR level. If False → leave stdout/stderr unchanged.
Also exported as vaft.code.init_snakemake_logger.
vaft.code.tes
TES forward-equilibrium adapter.
limited_iso_points
function
source
limited_iso_points(ods: Any, time: float, *, time_index: int | None = None) -> tuple[tuple[float, ...], tuple[float, ...]]
Iso-flux points for a plasma resting on the inboard limiter.
vaft.code.tes.config
Configuration, input, and result objects for the TES forward-equilibrium adapter.
TESConfig
class
source
TESConfig(executable: Optional[str] = None, workdir: Path | str = PosixPath('.'), env: Mapping[str, str] = <factory>, timeout: Optional[float] = None, niter: int = 0, restart: Optional[str] = None, emit_namelist: bool = False, shot: Optional[int] = None, time: Optional[float] = None, constraint_source: str = 'equilibrium', time_index: Optional[int] = None, mag_diagnostics: int = 1, mse_diagnostics: int = 0, nr: int = 129, nz: int = 129, rmin: float = 0.07, rmax: float = 0.8, zmin: float = -0.8, zmax: float = 0.8, init_r0: float = 0.3, init_z0: float = 0.0, init_a0: float = 0.2, prof_type: int = 0, ip0_kA: Optional[float] = None, major_r: float = 0.4, bt0: Optional[float] = None, betap: Optional[float] = None, betap_type: int = 0, alpha_p_a: float = 1.5, alpha_p_b: float = 2.0, alpha_f_a: float = 1.5, alpha_f_b: float = 2.0, nflux: int = 50, ntheta: int = 180, gps: float = 1.0, relax_sor: float = 1.1, relax_shp: float = 1.0, tikhonov_factor: float = 1.0, errtol_loop: float = 1e-09, errtol_shape: float = 1e-05, fix_shape: int = 0, flux_linkage: tuple[int, float] = (0, 0.0), nxpt: int = 0, xpr: Sequence[float] = (), xpz: Sequence[float] = (), active: Sequence[int] = (), snowflake: Sequence[int] = (), drsep: tuple[int, float] = (0, 0.0), dsep: tuple[int, float] = (0, 0.0), isor: Sequence[float] = (), isoz: Sequence[float] = (), grpid: Sequence[int] = (), limiter: Optional[tuple[Sequence[float], Sequence[float]]] = None, limiter_grid_margin: float = 1.5, limiter_spacing: Optional[float] = 0.01, coil_model: str = 'elements', shape_coils: tuple[str, ...] = (), eddy: bool = False, backend: Optional['ExecutionBackend'] = None) -> None
Runtime configuration and physics targets for a TES forward solve.
Also exported as vaft.code.TESConfig, vaft.code.tes.TESConfig.
59 fields · 2 members
executable: Optional[str]workdir: Path | strenv: Mapping[str, str]timeout: Optional[float]niter: intrestart: Optional[str]emit_namelist: boolshot: Optional[int]time: Optional[float]constraint_source: strtime_index: Optional[int]mag_diagnostics: intmse_diagnostics: intnr: intnz: intrmin: floatrmax: floatzmin: floatzmax: floatinit_r0: floatinit_z0: floatinit_a0: floatprof_type: intip0_kA: Optional[float]major_r: floatbt0: Optional[float]betap: Optional[float]betap_type: intalpha_p_a: floatalpha_p_b: floatalpha_f_a: floatalpha_f_b: floatnflux: intntheta: intgps: floatrelax_sor: floatrelax_shp: floattikhonov_factor: floaterrtol_loop: floaterrtol_shape: floatfix_shape: intflux_linkage: tuple[int, float]nxpt: intxpr: Sequence[float]xpz: Sequence[float]active: Sequence[int]snowflake: Sequence[int]drsep: tuple[int, float]dsep: tuple[int, float]isor: Sequence[float]isoz: Sequence[float]grpid: Sequence[int]limiter: Optional[tuple[Sequence[float], Sequence[float]]]limiter_grid_margin: floatlimiter_spacing: Optional[float]coil_model: strshape_coils: tuple[str, ...]eddy: boolbackend: Optional['ExecutionBackend']limited_shape_controlclassmethod — Hold a limited boundary by re-fitting the outer PF coils. sourcelegacy_double_nullclassmethod — Approximately the pre-#1469 deck: double-null shape control, legacy coils. source
TESInputs
class
source
TESInputs(workdir: Path, cinput: Path, ods: Any = None, namelist: Optional[Path] = None, files: tuple[Path, ...] = ()) -> None
Prepared input bundle for a TES run.
Also exported as vaft.code.TESInputs, vaft.code.tes.TESInputs.
5 fields
workdir: Pathcinput: Pathods: Anynamelist: Optional[Path]files: tuple[Path, ...]
TESResult
class
source
TESResult(returncode: Optional[int], workdir: Path, gfile: Optional[Path] = None, afile: Optional[Path] = None, result_file: Optional[Path] = None, bndry: Optional[Path] = None, logs: tuple[Path, ...] = (), stdout: str = '', stderr: str = '', geqdsk: tuple[Any, ...] = (), ods: Any = None, scalars: Mapping[str, Any] = <factory>, runtime_status: str = 'completed', elapsed_s: Optional[float] = None) -> None
Collected TES run status, output files, and parsed equilibrium.
Also exported as vaft.code.TESResult, vaft.code.tes.TESResult.
14 fields · 1 members
returncode: Optional[int]workdir: Pathgfile: Optional[Path]afile: Optional[Path]result_file: Optional[Path]bndry: Optional[Path]logs: tuple[Path, ...]stdout: strstderr: strgeqdsk: tuple[Any, ...]ods: Anyscalars: Mapping[str, Any]runtime_status: strelapsed_s: Optional[float]okproperty source
vaft.code.tes.inputs
Build TES input from an ODS.
prepare_tes_inputs
function
source
prepare_tes_inputs(ods: Any, config: TESConfig) -> TESInputs
Build the TES C-format input from an ODS and configuration.
Also exported as vaft.code.prepare_tes_inputs, vaft.code.tes.prepare_tes_inputs.
write_tes_cinput
function
source
write_tes_cinput(path: Path, P: dict) -> Path
Write the strict C-format input consumed directly by rtes.
Also exported as vaft.code.tes.write_tes_cinput.
write_tes_namelist
function
source
write_tes_namelist(path: Path, P: dict) -> Path
Write a human-readable Fortran-style namelist (debugging aid only).
Also exported as vaft.code.tes.write_tes_namelist.
vaft.code.tes.outputs
Collect and parse TES outputs.
collect_tes_outputs
function
source
collect_tes_outputs(workdir: str | Path, config: Optional[TESConfig] = None, *, before: Optional[FileSnapshot] = None) -> TESResult
Collect TES output files from a working directory and parse them.
Also exported as vaft.code.collect_tes_outputs, vaft.code.tes.collect_tes_outputs.
parse_result_coils
function
source
parse_result_coils(result_file: Path) -> list[dict[str, float | int]]
Parse the ‘EXT. COIL CURRENT UPDATED’ block: base -> updated : delta [kA].
Also exported as vaft.code.parse_result_coils, vaft.code.tes.parse_result_coils.
parse_result_scalars
function
source
parse_result_scalars(result_file: Path) -> dict[str, Any]
Parse the scalar header block of a TES .RESULT file into a flat dict.
Also exported as vaft.code.parse_result_scalars, vaft.code.tes.parse_result_scalars.
vaft.code.tes.runner
Run the TES (rtes) binary on prepared inputs.
run_tes
function
source
run_tes(inputs: TESInputs, config: TESConfig) -> TESResult
Execute rtes with prepared inputs and collect produced outputs.
Also exported as vaft.code.run_tes, vaft.code.tes.run_tes.
TES_COMPATIBILITY_ENV
data
TES_COMPATIBILITY_ENV = 'RTES'
TES_HOME_ENV
data
TES_HOME_ENV = 'TESHOME'
TES_HOME_EXECUTABLE
data
TES_HOME_EXECUTABLE = <pathlib.PosixPath>
vaft.code.tes.scan
Parameter scans over TES forward solves.
scan_tes
function
source
scan_tes(ods: Any, base_config: TESConfig, values: Sequence[Any], param: str = 'ip0_kA', subdir: Optional[Callable[[str, Any], str]] = None, on_result: Optional[Callable[[Any, TESResult], None]] = None) -> list[tuple[Any, TESResult]]
Run a one-parameter TES scan.
Also exported as vaft.code.scan_tes, vaft.code.tes.scan_tes.
vaft.code.tokamaker
TokaMaker equilibrium adapter (static, quasi-static, and stability).
reference_axis_pressure
function
source
reference_axis_pressure(ods: Any, time: float, *, time_index: int | None = None) -> float
Axis pressure [Pa] of the reference equilibrium slice nearest time.
vaft.code.tokamaker.bridge
Independent TokaMaker fixed-boundary vacuum-flux PF-current fit.
fit_free_boundary_coils_vfixed
function
source
fit_free_boundary_coils_vfixed(equilibrium: EquilibriumData, machine: Any, workdir: str | Path, *, config: TokaMakerConfig | None = None, **fit_options: Any) -> VFixedFitResult
Solve a TokaMaker fixed-boundary equilibrium and fit its vacuum field.
Also exported as vaft.code.tokamaker.fit_free_boundary_coils_vfixed.
fit_vfixed_samples
function
source
fit_vfixed_samples(points_m: np.ndarray, vfixed_psi_per_rad: np.ndarray, machine: Any, *, flux_scale_Wb: float, regularization: float = 0.0, current_scale_A: float = 1000.0, current_bounds: Mapping[str, tuple[float, float]] | None = None, current_penalties: Mapping[str, float] | None = None, flux_tolerance: float = 0.02, max_flux_tolerance: float = 0.04) -> VFixedFitResult
Fit physical PF currents to TokaMaker get_vfixed() samples.
Also exported as vaft.code.tokamaker.fit_vfixed_samples.
VFixedFitResult
class
source
VFixedFitResult(coil_names: tuple[str, ...], currents_A: Mapping[str, float], boundary_points_m: np.ndarray, required_vacuum_psi_Wb: np.ndarray, fitted_vacuum_psi_Wb: np.ndarray, relative_flux_residual_Wb: np.ndarray, rms_relative_flux: float, max_relative_flux: float, singular_values: np.ndarray, rank: int, condition_number: float, regularization_norm: float, active_bounds: tuple[str, ...], bounds_complete: bool, optimizer_success: bool, accepted: bool, status: str, fixed_stats: Mapping[str, Any] | None = None, fixed_profile_mode: str | None = None) -> None
Fixed-boundary vacuum-field fit in physical coil A and full Wb.
Also exported as vaft.code.tokamaker.VFixedFitResult.
19 fields
coil_names: tuple[str, ...]currents_A: Mapping[str, float]boundary_points_m: np.ndarrayrequired_vacuum_psi_Wb: np.ndarrayfitted_vacuum_psi_Wb: np.ndarrayrelative_flux_residual_Wb: np.ndarrayrms_relative_flux: floatmax_relative_flux: floatsingular_values: np.ndarrayrank: intcondition_number: floatregularization_norm: floatactive_bounds: tuple[str, ...]bounds_complete: booloptimizer_success: boolaccepted: boolstatus: strfixed_stats: Mapping[str, Any] | Nonefixed_profile_mode: str | None
vaft.code.tokamaker.closure
Fitted PF currents held fixed in a genuine free-boundary forward solve.
compare_equilibria
function
source
compare_equilibria(target: EquilibriumData, solved: EquilibriumData) -> dict[str, Any]
Compare canonical fields using the same definitions on both records.
Also exported as vaft.code.tokamaker.compare_equilibria.
fixed_to_free
function
source
fixed_to_free(target: EquilibriumData, machine: Any, workdir: str | Path, *, fit_backend: str = 'direct', config: TokaMakerConfig | None = None, fit_options: Mapping[str, Any] | None = None, refine_shape: bool = False, refinement_options: Mapping[str, Any] | None = None, verify_refinement: bool = False) -> FixedToFreeResult
Fit PF currents, hold them fixed and solve a true free-boundary equilibrium.
Also exported as vaft.code.tokamaker.fixed_to_free.
FixedToFreeResult
class
source
FixedToFreeResult(fit_backend: str, fit: Any, forward: TokaMakerResult, initial_currents_A: Mapping[str, float], realized_currents_A: Mapping[str, float], current_max_change_A: float | None, comparison: Mapping[str, Any], status: str, refined: TokaMakerResult | None = None, refined_comparison: Mapping[str, Any] = <factory>, refined_currents_A: Mapping[str, float] = <factory>, refinement_status: str | None = None, refinement_diagnostics: Mapping[str, Any] = <factory>, verified_free: TokaMakerResult | None = None, verified_comparison: Mapping[str, Any] = <factory>, verification_status: str | None = None) -> None
Initial inverse fit, forward solution and independent closure diagnostics.
Also exported as vaft.code.tokamaker.FixedToFreeResult.
16 fields
fit_backend: strfit: Anyforward: TokaMakerResultinitial_currents_A: Mapping[str, float]realized_currents_A: Mapping[str, float]current_max_change_A: float | Nonecomparison: Mapping[str, Any]status: strrefined: TokaMakerResult | Nonerefined_comparison: Mapping[str, Any]refined_currents_A: Mapping[str, float]refinement_status: str | Nonerefinement_diagnostics: Mapping[str, Any]verified_free: TokaMakerResult | Noneverified_comparison: Mapping[str, Any]verification_status: str | None
vaft.code.tokamaker.config
Configuration, input, and result objects for the TokaMaker forward adapter.
TokaMakerConfig
class
source
TokaMakerConfig(workdir: Path | str = PosixPath('.'), nthreads: int = 2, quiet: bool = True, maxits: Optional[int] = 100, urf: Optional[float] = None, nl_tol: Optional[float] = None, shot: Optional[int] = None, time: Optional[float] = None, constraint_source: str = 'equilibrium', time_index: Optional[int] = None, ip: Optional[float] = None, pax: Optional[float] = None, ip_ratio: Optional[float] = None, r0_target: Optional[float] = None, v0_target: Optional[float] = None, f0: Optional[float] = None, bt0: Optional[float] = None, major_r: float = 0.4, alpha_f_a: float = 1.5, alpha_f_b: float = 2.0, alpha_p_a: float = 4.0, alpha_p_b: float = 1.0, nprof: int = 40, profile_mode: str = 'power_law', profile_equilibrium: Any = None, profile_tables: Optional[Mapping[str, Any]] = None, init_equilibrium: Any = None, init_r0: float = 0.35, init_z0: float = 0.0, init_a0: float = 0.2, init_kappa: float = 1.5, init_delta: float = 0.0, order: int = 2, mesh_file: Optional[Path | str] = None, dx_plasma: float = 0.015, dx_coil: float = 0.01, dx_vacuum: float = 0.05, limiter: Optional[tuple[Sequence[float], Sequence[float]]] = None, lim_zmax: Optional[float] = 0.6, neck_limiter_zmax: Optional[float] = 0.73, coil_currents: Optional[Mapping[str, float]] = None, exclude_coils: tuple[str, ...] = (), include_vessel: bool = False, vessel_currents: bool = False, dx_conductor: float = 0.02, dx_conductor_min: float = 0.004, eta_vessel: float = 7.8e-07, vessel_eta: Optional[Mapping[str, float]] = None, vessel_noncontinuous: tuple[str, ...] = (), exclude_vessel_segments: tuple[str, ...] = (), vessel_min_thickness: float = 0.002, vessel_gap: float = 0.0003, vsc_coil: Optional[str] = None, vsc_weight: float = 0.01, split_coils: tuple[str, ...] = (), evolve_times: Optional[Sequence[float]] = None, evolve_start: Optional[float] = None, evolve_end: Optional[float] = None, evolve_dt: Optional[float] = None, evolve_on_failure: str = 'continue', evolve_vacuum: bool = False, evolve_eddy: bool = True, evolve_field_probes: Optional[Sequence[tuple[float, float]]] = None, wall_neigs: int = 8, td_neigs: int = 8, td_omega: float = -10000.0, td_include_bounds: bool = False, td_damping_scale: float = -1.0, eqdsk_nr: int = 129, eqdsk_nz: int = 129, eqdsk_lcfs_pad: float = 0.01, eqdsk_cocos: int = 2) -> None
Runtime configuration and physics targets for a TokaMaker forward solve.
Also exported as vaft.code.TokaMakerConfig, vaft.code.tokamaker.TokaMakerConfig.
72 fields
workdir: Path | strnthreads: intquiet: boolmaxits: Optional[int]urf: Optional[float]nl_tol: Optional[float]shot: Optional[int]time: Optional[float]constraint_source: strtime_index: Optional[int]ip: Optional[float]pax: Optional[float]ip_ratio: Optional[float]r0_target: Optional[float]v0_target: Optional[float]f0: Optional[float]bt0: Optional[float]major_r: floatalpha_f_a: floatalpha_f_b: floatalpha_p_a: floatalpha_p_b: floatnprof: intprofile_mode: strprofile_equilibrium: Anyprofile_tables: Optional[Mapping[str, Any]]init_equilibrium: Anyinit_r0: floatinit_z0: floatinit_a0: floatinit_kappa: floatinit_delta: floatorder: intmesh_file: Optional[Path | str]dx_plasma: floatdx_coil: floatdx_vacuum: floatlimiter: Optional[tuple[Sequence[float], Sequence[float]]]lim_zmax: Optional[float]neck_limiter_zmax: Optional[float]coil_currents: Optional[Mapping[str, float]]exclude_coils: tuple[str, ...]include_vessel: boolvessel_currents: booldx_conductor: floatdx_conductor_min: floateta_vessel: floatvessel_eta: Optional[Mapping[str, float]]vessel_noncontinuous: tuple[str, ...]exclude_vessel_segments: tuple[str, ...]vessel_min_thickness: floatvessel_gap: floatvsc_coil: Optional[str]vsc_weight: floatsplit_coils: tuple[str, ...]evolve_times: Optional[Sequence[float]]evolve_start: Optional[float]evolve_end: Optional[float]evolve_dt: Optional[float]evolve_on_failure: strevolve_vacuum: boolevolve_eddy: boolevolve_field_probes: Optional[Sequence[tuple[float, float]]]wall_neigs: inttd_neigs: inttd_omega: floattd_include_bounds: booltd_damping_scale: floateqdsk_nr: inteqdsk_nz: inteqdsk_lcfs_pad: floateqdsk_cocos: int
TokaMakerEvolutionInputs
class
source
TokaMakerEvolutionInputs(base: TokaMakerInputs, times: tuple[float, ...], coil_waveforms: Mapping[str, Any], ip_targets: Any, vacuum: bool = False) -> None
Prepared inputs for a quasi-static evolution across a shot.
Also exported as vaft.code.TokaMakerEvolutionInputs, vaft.code.tokamaker.TokaMakerEvolutionInputs.
5 fields
base: TokaMakerInputstimes: tuple[float, ...]coil_waveforms: Mapping[str, Any]ip_targets: Anyvacuum: bool
TokaMakerEvolutionResult
class
source
TokaMakerEvolutionResult(returncode: Optional[int], workdir: Path, times: tuple[float, ...] = (), steps: tuple[TokaMakerStepRecord, ...] = (), gfiles: tuple[Path, ...] = (), sidecar_file: Optional[Path] = None, mesh_file: Optional[Path] = None, error: str = '', ods: Any = None, scalars: Mapping[str, Any] = <factory>) -> None
Collected quasi-static evolution: per-step records plus the merged IDS.
Also exported as vaft.code.TokaMakerEvolutionResult, vaft.code.tokamaker.TokaMakerEvolutionResult.
10 fields · 1 members
returncode: Optional[int]workdir: Pathtimes: tuple[float, ...]steps: tuple[TokaMakerStepRecord, ...]gfiles: tuple[Path, ...]sidecar_file: Optional[Path]mesh_file: Optional[Path]error: strods: Anyscalars: Mapping[str, Any]okproperty source
TokaMakerInputs
class
source
TokaMakerInputs(workdir: Path, geometry: dict, mesh_file: Path, mesh_exists: bool, coil_currents: dict[str, float], targets: dict[str, float], f0: float, shot: int, time: float, ods: Any = None, files: tuple[Path, ...] = (), vessel_loop_currents: dict[str, dict[int, float]] = <factory>) -> None
Prepared input bundle for a TokaMaker run.
Also exported as vaft.code.TokaMakerInputs, vaft.code.tokamaker.TokaMakerInputs.
12 fields
workdir: Pathgeometry: dictmesh_file: Pathmesh_exists: boolcoil_currents: dict[str, float]targets: dict[str, float]f0: floatshot: inttime: floatods: Anyfiles: tuple[Path, ...]vessel_loop_currents: dict[str, dict[int, float]]
TokaMakerResult
class
source
TokaMakerResult(returncode: Optional[int], workdir: Path, gfile: Optional[Path] = None, stats_file: Optional[Path] = None, mesh_file: Optional[Path] = None, error: str = '', logs: tuple[Path, ...] = (), geqdsk: tuple[Any, ...] = (), ods: Any = None, scalars: Mapping[str, Any] = <factory>, verified_free: Optional['TokaMakerResult'] = None) -> None
Collected TokaMaker run status, output files, and parsed equilibrium.
Also exported as vaft.code.TokaMakerResult, vaft.code.tokamaker.TokaMakerResult.
11 fields · 1 members
returncode: Optional[int]workdir: Pathgfile: Optional[Path]stats_file: Optional[Path]mesh_file: Optional[Path]error: strlogs: tuple[Path, ...]geqdsk: tuple[Any, ...]ods: Anyscalars: Mapping[str, Any]verified_free: Optional['TokaMakerResult']okproperty source
TokaMakerStabilityResult
class
source
TokaMakerStabilityResult(returncode: Optional[int], workdir: Path, tau_wall_s: tuple[float, ...] = (), gamma_s: Optional[float] = None, eig_file: Optional[Path] = None, stats_file: Optional[Path] = None, gfile: Optional[Path] = None, error: str = '', scalars: Mapping[str, Any] = <factory>) -> None
Wall eigenmodes and/or vertical-stability growth rate.
Also exported as vaft.code.TokaMakerStabilityResult, vaft.code.tokamaker.TokaMakerStabilityResult.
9 fields · 1 members
returncode: Optional[int]workdir: Pathtau_wall_s: tuple[float, ...]gamma_s: Optional[float]eig_file: Optional[Path]stats_file: Optional[Path]gfile: Optional[Path]error: strscalars: Mapping[str, Any]okproperty source
TokaMakerStepRecord
class
source
TokaMakerStepRecord(index: int, time: float, converged: bool, error: str = '', gfile: Optional[Path] = None, stats: Mapping[str, Any] = <factory>, coil_currents_A: Mapping[str, float] = <factory>, vessel_currents_A: Mapping[str, float] = <factory>, probe_fields: Mapping[str, Any] = <factory>) -> None
One quasi-static evolution step.
Also exported as vaft.code.TokaMakerStepRecord, vaft.code.tokamaker.TokaMakerStepRecord.
9 fields
index: inttime: floatconverged: boolerror: strgfile: Optional[Path]stats: Mapping[str, Any]coil_currents_A: Mapping[str, float]vessel_currents_A: Mapping[str, float]probe_fields: Mapping[str, Any]
vaft.code.tokamaker.evolve
Quasi-static eddy-current evolution of VEST equilibria with TokaMaker.
EVOLVE_NL_TOL
data
EVOLVE_NL_TOL = 1e-05
run_tokamaker_evolution
function
source
run_tokamaker_evolution(inputs: TokaMakerEvolutionInputs, config: TokaMakerConfig) -> TokaMakerEvolutionResult
March the quasi-static evolution and collect per-slice outputs.
Also exported as vaft.code.run_tokamaker_evolution, vaft.code.tokamaker.run_tokamaker_evolution.
vaft.code.tokamaker.free_boundary
Free-boundary PF-coil-current scans with TokaMaker (issue #67).
CaseStatus
class
source
Also exported as vaft.code.CaseStatus, vaft.code.tokamaker.CaseStatus.
5 fields
PENDING: 'pending'SUCCEEDED: 'succeeded'FAILED: 'failed'NOT_CONVERGED: 'not_converged'SKIPPED: 'skipped'
CoilControl
class
source
CoilControl(coil: str, mode: str, values: tuple[float, ...]) -> None
One scan axis: a coil set varied in one mode.
3 fields · 1 members
coil: strmode: strvalues: tuple[float, ...]applymethod source
FreeBoundaryCaseResult
class
source
FreeBoundaryCaseResult(case_id: str, index: int, status: CaseStatus, requested: Mapping[str, Mapping[str, float]] = <factory>, commanded_currents: Mapping[str, float] = <factory>, materialized_currents: Mapping[str, float] = <factory>, held: Mapping[str, Any] = <factory>, achieved: Mapping[str, Any] = <factory>, topology: Optional[Mapping[str, Any]] = None, solver_x_points: tuple[tuple[float, float], ...] = (), solver_diverted: Optional[bool] = None, discontinuity: Mapping[str, Any] = <factory>, continuation_from: Optional[str] = None, continuation_break: bool = False, refinement_history: tuple[Mapping[str, Any], ...] = (), gfile: Optional[Path] = None, manifest: Optional[Path] = None, error: str = '', report: Optional[TopologyReport] = None) -> None
Also exported as vaft.code.FreeBoundaryCaseResult, vaft.code.tokamaker.FreeBoundaryCaseResult.
19 fields · 1 members
case_id: strindex: intstatus: CaseStatusrequested: Mapping[str, Mapping[str, float]]commanded_currents: Mapping[str, float]materialized_currents: Mapping[str, float]held: Mapping[str, Any]achieved: Mapping[str, Any]topology: Optional[Mapping[str, Any]]solver_x_points: tuple[tuple[float, float], ...]solver_diverted: Optional[bool]discontinuity: Mapping[str, Any]continuation_from: Optional[str]continuation_break: boolrefinement_history: tuple[Mapping[str, Any], ...]gfile: Optional[Path]manifest: Optional[Path]error: strreport: Optional[TopologyReport]okproperty source
FreeBoundaryScan
class
source
FreeBoundaryScan(ods: Any, *, axes: tuple[CoilControl, ...], mode: str, hold: tuple[str, ...], continuation: bool, refine_on_failure: int, jump_thresholds: Mapping[str, float], config: TokaMakerConfig, workdir: Path, classify_kwargs: Mapping[str, Any])
Materialized scan: inspect .cases, then .run() or .dry_run().
Also exported as vaft.code.FreeBoundaryScan, vaft.code.tokamaker.FreeBoundaryScan.
FreeBoundaryScanResult
class
source
FreeBoundaryScanResult(workdir: Path, cases: tuple[FreeBoundaryCaseResult, ...], manifest: Path) -> None
Also exported as vaft.code.FreeBoundaryScanResult, vaft.code.tokamaker.FreeBoundaryScanResult.
scan
function
source
scan(ods: Any, *, controls: Mapping[str, Mapping[str, Sequence[float]]], mode: str = 'product', hold: Sequence[str] = ('ip', 'profile_shape'), continuation: bool = True, refine_on_failure: int = 0, jump_thresholds: Optional[Mapping[str, float]] = None, config: Optional[TokaMakerConfig] = None, workdir: Optional[Path | str] = None, active_tolerance: float = 0.002, near_null_band: float = 0.05, contact_tolerance: Optional[float] = None) -> FreeBoundaryScan
Materialize a TokaMaker free-boundary PF-coil-current scan.
Also exported as vaft.code.free_boundary_scan, vaft.code.tokamaker.free_boundary.free_boundary_scan, vaft.code.tokamaker.free_boundary_scan.
ScanCase
class
source
ScanCase(case_id: str, index: int, requested: Mapping[str, Mapping[str, float]], commanded: Mapping[str, float], workdir: Path, config: TokaMakerConfig, config_sha: str) -> None
7 fields
case_id: strindex: intrequested: Mapping[str, Mapping[str, float]]commanded: Mapping[str, float]workdir: Pathconfig: TokaMakerConfigconfig_sha: str
vaft.code.tokamaker.geometry
Build a TokaMaker machine-geometry description from an ODS.
geometry_signature
function
source
geometry_signature(geometry: dict, config: TokaMakerConfig) -> str
Short stable hash of the geometry and the config fields that shape the mesh.
Also exported as vaft.code.geometry_signature, vaft.code.tokamaker.geometry_signature.
split_coil_names
function
source
split_coil_names(config: TokaMakerConfig) -> set[str]
Upper-cased names of coils whose U/L halves are independent coil sets.
tokamaker_geometry_from_ods
function
source
tokamaker_geometry_from_ods(ods: Any, config: TokaMakerConfig) -> dict
Build the TokaMaker geometry dict from an ODS.
Also exported as vaft.code.tokamaker.tokamaker_geometry_from_ods, vaft.code.tokamaker_geometry_from_ods.
vaft.code.tokamaker.inputs
Build TokaMaker forward-solve inputs from an ODS.
prepare_tokamaker_evolution_inputs
function
source
prepare_tokamaker_evolution_inputs(ods: Any, config: TokaMakerConfig) -> TokaMakerEvolutionInputs
Resolve everything a quasi-static evolution needs from an ODS.
Also exported as vaft.code.prepare_tokamaker_evolution_inputs, vaft.code.tokamaker.prepare_tokamaker_evolution_inputs.
prepare_tokamaker_inputs
function
source
prepare_tokamaker_inputs(ods: Any, config: TokaMakerConfig) -> TokaMakerInputs
Resolve geometry, currents, targets, and the mesh cache from an ODS.
Also exported as vaft.code.prepare_tokamaker_inputs, vaft.code.tokamaker.prepare_tokamaker_inputs.
resolve_mesh_file
function
source
resolve_mesh_file(geometry: dict, config: TokaMakerConfig) -> tuple[Path, bool]
Resolve the mesh-cache path (explicit mesh_file or hash-named) and existence.
Also exported as vaft.code.resolve_mesh_file, vaft.code.tokamaker.resolve_mesh_file.
vaft.code.tokamaker.mesh
Build and cache the TokaMaker finite-element mesh for a machine geometry.
build_tokamaker_mesh
function
source
build_tokamaker_mesh(geometry: dict, mesh_file: Path | str, config: TokaMakerConfig) -> Path
Mesh the geometry with gs_Domain and save it as an HDF5 cache file.
Also exported as vaft.code.build_tokamaker_mesh, vaft.code.tokamaker.build_tokamaker_mesh.
vaft.code.tokamaker.outputs
Collect and parse TokaMaker outputs from a working directory.
collect_tokamaker_evolution_outputs
function
source
collect_tokamaker_evolution_outputs(workdir: str | Path, config: Optional[TokaMakerConfig] = None) -> TokaMakerEvolutionResult
Rebuild an evolution result from a working directory (collect-only).
Also exported as vaft.code.collect_tokamaker_evolution_outputs, vaft.code.tokamaker.collect_tokamaker_evolution_outputs.
collect_tokamaker_outputs
function
source
collect_tokamaker_outputs(workdir: str | Path, config: Optional[TokaMakerConfig] = None) -> TokaMakerResult
Collect TokaMaker output files from a working directory and parse them.
Also exported as vaft.code.collect_tokamaker_outputs, vaft.code.tokamaker.collect_tokamaker_outputs.
collect_tokamaker_stability_outputs
function
source
collect_tokamaker_stability_outputs(workdir: str | Path, config: Optional[TokaMakerConfig] = None) -> TokaMakerStabilityResult
Rebuild a stability result from the sidecar and .npz files (collect-only).
Also exported as vaft.code.collect_tokamaker_stability_outputs, vaft.code.tokamaker.collect_tokamaker_stability_outputs.
EVOLUTION_SIDECAR_NAME
data
EVOLUTION_SIDECAR_NAME = 'tokamaker_evolution.json'
parse_stats_sidecar
function
source
parse_stats_sidecar(path: Path) -> dict[str, Any]
Flatten the tokamaker_result.json sidecar into a scalar dict.
Also exported as vaft.code.parse_stats_sidecar, vaft.code.tokamaker.parse_stats_sidecar.
SIDECAR_NAME
data
SIDECAR_NAME = 'tokamaker_result.json'
STABILITY_SIDECAR_NAME
data
STABILITY_SIDECAR_NAME = 'tokamaker_stability.json'
vaft.code.tokamaker.profiles
Canonical static source profiles for TokaMaker’s piecewise-linear input.
equilibrium_to_tokamaker_profiles
function
source
equilibrium_to_tokamaker_profiles(equilibrium: EquilibriumData) -> TokaMakerProfiles
Convert canonical static source profiles to native OFT table shapes.
Also exported as vaft.code.tokamaker.equilibrium_to_tokamaker_profiles.
TokaMakerProfiles
class
source
TokaMakerProfiles(psi_n: np.ndarray, pprime: np.ndarray, ffprime: np.ndarray, axis_pressure_Pa: float, edge_pressure_Pa: float = 0.0, ip_A: float | None = None) -> None
Native per-radian derivatives sampled axis to edge; pressure in Pa.
Also exported as vaft.code.tokamaker.TokaMakerProfiles.
6 fields · 1 members
psi_n: np.ndarraypprime: np.ndarrayffprime: np.ndarrayaxis_pressure_Pa: floatedge_pressure_Pa: floatip_A: float | Nonesolver_tablesmethod — Return OFT linterp definitions; its normalization sets amplitudes. source
vaft.code.tokamaker.refinement
Optional native shape optimization, kept separate from initial PF fitting.
prepare_shape_refinement
function
source
prepare_shape_refinement(target, currents, *, current_bounds, boundary_samples=64, x_points=None, regularization=1e-05, current_scale_A=1000.0, isoflux_weight=1.0, saddle_weight=1.0, xpoint_flux_weight=100.0) -> ShapeRefinement
Resample LCFS by arc length and validate physical optimizer controls.
Also exported as vaft.code.tokamaker.prepare_shape_refinement.
ShapeRefinement
class
source
ShapeRefinement(isoflux_points_m: np.ndarray, saddle_points_m: np.ndarray, reference_currents_A: Mapping[str, float], current_bounds_A: Mapping[str, tuple[float, float]], regularization: float = 1e-05, current_scale_A: float = 1000.0, isoflux_weight: float = 1.0, saddle_weight: float = 1.0, xpoint_flux_weight: float = 100.0) -> None
Native isoflux/saddle constraints and scaled current deviation penalty.
Also exported as vaft.code.tokamaker.ShapeRefinement.
9 fields
isoflux_points_m: np.ndarraysaddle_points_m: np.ndarrayreference_currents_A: Mapping[str, float]current_bounds_A: Mapping[str, tuple[float, float]]regularization: floatcurrent_scale_A: floatisoflux_weight: floatsaddle_weight: floatxpoint_flux_weight: float
vaft.code.tokamaker.runner
Run a TokaMaker forward free-boundary solve on prepared inputs.
run_tokamaker
function
source
run_tokamaker(inputs: TokaMakerInputs, config: TokaMakerConfig, *, refinement=None, verify_refinement: bool = False) -> TokaMakerResult
Execute a forward solve and collect the produced outputs.
Also exported as vaft.code.run_tokamaker, vaft.code.tokamaker.run_tokamaker.
vaft.code.tokamaker.scan
Parameter scans over TokaMaker forward solves.
scan_tokamaker
function
source
scan_tokamaker(ods: Any, base_config: TokaMakerConfig, values: Sequence[Any], param: str = 'ip', subdir: Optional[Callable[[str, Any], str]] = None, on_result: Optional[Callable[[Any, TokaMakerResult], None]] = None) -> list[tuple[Any, TokaMakerResult]]
Run a one-parameter TokaMaker scan.
Also exported as vaft.code.scan_tokamaker, vaft.code.tokamaker.scan_tokamaker.
vaft.code.tokamaker.stability
Wall eigenmodes and vertical-stability growth rates via TokaMaker.
run_tokamaker_vertical_stability
function
source
run_tokamaker_vertical_stability(inputs: TokaMakerInputs, config: TokaMakerConfig) -> TokaMakerStabilityResult
Forward static solve followed by the n=0 growth-rate eigensolve.
Also exported as vaft.code.run_tokamaker_vertical_stability, vaft.code.tokamaker.run_tokamaker_vertical_stability.
run_tokamaker_wall_eigenmodes
function
source
run_tokamaker_wall_eigenmodes(inputs: TokaMakerInputs, config: TokaMakerConfig) -> TokaMakerStabilityResult
Compute resistive wall L/R eigenmodes (no equilibrium solve needed).
Also exported as vaft.code.run_tokamaker_wall_eigenmodes, vaft.code.tokamaker.run_tokamaker_wall_eigenmodes.
vaft.code.tokamaker.topology
Scan-grade topology classification on top of the #65 boundary descriptors.
classify_boundary
function
source
classify_boundary(source: Any, *, active_tolerance: float = 0.002, near_null_band: float = 0.05, contact_tolerance: Optional[float] = None, time_index: int = 0, gap_angles: Mapping[str, float] | None = None) -> TopologyReport
Classify one equilibrium’s boundary topology for scan bookkeeping.
Also exported as vaft.code.classify_boundary, vaft.code.tokamaker.classify_boundary.
LimiterContact
class
source
LimiterContact(r: float, z: float, wall_r: float, wall_z: float, distance: float, side: str = 'unknown') -> None
Closest approach between the LCFS and the limiter.
6 fields
r: floatz: floatwall_r: floatwall_z: floatdistance: floatside: str
ScanTopology
class
source
Also exported as vaft.code.ScanTopology, vaft.code.tokamaker.ScanTopology.
7 fields
LIMITED: 'limited'NEAR_NULL: 'near_null'LOWER_SINGLE_NULL: 'lower_single_null'UPPER_SINGLE_NULL: 'upper_single_null'DOUBLE_NULL: 'double_null'AMBIGUOUS: 'ambiguous'UNKNOWN: 'unknown'
TopologyReport
class
source
TopologyReport(topology: ScanTopology, x_points: tuple[Mapping[str, float], ...] = (), d_r_sep: Optional[float] = None, null_margin: Optional[float] = None, limiter_contact: Optional[LimiterContact] = None, active_tolerance: float = 0.0, near_null_band: float = 0.0, contact_tolerance: Optional[float] = None, reason: Optional[str] = None, representation: Any = None) -> None
JSON-safe per-equilibrium topology classification for scan manifests.
Also exported as vaft.code.TopologyReport, vaft.code.tokamaker.TopologyReport.
10 fields · 1 members
topology: ScanTopologyx_points: tuple[Mapping[str, float], ...]d_r_sep: Optional[float]null_margin: Optional[float]limiter_contact: Optional[LimiterContact]active_tolerance: floatnear_null_band: floatcontact_tolerance: Optional[float]reason: Optional[str]representation: Anyto_dictmethod source
vaft.code.tokamaker.vessel
Synthesize TokaMaker conductor regions from the VEST pf_passive filaments.
vessel_segments_from_ods
function
source
vessel_segments_from_ods(ods: Any, config: TokaMakerConfig) -> dict[str, dict]
Build TokaMaker conductor-region descriptions from pf_passive.
Also exported as vaft.code.tokamaker.vessel_segments_from_ods, vaft.code.vessel_segments_from_ods.
vaft.code.transp.config
Discovering what a TRANSP run directory holds.
collect_transp_outputs
function
source
collect_transp_outputs(directory: str | Path) -> TRANSPResult
List the TRANSP output files in directory.
Also exported as vaft.code.collect_transp_outputs, vaft.code.transp.collect_transp_outputs.
OUTPUT_SUFFIX
data
OUTPUT_SUFFIX = '.CDF'
RUNID_PATTERN
data
RUNID_PATTERN = <re.Pattern>
TRANSPResult
class
source
TRANSPResult(returncode: Optional[int], workdir: Path, stdout: str = '', stderr: str = '', logs: tuple[Path, ...] = (), outputs: Mapping[str, tuple[Path, ...]] = <factory>, parsed: Any = None, runtime_status: str = 'completed', elapsed_s: Optional[float] = None, runid: str = '') -> None
What a TRANSP run directory holds.
Also exported as vaft.code.TRANSPResult, vaft.code.transp.TRANSPResult.
10 fields
returncode: Optional[int]workdir: Pathstdout: strstderr: strlogs: tuple[Path, ...]outputs: Mapping[str, tuple[Path, ...]]parsed: Anyruntime_status: strelapsed_s: Optional[float]runid: str
vaft.code.transp.outputs
Native TRANSP output containers: a transcript of one .CDF, unconverted.
EMPTY_PLACEHOLDERS
data
EMPTY_PLACEHOLDERS = <builtins.dict>
Also exported as vaft.code.transp.EMPTY_PLACEHOLDERS.
PROFILE_GRIDS
data
PROFILE_GRIDS = <builtins.dict>
Also exported as vaft.code.transp.PROFILE_GRIDS.
read_transp_output
function
source
read_transp_output(path: str | Path) -> TranspOutput
Open a TRANSP output .CDF.
Also exported as vaft.code.read_transp_output, vaft.code.transp.read_transp_output.
TIME_DIMENSIONS
data
TIME_DIMENSIONS = ('TIME', 'TIME3')
Also exported as vaft.code.transp.TIME_DIMENSIONS.
TranspFormatError
class
source
The file is not shaped like a TRANSP output.
Also exported as vaft.code.TranspFormatError, vaft.code.transp.TranspFormatError.
TranspOutput
class
source
TranspOutput(path: Path, _dataset: Any = None, _cache: dict = <factory>) -> None
A TRANSP run’s output file, read lazily.
Also exported as vaft.code.TranspOutput, vaft.code.transp.TranspOutput.
1 fields · 11 members
path: Pathclosemethod sourcevariablesproperty sourcedimsproperty sourceunitsmethod — The file’s ownunitsattribute, stripped;""when it has none. sourcelong_namemethod sourcedescribemethod — What a variable is, or a note that this adapter does not catalogue it. sourcegrid_ofmethod — Which radial grid a variable is on, from its dimension name. sourcevariablemethod — One variable, materialized and cached. sourcetimeproperty — The scalar time base [s]. sourcetime_indexmethod — Index of the sample nearesttime_s. sourceslicemethod — The run at the sample nearesttime_s. source
TranspSlice
class
source
TranspSlice(time_s: float, time_index: int, x: np.ndarray, xb: np.ndarray, _output: 'TranspOutput') -> None
One time of a TRANSP run: its grids and the variables on them.
Also exported as vaft.code.TranspSlice, vaft.code.transp.TranspSlice.
4 fields · 7 members
time_s: floattime_index: intx: np.ndarrayxb: np.ndarrayunitsmethod sourcedescribemethod sourcegrid_ofmethod sourcevariablemethod — One variable at this time, in the file’s own units. sourceon_xmethod — A zone-centre variable, refusing a zone-boundary one. sourceon_xbmethod — A zone-boundary variable, refusing a zone-centre one. sourcepsi_norm_xbproperty — Normalized poloidal flux on the zone boundaries,PLFLX / PLFLXA. source
TranspVariable
class
source
TranspVariable(name: str, dims: tuple[str, ...], units: str, long_name: str, values: np.ndarray) -> None
One variable, with the name, dimensions and units TRANSP gave it.
Also exported as vaft.code.TranspVariable, vaft.code.transp.TranspVariable.
VARIABLE_DESCRIPTIONS
data
VARIABLE_DESCRIPTIONS = <builtins.dict>
Also exported as vaft.code.transp.VARIABLE_DESCRIPTIONS.
vaft.code.transp.profiles
TRANSP profiles as VAFT’s kinetic container: the one conversion in this layer.
DEFAULT_TARGET_GRID
data
DEFAULT_TARGET_GRID = 'XB'
exb_frequency
function
source
exb_frequency(state: TranspSlice) -> np.ndarray
The E x B frequency on the zone boundaries [rad/s].
Also exported as vaft.code.exb_frequency, vaft.code.transp.exb_frequency.
kinetic_profiles_from_slice
function
source
kinetic_profiles_from_slice(state: TranspSlice, *, target_grid: str = 'XB') -> KineticProfiles
Convert one time of a TRANSP run into the kinetic container.
Also exported as vaft.code.kinetic_profiles_from_slice, vaft.code.transp.kinetic_profiles_from_slice.
PROFILE_SOURCES
data
PROFILE_SOURCES = <builtins.dict>
Also exported as vaft.code.transp.PROFILE_SOURCES.
read_transp_profiles
function
source
read_transp_profiles(path: str | Path, *, time_s: float, target_grid: str = 'XB') -> KineticProfiles
Read one time of a TRANSP .CDF as kinetic profiles.
Also exported as vaft.code.read_transp_profiles, vaft.code.transp.read_transp_profiles.
TRANSP_UNIT_LADDER
data
TRANSP_UNIT_LADDER = <builtins.dict>
Also exported as vaft.code.transp.TRANSP_UNIT_LADDER.
vaft.code.transp.torque
Torque from a TRANSP run: the input density, and what it encloses.
enclosed_torque
function
source
enclosed_torque(slice: TranspSlice) -> tuple[np.ndarray, np.ndarray]
Torque enclosed by each zone boundary.
Also exported as vaft.code.enclosed_torque, vaft.code.transp.enclosed_torque.
input_torque_density
function
source
input_torque_density(slice: TranspSlice) -> np.ndarray
TQIN at this time, in TRANSP’s own units [N m / cm^3], on X.
Also exported as vaft.code.input_torque_density, vaft.code.transp.input_torque_density.
zone_volume
function
source
zone_volume(slice: TranspSlice) -> np.ndarray
DVOL at this time [cm^3], on X – the volume of each zone.
Also exported as vaft.code.transp.zone_volume, vaft.code.zone_volume.