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

Cleaning model state #2124

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 8 additions & 64 deletions tardis/model/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,68 +24,6 @@
logger = logging.getLogger(__name__)


class ModelState:
"""
Store Model State Information.

Parameters
----------
v_inner : astropy.units.quantity.Quantity
v_outer : astropy.units.quantity.Quantity
r_inner : astropy.units.quantity.Quantity
r_outer : astropy.units.quantity.Quantity
density : astropy.units.quantity.Quantity
time_explosion : astropy.units.quantity.Quantity

Attributes
----------
geometry : pd.DataFrame
DataFrame storing `v_inner`, `v_outer`, `r_inner` and `r_outer`.
geometry_units : dict
Units of arrays stored in the `geometry` dataframe.
"""

def __init__(
self, v_inner, v_outer, r_inner, r_outer, time_explosion, density
):
self.time_explosion = time_explosion
self.density = density
self.geometry = pd.DataFrame(
{
"v_inner": v_inner.value,
"r_inner": r_inner.value,
"v_outer": v_outer.value,
"r_outer": r_outer.value,
}
)
self.geometry_units = {
"v_inner": v_inner.unit,
"r_inner": r_inner.unit,
"v_outer": v_outer.unit,
"r_outer": r_outer.unit,
}

@property
def v_inner(self):
"""Inner boundary velocity."""
return self.geometry.v_inner.values * self.geometry_units["v_inner"]

@property
def r_inner(self):
"""Inner radius of model shells."""
return self.geometry.r_inner.values * self.geometry_units["r_inner"]

@property
def v_outer(self):
"""Outer boundary velocity."""
return self.geometry.v_outer.values * self.geometry_units["v_outer"]

@property
def r_outer(self):
"""Outer radius of model shells."""
return self.geometry.r_outer.values * self.geometry_units["r_outer"]


class Radial1DGeometry:
"""
Holds information about model geometry for radial 1D models.
Expand All @@ -96,6 +34,11 @@ class Radial1DGeometry:
r_outer : astropy.units.quantity.Quantity
v_inner : astropy.units.quantity.Quantity
v_outer : astropy.units.quantity.Quantity

Attributes
----------
volume : astropy.units.quantity.Quantity
Volume in each shell
"""

def __init__(self, r_inner, r_outer, v_inner, v_outer):
Expand All @@ -106,6 +49,7 @@ def __init__(self, r_inner, r_outer, v_inner, v_outer):

@property
def volume(self):
"""Volume in shell computed from r_outer and r_inner"""
return (4.0 / 3) * np.pi * (self.r_outer**3 - self.r_inner**3)


Expand Down Expand Up @@ -162,7 +106,7 @@ def elemental_number_density(self):
)


class ModelState_Experimental:
class ModelState:
"""
Holds information about model geometry for radial 1D models.

Expand Down Expand Up @@ -348,7 +292,7 @@ def __init__(
v_inner=v_inner,
v_outer=v_outer,
)
self.model_state = ModelState_Experimental(
self.model_state = ModelState(
composition=composition,
geometry=geometry,
time_explosion=self.time_explosion,
Expand Down