pynucastro.nucdata.composition module#
Classes and methods for describing a collection of nuclei and their abundances.
- class pynucastro.nucdata.composition.Composition(nuclei, small=1e-16, init=None)[source]#
Bases:
UserDictA composition holds the mass fractions of the nuclei in a network.
- Parameters:
small (float) – a floor for nuclei mass fractions, used as the default value.
init (str) – Different modes to set up the initial composition. Valid choices are [uniform, random, solar]. If “solar” is selected, assume we work with metallicity, Z=0.02. If init=None, then no initial composition will be set.
- property X#
backwards-compatible getter for self.X
- bin_as(nuclei, *, verbose=False, exclude=None)[source]#
Given a list of nuclei, return a new Composition object with the current composition mass fractions binned into the new nuclei.
- Parameters:
- Returns:
new_composition – The new binned composition
- Return type:
- get_molar()[source]#
Return a dictionary of molar fractions, Y = X/A.
- Returns:
molar – {Nucleus : Y}
- Return type:
- normalize(*, half_life_thresh=None)[source]#
Normalize the mass fractions to sum to 1.
- Parameters:
half_life_thresh (float) – The half life value below which to zero the mass fraction of a nucleus. This prevents us from making a composition that is not really stable.
- plot(trace_threshold=0.1, hard_limit=None, size=(9, 5))[source]#
Make a pie chart of Composition. group trace nuclei together and explode into bar chart
- Parameters:
- Return type:
- set_all(xval)[source]#
Set all species to the same scalar value.
- Parameters:
xval (float) – mass fraction value for all species
- set_array(arr)[source]#
Set the mass fractions of all species to the values in arr, get_nuclei()
- Parameters:
arr (list, tuple, numpy.ndarray) – input values of mass fractions
- set_random(alpha=None, seed=None)[source]#
Set all species using a Dirichlet distribution with parameters alpha and specified rng seed.
- Parameters:
alpha (list, tuple, numpy.ndarray) – distribution length for the Dirichlet distribution
seed (float) – seed for the random number generator
- class pynucastro.nucdata.composition.LoddersComposition(Z=None, half_life_thresh=None)[source]#
Bases:
CompositionA class to use present day solar abundances from Lodders et al. 2020 & 2021.
- Parameters:
Z (float) – Target metallicity \(Z\) to scale the Lodders solar mixture to. If
None(the default), the unscaled Lodders abundances are used.half_life_thresh (float) – The half life value below which to zero the mass fraction of a nucleus. This prevents us from making a composition that is not really stable.
Notes
The Lodders abundances are stored in
LODDERS_DATAas mass fractions for individual isotopes.