Skip to content

Commit

Permalink
Cleanup and rename cell length (tardis-sn#100)
Browse files Browse the repository at this point in the history
* add functionality to read not gzipped files to marcs reader

* remove WIP for geometry that would break the reader

Co-authored-by: Jing Lu <[email protected]>
Co-authored-by: Yuki Matsumura <[email protected]>
Co-authored-by: 饒孝節 <[email protected]>

* Co-authored-by: Jing Lu <[email protected]>
Co-authored-by: Yuki Matsumura <[email protected]>
Co-authored-by: 饒孝節 <[email protected]>

* Change documentation and names of "cells"

* change radial1d.py mentions of cell to depth point

---------

Co-authored-by: Jing Lu <[email protected]>
Co-authored-by: Yuki Matsumura <[email protected]>
Co-authored-by: 饒孝節 <[email protected]>
Co-authored-by: Sona Chitchyan <[email protected]>
  • Loading branch information
5 people committed Jul 26, 2023
1 parent ea93b48 commit 4ab24a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
10 changes: 5 additions & 5 deletions stardis/model/geometry/radial1d.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
class Radial1DGeometry:

"""
Holds information about model geometry for radial 1D models.
Holds information about model geometry (distribution of depth points) for radial 1D models.
Parameters
----------
r : astropy.units.quantity.Quantity
The spacial coordinate of the depth point
----------
Attributes
----------
cell_length : astropy.units.quantity.Quantity
Length in each shell
dist_to_next_depth_point : astropy.units.quantity.Quantity
distance to the next depth point
"""

def __init__(self, r):
self.r = r

@property
def cell_length(self):
# NEED TO CHANGE THE NAME!!
def dist_to_next_depth_point(self):
return self.r[1:] - self.r[:-1]
21 changes: 11 additions & 10 deletions stardis/transport/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ def calc_weights(delta_tau):
return w0, w1


# cell_length name should be changed with radial1d geometry name
@numba.njit()
def single_theta_trace(
fv_geometry_cell_length,
geometry_dist_to_next_depth_point,
boundary_temps,
alphas,
tracing_nus,
Expand All @@ -78,8 +77,8 @@ def single_theta_trace(
Parameters
----------
fv_geometry_cell_length : numpy.ndarray
Cell length column as a numpy array from the finite volume model.
geometry_dist_to_next_depth_point : numpy.ndarray
Distance to next depth point in geometry column as a numpy array from the finite volume model.
boundary_temps : numpy.ndarray
Temperatures in K of all shell boundaries. Note that array must
be transposed.
Expand All @@ -98,17 +97,19 @@ def single_theta_trace(
intensity at each shell boundary for each frequency in tracing_nus.
"""

taus = alphas.T * fv_geometry_cell_length / np.cos(theta)
no_of_shells = len(fv_geometry_cell_length)
taus = alphas.T * geometry_dist_to_next_depth_point / np.cos(theta)
no_of_depth_gaps = len(geometry_dist_to_next_depth_point)

bb = bb_nu(tracing_nus, boundary_temps)
source = bb[1:]
delta_source = bb[1:] - bb[:-1] # for cells, not boundary
I_nu_theta = np.ones((no_of_shells + 1, len(tracing_nus))) * -99
delta_source = (
bb[1:] - bb[:-1]
) # for cells, not boundary - IS WRONG BUT SHOULD BE FIXED LATER
I_nu_theta = np.ones((no_of_depth_gaps + 1, len(tracing_nus))) * -99
I_nu_theta[0] = bb[0] # the innermost boundary is photosphere

for i in range(len(tracing_nus)): # iterating over nus (columns)
for j in range(no_of_shells): # iterating over cells/shells (rows)
for j in range(no_of_depth_gaps): # iterating over depth_gaps (rows)
curr_tau = taus[i, j]

w0, w1 = calc_weights(curr_tau)
Expand Down Expand Up @@ -157,7 +158,7 @@ def raytrace(stellar_model, alphas, tracing_nus, no_of_thetas=20):
for theta in thetas:
weight = 2 * np.pi * dtheta * np.sin(theta) * np.cos(theta)
F_nu += weight * single_theta_trace(
stellar_model.geometry.cell_length,
stellar_model.geometry.dist_to_next_depth_point,
stellar_model.boundary_temps,
alphas,
tracing_nus,
Expand Down

0 comments on commit 4ab24a4

Please sign in to comment.