Skip to content

Commit

Permalink
densities -> density
Browse files Browse the repository at this point in the history
  • Loading branch information
jvshields committed Aug 29, 2024
1 parent 80a913c commit 35cd09e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
12 changes: 6 additions & 6 deletions stardis/plasma/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
helium_lte_properties,
)
from stardis.plasma.molecules import (
MoleculeIonNumberDensities,
AlphaLineValdMolecules,
MoleculePartitionFunctions,
MoleculeIonNumberDensity,
AlphaLineValdMolecule,
MoleculePartitionFunction,
)


Expand Down Expand Up @@ -546,9 +546,9 @@ def create_stellar_plasma(
dilution_factor=np.ones_like(stellar_model.temperatures),
)
if config.opacity.line.include_molecules:
plasma_modules.append(MoleculeIonNumberDensities)
plasma_modules.append(MoleculePartitionFunctions)
plasma_modules.append(AlphaLineValdMolecules)
plasma_modules.append(MoleculeIonNumberDensity)
plasma_modules.append(MoleculePartitionFunction)
plasma_modules.append(AlphaLineValdMolecule)

return BasePlasma(
plasma_properties=plasma_modules,
Expand Down
30 changes: 15 additions & 15 deletions stardis/plasma/molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
logger = logging.getLogger(__name__)


class MoleculeIonNumberDensities(ProcessingPlasmaProperty):
class MoleculeIonNumberDensity(ProcessingPlasmaProperty):

# Need to think about negative ions - ignoring for now
# applicable for equilibrium constants given by Barklem and Collet 2016, which are given in SI units

outputs = ("molecule_number_densities",)
outputs = ("molecule_number_density",)

def calculate(self, ion_number_density, t_electrons, atomic_data):
# Preprocessing - split ions into symbol, charge, and number
Expand Down Expand Up @@ -123,16 +123,16 @@ def calculate(self, ion_number_density, t_electrons, atomic_data):
return molecule_densities_df


class MoleculePartitionFunctions(ProcessingPlasmaProperty):
class MoleculePartitionFunction(ProcessingPlasmaProperty):
"""
Attributes
----------
molecule_partition_functions : DataFrame
molecule_partition_function : DataFrame
A pandas DataFrame with dtype float. This represents the partition function
for each molecule at each depth point.
"""

outputs = ("molecule_partition_functions",)
outputs = ("molecule_partition_function",)

def calculate(self, t_electrons, atomic_data):
partition_functions = pd.DataFrame(
Expand All @@ -152,7 +152,7 @@ def calculate(self, t_electrons, atomic_data):
return partition_functions


class AlphaLineValdMolecules(ProcessingPlasmaProperty):
class AlphaLineValdMolecule(ProcessingPlasmaProperty):
"""
Attributes
----------
Expand All @@ -176,9 +176,9 @@ class AlphaLineValdMolecules(ProcessingPlasmaProperty):
def calculate(
self,
atomic_data,
molecule_number_densities,
molecule_number_density,
t_electrons,
molecule_partition_functions,
molecule_partition_function,
):
# solve n_lower : n_i = N * g_i / U * e ^ (-E_i/kT)
# get f_lu : loggf -> use g = 2j+1
Expand Down Expand Up @@ -213,8 +213,8 @@ def calculate(
).to(1)
)

molecule_densities_div_partition_function = (
molecule_number_densities.copy().div(molecule_partition_functions)
molecule_densities_div_partition_function = molecule_number_density.copy().div(
molecule_partition_function
)
molecule_densities_div_partition_function.index.name = "molecule"

Expand Down Expand Up @@ -281,7 +281,7 @@ def calculate(
return alphas, linelist


class AlphaLineShortlistValdMolecules(ProcessingPlasmaProperty):
class AlphaLineShortlistValdMolecule(ProcessingPlasmaProperty):
"""
Attributes
----------
Expand All @@ -305,9 +305,9 @@ class AlphaLineShortlistValdMolecules(ProcessingPlasmaProperty):
def calculate(
self,
atomic_data,
molecule_number_densities,
molecule_number_density,
t_electrons,
molecule_partition_functions,
molecule_partition_function,
):
# solve n_lower : n_i = N * g_i / U * e ^ (-E_i/kT)
# get f_lu : loggf -> use g = 2j+1
Expand Down Expand Up @@ -347,8 +347,8 @@ def calculate(
).to(1)
)

molecule_densities_div_partition_function = (
molecule_number_densities.copy().div(molecule_partition_functions)
molecule_densities_div_partition_function = molecule_number_density.copy().div(
molecule_partition_function
)
molecule_densities_div_partition_function.index.name = "molecule"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,9 +717,7 @@ def calculate_molecule_broadening(
(len(lines), len(stellar_model.geometry.no_of_depth_points)), dtype=float
)

ions = stellar_plasma.molecule_number_densities[["ion1", "ion2"]].loc[
lines.molecule
]
ions = stellar_plasma.molecule_number_density[["ion1", "ion2"]].loc[lines.molecule]

ion1_masses = stellar_model.composition.nuclide_masses.loc[ions.ion1].values
ion2_masses = stellar_model.composition.nuclide_masses.loc[ions.ion2].values
Expand Down

0 comments on commit 35cd09e

Please sign in to comment.