Skip to content

Commit

Permalink
Cleaning model state (#2124)
Browse files Browse the repository at this point in the history
* removed old model state

* Removed back whitespace

* Update docstring in geometry
  • Loading branch information
satwik-kambham authored Sep 28, 2022
1 parent 9ecc794 commit a12b983
Showing 1 changed file with 8 additions and 64 deletions.
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

0 comments on commit a12b983

Please sign in to comment.