synthesizer.particle.gas

A module for working with arrays of gas particles.

Contains the Gas class for use with particle based systems. This houses all the data detailing collections of gas particles. Each property is stored in (N_gas, ) shaped arrays for efficiency.

Extra optional properties can be set by providing them as keyword arguments.

Example usages:

gas = Gas(masses, metallicities,

redshift=redshift, coordinates=coordinates, …)

Classes

class synthesizer.particle.gas.Gas(masses, metallicities, star_forming=None, redshift=None, coordinates=None, velocities=None, smoothing_lengths=None, softening_lengths=None, dust_to_metal_ratio=None, dust_masses=None, verbose=False, centre=None, metallicity_floor=1e-05, tau_v=None, **kwargs)[source]

The particle Gas class.

This contains all data a collection of gas particles could contain. It inherits from the base Particles class holding attributes and methods common to all particle types, and from Component to provide distance calculations (e.g. get_angular_diameter_distance) that are needed for angular imaging.

The Gas class can be handed to methods elsewhere to pass information about the gas particles needed in other computations. A galaxy object should have a link to the Gas object containing its gas particles, for example.

Note that due to the wide range of possible properties and operations, this class has a large number of optional attributes which are set to None if not provided.

metallicities

The gas phase metallicity of each particle (integrated)

Type:

np.ndarray of float

star_forming

Flag for whether each gas particle is star forming or not.

Type:

np.ndarray of bool

log10metallicities

Convenience attribute containing log10(metallicity).

Type:

np.ndarray of float

smoothing_lengths

The smoothing lengths (describing the sph kernel) of each gas particle in simulation length units.

Type:

np.ndarray of float

dust_to_metal_ratio

The ratio between dust and total metal content in a gas particle. This can either be a single float or an array of values for each gas particle.

Type:

np.ndarray of float

dust_masses

The mass of dust in each particle in Msun.

Type:

unyt_quantity

star_forming

A boolean array indicating whether each gas particle is star forming or not.

Type:

np.ndarray of bool

calculate_dust_mass()[source]

Calculate dust mass from a given dust-to-metals ratio.

spatially_resample(resample_factor, kernel=None, seed=None, mask=None, attr_modes=None, velocity_dispersion=None)[source]

Resample this gas distribution spatially.

Each particle is replaced by resample_factor new particles whose positions are sampled from the SPH kernel centred on the original position. All standard Gas attributes and any extras registered at construction time (see _custom_attr_names) are harvested automatically.

Per-attribute resampling is controlled via attr_modes. See resample_by_mode() for the full list of supported modes.

Default modes per attribute:

  • masses, dust_masses"proportional" (sum conserved)

  • softening_lengths → scaled by resample_factor ** (-1/3) and tiled, like smoothing_lengths

  • all others → "duplicated" (children inherit parent value)

  • scalars (tau_v, dust_to_metal_ratio when not per-particle) → kept as-is

Warning

Optical depths need special treatment. Per-particle tau_v is duplicated by default, which is appropriate for simple dust-screen optical depths. If tau_v was derived from line-of-sight column densities, recompute the line-of-sight optical depths on the resampled distribution to remain self-consistent.

Parameters:
  • resample_factor (int) – Number of new particles per original particle (>= 2).

  • kernel (Kernel) – SPH kernel for position sampling (e.g. Kernel("cubic")). Required.

  • seed (int, optional) – Random seed for reproducibility.

  • mask (array-like, optional) – Boolean mask. True particles are resampled; False particles are kept unchanged.

  • attr_modes (dict, optional) – Override resampling mode for individual attributes. See resample_by_mode().

  • velocity_dispersion (float or unyt_quantity, optional) – Std. dev. of Gaussian velocity noise.

Returns:

A new Gas object with the resampled distribution.

Return type:

Gas