Skip to content

Commit 3a9eeb6

Browse files
hamelphiTorax team
authored andcommitted
Add fast ions to outputs.
PiperOrigin-RevId: 879024158
1 parent 23d0c01 commit 3a9eeb6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

torax/_src/output_tools/output.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,22 @@ def _save_core_profiles(
654654
coords={MAIN_ION: main_ions, TIME: self.times},
655655
name="main_ion_fractions",
656656
)
657+
# Handle fast ions
658+
first_fast_ions = self.core_profiles[0].fast_ions
659+
for i, first_fi in enumerate(first_fast_ions):
660+
source_key = f"{first_fi.source}_{first_fi.species}"
661+
n_data = np.stack([
662+
cp.fast_ions[i].n.cell_plus_boundaries() for cp in self.core_profiles
663+
])
664+
T_data = np.stack([
665+
cp.fast_ions[i].T.cell_plus_boundaries() for cp in self.core_profiles
666+
])
667+
xr_dict[f"n_fast_ion_{source_key}"] = self._pack_into_data_array(
668+
f"n_fast_ion_{source_key}", n_data
669+
)
670+
xr_dict[f"T_fast_ion_{source_key}"] = self._pack_into_data_array(
671+
f"T_fast_ion_{source_key}", T_data
672+
)
657673

658674
return xr_dict
659675

0 commit comments

Comments
 (0)