API

class hylightpy.HIAtom(nmax=60, recom=True, coll=True, cache_path='./cache/', caseB=True, verbose=False)

Compute level population for HI using the cascade matrix formalism. See Osterbrock & Ferland 2006, section 4.2

alpha_A(LogT=4.0)

Fit to Case A recombination coefficient at log temperature.

Parameters:

LogT (float) – Log10 of temperature. Default is 4.0.

Returns:

Fitted recombination rate coefficient.

Return type:

float

alpha_B(LogT=4.0)

Fit to Case B recombination coefficient at log temperature.

Parameters:

LogT (float) – Log10 of temperature. Default is 4.0.

Returns:

Fitted recombination rate coefficient.

Return type:

float

alpha_effective(n=2, l=0, LogT=4.0)

Effective recombination rate coefficient to a speciic level nl.

Parameters:
  • n (int) – Principle quantum number. Default is 2.

  • l (int) – Angular momentum quantum number. Default is 0.

  • LogT (float) – Temperature in log10. Default is 4.0.

Returns:

Effective recombination coefficient.

Return type:

float

branching_ratio(nupper=3, nlower=2, LogT=4.0, caseB=True)

Calculate the fraction of recombination that results in the emission of a specific line, taking into account only radiative processes. The definition can be found in Liu et al. 2025.

Parameters:
  • nupper (int) – Principle quantum number for the upper level. Default is 3.

  • nlower (int) – Principle quantum number for the lower level. Default is 2.

Returns:

The fraction of recombination that results in the emission of a specific line.

Return type:

float

collisional_deexcitation_rate_Lebedev_Beigman(nu=6, nl=1, Te=10000.0)

Collisional excitation rate calculated based on Lebedev & Beigman 1998 for Rydberg atoms (n >= 5).

Parameters:
  • nu (int) – Upper level. Default is 6.

  • nl (int) – Lower level. Default is 1.

  • Te (float) – Temperature. Default is 10000.0.

Returns:

Collisional excitation rate cefficient q_lu.

Return type:

float

collisional_excitation_rate_Lebedev_Beigman(nu=6, nl=1, Te=10000.0)

Collisional de-excitation rate calculated based on Lebedev & Beigman 1998 for Rydberg atoms (n >= 5).

Parameters:
  • nu (int) – Upper level. Default is 6.

  • nl (int) – Lower level. Default is 1.

  • Te (float) – Temperature. Default is 10000.0.

Returns:

Collisional de-excitation rate cefficient q_ul.

Return type:

float

compute_all_level_pops(nHII=unyt_array([100.], 'cm**(-3)'), ne=unyt_array([100.], 'cm**(-3)'), nHI=unyt_array([1.e-05], 'cm**(-3)'), temp=unyt_array([10000.], 'K'), verbose=False)

Compute level population for all levels.

Parameters:
  • nHII (float) – Proton number density [cm^{-3}]. Default is [1e2] * unyt.unyt_array(1, ‘cm**(-3)’).

  • ne (float) – Electron number density [cm^{-3}]. Default is [1e2] * unyt.unyt_array(1, ‘cm**(-3)’).

  • nHI (float) – Neutral hydrogen number density [cm^{-3}]. Default is [1e-5] * unyt.unyt_array(1, ‘cm**(-3)’). If collsional excitation is not enabled, any number input here will not go into the calculation.

  • temp (float) – Temperature. Default is [1e4] * unyt.unyt_array(1, ‘K’).

Returns:

Level population for all levels in units of cm^{-3}.

Return type:

float

compute_cascade_matrix()

Compute cascade matrix from Einstein coefficients

Returns:

Cascade matrix.

Return type:

dict

compute_level_pop(nHII=unyt_array([100.], 'cm**(-3)'), ne=unyt_array([100.], 'cm**(-3)'), nHI=unyt_array([1.e-05], 'cm**(-3)'), temp=unyt_array([10000.], 'K'), n=3, l=0, verbose=False)

Compute level population for a given level at a given density and temperature.

