Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add molecular data exposure to tardis atom data #2806

Merged
merged 13 commits into from
Aug 22, 2024
46 changes: 45 additions & 1 deletion tardis/io/atom_data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from astropy import units as u
from astropy.units import Quantity
from scipy import interpolate
from dataclasses import dataclass

from tardis import constants as const
from tardis.io.atom_data.util import resolve_atom_data_fname
Expand Down Expand Up @@ -100,6 +101,11 @@ class AtomData:
columns: atomic_number, element, Rad energy, Rad intensity decay mode.
Curated from nndc

molecule_data : MolecularData
A class containing the *molecular data* with:
equilibrium_constants, partition_functions, dissociation_energies


Attributes
----------
prepared : bool
Expand All @@ -116,6 +122,7 @@ class AtomData:
photoionization_data : pandas.DataFrame
two_photon_data : pandas.DataFrame
decay_radiation_data : pandas.DataFrame
molecule_data : MolecularData

Methods
-------
Expand Down Expand Up @@ -221,7 +228,14 @@ def from_hdf(cls, fname=None):
if "linelist" in store:
dataframes["linelist"] = store["linelist"]

atom_data = cls(**dataframes)
if "molecules" in store:
molecule_data = MoleculeData(
store["molecules/equilibrium_constants"],
store["molecules/partition_functions"],
store["molecules/dissociation_energies"],
)

atom_data = cls(**dataframes, molecule_data=molecule_data)

try:
atom_data.uuid1 = store.root._v_attrs["uuid1"]
Expand Down Expand Up @@ -284,6 +298,7 @@ def __init__(
two_photon_data=None,
linelist=None,
decay_radiation_data=None,
molecule_data=None,
):
self.prepared = False

Expand Down Expand Up @@ -346,6 +361,9 @@ def __init__(
if linelist is not None:
self.linelist = linelist

if molecule_data is not None:
self.molecule_data = molecule_data

if decay_radiation_data is not None:
self.decay_radiation_data = decay_radiation_data
self._check_related()
Expand Down Expand Up @@ -762,3 +780,29 @@ def get_collision_matrix(self, species, t_electrons):
)
)
return c_ul_matrix + c_lu_matrix.transpose(1, 0, 2)


@dataclass
class MoleculeData(object):
jvshields marked this conversation as resolved.
Show resolved Hide resolved
"""
Class to hold molecular data. Held by the AtomData object.

equilibrium_constants : pandas.DataFrame
A DataFrame containing the *molecular equilibrium constants* with:
index: molecule
columns: temperatures

partition_functions : pandas.DataFrame
A DataFrame containing the *molecular partition functions* with:
index: molecule
columns: temperatures

dissociation_energies : pandas.DataFrame
A DataFrame containing the *molecular dissociation energies* with:
index: molecule

"""

equilibrium_constants: pd.DataFrame
partition_functions: pd.DataFrame
dissociation_energies: pd.DataFrame
Loading