Skip to content

Add check that required terms are present in IMAS on load #1610

@theo-brown

Description

@theo-brown

I tried to load a JETTO IMAS geometry IDS and it threw a Pydantic ValidationError that was difficult to trace.

pydantic_core._pydantic_core.ValidationError: 1 validation error for ToraxConfig
  Value error, operands could not be broadcast together with shapes (70,) (0,)  [type=value_error, input_value={'plasma_composition': {}...alculator_type': 'chi'}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.11/v/value_error

After a bit of debugging, I found that it's due to a missing j_phi value in this line:

jtor = -1 * IMAS_data.profiles_1d.j_phi

Upstream, I'm making sure j_phi is present in JETTO IMAS outputs, so it shouldn't be an issue long-term. Nevertheless I think there are QoL changes we can make in TORAX to save time in future: we should add a check in all the IMAS loaders that asserts all the required profiles are there, and uses alternative definitions if they are not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions