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

vaft.code
BoundaryContourPolicyclass
EFIT_FAILURE_CODESdata
ExecutableNotLaunchableclass
vaft.code.base
CodeConfigclass
CodeInputsclass
CodeResultclass
CodeRunnerclass
RunOutcomeclass
vaft.code.chease
CHEASE_OUTPUT_NIDEALdata
CHEASEConfigclass
CHEASEInputsclass
CHEASEMaterializedInputclass
CHEASEResultclass
collect_chease_outputsfunction
comparison_metricsfunction
find_chease_executablefunction
GeqdskSignInfoclass
prepare_chease_inputsfunction
refine_equilibriumfunction
run_cheasefunction
vaft.code.chease_kinetic_iteration
build_consistent_statefunction
current_source_for_updatefunction
pressure_roundtripfunction
pressure_source_from_kineticfunction
PressureSourceErrorclass
validate_chease_updatefunction
vaft.code.chease_scan
apply_equilibrium_variationfunction
CHEASEScanCaseclass
EquilibriumVariationclass
scan_cheasefunction
vaft.code.chease_synthesis
build_input_equilibriumfunction
construct_boundaryfunction
requested_pressure_shapefunction
STATUSESdata
SUPPORTED_TARGETSdata
synthesize_equilibrium_from_0dfunction
SyntheticEquilibriumResultclass
ZeroDimensionalEquilibriumSpecclass
vaft.code.chease_synthesis_targets
assign_knobsfunction
DEFAULT_KNOBSdata
MULTI_TARGET_STATUSESdata
MultiTargetSynthesisResultclass
synthesize_equilibrium_to_targetsfunction
TARGET_DESCRIPTORSdata
TargetIterationRecordclass
TargetKnobclass
vaft.code.efit
EFITReducedLinearSolveclass
vaft.code.efit.applicability
constraints_not_applicable_reasonfunction
EFIT_NOT_APPLICABLEdata
KFILE_MANIFEST_NOT_APPLICABLEdata
kfile_manifest_not_applicable_reasonfunction
kfile_manifest_pathsfunction
kfile_manifest_textfunction
not_applicable_constraintsfunction
vaft.code.efit.config
DIAGNOSTIC_GROUPSdata
efit_parameter_gridfunction
EFITAcceptanceEnvelopeclass
EFITConstraintConfigclass
EFITInitializationConfigclass
EFITNumericsConfigclass
EFITProfileConfigclass
EFITScientificConfigclass
IGNORE_CRITERIONdata
routine_constraint_configfunction
routine_numerics_configfunction
routine_profile_configfunction
routine_scientific_configfunction
WORKING_UNCERTAINTY_SCALESdata
vaft.code.efit.efund
collect_efund_outputsfunction
efund_config_from_manifestfunction
EFUNDConfigclass
EFUNDInputsclass
EFUNDResultclass
expected_table_filesfunction
fortran_byte_orderfunction
generate_era_tablefunction
IDENTITY_EXCLUDED_FILESdata
LIMITER_NAMEdata
MHDIN_NAMEdata
prepare_efund_inputsfunction
read_fortran_arraysfunction
read_fortran_recordsfunction
read_table_manifestfunction
run_efundfunction
TABLE_DIR_MAX_CHARSdata
table_dir_textfunction
table_identityfunction
table_machine_erafunction
TABLE_MANIFEST_NAMEdata
TableExistsErrorclass
write_limiter_filefunction
write_mhdinfunction
write_table_manifestfunction
vaft.code.efit.iteration_history
compare_iteration_historiesfunction
EFITIterationclass
EFITIterationHistoryclass
EFITSliceIterationHistoryclass
iteration_history_from_workdirfunction
ITERATION_HISTORY_LEVELSdata
ITERATION_HISTORY_SCHEMAdata
ITERATION_HISTORY_SCHEMA_VERSIONdata
parse_iteration_historyfunction
plot_iteration_convergencefunction
printed_msfunction
read_iteration_historyfunction
SIDECAR_NAMEdata
vaft.code.efit.kfile
apply_channel_decisionsfunction
apply_validity_exclusionsfunction
build_efit_coil_currentsfunction
ConstraintErrorsclass
ConstraintWeightsclass
diamagnetic_anchored_slicesfunction
generate_constraints_odsfunction
generate_kfilefunction
MissingConstraintInputErrorclass
vaft.code.efit.kinetic
build_kinetic_core_profilesfunction
EQEdata
find_efit_executablefunction
inject_pressure_constraintfunction
kinetic_pressure_pointsfunction
KineticEFITConfigclass
KineticEFITInputsclass
KineticEFITResultclass
prepare_kinetic_efit_inputsfunction
PressurePointsclass
run_kinetic_chainfunction
run_kinetic_efitfunction
scale_plasmafunction
vaft.code.efit.legacy
annotate_constraint_equilibriumfunction
box_averagefunction
calculate_md_by_odsfunction
correct_flux_loopfunction
gauss_fit4function
min_gauss_fit4function
set_discharge_indexfunction
smoothfunction
vest_Halpha_tstart_tendfunction Deprecated
vest_rspv1function
vest_signal_onoffsetpeakfunction
vfit_equilibrium_form_constraintsfunction
vfit_signal_startendfunction
vaft.code.efit.linearization
analyze_efit_identifiabilityfunction
EFITLinearizationclass
EFITLinearizationBlockclass
EFITLinearizationErrorclass
FAMILY_IDSdata
FamilyInformationclass
IdentifiabilityConfigclass
IdentifiabilityReportclass
IpAccountingclass
LinearSolveValidationclass
ModeInformationclass
PARAMETER_ROLE_IDSdata
read_efit_linearizationfunction
RowInformationclass
SCHEMA_IDdata
SCHEMA_VERSIONdata
SubsetInformationclass
vaft.code.efit.magnetic
collect_efit_outputsfunction
EFIT_EXEC_ENVdata
EFIT_HOME_ENVdata
EFIT_HOME_EXECUTABLEdata
EFITConfigclass
EFITInputsclass
EFITResultclass
find_efit_executablefunction
gfile_to_omasfunction
prepare_efit_inputsfunction
resolved_efit_configurationfunction
run_efitfunction
unrecorded_efit_configurationfunction
UNRECORDED_SCIENTIFIC_SHA256data
vaft.code.efit.presets
apply_sigma_floorfunction
DEFAULT_PRESETdata
efit_presetfunction
EFITPresetclass
FLOOR_FAMILIESdata
preset_offunction
PRESET_RECORDdata
PRESETSdata
PSI_ONLY_MAX_ITERATIONSdata
PSI_ONLY_SAICONdata
vaft.code.efit.recovery
family_offunction
gaussian_probe_recoveryfunction
GAUSSIAN_PROVENANCEdata
IP_FIT_FLOORdata
probe_familiesfunction
PROBE_Z_TABLEdata
ProbeFamiliesclass
vaft.code.efit.slice_name
decode_time_suffixfunction
encode_time_suffixfunction
file_name_microsecondsfunction
slice_file_namefunction
split_slice_file_namefunction
time_to_microsecondsfunction
whole_millisecond_tstepfunction
vaft.code.efit.status
apply_temporal_continuityfunction
EFIT_FAILURE_CODESdata
EFITSliceStatusclass
EFITValidationConfigclass
validate_efit_slicefunction
vaft.code.efit.termination
EFIT_LOG_PATTERNSdata
parse_slicesfunction
vaft.code.efit.toolchain
BUILD_TREE_LAYOUTdata
EFIT_HOME_ENVdata
EFIT_LEGACY_EXEC_ENVdata
EFIT_ROLESdata
executable_identityfunction
ExecutableIdentityclass
INSTALLED_LAYOUTdata
resolve_rolefunction
resolve_toolchainfunction
toolchain_identitiesfunction
unconfigured_reasonfunction
vaft.code.execution
BACKEND_ENVdata
BACKEND_NAMESdata
default_backendfunction
execution_environmentfunction
ExecutionBackendclass
ExecutionRequestclass
ExecutionResultclass
LocalBackendclass
resolve_backendfunction
ResourceRequestclass
RUNTIME_COMPLETEDdata
RUNTIME_MEMORY_LIMITdata
RUNTIME_QUEUE_TIMEOUTdata
RUNTIME_STATUSESdata
RUNTIME_TIMEOUTdata
THREAD_ENV_VARIABLESdata
timeout_reasonfunction
vaft.code.flare
BRZPHI_IMAGINARY_COLUMNSdata
flare_equilibrium_scalesfunction
flare_executablefunction
FLARE_TASKSdata
FlareConfigclass
FlareEquilibriumScalesclass
FlareResultclass
run_flarefunction
write_helicity_flipped_fieldfunction
vaft.code.formalism
AXESdata
BULK_DESCRIPTIONSdata
DISTRIBUTION_FORMULATIONSdata
FIELD_MODELSdata
FLUID_MODELSdata
KINETIC_COUPLINGSdata
KINETIC_EQUATIONSdata
ORBIT_REPRESENTATIONSdata
PlasmaFormalismclass
REGIMESdata
SCHEMA_VERSIONdata
SCIENTIFIC_OPERATIONSdata
SPATIAL_DOMAINSdata
TOPOLOGY_DOMAINSdata
UNKNOWNdata
vaft.code.gacode
available_platformsfunction
find_gacode_executablefunction
GACODE_COMPATIBILITY_ENVSdata
gacode_environmentfunction
gacode_homefunction
GACODE_HOME_ENVdata
gacode_platformfunction
GACODE_PLATFORM_ENVdata
GACODE_ROOT_ENVdata
GACODEConfigclass
GACODERunclass
launcher_relative_pathfunction
require_gacode_executablefunction
run_gacodefunction
SUITE_CODESdata
SUPPORTED_CODESdata
vaft.code.gacode.cgyro
CGYROConfigclass
CGYROResultclass
FIELD_MODELSdata
formalismfunction
MAX_SPECIESdata
plasma_formalismfunction
stage_cgyro_casefunction
TGLF_FIELD_MODELdata
vaft.code.gacode.cgyro.fields
FieldHistoryclass
read_field_historyfunction
vaft.code.gacode.cgyro.inputs
cgyro_input_from_tglffunction
cgyro_parametersfunction
CGYROInputclass
CGYROInputsclass
compare_with_oraclefunction
input_sha256function
prepare_cgyro_casefunction
prepare_cgyro_inputfunction
write_input_cgyrofunction
vaft.code.gacode.cgyro.locality
BOX_THRESHOLDSdata
locality_reportfunction
LOCALITY_THRESHOLDSdata
radial_correlation_lengthfunction
scale_lengthsfunction
vaft.code.gacode.cgyro.outputs
CgyroOutputsclass
collect_cgyro_outputsfunction
FIELD_NAMESdata
FLUX_MOMENTSdata
FREQUENCY_SIGN_CONVENTIONdata
parse_equilibriumfunction
parse_gridsfunction
SCHEMAdata
SCHEMA_VERSIONdata
vaft.code.gacode.cgyro.runner
CGYROExecutionErrorclass
gacode_revisionfunction
local_ordering_statefunction
read_cgyro_casefunction
run_cgyrofunction
run_cgyro_casefunction
vaft.code.gacode.cgyro.time
CgyroTimeNormalizationclass
gyrokinetic_elapsed_time_sfunction
gyrokinetic_normalized_timefunction
gyrokinetic_time_scale_sfunction
vaft.code.gacode.inputs
GACODEInputsclass
IMPURITIESdata
impurity_fractionsfunction
prepare_gacode_inputsfunction
prepare_gacode_profilefunction
ProfileConversionErrorclass
vaft.code.gacode.neo
NEO_DEFAULTSdata
NEOConfigclass
NEOResultclass
plasma_formalismfunction
vaft.code.gacode.neo.inputs
conductivity_parametersfunction
neo_parametersfunction
NEOInputsclass
prepare_neo_casefunction
prepare_neo_conductivity_casefunction
write_input_neofunction
vaft.code.gacode.neo.outputs
collect_neo_outputsfunction
NeoGridclass
NeoNormalisationclass
NeoOutputsclass
SCHEMAdata
SCHEMA_VERSIONdata
THEORY_SCALARSdata
vaft.code.gacode.neo.runner
NEOExecutionErrorclass
read_neo_casefunction
run_neofunction
run_neo_casefunction
run_neo_conductivity_casefunction
run_neo_pairfunction
vaft.code.gacode.output_audit
mapping_transformationsfunction
output_auditfunction
vaft.code.gacode.result_identity
collection_recordfunction
digestfunction
encodefunction
input_value_statusfunction
parametersfunction
plainfunction
prepare_targetfunction
preserve_time_semanticsfunction
read_native_inputfunction
vaft.code.gacode.tglf
MAX_SPECIESdata
plasma_formalismfunction
TGLF_DEFAULT_SCALARSdata
TGLF_DEFAULT_SPECIESdata
TGLFConfigclass
TGLFResultclass
vaft.code.gacode.tglf.inputs
bound_derivfunction
LocalConversionErrorclass
prepare_tglf_casefunction
prepare_tglf_inputfunction
read_local_inputfunction
tglf_parametersfunction
TGLFInputclass
TGLFInputsclass
TGLFNormalisationclass
write_input_tglffunction
vaft.code.gacode.tglf.outputs
collect_tglf_outputsfunction
FIELD_SPECTRUM_COLUMNSdata
FLUX_SPECTRUM_FIELDSdata
FLUX_SPECTRUM_QUANTITIESdata
GBFLUX_QUANTITIESdata
INTENSITY_MOMENTSdata
SCHEMAdata
SCHEMA_VERSIONdata
TglfOutputsclass
vaft.code.gacode.tglf.runner
read_tglf_casefunction
run_tglffunction
run_tglf_casefunction
TGLFExecutionErrorclass
vaft.code.gacode.tglf.spectral
closure_splitfunction
ClosureSplitclass
flux_decompositionfunction
FluxDecompositionclass
ky_integration_weightsfunction
LINEAR_RTOLdata
QLA_OTHERdata
RECONSTRUCTION_RTOLdata
sat3_qla_factorsfunction
vaft.code.gacode.tglf.surrogate
DOMAIN_MEASUREdata
DomainAuditclass
ModelContractErrorclass
ModelIdentityclass
ModelResolutionErrorclass
SurrogateErrorclass
SurrogateMetadataclass
SurrogatePredictionclass
TrainingDomainErrorclass
vaft.code.gacode.tglf.surrogate.domain
audit_featuresfunction
audit_training_domainfunction
build_featuresfunction
DEFAULT_DOMAIN_THRESHOLDdata
vaft.code.gacode.tglf.surrogate.inference
ensemble_predictfunction
run_surrogatefunction
vaft.code.gacode.tglf.surrogate.resolver
available_modelsfunction
KNOWN_DEVICESdata
load_metadatafunction
METADATA_FILESdata
MODELS_COMPATIBILITY_ENVSdata
MODELS_HOME_ENVdata
parse_model_namefunction
resolve_modelfunction
vaft.code.genray.config
GENRAY_HOME_ENVdata
GENRAY_HOME_EXECUTABLEdata
GENRAYConfigclass
GENRAYInputsclass
GENRAYResultclass
vaft.code.genray.inputs
eccone_anglesfunction
EQDSK_NAMEdata
GENRAY_INPUT_NAMEdata
genray_namelistsfunction
prepare_genray_inputsfunction
PROVENANCE_NAMEdata
render_namelistsfunction
vaft.code.genray.outputs
collect_genray_outputsfunction
EC_WAVE_TYPEdata
genray_to_wavesfunction
RAY_STOP_REASONSdata
read_genray_netcdffunction
vaft.code.genray.runner
find_genray_executablefunction
runfunction
run_genrayfunction
vaft.code.gpec
audit_coil_field_phasefunction
BRZPHI_COMPONENTSdata
BrzphiHarmonicsclass
coil_filaments_from_coil_infunction
CoilInputSpecclass
CoilPhaseAuditclass
collect_gpec_suite_outputsfunction
DCON_PRODUCTS_FOR_GPECdata
dcon_scan_rowfunction
DconCoordinatesclass
DconEdgeScanclass
DconEigenfunctionclass
DconEquilibriumclass
DconEvaluationclass
DCONOptionsclass
DconOutputclass
emit_coil_datfunction
find_gpec_executablefunction
format_gfile_header_for_gpecfunction
GPEC_HOME_ENVdata
GpecAsciiOutputclass
GpecAsciiSectionclass
GpecAsciiTableclass
GPECCaseInputsclass
GpecCoilFilamentsclass
GpecControlOutputclass
GpecCylindricalOutputclass
GpecIdealResultclass
GPECModuleRunclass
GpecProfileOutputclass
GPECSuiteConfigclass
GPECSuiteResultclass
IdealGPECOptionsclass
JACOBIAN_NAMESdata
ordering_state_for_casefunction
PENTRC_COLLISION_OPERATORSdata
PENTRC_IMPURITY_SPECIESdata
PENTRC_ION_SPECIESdata
PENTRC_MODULEdata
pentrc_output_namefunction
PENTRCOptionsclass
peq_jacobianfunction
peq_toroidal_anglefunction
Pest3MatchingOutputclass
prepare_gpec_suite_casefunction
prepare_pentrc_runfunction
PRIOR_PENTRC_INPUTdata
RDCONOptionsclass
read_brzphi_harmonicsfunction
read_coil_controlfunction
read_coil_infunction
read_dcon_outputfunction
read_dcon_scanfunction
read_gpec_asciifunction
read_gpec_netcdffunction
read_gpec_profile_outputfunction
read_gpec_responsefunction
read_gpec_singcoupfunction
read_namelist_groupfunction
read_pest3_matching_outputfunction
read_resonant_tablefunction
read_solutions_binfunction
resolve_coil_inputsfunction
run_gpec_suite_casefunction
run_pentrcfunction
SCAN_COLUMNSdata
scan_pentrc_logfunction
stage_coil_datafunction
stage_dcon_productsfunction
STRIDEOptionsclass
THRESHOLD_PENTRC_INPUTdata
validate_dcon_resultfunction
validate_pentrc_inputsfunction
validate_threshold_inputsfunction
write_coil_infunction
write_threshold_pentrc_inputfunction
vaft.code.mitim.availability
mitim_availabilityfunction
MITIMAvailabilityclass
PROBEdata
STATUSESdata
vaft.code.mitim.compare
compare_neo_fluxesfunction
compare_tglf_inputsfunction
effective_tglf_controlsfunction
neo_input_chargesfunction
neo_local_to_profile_normalisationfunction
PHYSICS_KEYSdata
read_input_neofunction
read_input_tglffunction
vaft.code.mitim.config
MITIM_CODESdata
MITIM_PYTHON_ENVdata
mitim_user_configfunction
MITIMConfigclass
MITIMResultclass
SUPPORTED_MITIM_VERSIONSdata
VAFT_MACHINEdata
vaft.code.mitim.coordinates
r_over_a_atfunction
rho_tor_norm_atfunction
vaft.code.mitim.drivers.neo_smoke
mainfunction
vaft.code.mitim.drivers.portals_closed_loop
mainfunction
vaft.code.mitim.drivers.portals_tglf_closed_loop
mainfunction
vaft.code.mitim.drivers.tglf_local_inputs
mainfunction
vaft.code.mitim.drivers.tglf_run
mainfunction
split_by_radiusfunction
vaft.code.mitim.portals
closed_loop_reportfunction
ClosedLoopReportclass
NO_EARLY_STOPdata
run_portals_closed_loopfunction
vaft.code.mitim.runner
mitim_tglf_local_inputsfunction
run_mitim_driverfunction
run_mitim_neofunction
run_mitim_tglffunction
run_neo_smokefunction
vaft.code.nice.config
NiceConfigclass
NiceDiagnosticclass
NiceInputsclass
NiceResultclass
vest_reference_parameter_filefunction
vaft.code.nice.diagnostics
diagnostics_from_odsfunction
vaft.code.nice.geometry
geometry_hashfunction
nice_geometry_from_odsfunction
validate_contourfunction
vaft.code.nice.inputs
prepare_nice_inputsfunction
vaft.code.nice.outputs
collect_nice_outputsfunction
vaft.code.nice.response
active_responsefunction
vaft.code.nice.runner
NICE_HOME_ENVdata
resolve_nice_executablefunction
run_nicefunction
vaft.code.nice.study
assert_same_physical_channelsfunction
compare_diagnostic_residualsfunction
compare_equilibriafunction
constraint_family_configsfunction
lcfs_rms_displacementfunction
physical_channel_signaturefunction
run_nice_windowfunction
summarize_windowfunction
write_study_reportfunction
write_window_reportfunction
vaft.code.nice.validate_reference
mainfunction
vaft.code.nubeam
build_plasma_statefunction
input_plasma_state_namefunction
NUBEAM_NAMELISTSdata
run_nubeam_odsfunction
stage_nubeam_namelistsfunction
StagedNamelistsclass
vaft.code.nubeam.config
NUBEAM_GENERATOR_EXECUTABLEdata
NUBEAM_HOME_ENVdata
NUBEAM_HOME_EXECUTABLEdata
NUBEAM_LONGEST_OUTPUT_SUFFIXdata
NUBEAM_PATH_BUFFER_CHARSdata
NUBEAM_UPDATE_STATE_EXECUTABLEdata
NUBEAMConfigclass
workdir_budgetfunction
vaft.code.nubeam.inputs
check_workdir_lengthfunction
inputf_runidfunction
inputf_state_filenamefunction
NUBEAMCaseclass
NUBEAMInputErrorclass
NUBEAMInputsclass
packaged_vest_casefunction
PACKAGED_VEST_CASE_DIRdata
PACKAGED_VEST_CASE_GFILEdata
prepare_nubeam_inputsfunction
rewrite_inputf_equilibriumfunction
vaft.code.nubeam.outputs
collect_nubeam_outputsfunction
LOST_PARTICLE_FIELDSdata
NUBEAMBirthMarkersclass
NUBEAMFluxSurfaceAveragesclass
NUBEAMLostParticlesclass
NUBEAMOutputsclass
NUBEAMPowerBalanceclass
NUBEAMRadialGridclass
NUBEAMResultclass
parse_power_balancefunction
PROFILE_DESCRIPTIONSdata
vaft.code.nubeam.plasma_state
check_spec_against_namelistsfunction
count_beamsfunction
GENERATOR_MAX_BEAMSdata
GENERATOR_MAX_GAS_SOURCESdata
GENERATOR_MAX_IONSdata
GENERATOR_MAX_POINTSdata
ion_densities_from_zefffunction
legacy_case_specfunction
LegacyProfilesclass
PLASMA_STATE_NAMELISTdata
PlasmaStateInputErrorclass
PlasmaStateProfilesclass
PlasmaStateSpecclass
PROFILE_COORDINATESdata
profiles_from_core_profilesfunction
read_legacy_profilesfunction
read_shot_configurationfunction
render_plasma_state_namelistfunction
ShotConfigurationclass
spec_from_odsfunction
vaft.code.nubeam.runner
find_nubeam_executablefunction
find_plasma_state_generatorfunction
find_update_state_executablefunction
generate_plasma_statefunction
nubeam_homefunction
NUBEAMExecutionErrorclass
run_nubeamfunction
run_nubeam_casefunction
vaft.code.pentrc.outputs
energy_profilefunction
PentrcFormatErrorclass
PentrcOutputclass
PROFILE_VARIABLESdata
read_pentrc_outputfunction
TORQUE_GRIDSdata
TORQUE_LONG_NAMEdata
TORQUE_METHODSdata
torque_profilefunction
TORQUE_QUANTITIESdata
vaft.code.remote
FETCH_ALLdata
FETCH_NONEdata
RemoteHostclass
RemoteSlurmBackendclass
UNFORWARDED_ENVIRONMENTdata
vaft.code.resources
cgroup_usage_mbfunction
memory_budgetfunction
MEMORY_BUDGET_ENVdata
MEMORY_ENV_VARIABLESdata
MemoryBudgetclass
MemoryBudgetExceededclass
MemoryBudgetInfoclass
peak_rss_mbfunction
rss_mbfunction
vaft.code.slurm
exported_environmentfunction
LIVE_STATESdata
SCRATCH_DIRECTORYdata
SlurmBackendclass
TIMEOUT_STATESdata
walltimefunction
vaft.code.snakemake
init_snakemake_loggerfunction
vaft.code.tes
limited_iso_pointsfunction
vaft.code.tes.config
TESConfigclass
TESInputsclass
TESResultclass
vaft.code.tes.inputs
prepare_tes_inputsfunction
write_tes_cinputfunction
write_tes_namelistfunction
vaft.code.tes.outputs
collect_tes_outputsfunction
parse_result_coilsfunction
parse_result_scalarsfunction
vaft.code.tes.runner
run_tesfunction
TES_COMPATIBILITY_ENVdata
TES_HOME_ENVdata
TES_HOME_EXECUTABLEdata
vaft.code.tes.scan
scan_tesfunction
vaft.code.tokamaker
reference_axis_pressurefunction
vaft.code.tokamaker.bridge
fit_free_boundary_coils_vfixedfunction
fit_vfixed_samplesfunction
VFixedFitResultclass
vaft.code.tokamaker.closure
compare_equilibriafunction
fixed_to_freefunction
FixedToFreeResultclass
vaft.code.tokamaker.config
TokaMakerConfigclass
TokaMakerEvolutionInputsclass
TokaMakerEvolutionResultclass
TokaMakerInputsclass
TokaMakerResultclass
TokaMakerStabilityResultclass
TokaMakerStepRecordclass
vaft.code.tokamaker.evolve
EVOLVE_NL_TOLdata
run_tokamaker_evolutionfunction
vaft.code.tokamaker.free_boundary
CaseStatusclass
CoilControlclass
FreeBoundaryCaseResultclass
FreeBoundaryScanclass
FreeBoundaryScanResultclass
scanfunction
ScanCaseclass
vaft.code.tokamaker.geometry
geometry_signaturefunction
split_coil_namesfunction
tokamaker_geometry_from_odsfunction
vaft.code.tokamaker.inputs
prepare_tokamaker_evolution_inputsfunction
prepare_tokamaker_inputsfunction
resolve_mesh_filefunction
vaft.code.tokamaker.mesh
build_tokamaker_meshfunction
vaft.code.tokamaker.outputs
collect_tokamaker_evolution_outputsfunction
collect_tokamaker_outputsfunction
collect_tokamaker_stability_outputsfunction
EVOLUTION_SIDECAR_NAMEdata
parse_stats_sidecarfunction
SIDECAR_NAMEdata
STABILITY_SIDECAR_NAMEdata
vaft.code.tokamaker.profiles
equilibrium_to_tokamaker_profilesfunction
TokaMakerProfilesclass
vaft.code.tokamaker.refinement
prepare_shape_refinementfunction
ShapeRefinementclass
vaft.code.tokamaker.runner
run_tokamakerfunction
vaft.code.tokamaker.scan
scan_tokamakerfunction
vaft.code.tokamaker.stability
run_tokamaker_vertical_stabilityfunction
run_tokamaker_wall_eigenmodesfunction
vaft.code.tokamaker.topology
classify_boundaryfunction
LimiterContactclass
ScanTopologyclass
TopologyReportclass
vaft.code.tokamaker.vessel
vessel_segments_from_odsfunction
vaft.code.transp.config
collect_transp_outputsfunction
OUTPUT_SUFFIXdata
RUNID_PATTERNdata
TRANSPResultclass
vaft.code.transp.outputs
EMPTY_PLACEHOLDERSdata
PROFILE_GRIDSdata
read_transp_outputfunction
TIME_DIMENSIONSdata
TranspFormatErrorclass
TranspOutputclass
TranspSliceclass
TranspVariableclass
VARIABLE_DESCRIPTIONSdata
vaft.code.transp.profiles
DEFAULT_TARGET_GRIDdata
exb_frequencyfunction
kinetic_profiles_from_slicefunction
PROFILE_SOURCESdata
read_transp_profilesfunction
TRANSP_UNIT_LADDERdata
vaft.code.transp.torque
enclosed_torquefunction
input_torque_densityfunction
zone_volumefunction

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: float
  • closed_bonus: float
  • positive_r_fraction: float
  • positive_r_rule: str
  • positive_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 | str
  • args: 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: Path
  • files: 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: Path
  • stdout: str
  • stderr: str
  • logs: tuple[Path, ...]
  • outputs: Mapping[str, tuple[Path, ...]]
  • parsed: Any
  • runtime_status: str
  • elapsed_s: Optional[float]
  • ok property 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
  • run method — Run the configured external code. source

