trident.ion_balance.calculate_ion_fraction
- trident.ion_balance.calculate_ion_fraction(ion, density, temperature, redshift, ionization_table=None)[source]
Calculate ion fraction at specified density, temperature, and redshift
This simple function interpolates ion fraction values from the relevant ion_balance data table for arrays of density, temperature, and redshift values.
Users can specify individual coordinates in density, temperature, and redshift or N-sized arrays to derived values in parallel.
Ion fractions are calculated assuming collisional ionization and photoionization in the optically thin limit from a redshift-dependent metagalactic ionizing background using the ionization_table specified.
Trilinear interpolation is assumed across density, temperature, and redshift.
Parameters
- Ion:
string
The desired ion following the form: “<element> <ionization_state>” Examples: “H I”, “C II”, “Mg II”
- Density:
float or array of floats
Gas density in the form of hydrogen number density cm$**{-3}$
- Temperature:
float or array of floats
Gas temperature in kelvin
- Redshift:
float or array of floats
Redshift at which to assume the metagalactic UV background
- Ionization_table:
string, optional
Path to an appropriately formatted HDF5 table that can be used to compute the ion fraction as a function of density, temperature, metallicity, and redshift. When set to None, it uses the table specified in ~/.trident/config Default: None
Example
To calculate the ion fraction of Mg II for gas with hydrogen number density 1e-2 cm**-3 and redshift 0.25 and temperatures 1e4K:
>>> import trident >>> trident.calculate_ion_fraction('Mg II', 1e-2, 1e4, 0.25)