You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Converts core_profiles IDS to a dict with the input profiles for the config.
56
59
Args:
57
-
ids: IDS object. Can be either core_profiles or plasma_profiles.
60
+
ids: IDS object. Can be either core_profiles or plasma_profiles. The IDS can contain several time slices.
58
61
read_psi_from_geo: Decides either to read psi from the geometry or from the input core/plasma_profiles IDS. Default value is True meaning that psi is taken from the geometry.
59
62
60
63
Returns:
@@ -65,16 +68,13 @@ def core_profiles_from_IMAS(
65
68
# numerics
66
69
t_initial=float(profiles_1d[0].time)
67
70
68
-
#plasma_composition (should be set in the config as user defined free parameter)
Takes the cell grid as a basis and converts values on face grid to cell.
134
136
Args:
137
+
config: TORAX config used for the simulation to get the names of the ions.
138
+
dynamic_runtime_params_slice: Used to get the ions fractions for the time slice used.
135
139
post_processed_outputs: TORAX post_processed_outputs with many useful data to output to the IDS.
136
140
state: A ToraxSimState object.
137
141
ids: Optional IDS object to be filled. Can be either core_profiles or plasma_profiles. Default is an empty core_profiles IDS. Note that both exists currently from Data Dictionary version 4, with plasma_profiles being the union of core_profiles and edge_profiles.
@@ -142,7 +146,7 @@ def core_profiles_to_IMAS(
142
146
cp_state=state.core_profiles
143
147
cs_state=state.core_sources
144
148
geometry=state.geometry
145
-
ids.ids_properties.comment="IDS built from TORAX sim output. Grid based on torax cell grid, used cell grid values and interpolated face grid values"
149
+
ids.ids_properties.comment="IDS built from TORAX sim output. Grid based on torax cell grid + boundaries."
ids.global_quantities.ion.resize(1) #Volume average Ti and ni only available for main ion (could be modified to define it for each of the main ions at least, and t_i_average for all ions, impurities included).
ids.global_quantities.ion[iion].n_i_volume_average[0] =post_processed_outputs.n_i_volume_avg*frac#Valid to do like this ? Volume average ni only available for main ion.
235
+
236
+
#Fill impurity quantities
237
+
#TODO: Include the impurity_mode from PR #1408 for the fractions calculations etc and impurity fractions stacked into core_profiles.
#Should we read z_ion_1d from charge_states.get_average_charge_state().Z_per_species ?
242
+
# ids.profiles_1d[0].ion[num_of_main_ions+iion].z_ion = np.mean(cp_state.Z_impurity_face) # Change to make it correspond to volume average over plasma radius
ids.global_quantities.ion[num_of_main_ions+iion].t_i_volume_average[0] =post_processed_outputs.T_i_volume_avg*1e3#Volume average Ti and ni only available for main ion.
ids.profiles_1d[0].j_ohmic=-1*post_processed_outputs.j_ohmic#TODO: Extend grid with boundaries : Need to find a way for these 2 as there is only values on cell grid for external current sources
239
264
ids.profiles_1d[0].j_non_inductive=-1*(sum(cs_state.psi.values()) +cs_state.bootstrap_current.j_bootstrap) # Extend grid with boundaries
0 commit comments