RunOutcome

class source
RunOutcome()

status and timed_out for a result that carries runtime_status.

2 members
  • status property — "completed" when the result is usable (ok), else "failed". source
  • timed_out property — The program was stopped by a limit, or never started: time, queue or memory (#1460). source

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 | str
  • target_psin: float
  • relax: float
  • output: str
  • nideal: Optional[int]
  • nw: int
  • nh: Optional[int]
  • ns: Optional[int]
  • nt: Optional[int]
  • npsi: Optional[int]
  • nchi: Optional[int]
  • epslon_exponent: int
  • q_constraint_psi_norm: Optional[float]
  • ncscal: int
  • edge_zero: bool
  • boundary_smoothing: str
  • boundary_fft_num: int
  • boundary_contour_policy: BoundaryContourPolicy
  • auto_cocos: bool
  • output_cocos: str
  • preserve_boundary_limiter: bool
  • create_plot: bool
  • cleanup: bool
  • env: Mapping[str, str]
  • args: Sequence[str]
  • timeout: Optional[float]
  • backend: Optional['ExecutionBackend']
  • resolved_mesh property — The solver mesh written to the namelist: the NIDEAL default, overridden by whichever of ns/nt/npsi/nchi are set. source
  • resolved_nh property — The NZBOX written to the namelist: nh, or nw for a square box. source
  • resolved_nideal property — The NIDEAL written 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: Path
  • source: Any
  • input_geqdsk: Path | None
  • expeq: Path | None
  • namelist: Path | None
  • geqdsk: Any
  • files: 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.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]

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: Path
  • input_geqdsk: Path | None
  • refined_geqdsk: Path | None
  • refined_ods: Any
  • logs: tuple[Path, ...]
  • manifests: tuple[Path, ...]
  • figures: tuple[Path, ...]
  • outputs: Mapping[str, tuple[Path, ...]]
  • comparison: Mapping[str, float]
  • stdout: str
  • stderr: str
  • materialized: Optional['CHEASEMaterializedInput']
  • runtime_status: str
  • elapsed_s: Optional[float]
  • ok property 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: float
  • psi_boundary: float
  • dpsi: float
  • bcentr: float
  • current: float
  • fpol_median: float
  • q_median: float
  • ffprim_median: float
  • pprime_median: float
  • dpsi_sign property source
  • bcentr_sign property source
  • current_sign property source
  • fpol_sign property source
  • q_sign property source
  • as_dict method 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: EquilibriumVariation
  • workdir: Path
  • result: Optional[CHEASEResult]
  • error: Optional[str]
  • shape: Optional[tuple[float, float, float, float]]
  • target_psin: Optional[float]
  • boundary: Optional[Contour]
  • shape_parameters: Mapping[str, float]
  • converged property — 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: str
  • pressure_scale: float
  • current_peaking: float
  • elongation_scale: float
  • triangularity_shift: float
  • boundary: Optional[Contour]
  • reshapes_boundary property — 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: str
  • reason: str | None
  • spec: ZeroDimensionalEquilibriumSpec
  • target: str
  • requested: Mapping[str, float]
  • achieved: Mapping[str, float]
  • residuals: Mapping[str, float]
  • boundary: Any
  • source_profiles: Mapping[str, np.ndarray]
  • chease: Optional[CHEASEResult]
  • refined_geqdsk: Optional[Path]
  • refined_ods: Any
  • achieved_profiles: Mapping[str, np.ndarray]
  • ok property 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: float
  • minor_radius: float
  • elongation: float
  • triangularity: float
  • toroidal_field: float
  • plasma_current: float
  • vertical_position: float
  • squareness: float
  • pressure_fraction: float
  • pressure_alpha: float
  • pressure_beta: float
  • current_alpha: float
  • current_beta: float
  • pressure_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: str
  • reason: Optional[str]
  • spec: ZeroDimensionalEquilibriumSpec
  • targets: Mapping[str, float]
  • imposed: Optional[str]
  • assignment: Mapping[str, TargetKnob]
  • tolerances: Mapping[str, float]
  • history: list
  • record: Optional[TargetIterationRecord]
  • reachable: Mapping[str, tuple]
  • ok property source
  • result property — The single-target synthesis of the reported solve. source
  • final_spec property source
  • achieved property source
  • residuals property source
  • iterations property source
  • table method — Requested vs achieved per target (achieved None when 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: 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]
  • ok property 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: str
  • lower: float
  • upper: float
  • logarithmic property — Shape exponents act multiplicatively, so they are iterated in log. source
  • clip method source
  • to_unit method — The knob value as a coordinate in [0, 1] across its bounds (clipped). source
  • from_unit method — Inverse of to_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.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

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: float
  • aminor_max: float
  • rcntr_min: float
  • rcntr_max: float
  • zcntr_min: float
  • zcntr_max: float
  • rcurrt_min: float
  • rcurrt_max: float
  • zcurrt_min: float
  • zcurrt_max: float
  • elong_min: float
  • elong_max: float
  • li_min: float
  • li_max: float
  • betap_max: float
  • betat_max: float
  • qstar_min: float
  • qstar_max: float
  • qout_min: float
  • qout_max: float
  • sepin_check: float
  • gapin_min: float
  • gapout_min: float
  • gaptop_min: float
  • plasma_diff: float
  • dbpli_diff: float
  • delbp_diff: float
  • to_namelist method — The &incheck keys, in the spelling EFIT reads. source
  • to_dict method source
  • sha256 property 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: str
  • sigma_floor: float
  • sigma_floor_families: tuple[str, ...]
  • legacy_vbit: float
  • legacy_weight_scale: float
  • use_diamagnetic_flux: bool
  • diamagnetic_flux_sign: str
  • diamagnetic_flux_input_units: str
  • wall_current_mode: str
  • passive_structure_mode: str
  • use_coil_relation_constraints: bool
  • coil_constraint_matrix: tuple[tuple[float, ...], ...] | None
  • coil_constraint_targets: tuple[float, ...] | None
  • nccoil: 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: float
  • zzero: float
  • minor_radius: float
  • elongation: float
  • current_threshold: float
  • icinit: int | None
  • ellipse_rzero: float | None
  • seed_rzero property — 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: float
  • error_tolerance: float
  • measurement_error_floor: float
  • max_iterations: int
  • error_minimum: float | None
  • chi_squared_target: float | None
  • convergence_mode: int | None
  • inner_iterations: int | None
  • termination_keys method — The &IN1 keys 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: int
  • kffcur: int
  • kppfnc: int
  • kfffnc: int
  • pcurbd: int
  • fcurbd: int
  • fwtbp: 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: EFITProfileConfig
  • initialization: EFITInitializationConfig
  • numerics: EFITNumericsConfig
  • constraints: EFITConstraintConfig
  • to_dict method — Return a sorted, JSON-compatible resolved representation. source
  • from_dict classmethod — Rebuild a validated configuration from to_dict output. source
  • sha256 property — 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 | str
  • nw: int
  • nh: int
  • rleft: float
  • rright: float
  • zbotto: float
  • ztop: float
  • igrid: int
  • ifcoil: int
  • ivesel: int
  • iecoil: int
  • iacoil: int
  • islpfc: int
  • isize: int
  • nsmp2: int
  • mgaus1: int
  • mgaus2: int
  • device: str
  • executable: Optional[str]
  • env: Mapping[str, str]
  • timeout: Optional[float]
  • stack_size_kb: int | str | None
  • backend: Optional['ExecutionBackend']
  • table_suffix property — The <nw><nh> EFUND appends to grid-sized table names. source
  • argv property — EFUND’s command-line arguments: nw and, when different, nh. source
  • in5 method — The &in5 namelist values. source
  • to_dict method — The scientific content only: no paths, executable, or timeouts. source
  • sha256 property 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: Path
  • mhdin: Path
  • mhdin_sha256: str
  • geometry: EFUNDGeometry
  • counts: 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: Path
  • status: str
  • reason: str
  • files: dict[str, Path]
  • expected: dict[str, Optional[int]]
  • problems: tuple[str, ...]
  • executable: Optional[Path]
  • logs: tuple[Path, ...]
  • stdout: str
  • stderr: str
  • manifest: Optional[Path]
  • ok property 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.

