@@ -115,7 +115,7 @@ def plasma_composition_from_IMAS(
115115 ids : ids_toplevel .IDSToplevel ,
116116 t_initial : float | None = None ,
117117 excluded_impurities : Collection [str ] | None = None ,
118- main_ions_symbols : Collection [str ] = constants . HYDROGENIC_IONS ,
118+ main_ions_symbols : Collection [str ] | None = None ,
119119) -> Mapping [str , Any ]:
120120 """Returns dict with args for plasma_composition config from a given ids.
121121
@@ -137,12 +137,12 @@ def plasma_composition_from_IMAS(
137137 initial time will be the time of the first time slice of the ids. Else all
138138 time slices will be shifted such that the first time slice has time =
139139 t_initial.
140- excluded_impurities: Optional arg to specify which impurities from the IDS
141- should not be parsed.
140+ excluded_impurities: Optional arg to specify which impurities from the IDS
141+ should not be parsed.
142142 main_ions_symbols: collection of ions to be used to define the main_ion
143- mixture. If value is not the default one , will check that the given ions
144- exist in the IDS and their density is filled. Default are hydrogenic ions
145- H, D, T.
143+ mixture. If value is not None , will check that the given ions
144+ exist in the IDS and their density is filled. If not explicitly provided,
145+ will parse H, D, T as main ions .
146146
147147 Returns:
148148 The updated fields read from the IDS that can be used to completely or
@@ -160,7 +160,14 @@ def plasma_composition_from_IMAS(
160160 ]
161161 else :
162162 parsed_ions = [ion .name for ion in profiles_1d [0 ].ion if ion .density ]
163- _validate_ids_ions (parsed_ions , main_ions_symbols )
163+ # main_ions_symbols not explicitly provided: no validation of main ions and
164+ # value set to hydrogenic ions.
165+ if main_ions_symbols is None :
166+ main_ions_symbols = constants .HYDROGENIC_IONS
167+ validate_main_ions = False
168+ else :
169+ validate_main_ions = True
170+ _validate_ids_ions (parsed_ions , main_ions_symbols , validate_main_ions )
164171
165172 Z_eff = (
166173 time_array ,
@@ -227,6 +234,7 @@ def _get_time_and_radial_arrays(
227234def _validate_ids_ions (
228235 parsed_ions : list [str ],
229236 main_ion_symbols : Collection [str ],
237+ validate_main_ions : bool ,
230238) -> None :
231239 """Check if all ions are recognized and expected_main_ions present in the IDS."""
232240 # Check if IDS ion symbol is valid.
@@ -239,8 +247,8 @@ def _validate_ids_ions(
239247 "typing or add the ion to the excluded_impurities."
240248 )
241249 )
242- # Check presence of main_ion_symbols in the IDS if not default value .
243- if main_ion_symbols is not constants . HYDROGENIC_IONS :
250+ # Check presence of main_ion_symbols in the IDS if explicitly provided .
251+ if validate_main_ions :
244252 for ion in main_ion_symbols :
245253 if ion not in constants .ION_PROPERTIES_DICT .keys ():
246254 raise (
0 commit comments