Skip to content

Commit

Permalink
Merge pull request #119 from ssim/nu_line_fix
Browse files Browse the repository at this point in the history
Fix to deal with possible problem in end of line list
  • Loading branch information
wkerzendorf committed Apr 14, 2014
2 parents fe70c29 + 110dfbf commit bd88c4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit bd88c4e

Please sign in to comment.