Skip to content

Commit

Permalink
Refactor how model parameters are stored and passed
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Nov 12, 2022
1 parent 98f1372 commit f99c528
Show file tree
Hide file tree
Showing 8 changed files with 364 additions and 351 deletions.
365 changes: 188 additions & 177 deletions examples/ZrnHeInversionVartCryst.jl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Thermochron.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Thermochron
using ProgressMeter: @showprogress

include("minerals.jl")
include("ZrnHe.jl")
include("zirconhelium.jl")
include("inversion.jl")

end
7 changes: 3 additions & 4 deletions src/inversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
sigma = sqrt(sigma_analytical^2 + sigma_annealing^2)
"""
function simannealsigma(n, sigma_analytical; params=(25.0, 35.0, 10/10^5))
σₘ, σᵢ, λ = params
sigma_annealing = σᵢ*exp(-λ*n) + σₘ
return sqrt(sigma_analytical^2 + sigma_annealing^2)
function simannealsigma(n, sigma_analytical; params=(σModel=25.0, σAnnealing=35.0, λAnnealing=10/10^5))
sigma_combined = params.σAnnealing * exp(-params.λAnnealing*n) + params.σModel
return sqrt(sigma_analytical^2 + sigma_combined^2)
end
export simannealsigma
17 changes: 9 additions & 8 deletions src/ZrnHe.jl → src/zirconhelium.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@

"""
```julia
ρᵣ = DamageAnnealing(dt::Number, tSteps::Vector, TSteps::Matrix)
ρᵣ = anneal(dt::Number, tSteps::Vector, TSteps::Matrix, [model::Symbol])
```
Zircon damage annealing model as in Guenthner et al. 2013 (AJS)
"""
function DamageAnnealing(dt::Number, tSteps::DenseVector, TSteps::DenseVector)
function anneal(dt::Number, tSteps::DenseVector, TSteps::DenseVector, model=:zrdaam)
# Allocate matrix to hold reduced track lengths for all previous timesteps
ρᵣ = zeros(length(tSteps),length(tSteps))
# In=-place version
DamageAnnealing!(ρᵣ, dt, tSteps, TSteps)
anneal!(ρᵣ, dt, tSteps, TSteps, model)
end
export DamageAnnealing
export anneal

"""
```julia
DamageAnnealing!(ρᵣ::Matrix, dt::Number, tSteps::Vector, TSteps::Vector)
anneal!(ρᵣ::Matrix, dt::Number, tSteps::Vector, TSteps::Vector, [model::Symbol])
```
In-place version of `DamageAnnealing`
In-place version of `anneal`
"""
function DamageAnnealing!(ρᵣ::DenseMatrix, dt::Number, tSteps::DenseVector, TSteps::DenseVector)
anneal!(ρᵣ::DenseMatrix, dt::Number, tSteps::DenseVector, TSteps::DenseVector, model::Symbol) = anneal!(ρᵣ, dt, tSteps, TSteps, Val(model))
function anneal!(ρᵣ::DenseMatrix, dt::Number, tSteps::DenseVector, TSteps::DenseVector, ::Val{:zrdaam})
# Annealing model constants
B=-0.05721
C0=6.24534
Expand Down Expand Up @@ -63,7 +64,7 @@ function DamageAnnealing!(ρᵣ::DenseMatrix, dt::Number, tSteps::DenseVector, T

return ρᵣ
end
export DamageAnnealing!
export anneal!


"""
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ using Thermochron
using LinearAlgebra
using Test

@testset "Zircon helium" begin include("testZrnHe.jl") end
@testset "Zircon helium" begin include("testzirconhelium.jl") end
@testset "Inversion" begin include("testinversion.jl") end
@testset "Integrated Examples" begin include("testexamples.jl") end
Loading

2 comments on commit f99c528

@brenhinkeller
Copy link
Member Author

@brenhinkeller brenhinkeller commented on f99c528 Nov 12, 2022

Choose a reason for hiding this comment

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

@JuliaRegistrator register

Release notes:

  • Add custom types to store reusable information about individual chronometers
  • Add in-place DamageAnnealing! (now anneal!) function
  • Refactor ZrnHeAgeSpherical (now HeAgeSpherical) to store and reuse damage matrices, etc.
  • Refactor how model parameters are stored and passed around
  • Rename various things to be closer in line with Julia naming conventions

@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/72121

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.3.0 -m "<description of version>" f99c528c5b88938f10e3feec623ffc7d017a7dac
git push origin v0.3.0

Please sign in to comment.