Gas¶
A Gas component contains all information about the gaseous medium in a galaxy. Below we provide examples of particle Gas
objects, and how to initialise and interact with them.
We do not define a parametric Gas component in the current version of synthesizer.
Particle Gas¶
To initialise a Gas
object you always need to provide the particle masses and metallicities along with units. The toy example below shows how to initialise a Gas
object with 1000 particles.
[1]:
import numpy as np
from unyt import Mpc, Msun
from synthesizer.particle import Gas
gas = Gas(
masses=np.ones(1000) * 10**6 * Msun,
metallicities=np.random.rand(1000) * 0.02,
)
print(gas)
+-----------------------------------------------------------------------------------+
| GAS |
+----------------------------+------------------------------------------------------+
| Attribute | Value |
+----------------------------+------------------------------------------------------+
| nparticles | 1000 |
+----------------------------+------------------------------------------------------+
| metallicity_floor | 1.00e-05 |
+----------------------------+------------------------------------------------------+
| name | 'Gas' |
+----------------------------+------------------------------------------------------+
| dust_to_metal_ratio | 0.30 |
+----------------------------+------------------------------------------------------+
| masses (1000,) | 1.00e+06 Msun -> 1.00e+06 Msun (Mean: 1.00e+06 Msun) |
+----------------------------+------------------------------------------------------+
| metallicities (1000,) | 2.97e-07 -> 2.00e-02 (Mean: 1.01e-02) |
+----------------------------+------------------------------------------------------+
| dust_masses (1000,) | 8.91e-02 Msun -> 6.00e+03 Msun (Mean: 3.02e+03 Msun) |
+----------------------------+------------------------------------------------------+
| log10metallicities (1000,) | -6.53e+00 -> -1.70e+00 (Mean: -2.14e+00) |
+----------------------------+------------------------------------------------------+
Like all other components, a Gas
object also supports a number of predefined kwargs including (but not limited to) velocities
, coordinates
, smoothing_lengths
and dust_masses
or dust_to_metal_ratio
. In addition, you can also provide custom kwargs to store arbitrary properties. Below we’ll intialise arbitrary HII region properties for any gas particles that represent HII regions (hii_mass
, hii_metallicity
), but in reality these can be any properties describing the
gas particles.
[2]:
gas = Gas(
masses=np.ones(1000) * 10**6 * Msun,
metallicities=np.random.rand(1000) * 0.02,
dust_to_metal_ratio=0.25,
coordinates=np.random.rand(1000, 3) * 1 * Mpc,
centre=np.mean(np.random.rand(1000, 3) * 1, axis=0) * Mpc,
hii_mass=np.random.rand(1000) * 1e4 * Msun,
hii_metallicity=np.random.rand(1000) * 0.02,
)
print(gas)
+---------------------------------------------------------------------------------------+
| GAS |
+--------------------------------+------------------------------------------------------+
| Attribute | Value |
+--------------------------------+------------------------------------------------------+
| nparticles | 1000 |
+--------------------------------+------------------------------------------------------+
| metallicity_floor | 1.00e-05 |
+--------------------------------+------------------------------------------------------+
| name | 'Gas' |
+--------------------------------+------------------------------------------------------+
| dust_to_metal_ratio | 0.25 |
+--------------------------------+------------------------------------------------------+
| coordinates (1000, 3) | 9.63e-04 Mpc -> 1.00e+00 Mpc (Mean: 5.02e-01 Mpc) |
+--------------------------------+------------------------------------------------------+
| masses (1000,) | 1.00e+06 Msun -> 1.00e+06 Msun (Mean: 1.00e+06 Msun) |
+--------------------------------+------------------------------------------------------+
| centre | [0.49004691 0.49473499 0.50164326] Mpc |
+--------------------------------+------------------------------------------------------+
| metallicities (1000,) | 9.76e-06 -> 2.00e-02 (Mean: 1.01e-02) |
+--------------------------------+------------------------------------------------------+
| dust_masses (1000,) | 2.44e+00 Msun -> 4.99e+03 Msun (Mean: 2.52e+03 Msun) |
+--------------------------------+------------------------------------------------------+
| hii_mass (1000,) | 8.10e+30 kg -> 1.99e+34 kg (Mean: 1.03e+34 kg) |
+--------------------------------+------------------------------------------------------+
| hii_metallicity (1000,) | 2.44e-06 -> 2.00e-02 (Mean: 9.79e-03) |
+--------------------------------+------------------------------------------------------+
| centered_coordinates (1000, 3) | -5.00e-01 Mpc -> 5.10e-01 Mpc (Mean: 6.66e-03 Mpc) |
+--------------------------------+------------------------------------------------------+
| log10metallicities (1000,) | -5.01e+00 -> -1.70e+00 (Mean: -2.12e+00) |
+--------------------------------+------------------------------------------------------+
Once a Gas
object is initialised, it can be attached to a Galaxy
object and used in LOS calculations, or to analyse the gas distribution via maps or numerous other methods.
Default dust properties¶
You may have noticed that the original Gas
object we initialised automatically populated dust properties. This is because the dust_to_metal_ratio
is by default set to 0.3 if neither dust_masses
nor dust_to_metal_ratio
are provided. This default value is then used to calculate the dust masses from the gas metallicities. If a dust_to_metal_ratio
is provided, the dust masses are calculated from the gas metallicities and the provided ratio. If dust_masses
are provided
explicitly, the dust-to-metal ratio is calculated but ignored in all future calculations.
Computing characteristics radii¶
Like Stars
, characteristic radii can be computed for the gas particle distribution. We can either calculate the half-mass radius.
[3]:
r = gas.get_half_mass_radius()
print(r)
0.492220203374761 Mpc
Or use an aribtrary attribute for the radius weight. Here we’ll use the dust masses for a “half dust mass radius”.
[4]:
r = gas.get_attr_radius("dust_masses")
print(r)
0.48846898235673714 Mpc
We can also compute radii for different fractions by passing the fraction we want to calculate a radius for.
[5]:
r20 = gas.get_attr_radius("masses", frac=0.2)
r80 = gas.get_attr_radius("masses", frac=0.8)
print(r20, r80)
0.37152229756507504 Mpc 0.5979710856040797 Mpc