7 fields · 2 members
  • cumulative: int
  • chi2: float
  • error: float
  • axis_z: float
  • dz: float
  • outer: int | None
  • inner: int | None
  • to_dict method source
  • from_dict classmethod source

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: str
  • numbering: Mapping[str, Any]
  • provenance: Mapping[str, Any]
  • schema: str
  • schema_version: int
  • times property source
  • at_time method — The slice nearest time (seconds); KeyError if none is within tolerance. source
  • to_dict method source
  • from_dict classmethod source
  • write_json method — Write the history as JSON; NaN is written as null. 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: float
  • iterations: tuple[EFITIteration, ...]
  • time_ms: int | None
  • exit_path: str | None
  • iconvr: int | None
  • accepted: bool | None
  • collapsed: bool | None
  • failures: tuple[Mapping[str, Any], ...]
  • warnings: tuple[Mapping[str, Any], ...]
  • solver_errors: tuple[Mapping[str, Any], ...]
  • sources: tuple[str, ...]
  • mfile: str | None
  • notes: tuple[str, ...]
  • iterations_n property source
  • cumulative property source
  • chi2 property source
  • error property source
  • axis_z property source
  • dz property source
  • to_dict method source
  • from_dict classmethod 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: 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
  • from_sequence classmethod — The legacy positional list, in its documented order. source
  • coerce classmethod 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.

