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

Add next term van noort intensity solver #120

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
20 changes: 17 additions & 3 deletions stardis/transport/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def calc_weights(delta_tau):
-------
w0 : float
w1 : float
w2: float
"""

if delta_tau < 5e-4:
Expand All @@ -61,7 +62,8 @@ def calc_weights(delta_tau):
exp_delta_tau = np.exp(-delta_tau)
w0 = 1 - exp_delta_tau
w1 = w0 - delta_tau * exp_delta_tau
return w0, w1
w2 = 2 * w1 - delta_tau * delta_tau * exp_delta_tau
return w0, w1, w2


@numba.njit()
Expand Down Expand Up @@ -111,22 +113,34 @@ def single_theta_trace(
for i in range(len(tracing_nus)): # iterating over nus (columns)
for j in range(no_of_depth_gaps): # iterating over depth_gaps (rows)
curr_tau = taus[i, j]
next_tau = taus[i, j + 1]

w0, w1 = calc_weights(curr_tau)
w0, w1, w2 = calc_weights(curr_tau)

if curr_tau == 0:
second_term = 0
else:
second_term = w1 * delta_source[j, i] / curr_tau
if j < no_of_depth_gaps - 1:
third_term = w2 * (
(
(delta_source[j + 1, i] / next_tau)
+ (-delta_source[j, i] / curr_tau)
)
/ (curr_tau + next_tau)
)

else:
third_term = 0
I_nu_theta[j + 1, i] = (
(1 - w0) * I_nu_theta[j, i]
+ w0
* source[
j + 1, i
] # Changed to j + 1 b/c van Noort 2001 mentions using Source of future point to update, not current.
+ second_term
) # van Noort 2001 eq 14
+ third_term
)

return I_nu_theta

Expand Down
Loading