astronomix.data_classes.simulation_helper_data module#
Geometric helper data for the simulation.
Bundles the precomputed per-cell geometry (cell centers, radii, volumes, cell
boundaries) used throughout the solver and the snapshot diagnostics, together
with the machinery to build only the fields the active subsystems actually need
(see HelperDataRequirements), optionally on the host, and to pad /
shard / unpad them for the time integrator.
- class astronomix.data_classes.simulation_helper_data.HelperData(geometric_centers: Array = None, volumetric_centers: Array = None, cell_centers_x: Array = None, cell_centers_y: Array = None, cell_centers_z: Array = None, r: Array = None, r_hat_alpha: Array = None, cell_volumes: Array = None, inner_cell_boundaries: Array = None, outer_cell_boundaries: Array = None)[source]#
Bases:
NamedTupleHelper data used throughout the simulation.
- cell_centers_x: Array#
1D arrays of cell centers along each Cartesian axis. Shape
(N_axis + 2 * ngc,). These broadcast against the state array so consumers that only need one axis (e.g. the frame tracker) avoid materialising the full meshgrid.
- cell_centers_y: Array#
Alias for field number 3
- cell_centers_z: Array#
Alias for field number 4
- cell_volumes: Array#
The cell volumes.
- geometric_centers: Array#
The geometric centers of the cells. For Cartesian
dimensionality > 1this is the full meshgrid of cell coordinates with shape(Nx, Ny[, Nz], dim). Subsystems that only need a single axis should prefercell_centers_x/cell_centers_y/cell_centers_zso the full meshgrid does not need to be materialised.
- inner_cell_boundaries: Array#
Coordinates of the inner cell boundaries.
- outer_cell_boundaries: Array#
Coordinates of the outer cell boundaries.
- r: Array#
cell center to box center distances only for config.dimensionality > 1
- r_hat_alpha: Array#
A helper variable, defined as hat{r}^alpha = V_j / (2 * alpha * pi * Delta r) with V_j the volume of cell j, alpha the geometry factor and Delta r the cell width.
- volumetric_centers: Array#
The volumetric centers of the cells. Same as the geometric centers for Cartesian geometry.
- class astronomix.data_classes.simulation_helper_data.HelperDataRequirements(needs_geometric_centers: bool = False, needs_volumetric_centers: bool = False, needs_cell_centers_x: bool = False, needs_cell_centers_y: bool = False, needs_cell_centers_z: bool = False, needs_r: bool = False, needs_r_hat_alpha: bool = False, needs_cell_volumes: bool = False, needs_inner_cell_boundaries: bool = False, needs_outer_cell_boundaries: bool = False)[source]#
Bases:
NamedTuplePer-field requirements for
HelperData.Each flag indicates whether the matching
HelperDatafield is consumed by any active subsystem (solver, physics module, snapshot calculator). Fields whose flag isFalseare left unmaterialised and stay at theHelperDatadefault ofNone.- needs_cell_centers_x: bool#
Alias for field number 2
- needs_cell_centers_y: bool#
Alias for field number 3
- needs_cell_centers_z: bool#
Alias for field number 4
- needs_cell_volumes: bool#
Alias for field number 7
- needs_geometric_centers: bool#
Alias for field number 0
- needs_inner_cell_boundaries: bool#
Alias for field number 8
- needs_outer_cell_boundaries: bool#
Alias for field number 9
- needs_r: bool#
Alias for field number 5
- needs_r_hat_alpha: bool#
Alias for field number 6
- needs_volumetric_centers: bool#
Alias for field number 1
- astronomix.data_classes.simulation_helper_data.get_helper_data(config: SimulationConfig, sharding: None | NamedSharding = None, padded: bool = False, requirements: None | HelperDataRequirements = None) HelperData[source]#
Generate the helper data for the simulation.
Only the fields requested by
requirementsare materialised; the rest stay at theHelperDatadefault ofNone. WhenrequirementsisNone(the default), all fields are built so that scripts usingget_helper_datato construct initial conditions keep working. The time integrator passes a config-derivedHelperDataRequirementsexplicitly so the in-simulation helper data is minimal.With
config.host_helper_data=Truethe arrays are built inside a CPU device context and only the requested fields are moved onto the target device (respectingshardingfor 3D Cartesiangeometric_centers). Fields needed only as intermediates (e.g. the fullX, Y, Zmeshgrid when onlyris requested) never materialise on the accelerator.