8 fields · 4 members
  • 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
  • probe method source
  • flux_loop method source
  • from_sequence classmethod source
  • coerce classmethod source

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 | str
  • shot: Optional[int]
  • time_ms: Optional[float]
  • encoding: str
  • scales: Sequence[float]
  • grid_size: int
  • ti_te_ratio: Any
  • ti_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: Path
  • ods: Any
  • geqdsk: Any
  • base_kfile_text: str
  • points: 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: Path
  • gfile: Optional[Path]
  • scale: Optional[float]
  • converged: bool
  • chi2: Optional[float]
  • status: str
  • reason: str
  • efit_result: Any
  • ok property 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: 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]
  • time_seconds property source
  • block method 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: 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
  • outer_iteration: int | None
  • total_iteration: int | None
  • status: int | None
  • condin: float | None
  • condno: float | None
  • nrow property source
  • ncol property source
  • nexact property source
  • solver_residual property — 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: 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, ...]

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: str
  • condin: float | None
  • cutoff_multipliers: tuple[float, ...]
  • resolved_multiple: float
  • unresolved_multiple: float
  • independent_norm_fraction: float
  • reinforcing_weak_lift: float
  • reinforcing_trace_reduction: float
  • overwhelmed_objective_share: float
  • core_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: 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
  • to_dict method — 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 | None
  • reconstructed: float | None
  • solve_residual: float | None
  • vessel_current_sum: float | None
  • predicted_vcurrt_chi2: float | None
  • reported_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: 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

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: 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]

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: 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

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: 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

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 | str
  • shot: 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 | None
  • initialization: EFITInitializationConfig
  • numerics: EFITNumericsConfig
  • constraints: EFITConstraintConfig
  • provenance: Mapping[str, Any]
  • ordering_state: Mapping[str, Any]
  • export_linearization: bool
  • direction_constraint: Path | str | None
  • restart_from: Path | str | None
  • write_restart: bool
  • iteration_history: str
  • backend: Optional['ExecutionBackend']
  • scientific_config method — 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: Path
  • ods: Any
  • geqdsk: Any
  • kfiles: 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: 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]
  • ods: Any
  • status: str
  • reason: str
  • slice_statuses: tuple[EFITSliceStatus, ...]
  • configuration: Mapping[str, Any]
  • linearization_files: tuple[Path, ...]
  • linearizations: tuple[EFITLinearization, ...]
  • restart_file: Path | None
  • diagnostic_errors: tuple[str, ...]
  • iteration_history: EFITIterationHistory | None
  • iteration_history_file: Path | None
  • ok property source
  • usable property — 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: str
  • description: str
  • scientific: EFITScientificConfig
  • sigma_floor property — The configuration’s relative sigma floor (constraints.sigma_floor). source
  • floor_families property source
  • prepare_constraints method — A copy of ods with this preset’s sigma floor applied, and what it changed. source
  • record method — 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: 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]
  • provenance: Mapping[str, Any]
  • usable property source
  • to_dict method — Return a JSON-compatible representation. source
  • from_dict classmethod — Restore a status serialized by to_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: bool
  • require_mfile: bool
  • pressure_negative_tolerance: float
  • stored_energy_negative_tolerance: float
  • li_range: tuple[float, float]
  • beta_range: tuple[float, float]
  • q_absolute_range: tuple[float, float]
  • volume_range: tuple[float, float]
  • minimum_boundary_area: float
  • maximum_axis_step: float | None
  • maximum_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: str
  • path: str
  • sha256: str
  • size: int
  • mtime: str
  • build_revision: str | None
  • build_root: str | None
  • as_dict method 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
  • run method — 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: Path
  • env: Mapping[str, str]
  • stdin: Optional[str]
  • timeout: Optional[float]
  • log_path: Optional[Path]
  • resources: ResourceRequest
  • label: 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: str
  • stderr: str
  • timed_out: bool
  • elapsed_s: float
  • launcher: tuple[str, ...]
  • log_path: Optional[Path]
  • job_id: Optional[str]
  • runtime_status: str
  • run_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

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: int
  • threads_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 | str
  • processes: 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: int
  • scale_bt: int
  • source_cocos: int
  • target_cocos: int
  • psi_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: Path
  • task: str
  • command: tuple[str, ...]
  • stdout: str
  • stderr: str
  • runtime_status: str
  • elapsed_s: Optional[float]
  • ok property 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: str
  • bulk_description: str
  • fluid_model: str | None
  • kinetic_equation: str | None
  • kinetic_coupling: str | None
  • kinetic_population: tuple[str, ...] | None
  • distribution_formulation: str | None
  • orbit_representation: str | None
  • spatial_domain: str | None
  • topology_domain: str | None
  • regime: str | None
  • field_model: str | None
  • derived_from: str | None
  • solver: str | None
  • extensions: Mapping[str, Any]
  • as_dict method — A stable, JSON-ready dict: every field present, None kept, versioned. source
  • to_json method — as_dict as canonical JSON (sorted keys), for hashing and storage. source
  • from_dict classmethod — Rebuild a record from as_dict output; 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 | str
  • args: Sequence[str]
  • env: Mapping[str, str]
  • timeout: Optional[float]
  • backend: Optional['ExecutionBackend']
  • home: Optional[str]
  • platform: Optional[str]
  • n_mpi: int
  • n_omp: int
  • memory_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).

