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 Msun, Mpc

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.72e-05 -> 2.00e-02 (Mean: 1.00e-02)                |
+----------------------------+------------------------------------------------------+
| dust_masses (1000,)        | 8.15e+00 Msun -> 6.00e+03 Msun (Mean: 3.01e+03 Msun) |
+----------------------------+------------------------------------------------------+
| log10metallicities (1000,) | -4.57e+00 -> -1.70e+00 (Mean: -2.12e+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 with some HII properties).

[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)          | 1.17e-04 Mpc -> 1.00e+00 Mpc (Mean: 5.05e-01 Mpc)    |
+--------------------------------+------------------------------------------------------+
| masses (1000,)                 | 1.00e+06 Msun -> 1.00e+06 Msun (Mean: 1.00e+06 Msun) |
+--------------------------------+------------------------------------------------------+
| centre                         | [0.51057606 0.4983918  0.50725673] Mpc               |
+--------------------------------+------------------------------------------------------+
| metallicities (1000,)          | 2.59e-05 -> 2.00e-02 (Mean: 9.78e-03)                |
+--------------------------------+------------------------------------------------------+
| dust_masses (1000,)            | 6.47e+00 Msun -> 5.00e+03 Msun (Mean: 2.44e+03 Msun) |
+--------------------------------+------------------------------------------------------+
| hii_mass (1000,)               | 2.89e+30 kg -> 1.99e+34 kg (Mean: 1.02e+34 kg)       |
+--------------------------------+------------------------------------------------------+
| hii_metallicity (1000,)        | 7.86e-06 -> 2.00e-02 (Mean: 1.01e-02)                |
+--------------------------------+------------------------------------------------------+
| centered_coordinates (1000, 3) | -5.09e-01 Mpc -> 5.01e-01 Mpc (Mean: -5.22e-04 Mpc)  |
+--------------------------------+------------------------------------------------------+
| log10metallicities (1000,)     | -4.59e+00 -> -1.70e+00 (Mean: -2.15e+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.4926678809146555 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.5019214709765333 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.36389190631577134 Mpc 0.5935689878995211 Mpc