Skip to content

Commit

Permalink
move back to old weights and theta sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
jvshields committed Sep 26, 2024
1 parent cbd238a commit 8cc172e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions stardis/radiation_field/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,18 @@ def __init__(self, frequencies, source_function, stellar_model, num_of_thetas):
self.opacities = Opacities(frequencies, stellar_model)
self.F_nu = np.zeros((stellar_model.no_of_depth_points, len(frequencies)))

thetas, weights = np.polynomial.legendre.leggauss(num_of_thetas)
self.thetas = (thetas / 2) + 0.5 * np.pi / 2
self.I_nus_weights = weights * np.pi / 2
# thetas, weights = np.polynomial.legendre.leggauss(num_of_thetas) # This block migrates to Gauss-Legendre quadrature
# self.thetas = (thetas / 2) + 0.5 * np.pi / 2
# self.I_nus_weights = weights * np.pi / 2

dtheta = (np.pi / 2) / num_of_thetas # Korg uses Gauss-Legendre quadrature here
start_theta = dtheta / 2
end_theta = (np.pi / 2) - (dtheta / 2)
self.thetas = np.linspace(start_theta, end_theta, num_of_thetas)
self.I_nus_weights = (
2 * np.pi * dtheta * np.sin(self.thetas) * np.cos(self.thetas)
)

self.I_nus = np.zeros(
(stellar_model.no_of_depth_points, len(frequencies), len(self.thetas))
)
Expand Down
4 changes: 2 additions & 2 deletions stardis/radiation_field/radiation_field_solvers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ def calculate_spherical_ray(thetas, depth_points_radii):
ray_distance_through_layer_by_impact_parameter = np.zeros(
(len(depth_points_radii) - 1, len(thetas))
)

dr = np.diff(depth_points_radii)
for theta_index, theta in enumerate(thetas):
b = depth_points_radii[-1] * np.sin(theta) # impact parameter of the ray
ray_z_coordinate_grid = np.sqrt(
depth_points_radii**2 - b**2
) # Rays that don't go deeper than a layer will have a nan here

ray_distance = dr * depth_points_radii[1:] / ray_z_coordinate_grid[1:]
# ray_distance = np.diff(ray_z_coordinate_grid)
ray_distance_through_layer_by_impact_parameter[
Expand Down

0 comments on commit 8cc172e

Please sign in to comment.