Skip to content

Commit

Permalink
More efficient alpha deposition and damage when constructing Zircons
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Nov 15, 2022
1 parent 57d34b7 commit 859a4ac
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/minerals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,36 @@ function Zircon(r::T, dr::Number, Uppm::T, Thppm::T, dt::Number, ageSteps::Abstr
end
end

# Calculate corrected alpha deposition each time step for each radius
alphaDeposition = (exp.(λ238U.*(ageSteps .+ dt/2)) - exp.(λ238U.*(ageSteps .- dt/2))) * (r238UHe') +
(exp.(λ235U.*(ageSteps .+ dt/2)) - exp.(λ235U.*(ageSteps .- dt/2))) * (r235UHe') +
(exp.(λ232Th.*(ageSteps .+ dt/2)) - exp.(λ232Th.*(ageSteps .- dt/2))) * (r232ThHe')

# Alpha decay recoil damage
r238Udam = 8*r238U # No smoothing of alpha damage, 8 alphas per 238U
r235Udam = 7*r235U # No smoothing of alpha damage, 7 alphas per 235U
r232Thdam = 6*r232Th # No smoothing of alpha damage, 6 alphas per 232 Th

# Calculate corrected alpha damage at each time step for each radius
alphaDamage = (exp.(λ238U.*(ageSteps .+ dt/2)) - exp.(λ238U.*(ageSteps .- dt/2))) * (r238Udam') +
(exp.(λ235U.*(ageSteps .+ dt/2)) - exp.(λ235U.*(ageSteps .- dt/2))) * (r235Udam') +
(exp.(λ232Th.*(ageSteps .+ dt/2)) - exp.(λ232Th.*(ageSteps .- dt/2))) * (r232Thdam')
# Calculate corrected alpha deposition and recoil damage each time step for each radius
dt_2 = dt/2
decay = Array{T}(undef, ntSteps)
buffer = zeros(T, ntSteps, nrSteps-2)
# Allocate deposition and damage arrays
alphaDeposition = zeros(T, ntSteps, nrSteps-2)
alphaDamage = zeros(T, ntSteps, nrSteps-2)
# 238U
@turbo @. decay = exp(λ238U*(ageSteps + dt_2)) - exp(λ238U*(ageSteps - dt_2))
mul!(buffer, decay, r238UHe')
@turbo @. alphaDeposition += buffer
mul!(buffer, decay, r238Udam')
@turbo @. alphaDamage += buffer
# 235U
@turbo @. decay = exp(λ235U*(ageSteps + dt_2)) - exp(λ235U*(ageSteps - dt_2))
mul!(buffer, decay, r235UHe')
@turbo @. alphaDeposition += buffer
mul!(buffer, decay, r235Udam')
@turbo @. alphaDamage += buffer
# 232Th
@turbo @. decay = exp(λ232Th*(ageSteps + dt_2)) - exp(λ232Th*(ageSteps - dt_2))
mul!(buffer, decay, r232ThHe')
@turbo @. alphaDeposition += buffer
mul!(buffer, decay, r232Thdam')
@turbo @. alphaDamage += buffer

# Allocate additional variables that will be needed for Crank-Nicholson
annealedDamage = similar(alphaDamage)
Expand Down

2 comments on commit 859a4ac

@brenhinkeller
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register

Release notes:

  • Use more efficient in-place linterp1s! in MCMC_vartcryst
  • More efficient alpha deposition and damage when constructing Zircon objects
  • Use ProgressMeter.update! interface in place of @showprogress
  • Dispatch damage model on struct instead of Val(symbol) (i.e., ZRDAAM instead of Val(:zrdaam)) for flexibility in future implementation
  • Add DOI and citation

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/72272

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.5 -m "<description of version>" 859a4ac9c9cabd07f91ef69447a4337fe9719244
git push origin v0.4.5

Please sign in to comment.