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

Fixed floating point exception in adiabatic conversion initialize! #569

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 2 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
10 changes: 7 additions & 3 deletions src/dynamics/adiabatic_conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ function initialize!(
σ_lnp_A[1] = 0 # the corresponding sum is 1:k-1 so 0 to replace log(0) from above

# precompute the αₖ = 1 - p_k-1/2/Δpₖ*log(p_k+1/2/p_k-1/2) term in σ coordinates
σ_lnp_B .= 1 .- σ_levels_half[1:end-1]./σ_levels_thick .*
log.(σ_levels_half[2:end]./σ_levels_half[1:end-1])
σ_lnp_B[1] = σ_levels_half[1] <= 0 ? log(2) : σ_lnp_B[1] # set α₁ = log(2), eq. 3.19
if σ_levels_half[1] <= 0
σ_lnp_B[1] = log(2) # set α₁ = log(2), eq. 3.19
else
σ_lnp_B[1] *= 1 - σ_levels_half[1] / σ_levels_thick[1] * log(σ_levels_half[2] / σ_levels_half[1])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the *= for? I believe this array is intialized with zeros, so it should be set with =?

end
σ_lnp_B[2:end] .= 1 .- σ_levels_half[2:end-1]./σ_levels_thick[2:end] .*
log.(σ_levels_half[3:end]./σ_levels_half[2:end-1])
σ_lnp_B .*= -1 # absorb sign from -1/Δσₖ only, eq. 3.12
return nothing
end
Loading