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

Fast formal integral #2731

Merged
merged 22 commits into from
Jul 23, 2024
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
259676b
Added faster double-grid formal integral method
Rodot- Jul 22, 2024
a7787c5
Removed the old cuda formal integral method
Rodot- Jul 22, 2024
fc074a5
Ran Black
Rodot- Jul 22, 2024
89553a2
Edited some comments
Rodot- Jul 22, 2024
b9c24dd
Updated docstrings to be more descriptive, added in better comments o…
Rodot- Jul 22, 2024
09dbbe6
removed comment about boundary condition (verified by Jack as correct…
Rodot- Jul 22, 2024
abfa976
Merge pull request #17 from Rodot-/fast_formal_integral_subbranch
Rodot- Jul 22, 2024
42632c8
Removed unneccessary branching
Rodot- Jul 22, 2024
59a69da
Ran black
Rodot- Jul 22, 2024
de3adfa
Merge pull request #18 from Rodot-/fast_formal_integral_subbranch
Rodot- Jul 22, 2024
098db98
small implimentation detail with indexing
Rodot- Jul 22, 2024
9aa9983
Merge pull request #19 from Rodot-/fast_formal_integral_subbranch
Rodot- Jul 22, 2024
90a1072
added back the z_end
Rodot- Jul 22, 2024
2c44873
Merge pull request #20 from Rodot-/fast_formal_integral_subbranch
Rodot- Jul 22, 2024
1657e9b
Merge branch 'master' of github.com:tardis-sn/tardis into fast_formal…
Rodot- Jul 23, 2024
acd6d87
Merge pull request #21 from Rodot-/fast_formal_integral_subbranch
Rodot- Jul 23, 2024
59dfd20
Update tardis/spectrum/formal_integral_cuda.py
andrewfullard Jul 23, 2024
553db75
Merge branch 'master' of github.com:tardis-sn/tardis into fast_formal…
Rodot- Jul 23, 2024
2834c70
Fixed logic issue with how the first iteration is handled
Rodot- Jul 23, 2024
bbc1183
Merge branch 'tardis-sn:master' into fast_formal_integral
Rodot- Jul 23, 2024
900d340
Merge branch 'fast_formal_integral' of https://github.com/Rodot-/tard…
Rodot- Jul 23, 2024
79c4545
ran black
Rodot- Jul 23, 2024
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
57 changes: 24 additions & 33 deletions tardis/spectrum/formal_integral_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@
pJred_lu = int(offset + idx_nu_start)
pJblue_lu = int(offset + idx_nu_start)

first = 1

Check warning on line 170 in tardis/spectrum/formal_integral_cuda.py

View check run for this annotation

Codecov / codecov/patch

tardis/spectrum/formal_integral_cuda.py#L170

Added line #L170 was not covered by tests

# loop over all interactions
for i in range(size_z - 1):
escat_op = electron_density[int(shell_id_thread[i])] * SIGMA_THOMSON
Expand All @@ -175,46 +177,35 @@
) # +1 is the offset as the original is from z[1:]

nu_end_idx = line_search_cuda(line_list_nu, nu_end, len(line_list_nu))
zend = time_explosion / C_INV * (1.0 - line_list_nu[pline] / nu)
escat_contrib += (
(zend - zstart)
* escat_op
* (Jblue_lu[pJblue_lu] - I_nu_thread[p_idx])
)
pJred_lu += 1
I_nu_thread[p_idx] += escat_contrib
# // Lucy 1999, Eq 26
I_nu_thread[p_idx] *= exp_tau[pexp_tau]
I_nu_thread[p_idx] += att_S_ul[patt_S_ul]

# // reset e-scattering opacity
escat_contrib = 0.0
zstart = zend

pline += 1
pexp_tau += 1
patt_S_ul += 1
pJblue_lu += 1

for _ in range(1, max(nu_end_idx - pline, 1)):
for _ in range(max(nu_end_idx - pline, 0)):

Check warning on line 180 in tardis/spectrum/formal_integral_cuda.py

View check run for this annotation

Codecov / codecov/patch

tardis/spectrum/formal_integral_cuda.py#L180

Added line #L180 was not covered by tests
# calculate e-scattering optical depth to next resonance point
zend = time_explosion / C_INV * (1.0 - line_list_nu[pline] / nu)

# Account for e-scattering, c.f. Eqs 27, 28 in Lucy 1999
Jkkp = 0.5 * (Jred_lu[pJred_lu] + Jblue_lu[pJblue_lu])
escat_contrib += (
(zend - zstart) * escat_op * (Jkkp - I_nu_thread[p_idx])
)
# this introduces the necessary offset of one element between
# pJblue_lu and pJred_lu
pJred_lu += 1
zend = (

Check warning on line 182 in tardis/spectrum/formal_integral_cuda.py

View check run for this annotation

Codecov / codecov/patch

tardis/spectrum/formal_integral_cuda.py#L182

Added line #L182 was not covered by tests
time_explosion / C_INV * (1.0 - line_list_nu[pline] / nu)
) # check

if first == 1:
escat_contrib += (

Check warning on line 187 in tardis/spectrum/formal_integral_cuda.py

View check run for this annotation

Codecov / codecov/patch

tardis/spectrum/formal_integral_cuda.py#L186-L187

Added lines #L186 - L187 were not covered by tests
(zend - zstart)
* escat_op
* (Jblue_lu[pJblue_lu] - I_nu_thread[p_idx])
)
first = 0

Check warning on line 192 in tardis/spectrum/formal_integral_cuda.py

View check run for this annotation

Codecov / codecov/patch

tardis/spectrum/formal_integral_cuda.py#L192

Added line #L192 was not covered by tests
else:
# Account for e-scattering, c.f. Eqs 27, 28 in Lucy 1999
Jkkp = 0.5 * (Jred_lu[pJred_lu] + Jblue_lu[pJblue_lu])
escat_contrib += (

Check warning on line 196 in tardis/spectrum/formal_integral_cuda.py

View check run for this annotation

Codecov / codecov/patch

tardis/spectrum/formal_integral_cuda.py#L195-L196

Added lines #L195 - L196 were not covered by tests
(zend - zstart) * escat_op * (Jkkp - I_nu_thread[p_idx])
)
# this introduces the necessary ffset of one element between
# pJblue_lu and pJred_lu
pJred_lu += 1

Check warning on line 201 in tardis/spectrum/formal_integral_cuda.py

View check run for this annotation

Codecov / codecov/patch

tardis/spectrum/formal_integral_cuda.py#L201

Added line #L201 was not covered by tests
I_nu_thread[p_idx] += escat_contrib
# // Lucy 1999, Eq 26
I_nu_thread[p_idx] *= exp_tau[pexp_tau]
I_nu_thread[p_idx] += att_S_ul[patt_S_ul]

# // reset e-scattering opacity
escat_contrib = 0.0
escat_contrib = 0

Check warning on line 208 in tardis/spectrum/formal_integral_cuda.py

View check run for this annotation

Codecov / codecov/patch

tardis/spectrum/formal_integral_cuda.py#L208

Added line #L208 was not covered by tests
zstart = zend

pline += 1
Expand Down
Loading