-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added NumbaRadial1DGeometry * Added to_numba function * Fixed incorrect naming of numba spec * Updated docstring * Updated to_numba docstring * Updated docstring * Updated numba model to contain only time explosion * updated docstring formatting error * Moved geometry to new geometry sub package * Updated all functions where numba model was used * Updated to specify units * converting time_explosion to seconds specifically * Added numba geometry fixture * Updated tests to work with numba geometry * Updated formatting * Fixed issue with geometry initialization * Fixed formatting
- Loading branch information
1 parent
f7dc2bb
commit e39fa6f
Showing
15 changed files
with
283 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from numba import float64 | ||
from numba.experimental import jitclass | ||
import numpy as np | ||
from astropy import units as u | ||
|
||
|
||
class Radial1DGeometry: | ||
""" | ||
Holds information about model geometry for radial 1D models. | ||
Parameters | ||
---------- | ||
r_inner : astropy.units.quantity.Quantity | ||
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): | ||
self.r_inner = r_inner | ||
self.r_outer = r_outer | ||
self.v_inner = v_inner | ||
self.v_outer = 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) | ||
|
||
def to_numba(self): | ||
""" | ||
Returns a new NumbaRadial1DGeometry object | ||
Returns | ||
------- | ||
NumbaRadial1DGeometry | ||
Numba version of Radial1DGeometry with properties in cgs units | ||
""" | ||
return NumbaRadial1DGeometry( | ||
self.r_inner.to(u.cm).value, | ||
self.r_outer.to(u.cm).value, | ||
self.v_inner.to(u.cm / u.s).value, | ||
self.v_outer.to(u.cm / u.s).value, | ||
) | ||
|
||
|
||
numba_geometry_spec = [ | ||
("r_inner", float64[:]), | ||
("r_outer", float64[:]), | ||
("v_inner", float64[:]), | ||
("v_outer", float64[:]), | ||
] | ||
|
||
|
||
@jitclass(numba_geometry_spec) | ||
class NumbaRadial1DGeometry(object): | ||
def __init__(self, r_inner, r_outer, v_inner, v_outer): | ||
""" | ||
Radial 1D Geometry for the Numba mode | ||
Parameters | ||
---------- | ||
r_inner : numpy.ndarray | ||
r_outer : numpy.ndarray | ||
v_inner : numpy.ndarray | ||
v_outer : numpy.ndarray | ||
""" | ||
self.r_inner = r_inner | ||
self.r_outer = r_outer | ||
self.v_inner = v_inner | ||
self.v_outer = v_outer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.