Parameters:
  • nHII (float) – Proton number density [cm^{-3}]. Default is [1e2] * unyt.unyt_array(1, ‘cm**(-3)’).

  • ne (float) – Electron number density [cm^{-3}]. Default is [1e2] * unyt.unyt_array(1, ‘cm**(-3)’).

  • nHI (float) – Neutral hydrogen density [cm^{03}]. Default is [1e-5] * unyt.unyt_array(1, ‘cm**(-3)’). If collsional excitation is not enabled, any number input here will not go into the calculation.

  • temp (float) – Temperature. Default is [1e4] * unyt.unyt_array(1, ‘K’).

  • n (int) – Principle quantum number of the desired level. Default is 2.

  • l (int) – Angular momentum quantum number of the desired level. Default is 0.

  • verbose (boolean) – Output diagnostic information. Default is False.

Returns:

Level population density of the desired level in units of cm^{-3}.

Return type:

float

config(n=1, l=1)

Configuration states are tuples of the form (n,l), where n = principle quantum number l = angular momentum quantum number

Parameters:
  • n (int) – Principle quantum number. Default is 1.

  • l (int) – Angular momentum quantum number. Default is 1.

Returns:

Configuration of a specific state in tuple.

Return type:

tuple

de_config(config=(1, 0))

Extract n and l value for a given configuration.

Parameters:

config (tuple) – Configuration of a state.

Returns:

Principle quantum number and angular momentum quantum number.

Return type:

int, int

fit_collisional_ex_rates()

Provide fitting function for collisional excitation rate from the ground state. The fitting funcition is of the form: Collisional_rate(n, l, T) = 10**q_lu(10**LogT)

Returns:

Fitting function of the collisioanl excitation rate coefficient.

fit_recombination_rates()

Provide fitting function for recombination rate as a function of log10 T. The fitting funcition is of the form: Recombination_rate(n, l, T) = 10**Alpha_nk(10**LogT)

Returns:

Fitting function.

get_A_coeffs(nupper=3, nlower=2)

Summing Einstein coefficients for all substates in the upper level.

Parameters:
  • nupper (int) – Principle quantum number for the upper level. Default is 3.

  • nlower (int) – Principle quantum number for the lower level. Default is 2.

Returns:

Summed Einstein coefficient.

Return type:

dict

get_all_configs()

Get all the configurations of all the atomic states (n, l).

Returns:

All the configurations of the atomic states.

get_emissivity(ne=unyt_array([100.], 'cm**(-3)'), nHI=unyt_array([1.e-05], 'cm**(-3)'), nHII=unyt_array([100.], 'cm**(-3)'), temp=unyt_array([10000.], 'K'), nupper=3, nlower=2)

Compute line emissivity for given density and temperature.

Parameters:
  • ne (float) – Electron density. Default is [1e2] * unyt.unyt_array(1, ‘cm**(-3)’).

  • nHI (float) – Neutral hydrogen density. Default is [1e-5] * unyt.unyt_array(1, ‘cm**(-3)’).

  • nHII (float) – Proton density. Default is [1e2] * unyt.unyt_array(1, ‘cm**(-3)’).

  • temp – Temperature. Default is [1e4] * unyt.unyt_array(1, ‘K’).

  • nupper (int) – Principle quantum number for the upper level. Default is 3.

  • nlower (int) – Principle quantum number for the lower level. Default is 2.

Type:

float

Returns:

Line emissisity in erg s**(-1) cm**(-3)

Return type:

float

psi(nu, nl, Te)

E1 is the first order exponential integral. I have used sc.exp1 to calculate that. The energy difference is expressed in absolute values, see Lebedev & Beigman 1998 page 225 eq. 8.30.

read_effective_collisional_strength(verbose=False)

Read level-resolved collisional strength up to n = 5 level from ascii file in the data folder (h_coll_str.dat).

Parameters:

verbose (boolean) – Output diagnostic information.

Returns:

Collisional stength up to n = 5 tabulated by Anderson et al. 2000.

Return type:

dict

read_recombination_rates(fname)

Read level-resolved recombination rates from ascii file in the data folder (h_iso_recomb_HI_150.dat).

Parameters:

fname (str) – Name of the tabulated recombination coefficient file.

Returns:

Dictionary of the recombination coefficients.

Return type:

dict

read_tabulated_Einstein_coefficients(fname)

Read tabulated Einstein coefficients.

Parameters:

fname (str) – Filename.

Returns:

Dictionary of Einstein A values.

Return type:

dict