.. _physics-chemicalState: Chemical State ============== Class providing the chemical state of gas, specifically the free electron number density (in cm\ :math:`^{-3}`) and its logarithmic gradients with respect to temperature and total density, as functions of hydrogen number density, temperature, elemental abundances, and an ambient radiation field. The electron density enters cooling rates, recombination rates, and the Jeans mass, while the logarithmic slopes are needed for implicit solvers and stability analyses. Implementations range from collisional ionization equilibrium (:term:`CIE`) tables to non-equilibrium photoionization models. **Default implementation:** ``chemicalStateAtomicCIECloudy`` Methods ------- ``electronDensity`` → ``double precision`` Return the electron density at the given temperature and hydrogen density for the specified set of abundances and radiation field. Units of the returned electron density are cm\ :math:`^-3`. * ``double precision , intent(in ) :: numberDensityHydrogen, temperature`` * ``type (abundances ), intent(in ) :: gasAbundances`` * ``class (radiationFieldClass), intent(inout) :: radiation`` ``electronDensityTemperatureLogSlope`` → ``double precision`` Return the logarithmic gradient of electron density with temperature at the given temperature and hydrogen density for the specified set of abundances and radiation field. * ``double precision , intent(in ) :: numberDensityHydrogen, temperature`` * ``type (abundances ), intent(in ) :: gasAbundances`` * ``class (radiationFieldClass), intent(inout) :: radiation`` ``electronDensityDensityLogSlope`` → ``double precision`` Return the logarithmic gradient of electron density with respect to density at the given temperature and hydrogen density for the specified set of abundances and radiation field. * ``double precision , intent(in ) :: numberDensityHydrogen, temperature`` * ``type (abundances ), intent(in ) :: gasAbundances`` * ``class (radiationFieldClass), intent(inout) :: radiation`` ``chemicalDensities`` → ``void`` Return the densities of chemical species at the given temperature and hydrogen density for the specified set of abundances and radiation field. Units of the returned electron density are cm\ :math:`^-3`. * ``type (chemicalAbundances ), intent(inout) :: chemicalDensities`` * ``double precision , intent(in ) :: numberDensityHydrogen, temperature`` * ``type (abundances ), intent(in ) :: gasAbundances`` * ``class (radiationFieldClass), intent(inout) :: radiation`` .. _physics-chemicalStateAtomicCIECloudy: ``chemicalStateAtomicCIECloudy`` -------------------------------- A chemical state class that computes the chemical state using the Cloudy code and under the assumption of collisional ionization equilibrium with no molecular contribution. Abundances are Solar, except for zero metallicity calculations which use Cloudy's "primordial" metallicity. The helium abundance for non-zero metallicity is scaled between primordial and Solar values linearly with metallicity. The Cloudy code will be downloaded and run to compute the cooling function as needed, which will then be stored for future use. As this process is slow, a precomputed table is provided with Galacticus. If metallicities outside the range tabulated in this file are required it will be regenerated with an appropriate range. **(Default implementation)** **Methods** * ``tabulate`` — Run Cloudy to tabulate chemical state as necessary. .. _physics-chemicalStateCIEFile: ``chemicalStateCIEFile`` ------------------------ A chemical state class providing chemical state via interpolation of tabulated values read from file. The HDF5 file containing the table should have the following form: .. code-block:: none HDF5 "chemicalState.hdf5" { GROUP "/" { ATTRIBUTE "fileFormat" { DATATYPE H5T_STRING { STRSIZE 1; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } DATASPACE SCALAR DATA { (0): "1" } } DATASET "electronDensity" { DATATYPE H5T_IEEE_F64LE DATASPACE SIMPLE { ( 7, 8 ) / ( 7, 8 ) } } DATASET "hiDensity" { DATATYPE H5T_IEEE_F64LE DATASPACE SIMPLE { ( 7, 8 ) / ( 7, 8 ) } } DATASET "hiiDensity" { DATATYPE H5T_IEEE_F64LE DATASPACE SIMPLE { ( 7, 8 ) / ( 7, 8 ) } } DATASET "metallicity" { DATATYPE H5T_IEEE_F64LE DATASPACE SIMPLE { ( 8 ) / ( 8 ) } ATTRIBUTE "extrapolateHigh" { DATATYPE H5T_STRING { STRSIZE 3; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } DATASPACE SCALAR DATA { (0): "fix" } } ATTRIBUTE "extrapolateLow" { DATATYPE H5T_STRING { STRSIZE 3; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } DATASPACE SCALAR DATA { (0): "fix" } } } DATASET "temperature" { DATATYPE H5T_IEEE_F64LE DATASPACE SIMPLE { ( 7 ) / ( 7 ) } ATTRIBUTE "extrapolateHigh" { DATATYPE H5T_STRING { STRSIZE 3; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } DATASPACE SCALAR DATA { (0): "fix" } } ATTRIBUTE "extrapolateLow" { DATATYPE H5T_STRING { STRSIZE 3; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } DATASPACE SCALAR DATA { (0): "fix" } } } } } The ``temperature`` dataset should specify temperature (in Kelvin), while the ``metallicity`` dataset should give the logarithmic metallicity relative to Solar (a value of -999 or less is taken to imply zero metallicity). The ``electronDensity`` dataset should specify the number density of electrons relative to hydrogen at each temperature/metallicity pair. Optionally ``hiDensity`` and ``hiiDensity`` datasets may be added giving the number densities of H i and H ii relative to hydrogen respectively The ``extrapolateLow`` and ``extrapolateHigh`` attributes of the ``temperature`` and ``metallicity`` datasets specify how the cooling rate should be extrapolated in the low and high vale limits. Allowed options for these attributes are: ``zero`` The electron density is set to zero beyond the relevant limit. ``fixed`` The electron density is held fixed at the value at the relevant limit. ``power law`` The electron density is extrapolated assuming a power-law dependence beyond the relevant limit. This option is only allowed if the electron density is everywhere positive. If the electron density is everywhere positive the interpolation will be done in the logarithmic of temperature, metallicity\footnoteThe exception is if the first electron density is tabulated for zero metallicity. In that case, a linear interpolation in metallicity is always used between zero and the first non-zero tabulated metallicity. and electron density. Otherwise, interpolation is linear in these quantities. The electron density is scaled assuming a linear dependence on hydrogen density. **Methods** * ``readFile`` — Read the named chemical state file. * ``interpolatingFactors`` — Compute interpolating factors in a CIE chemical state file. * ``interpolate`` — Interpolate in the given density table. **Parameters** * ``[fileName]`` — The name of the file containing a tabulation of the collisional ionization equilibrium cooling function. * ``[fileName]`` — The name of the file containing a tabulation of the collisional ionization equilibrium chemical state.