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,) | 1.23e-05 -> 2.00e-02 (Mean: 9.86e-03) |
+----------------------------+------------------------------------------------------+
| log10metallicities (1000,) | -4.91e+00 -> -1.70e+00 (Mean: -2.14e+00) |
+----------------------------+------------------------------------------------------+
| dust_masses (1000,) | 3.68e+00 Msun -> 5.99e+03 Msun (Mean: 2.96e+03 Msun) |
+----------------------------+------------------------------------------------------+
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) | 2.30e-04 Mpc -> 9.99e-01 Mpc (Mean: 4.98e-01 Mpc) |
+--------------------------------+------------------------------------------------------+
| masses (1000,) | 1.00e+06 Msun -> 1.00e+06 Msun (Mean: 1.00e+06 Msun) |
+--------------------------------+------------------------------------------------------+
| centre | [0.51313391 0.48972213 0.50343027] Mpc |
+--------------------------------+------------------------------------------------------+
| metallicities (1000,) | 1.29e-05 -> 1.99e-02 (Mean: 1.01e-02) |
+--------------------------------+------------------------------------------------------+
| log10metallicities (1000,) | -4.89e+00 -> -1.70e+00 (Mean: -2.13e+00) |
+--------------------------------+------------------------------------------------------+
| dust_masses (1000,) | 3.22e+00 Msun -> 4.98e+03 Msun (Mean: 2.53e+03 Msun) |
+--------------------------------+------------------------------------------------------+
| hii_mass (1000,) | 8.16e+30 kg -> 1.99e+34 kg (Mean: 1.02e+34 kg) |
+--------------------------------+------------------------------------------------------+
| hii_metallicity (1000,) | 4.04e-07 -> 2.00e-02 (Mean: 9.88e-03) |
+--------------------------------+------------------------------------------------------+
| centered_coordinates (1000, 3) | -5.13e-01 Mpc -> 5.07e-01 Mpc (Mean: -4.46e-03 Mpc) |
+--------------------------------+------------------------------------------------------+
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.490726752858331 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.4891218892729688 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.35511406786213784 Mpc 0.5994559301347475 Mpc