diff --git a/imas_validator/assets/rulesets/efitpp_code/__init__.py b/imas_validator/assets/rulesets/efitpp_code/__init__.py new file mode 100644 index 0000000..df8b10b --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp_code/__init__.py @@ -0,0 +1 @@ +"""Folder for bundled code-specific IMAS-Validator tests""" diff --git a/imas_validator/assets/rulesets/efitpp_code/magnetics.py b/imas_validator/assets/rulesets/efitpp_code/magnetics.py new file mode 100644 index 0000000..86531cb --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp_code/magnetics.py @@ -0,0 +1,52 @@ +"""Required fields of EFIT++ in the magnetics IDS""" + +@validator("magnetics") +def validate_required_fields(ids): + """Validate that the magnetics IDS has required fields.""" + + # Magnetic field probes + for b_field_pol_probe in ids.b_field_pol_probe: + # machine description + assert b_field_pol_probe.name.has_value + assert b_field_pol_probe.identifier.has_value + assert b_field_pol_probe.position.r.has_value + assert b_field_pol_probe.position.z.has_value + assert b_field_pol_probe.position.phi.has_value + assert b_field_pol_probe.poloidal_angle.has_value + # toroidal angle is not read by EFIT++? + # assert b_field_pol_probe.toroidal_angle.has_value + if b_field_pol_probe.type.index == 2: # 'Mirnov probe' + assert b_field_pol_probe.area.has_value + assert b_field_pol_probe.length.has_value + assert b_field_pol_probe.turns.has_value + # diagnostic data + assert b_field_pol_probe.field.data.has_value + assert b_field_pol_probe.field.data_error_upper.has_value + assert b_field_pol_probe.field.data.coordinates[0].has_value + + # Flux loops + for flux_loop in ids.flux_loop: + # machine description + assert flux_loop.name.has_value + assert flux_loop.identifier.has_value + # position + for position in flux_loop.position: + assert position.r.has_value + assert position.z.has_value + assert position.phi.has_value + # diagnostic data + assert flux_loop.flux.data.has_value + assert flux_loop.flux.data_error_upper.has_value + assert flux_loop.flux.data.coordinates[0].has_value + + # Plasma current (reconstructed data) + for ip in ids.ip: + assert ip.data.has_value + assert ip.data_error_upper.has_value + assert ip.data.coordinates[0].has_value + + # Diamagnetic flux (reconstructed data) + for diamagnetic_flux in ids.diamagnetic_flux: + assert diamagnetic_flux.data.has_value + assert diamagnetic_flux.data_error_upper.has_value + assert diamagnetic_flux.data.coordinates[0].has_value diff --git a/imas_validator/assets/rulesets/efitpp_code/pf_active.py b/imas_validator/assets/rulesets/efitpp_code/pf_active.py new file mode 100644 index 0000000..bb8d907 --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp_code/pf_active.py @@ -0,0 +1,28 @@ +"""Required fields of EFIT++ in the pf_active IDS""" + +@validator("pf_active") +def validate_required_fields(ids): + """Validate that the pf_active IDS has required fields.""" + + # Axisymmetric poloidal field coils + for coil in ids.coil: + # machine description + assert coil.name.has_value + assert coil.identifier.has_value + for element in coil.element: + assert element.geometry.geometry_type in [2, 3, 5, 6] + assert element.turns_with_sign.has_value + + # data + assert coil.current.data.has_value + assert coil.current.data_error_upper.has_value + assert coil.current.data.coordinates[0].has_value + + # PF power supplies + for supply in ids.supply: + assert supply.name.has_value + assert supply.identifier.has_value + + # Circuits + for circuit in ids.circuit: + assert circuit.connections.has_value diff --git a/imas_validator/assets/rulesets/efitpp_code/pf_passive.py b/imas_validator/assets/rulesets/efitpp_code/pf_passive.py new file mode 100644 index 0000000..b0c398f --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp_code/pf_passive.py @@ -0,0 +1,17 @@ +"""Required fields of EFIT++ in the pf_passive IDS""" + +@validator("pf_passive") +def validate_required_fields(ids): + """Validate that the pf_passive IDS has required fields.""" + + # Axisymmetric passive conductors + for loop in ids.loop: + # machine description + assert loop.name.has_value + for element in loop.element: + assert element.geometry.geometry_type in [2, 3, 5, 6] + assert element.turns_with_sign.has_value + # data + assert loop.current.has_value + assert loop.current_error_upper.has_value + assert loop.current.coordinates[0].has_value diff --git a/imas_validator/assets/rulesets/efitpp_code/tf.py b/imas_validator/assets/rulesets/efitpp_code/tf.py new file mode 100644 index 0000000..c66824a --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp_code/tf.py @@ -0,0 +1,9 @@ +"""Required fields of EFIT++ in the tf IDS""" + +@validator("tf") +def validate_required_fields(ids): + """Validate that the tf IDS has required fields.""" + + # Vacuume field times major radius in the toroidal field magnet. + assert ids.b_field_tor_vacuum_r.data.has_value + assert ids.b_field_tor_vacuum_r.data.coordinates[0].has_value diff --git a/imas_validator/assets/rulesets/efitpp_code/wall.py b/imas_validator/assets/rulesets/efitpp_code/wall.py new file mode 100644 index 0000000..7c80c67 --- /dev/null +++ b/imas_validator/assets/rulesets/efitpp_code/wall.py @@ -0,0 +1,12 @@ +"""Required fields of EFIT++ in the wall IDS""" + +@validator("wall") +def validate_required_fields(ids): + """Validate that the wall IDS has required fields.""" + + # Wall limiter 2d + for description_2d in ids.description_2d: + # machine description + for unit in description_2d.limiter.unit: + assert unit.outline.r.has_value + assert unit.outline.z.has_value