2 members

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 | str
  • args: Sequence[str]
  • env: Mapping[str, str]
  • timeout: Optional[float]
  • backend: Optional['ExecutionBackend']
  • home: Optional[str]
  • platform: Optional[str]
  • n_mpi: int
  • n_omp: int
  • memory_mb: Optional[int]
  • n_energy: int
  • n_xi: int
  • n_theta: int
  • n_radial: int
  • n_toroidal: int
  • ky: float
  • box_size: int
  • nonlinear: bool
  • field_model: str
  • collision_model: int
  • delta_t: float
  • delta_t_method: int
  • max_time: float
  • freq_tol: float
  • print_step: int
  • restart: bool
  • extra_parameters: Mapping[str, Any]
  • n_field property source
  • regime property source
  • resolution method — 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: Path
  • stdout: str
  • stderr: str
  • logs: tuple[Path, ...]
  • outputs: Mapping[str, tuple[Path, ...]]
  • parsed: Any
  • runtime_status: str
  • elapsed_s: Optional[float]
  • outputs_native: Optional[Any]
  • provenance: Mapping[str, Any]
  • executed property source
  • ok property source
  • qualified property 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.ndarray
  • records: numpy.ndarray
  • theta_indices: numpy.ndarray
  • time: numpy.ndarray
  • theta: numpy.ndarray
  • kx: numpy.ndarray
  • ky: numpy.ndarray
  • radial_start: int
  • metadata: collections.abc.Mapping[str, typing.Any]
  • read method — 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: 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]]
  • n_species property source
  • normalisation property source
  • z_eff property — sum(n_i Z_i^2)/n_e over the species list – what CGYRO computes. source
  • missing method — 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: Path
  • files: tuple[Path, ...]
  • ods: Any
  • local: 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: str
  • grid: 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_time property — Native elapsed time, unchanged and restart-aligned like time. source
  • time_normalization property — Verified SI scales from native output; unavailable scales raise ValueError. source
  • gyrokinetic_elapsed_time_s property — Elapsed seconds from the solver origin, never a discharge timestamp. source
  • ky property — |k_y rho_s| per toroidal mode. source
  • nonlinear property source
  • final_frequency property — Native omega at the last print step, per toroidal mode. source
  • final_growth_rate property source
  • frequency_ion_negative property — Final omega with the ion diamagnetic direction negative, as TGLF writes it. source
  • converged property — CGYRO’s linear frequency met FREQ_TOL before MAX_TIME. source
  • decayed property — The field decayed below CGYRO’s 1e-12 floor and the run stopped. source
  • solved property — No error, a finished kernel, and finite physics at the end of the run. source
  • flux_time_trace method — (n_species, 3, n_time): fluxes summed over fields and toroidal modes. source
  • time_average_flux method — (n_species, 3) time average over [t0, t1] in a/c_s. source
  • align_records method — A raw time-history array (time on the last axis) aligned to time. source
  • missing method source
  • to_dict method source
  • from_dict classmethod source
  • write_json method source
  • read_json classmethod 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: float
  • electron_temperature_j: float
  • reference_mass_kg: float
  • sound_speed_m_s: float
  • source: str
  • from_equilibrium classmethod — Read native a_meters, temp_norm [keV], mass_norm [1e-27 kg], vth_norm [m/s]. source
  • from_normalisation classmethod — Use an explicit TGLFNormalisation shared with the CGYRO local input. source
  • from_metadata classmethod — Restore available serialized scales, rejecting a contradictory saved factor. source
  • gyrokinetic_time_scale_s property — One native a/c_s unit in seconds. source
  • metadata method — 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: Path
  • files: tuple[Path, ...]
  • ods: Any
  • profile: 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 | str
  • args: Sequence[str]
  • env: Mapping[str, str]
  • timeout: Optional[float]
  • backend: Optional['ExecutionBackend']
  • home: Optional[str]
  • platform: Optional[str]
  • n_mpi: int
  • n_omp: int
  • memory_mb: Optional[int]
  • n_energy: int
  • n_xi: int
  • n_theta: int
  • n_radial: int
  • rmin_over_a: float
  • rmin_over_a_2: float
  • collision_model: int
  • profile_model: int
  • profile_erad0_model: int
  • rotation_model: int
  • spitzer_model: int
  • equilibrium_model: int
  • ipccw: int
  • btccw: int
  • n_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: Path
  • stdout: str
  • stderr: str
  • logs: tuple[Path, ...]
  • outputs: Mapping[str, tuple[Path, ...]]
  • parsed: Any
  • runtime_status: str
  • elapsed_s: Optional[float]
  • outputs_native: Optional[Any]
  • provenance: Mapping[str, Any]
  • ok property 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: Path
  • files: tuple[Path, ...]
  • ods: Any
  • profile: 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: int
  • n_energy: int
  • n_xi: int
  • n_theta: int
  • theta: np.ndarray
  • n_radial: int
  • r_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.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

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: str
  • grid: 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_species property source
  • bootstrap_current property — NEO’s own drift-kinetic <j_par B>, normalised. source
  • effective_charge property — Z_eff as this run’s own species list implies it, per radius. source
  • ion_density_fraction property — sum(n_i)/n_e from this run’s species list, per radius. source
  • trapped_fraction property — The trapped fraction NEO computed from the surface geometry. source
  • solved property — Whether NEO completed the problem it was asked to solve. source
  • describe method — What a transported quantity means and how it is normalised. source
  • missing method — Products this run did not write, so absent never reads as zero. source
  • to_dict method — A JSON-ready payload that from_dict reads back exactly. source
  • from_dict classmethod source
  • write_json method source
  • read_json classmethod 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 | str
  • args: Sequence[str]
  • env: Mapping[str, str]
  • timeout: Optional[float]
  • backend: Optional['ExecutionBackend']
  • home: Optional[str]
  • platform: Optional[str]
  • n_mpi: int
  • n_omp: int
  • memory_mb: Optional[int]
  • sat_rule: int
  • use_transport_model: bool
  • geometry_flag: int
  • use_bper: bool
  • use_bpar: bool
  • n_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: Path
  • stdout: str
  • stderr: str
  • logs: tuple[Path, ...]
  • outputs: Mapping[str, tuple[Path, ...]]
  • parsed: Any
  • runtime_status: str
  • elapsed_s: Optional[float]
  • outputs_native: Optional[Any]
  • provenance: Mapping[str, Any]
  • ok property 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: 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]
  • names: Sequence[str]
  • normalisation: Optional['TGLFNormalisation']
  • provenance: Mapping[str, Mapping[str, Any]]
  • n_species property source
  • missing method — Names this input records as unavailable, in provenance order. source
  • check_tglf_requirements method — 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: Path
  • files: tuple[Path, ...]
  • ods: Any
  • local: 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: float
  • electron_temperature: float
  • sound_speed: float
  • gyroradius: float
  • minor_radius: float
  • b_unit: float
  • particle_flux property — Gamma_GB [m^-2 s^-1]. source
  • energy_flux property — Q_GB [W m^-2]. source
  • momentum_flux property — Pi_GB [J m^-2], which is TGYRO’s own label for it. source
  • exchange_power property — 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: str
  • gbflux: 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_species property source
  • energy_flux property — Gyro-Bohm normalised energy flux per species, electrons first. source
  • particle_flux property source
  • growth_rate property — Linear growth rate (ky, mode) in c_s/a, from the eigenvalue spectrum. source
  • frequency property — Real frequency (ky, mode) in c_s/a; TGLF’s sign convention, unlabelled. source
  • solved property — Whether TGLF completed the problem it was asked to solve. source
  • missing method — Fields this run did not produce, in declaration order. source
  • to_dict method source
  • from_dict classmethod source
  • write_json method source
  • read_json classmethod 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: str
  • reason: str
  • linear_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: str
  • reason: str
  • relative_error: Optional[float]
  • tolerance: float
  • sat_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]
  • validated property source
  • integrated method — (species, field, 5) ky-integrated, mode-summed totals of flux (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.

8 fields · 2 members
  • model: str
  • z_scores: Mapping[str, float]
  • threshold: float
  • violations: tuple[str, ...]
  • max_abs_z: float
  • assumed: tuple[str, ...]
  • measure: str
  • bounds_available: bool
  • in_domain property source
  • summary method — One line a refusal message or a log can carry verbatim. source

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: str
  • directory: str
  • members: tuple[str, ...]
  • sha256: Mapping[str, str]
  • resolved_by: str
  • format: str
  • sat_rule: Optional[int]
  • electromagnetic: Optional[bool]
  • devices: tuple[str, ...]
  • tags: tuple[str, ...]
  • upstream_version: Optional[str]
  • alternatives: tuple[str, ...]
  • physics_source: str
  • ensemble_size property 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.ndarray
  • xsigma: np.ndarray
  • ym: np.ndarray
  • ysigma: np.ndarray
  • requires_base_model_outputs property — 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: ModelIdentity
  • domain: DomainAudit
  • features: Mapping[str, float]
  • provenance: Mapping[str, Any]
  • qualified property — Whether this prediction rests on an input the model was trained for. source
  • relative_spread method — 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: str
  • time: float
  • time_tolerance: float
  • beam_index: int
  • harmonic: int
  • power_w: Optional[float]
  • zeff: Optional[float]
  • minimum_temperature_ev: Optional[float]
  • n_rho: int
  • max_steps: int
  • max_reflections: int
  • namelist_overrides: Mapping[str, Mapping[str, Any]]
  • executable: Optional[str]
  • workdir: Path | str
  • env: Mapping[str, str]
  • timeout: Optional[float]
  • backend: Optional['ExecutionBackend']
  • ioxm property 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: Path
  • genray_in: Path
  • eqdsk: Path
  • provenance: 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: Path
  • stdout: str
  • stderr: str
  • netcdf: Optional[Path]
  • parsed: Any
  • provenance: dict[str, Any]
  • runtime_status: str
  • elapsed_s: Optional[float]
  • ok property — Exit 0, a genray.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.ndarray
  • values: np.ndarray
  • region: np.ndarray
  • n_tor: int | None
  • modes: 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: str
  • currents_a: tuple[float, ...]
  • from_excitation classmethod 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: int
  • coil_in: str
  • coil_brzphi: str
  • machine: str
  • coil_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.

6 fields · 3 members
  • jacobian: str
  • power_bp: Optional[float]
  • power_b: Optional[float]
  • power_r: Optional[float]
  • mpsi: Optional[int]
  • mtheta: Optional[int]
  • from_attrs classmethod source
  • to_dict method source
  • from_dict classmethod source

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.ndarray
  • q: np.ndarray
  • dW: np.ndarray
  • from_dataset classmethod source
  • peak_search_start method — Index of the first entry DCON’s peak search looks at. source
  • q_edge_start method — DCON’s qedgestart = INT(q(psiedge)), recovered exactly from the scan. source
  • to_dict method source
  • from_dict classmethod 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.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
  • amplitude property — |xi . grad(psi)| per (harmonic, step), preserving the NaN padding. source
  • b_normal method — Normal perturbed field per (harmonic, step), complex. source
  • to_dict method source
  • from_dict classmethod 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_attrs classmethod — Build from a dataset’s global attributes, or None if it carries none of them. source
  • to_dict method source
  • from_dict classmethod 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: str
  • mercier property — Whether di/dr may be read as physics. source
  • ballooning property — Whether ca1 may be read as physics. source
  • requested_psiedge property — The psiedge the run asked for, with DCON’s default filled in. source
  • from_run_dir classmethod source
  • to_dict method source
  • from_dict classmethod 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: bool
  • qhigh: float
  • psiedge: float
  • mer_flag: bool
  • bal_flag: bool
  • thmax0: float
  • con_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: int
  • mlow: int
  • mhigh: int
  • mpert: int
  • mband: int
  • psi_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]
  • plasma1 property — Least-stable plasma-response energy eigenvalue (dcon/free.f’s plasma1). source
  • vacuum1 property source
  • total1 property — Least-stable total-energy eigenvalue – dcon/free.f’s total1, the W_t_eigenvalue entry labelled by mode 1. source
  • edge_treatment property — Which of DCON’s two edge solutions this output describes. source
  • m_pol_dominant property — The poloidal mode number carrying the largest peak |xi . grad(psi)|. source
  • stable_free_boundary property — Free-boundary stability from sign(Re(total1)) (dcon/dcon.f:306-314). source
  • to_dict method source
  • from_dict classmethod source
  • write_json method source
  • read_json classmethod 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: str
  • description: str
  • version: str
  • notes: tuple[str, ...]
  • attrs: dict[str, Any]
  • sections: tuple[GpecAsciiSection, ...]
  • unparsed: tuple[tuple[int, str], ...]
  • path: str
  • titles property source
  • section method — The first section with this exact title. source
  • sections_named method — Every section with this title – gpec_response repeats “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: str
  • tables: tuple[GpecAsciiTable, ...]
  • legend: tuple[str, ...]
  • table property — 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.ndarray
  • header: dict[str, Any]
  • column method — One column by its file name. source
  • complex_column method — real(name) and imag(name) combined, without reinterpreting them. source
  • complex_names property — Names that appear as a real/imag column pair. source
  • to_dict method — 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: int
  • time_ms: int | str | None
  • geqdsk: Path
  • workdir: Path
  • coil_in: Path | None
  • dcon_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.ndarray
  • coil_names: tuple[str, ...]
  • machine: str
  • source_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: 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]
  • 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_total property — 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: int
  • R: np.ndarray
  • z: np.ndarray
  • l: 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: GpecControlOutput
  • cylindrical: Optional[GpecCylindricalOutput]
  • source_paths: dict[str, str]
  • n_tor property source
  • from_netcdf classmethod — Read a run directory’s control (required), cylindrical and profile files. source
  • to_dict method — JSON-safe transcript of the control output plus source provenance. source
  • write_json method 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: str
  • mode: int
  • workdir: Path
  • returncode: Optional[int]
  • status: str
  • reason: str
  • logs: 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]]
  • formalism property — The vaft.code.formalism.PlasmaFormalism of this run, or None. source
  • ok property — 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: int
  • machine: str
  • shot: int
  • time: float
  • version: str
  • helicity: 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_rational property — Number of rational surfaces in the file. source
  • m_rational property — Resonant poloidal mode number n * q at each rational surface. source
  • resonant_table method — 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 | None
  • executable_dir: Path | str | None
  • modules: Sequence[str]
  • modes: Sequence[int]
  • run_mode: str
  • templates_dir: Path | str | None
  • coil_data_dir: Path | str | None
  • psilow: float
  • psihigh: float
  • verify_outputs: bool
  • timeout: Optional[float]
  • env: Mapping[str, str]
  • ordering_state: Mapping[str, Any]
  • dcon: DCONOptions
  • rdcon: RDCONOptions
  • stride: STRIDEOptions
  • gpec: IdealGPECOptions
  • backend: 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: Path
  • shot: int | None
  • time_ms: int | str | None
  • records: tuple[GPECModuleRun, ...]
  • logs: tuple[Path, ...]
  • outputs: Mapping[str, tuple[Path, ...]]
  • stdout: str
  • stderr: str
  • parsed: Any
  • input_equilibrium_sha256: str
  • ok property 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: bool
  • ascii_flag: Optional[bool]
  • xclebsch_flag: Optional[bool]
  • coil_specs: Optional[Sequence['CoilInputSpec']]
  • machine: str
  • coil_config: Optional[Mapping[str, 'CoilSet3D']]
  • ip_direction: Optional[str]
  • bt_direction: Optional[str]
  • singthresh_flag: bool
  • singthresh_callen_flag: bool
  • singthresh_slayer_flag: bool
  • singthresh_slayer_inpr: Optional[float]
  • singthresh_slayer_inpr_prof: Optional[Sequence[float]]
  • writes_pentrc_input property — Whether this run will leave the ASCII displacement PENTRC reads. source
  • wants_callen_threshold property — Whether this run will compute Callen’s critical width [-]. source
  • wants_slayer_threshold property — Whether this run will compute SLAYER’s critical resonant field [-]. source
  • wants_any_threshold property — 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: str
  • impurity: str
  • collision_operator: str
  • bounce_harmonics: int
  • moment: str
  • electron: bool
  • psi_limits: Optional[tuple[float, float]]
  • grids: Sequence[str]
  • artificial_factors: Optional[Mapping[str, float]]
  • data_dir: str
  • threads: int
  • output_ascii: bool
  • output_netcdf: bool
  • species_namelist property — The four pentrc.in species 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: str
  • n_tor: int
  • mlow: int
  • mhigh: int
  • mpert: int
  • mband: int
  • m: 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]
  • msing property source
  • delta_prime_diagonal method — The single-surface (diagonal) classical Delta-prime per rational surface. source
  • rational_surface_stability method — One row per rational surface: diagonal Delta-prime and the local criteria there. source
  • stable property — Free-boundary-style stability from sign(Re(total1)), when available. source
  • to_dict method source
  • from_dict classmethod source
  • write_json method source
  • read_json classmethod 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: float
  • z_eff: Optional[float]
  • ln_lambda: Optional[float]
  • has_kinetic_profiles property 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: str
  • detail: str
  • python: Optional[str]
  • python_version: Optional[str]
  • version: Optional[str]
  • revision: Optional[str]
  • root: Optional[str]
  • portals: bool
  • gacode_root: Optional[str]
  • gacode_platform: Optional[str]
  • gacode_revision: Optional[str]
  • supported_versions: tuple[str, ...]
  • ready property source
  • as_dict method 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: int
  • timeout: Optional[float]
  • backend: Optional['ExecutionBackend']
  • env: Mapping[str, str]
  • verbose_level: int
  • interpreter method — 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: Path
  • stdout: str
  • stderr: str
  • runtime_status: str
  • elapsed_s: Optional[float]
  • result: Optional[Mapping[str, Any]]
  • record: Mapping[str, Any]
  • ok property — The driver exited 0 and reported success in result.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.

main

function source
main(argument_file)

vaft.code.mitim.drivers.portals_closed_loop

PORTALS/powertorch synthetic closed loop with a manufactured source (#1588 C1).

main

function source
main(argument_file)

vaft.code.mitim.drivers.portals_tglf_closed_loop

PORTALS (TGLF + NEO) synthetic closed loop with a manufactured source (#1588 C1b).

main

function source
main(argument_file)

vaft.code.mitim.drivers.tglf_local_inputs

MITIM’s own TGLF local inputs at exact r/a, written but not run (#1588 A2).

main

function source
main(argument_file)

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: float
  • recovery_error: float
  • final_flux_error: float
  • sign_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: str
  • workdir: Path | str
  • parameter_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: int
  • cocos_out: int
  • major_radius: float
  • include_plasma_current: bool
  • include_flux_loops: bool
  • include_bpol_probes: bool
  • include_diamagnetic_flux: bool
  • disabled_channels: tuple[str, ...]
  • diagnostic_source: str
  • correct_active_response: bool
  • flux_loop_input_sign: float
  • default_bpol_uncertainty: float
  • default_flux_uncertainty: float
  • default_ip_uncertainty: float
  • default_diamagnetic_uncertainty: float
  • passive_currents: Optional[tuple[float, ...]]
  • passive_current_mode: str
  • backend: 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: str
  • ods_path: str
  • identifier: str
  • geometry: Mapping[str, Any]
  • value: float
  • uncertainty: float
  • normalization: float
  • enabled: bool
  • reason: str
  • original_value: Optional[float]
  • conditioned_value: Optional[float]
  • weight: float
  • passive_response: float
  • active_response_correction: float
  • original_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: 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

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: Path
  • process_succeeded: bool
  • converged: Optional[bool]
  • scientifically_usable: Optional[bool]
  • termination_reason: str
  • nonlinear_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: str
  • stderr: str
  • parsing_errors: tuple[str, ...]
  • provenance: Mapping[str, Any]
  • ods: Any
  • runtime_status: str
  • elapsed_s: Optional[float]
  • ok property 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.

main

function source
main()

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: Path
  • files: tuple[Path, ...]
  • mdescr: Path
  • sconfig: Path
  • state_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 | str
  • args: Sequence[str]
  • env: Mapping[str, str]
  • timeout: Optional[float]
  • backend: Optional['ExecutionBackend']
  • runid: str
  • repeat_count: str
  • postproc: str
  • frantic: bool
  • frantic_zones: int
  • preact_dir: Optional[Path]
  • adas_dir: Optional[Path]
  • generator_executable: Optional[str]
  • update_state_executable: Optional[str]
  • nptcls: Optional[int]
  • path_buffer_chars: int
  • workdir_budget property — 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: Path
  • gfile: 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: Path
  • files: tuple[Path, ...]
  • ods: Any
  • inputf: Optional[Path]
  • gfile: Optional[Path]
  • plasma_state: Optional[Path]
  • runid: str
  • manifests: 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: Path
  • species: str
  • count: int
  • columns: 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: Any
  • gm1: Any
  • gm5: Any
  • at_zone_centres method — 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.

3 fields · 2 members
  • path: Path
  • count: int
  • columns: Mapping[str, Any]
  • prompt property — Boolean mask selecting the prompt-loss markers. source
  • channel_counts method — Marker counts per loss channel. source

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: Path
  • runid: 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: int
  • describe method — 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: str
  • entries: Mapping[str, float]
  • residual: Optional[float]
  • injected property — Injected power [W], the quantity everything else is a fraction of. source
  • sinks method — Loss and heating channels, as positive watts. source
  • fractions method — 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
  • rho: Any
  • volume: Any
  • area: Any
  • zone_volume property — Volume of each zone [m^3], one per profile point. source
  • zone_area property — Cross-sectional area of each zone [m^2], one per profile point. source
  • rho_centres property — Zone centres, which is where a zone-averaged profile belongs. source

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: Path
  • stdout: str
  • stderr: str
  • logs: tuple[Path, ...]
  • outputs: Mapping[str, tuple[Path, ...]]
  • parsed: Any
  • runtime_status: str
  • elapsed_s: Optional[float]
  • outputs_native: Optional[NUBEAMOutputs]
  • ok property 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: PlasmaStateProfiles
  • beam_power_w: tuple[float, ...]
  • beam_energy_kev: tuple[float, ...]
  • edge_neutral_density: float
  • neutral_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.ndarray
  • ne: np.ndarray
  • te_kev: np.ndarray
  • ti_kev: np.ndarray
  • zeff: np.ndarray
  • ion_densities: tuple[np.ndarray, ...]
  • coordinate: str
  • omegat: 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: Path
  • sconfig: Path
  • gfile: Path
  • profiles: PlasmaStateProfiles
  • beam_power_w: tuple[float, ...]
  • beam_energy_kev: tuple[float, ...]
  • t0: float
  • t1: float
  • runid: str
  • output_name: str
  • edge_neutral_density: float
  • neutral_energy_kev: tuple[float, ...]
  • recycling: tuple[int, ...]
  • nrho: int
  • nth_eq: int
  • bdy_crat: float
  • nmom: int
  • limiter_from_geqdsk: bool
  • label: 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: Path
  • n_tor: int
  • attrs: dict
  • close method — Release the underlying dataset. source
  • dataset property — The open xarray dataset. source
  • available method — Every (method, grid) pair this run actually wrote, sorted. source
  • psi_norm method — The radial grid one calculation was written on [-]. source
  • profile_psi_norm method — The psi_n grid the equilibrium and kinetic profiles sit on [-]. source
  • profile method — One equilibrium or kinetic profile, in PENTRC’s own units. source
  • complex_quantity method — One (psi, ell) complex array, unsummed. source
  • long_name method — The long_name PENTRC gave one variable, or "". source
  • ell method — 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: str
  • work_root: str
  • user: 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: bool
  • rsync_options: tuple[str, ...]
  • ssh_executable: str
  • rsync_executable: str
  • target property — user@host or just host: the ssh and rsync destination. source
  • ssh_prefix method — The ssh command up to but not including the destination. source
  • ssh_argv method — Full argv to run one shell command on the host. source
  • rsync_prefix method — The rsync command up to but not including the paths. source
  • remote method — path as the host sees it; return a destination string for rsync. source
  • remote_path method — local under the first matching path_maps pair, else None. source
  • translate method — One command argument with any mapped path prefix rewritten. source
  • translate_value method — One environment value, treating it as a :-separated path list. source
  • forwarded_environment method — env with submitting-machine-only names dropped and paths translated. source
  • from_environment classmethod — Build a host from VAFT_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.

2 members
  • from_environment classmethod — Build a backend from VAFT_REMOTE_* and VAFT_SLURM_* variables. source
  • run method source

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_mb property — fraction x limit_mb, or None without a limit. source
  • sample method — Read RSS now and fold it into peak_mb; never raises. source
  • usage method — The memory in use that the budget is compared against, in MiB (also folds RSS into the peaks). source
  • start_interval method — Start a new interval_peak_mb window; returns the one that ended. source
  • check method — Raise MemoryBudgetExceeded if RSS is above the threshold. source
  • as_dict method — 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_dict method — 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.

3 members
  • from_environment classmethod — Build a backend from VAFT_SLURM_* variables. source
  • resolved_mode method — "step" or "batch": what run would do right now. source
  • run method source

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 | str
  • env: Mapping[str, str]
  • timeout: Optional[float]
  • niter: int
  • restart: Optional[str]
  • emit_namelist: bool
  • shot: Optional[int]
  • time: Optional[float]
  • constraint_source: str
  • time_index: Optional[int]
  • mag_diagnostics: int
  • mse_diagnostics: int
  • nr: int
  • nz: int
  • rmin: float
  • rmax: float
  • zmin: float
  • zmax: float
  • init_r0: float
  • init_z0: float
  • init_a0: float
  • prof_type: int
  • ip0_kA: Optional[float]
  • major_r: float
  • bt0: Optional[float]
  • betap: Optional[float]
  • betap_type: int
  • alpha_p_a: float
  • alpha_p_b: float
  • alpha_f_a: float
  • alpha_f_b: float
  • nflux: int
  • ntheta: int
  • gps: float
  • relax_sor: float
  • relax_shp: float
  • tikhonov_factor: float
  • errtol_loop: float
  • errtol_shape: float
  • fix_shape: int
  • flux_linkage: tuple[int, float]
  • nxpt: int
  • xpr: 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: float
  • limiter_spacing: Optional[float]
  • coil_model: str
  • shape_coils: tuple[str, ...]
  • eddy: bool
  • backend: Optional['ExecutionBackend']
  • limited_shape_control classmethod — Hold a limited boundary by re-fitting the outer PF coils. source
  • legacy_double_null classmethod — 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: Path
  • cinput: Path
  • ods: Any
  • namelist: 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: Path
  • gfile: Optional[Path]
  • afile: Optional[Path]
  • result_file: Optional[Path]
  • bndry: Optional[Path]
  • logs: tuple[Path, ...]
  • stdout: str
  • stderr: str
  • geqdsk: tuple[Any, ...]
  • ods: Any
  • scalars: Mapping[str, Any]
  • runtime_status: str
  • elapsed_s: Optional[float]
  • ok property 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.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
  • fixed_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: 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
  • refined_comparison: Mapping[str, Any]
  • refined_currents_A: Mapping[str, float]
  • refinement_status: str | None
  • refinement_diagnostics: Mapping[str, Any]
  • verified_free: TokaMakerResult | None
  • verified_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 | str
  • nthreads: int
  • quiet: bool
  • maxits: Optional[int]
  • urf: Optional[float]
  • nl_tol: Optional[float]
  • shot: Optional[int]
  • time: Optional[float]
  • constraint_source: str
  • time_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: float
  • alpha_f_a: float
  • alpha_f_b: float
  • alpha_p_a: float
  • alpha_p_b: float
  • nprof: int
  • profile_mode: str
  • profile_equilibrium: Any
  • profile_tables: Optional[Mapping[str, Any]]
  • init_equilibrium: Any
  • init_r0: float
  • init_z0: float
  • init_a0: float
  • init_kappa: float
  • init_delta: float
  • order: int
  • mesh_file: Optional[Path | str]
  • dx_plasma: float
  • dx_coil: float
  • dx_vacuum: float
  • limiter: 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: bool
  • vessel_currents: bool
  • dx_conductor: float
  • dx_conductor_min: float
  • eta_vessel: float
  • vessel_eta: Optional[Mapping[str, float]]
  • vessel_noncontinuous: tuple[str, ...]
  • exclude_vessel_segments: tuple[str, ...]
  • vessel_min_thickness: float
  • vessel_gap: float
  • vsc_coil: Optional[str]
  • vsc_weight: float
  • split_coils: tuple[str, ...]
  • evolve_times: Optional[Sequence[float]]
  • evolve_start: Optional[float]
  • evolve_end: Optional[float]
  • evolve_dt: Optional[float]
  • evolve_on_failure: str
  • evolve_vacuum: bool
  • evolve_eddy: bool
  • evolve_field_probes: Optional[Sequence[tuple[float, float]]]
  • wall_neigs: int
  • td_neigs: int
  • td_omega: float
  • td_include_bounds: bool
  • td_damping_scale: float
  • eqdsk_nr: int
  • eqdsk_nz: int
  • eqdsk_lcfs_pad: float
  • eqdsk_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: TokaMakerInputs
  • times: tuple[float, ...]
  • coil_waveforms: Mapping[str, Any]
  • ip_targets: Any
  • vacuum: 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: Path
  • times: tuple[float, ...]
  • steps: tuple[TokaMakerStepRecord, ...]
  • gfiles: tuple[Path, ...]
  • sidecar_file: Optional[Path]
  • mesh_file: Optional[Path]
  • error: str
  • ods: Any
  • scalars: Mapping[str, Any]
  • ok property 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: 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
  • files: 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: Path
  • gfile: Optional[Path]
  • stats_file: Optional[Path]
  • mesh_file: Optional[Path]
  • error: str
  • logs: tuple[Path, ...]
  • geqdsk: tuple[Any, ...]
  • ods: Any
  • scalars: Mapping[str, Any]
  • verified_free: Optional['TokaMakerResult']
  • ok property 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: Path
  • tau_wall_s: tuple[float, ...]
  • gamma_s: Optional[float]
  • eig_file: Optional[Path]
  • stats_file: Optional[Path]
  • gfile: Optional[Path]
  • error: str
  • scalars: Mapping[str, Any]
  • ok property 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: int
  • time: float
  • converged: bool
  • error: str
  • gfile: 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: str
  • mode: str
  • values: tuple[float, ...]
  • apply method 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: str
  • index: int
  • status: CaseStatus
  • requested: 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: bool
  • refinement_history: tuple[Mapping[str, Any], ...]
  • gfile: Optional[Path]
  • manifest: Optional[Path]
  • error: str
  • report: Optional[TopologyReport]
  • ok property 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.

2 members
  • dry_run method — Materialize case directories and manifests without solving. source
  • run method — Execute the scan with one TokaMaker instance across all cases. source

FreeBoundaryScanResult

class source
FreeBoundaryScanResult(workdir: Path, cases: tuple[FreeBoundaryCaseResult, ...], manifest: Path) -> None

Also exported as vaft.code.FreeBoundaryScanResult, vaft.code.tokamaker.FreeBoundaryScanResult.

3 fields · 2 members
  • workdir: Path
  • cases: tuple[FreeBoundaryCaseResult, ...]
  • manifest: Path
  • succeeded property source
  • failed property source

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: str
  • index: int
  • requested: Mapping[str, Mapping[str, float]]
  • commanded: Mapping[str, float]
  • workdir: Path
  • config: TokaMakerConfig
  • config_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.ndarray
  • pprime: np.ndarray
  • ffprime: np.ndarray
  • axis_pressure_Pa: float
  • edge_pressure_Pa: float
  • ip_A: float | None
  • solver_tables method — 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.ndarray
  • saddle_points_m: np.ndarray
  • reference_currents_A: Mapping[str, float]
  • current_bounds_A: Mapping[str, tuple[float, float]]
  • regularization: float
  • current_scale_A: float
  • isoflux_weight: float
  • saddle_weight: float
  • xpoint_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: float
  • z: float
  • wall_r: float
  • wall_z: float
  • distance: float
  • side: 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: ScanTopology
  • x_points: tuple[Mapping[str, float], ...]
  • d_r_sep: Optional[float]
  • null_margin: Optional[float]
  • limiter_contact: Optional[LimiterContact]
  • active_tolerance: float
  • near_null_band: float
  • contact_tolerance: Optional[float]
  • reason: Optional[str]
  • representation: Any
  • to_dict method 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: Path
  • stdout: str
  • stderr: str
  • logs: tuple[Path, ...]
  • outputs: Mapping[str, tuple[Path, ...]]
  • parsed: Any
  • runtime_status: str
  • elapsed_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: Path
  • close method source
  • variables property source
  • dims property source
  • units method — The file’s own units attribute, stripped; "" when it has none. source
  • long_name method source
  • describe method — What a variable is, or a note that this adapter does not catalogue it. source
  • grid_of method — Which radial grid a variable is on, from its dimension name. source
  • variable method — One variable, materialized and cached. source
  • time property — The scalar time base [s]. source
  • time_index method — Index of the sample nearest time_s. source
  • slice method — The run at the sample nearest time_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: float
  • time_index: int
  • x: np.ndarray
  • xb: np.ndarray
  • units method source
  • describe method source
  • grid_of method source
  • variable method — One variable at this time, in the file’s own units. source
  • on_x method — A zone-centre variable, refusing a zone-boundary one. source
  • on_xb method — A zone-boundary variable, refusing a zone-centre one. source
  • psi_norm_xb property — 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.

5 fields · 2 members
  • name: str
  • dims: tuple[str, ...]
  • units: str
  • long_name: str
  • values: np.ndarray
  • grid property — "X", "XB" or None – from the dimension name. source
  • is_profile property source

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.

results matching ""

    No results matching ""