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

Fix to deal with possible problem in end of line list #119

Merged
merged 1 commit into from
Apr 14, 2014
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Bugfixes
- logger statement added for coronal approximation
- warning added to documentation since plasma is out of date (temp
solution only) #108
- fix to binary search to deal with packets at end of line list

New Features
^^^^^^^^^^^^
Expand Down
7 changes: 3 additions & 4 deletions tardis/montecarlo.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ cdef int_type_t binary_search(float_type_t*nu, float_type_t nu_insert, int_type_
if nu_insert > nu[imin]:
return imin
elif nu_insert < nu[imax]:
return imax
return imax+1

cdef int_type_t imid
while imax - imin > 2:
Expand Down Expand Up @@ -599,7 +599,7 @@ def montecarlo_radial1d(model, int_type_t virtual_packet_flag=0):
current_energy = current_energy / (1 - (current_mu * current_r * storage.inverse_time_explosion * inverse_c))

#linelists
current_line_id = binary_search(storage.line_list_nu, comov_current_nu, 0, storage.no_of_lines)
current_line_id = binary_search(storage.line_list_nu, comov_current_nu, 0, storage.no_of_lines-1)

if current_line_id == storage.no_of_lines:
#setting flag that the packet is off the red end of the line list
Expand Down Expand Up @@ -1066,8 +1066,7 @@ cdef int_type_t montecarlo_one_packet_loop(StorageModel storage, float_type_t*cu
current_line_id[0] += 1

#check for last line
if current_line_id[0] >= storage.no_of_lines:
current_line_id[0] = storage.no_of_lines
if current_line_id[0] == storage.no_of_lines:
last_line[0] = 1

if (virtual_packet > 0):
Expand Down