Skip to content

Add mapping for output core_transport to IMAS#2224

Open
MateoBell wants to merge 2 commits into
mainfrom
feature/imas-core-transport-output
Open

Add mapping for output core_transport to IMAS#2224
MateoBell wants to merge 2 commits into
mainfrom
feature/imas-core-transport-output

Conversation

@MateoBell

Copy link
Copy Markdown
Collaborator

No description provided.


# pylint: disable=invalid-name,unused-argument,too-many-positional-arguments
def core_transport_to_IMAS(
torax_config: model_config.ToraxConfig,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think again, the config is not used?

return ids


def _fill_metadata(ids: ids_toplevel.IDSToplevel):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to abstract the common parts of this to a function that can be used for multiple IDS?

_fill_metadata(ids)
ids.time = times

model_names = ["combined", "transport_solver", "neoclassical", "anomalous"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you retrieve these from the .keys() defined above?

for idx, model_name in enumerate(model_names):
model_node = ids.model[idx]
model_node.identifier.name = model_name
model_node.identifier.index = _IMAS_MODEL_ID_TO_IDENTIFIER_INDEX.get(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar comment if we actually need the index

model_name, 0
)

if model_name == "anomalous":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed to only fill in the turbulent transport models in the anomalous field here

"""Fills metadata in-place for the core_transport IDS."""
ids.ids_properties.comment = (
"IDS built from TORAX simulation transport coefficients. Grid based on "
"TORAX cell grid + boundaries."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar comment to core_sources, probably best to output quantities on face grid here (as that's where TORAX transport coefficients are computed)

]
if non_constant_names:
model_node.code.name = "+".join(non_constant_names)
elif not model_name == "constant":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be transport_cfg.model_name?

from torax._src.output_tools import post_processing
from torax._src.torax_pydantic import model_config

_IMAS_MODEL_ID_TO_IDENTIFIER_INDEX = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the values of this mapping are not used, does it need to be a mapping?


model_node.profiles_1d.resize(len(times))

for i in range(len(times)):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use enumerate here to get i and the t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants