Skip to content
Snippets Groups Projects
Commit f4bbc4b6 authored by Brian Groenke's avatar Brian Groenke
Browse files

Merge branch 'feature/trend-scaling' into 'master'

Add period scaling to LinearTrend parameter transform

See merge request sparcs/cryogrid/cryogridjulia!66
parents 4e3021dc ab242e36
No related branches found
No related tags found
1 merge request!66Add period scaling to LinearTrend parameter transform
name = "CryoGrid" name = "CryoGrid"
uuid = "a535b82e-5f3d-4d97-8b0b-d6483f5bebd5" uuid = "a535b82e-5f3d-4d97-8b0b-d6483f5bebd5"
authors = ["Brian Groenke <brian.groenke@awi.de>", "Moritz Langer <moritz.langer@awi.de>"] authors = ["Brian Groenke <brian.groenke@awi.de>", "Moritz Langer <moritz.langer@awi.de>"]
version = "0.6.0" version = "0.6.1"
[deps] [deps]
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66" ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
......
...@@ -12,14 +12,15 @@ using Unitful ...@@ -12,14 +12,15 @@ using Unitful
include("coupled.jl") include("coupled.jl")
include("Boundaries/Boundaries.jl") include("Boundaries/Boundaries.jl")
include("WaterBalance/WaterBalance.jl")
include("HeatConduction/HeatConduction.jl") include("HeatConduction/HeatConduction.jl")
include("WaterBalance/WaterBalance.jl")
include("Soils/Soils.jl") include("Soils/Soils.jl")
include("SEB/SEB.jl") include("SEB/SEB.jl")
include("Sources/Sources.jl") include("Sources/Sources.jl")
@reexport using .Boundaries @reexport using .Boundaries
@reexport using .HeatConduction @reexport using .HeatConduction
@reexport using .WaterBalance
@reexport using .Soils @reexport using .Soils
@reexport using .SEB @reexport using .SEB
@reexport using .Sources @reexport using .Sources
......
...@@ -76,19 +76,19 @@ end ...@@ -76,19 +76,19 @@ end
return pmodel return pmodel
end end
end end
# Transform implementations # Transform implementations
@with_kw struct LinearTrend{P} <: ParamTransform @with_kw struct LinearTrend{P} <: ParamTransform
slope::P = Param(0.0) slope::P = Param(0.0)
intercept::P = Param(0.0) intercept::P = Param(0.0)
tstart::Float64 = 0.0 tstart::Float64 = 0.0
tstop::Float64 = Inf; @assert tstop > tstart tstop::Float64 = Inf; @assert tstop > tstart
period::Float64 = 1.0
minval::Float64 = -Inf minval::Float64 = -Inf
maxval::Float64 = Inf maxval::Float64 = Inf
end end
function transform(state, trend::LinearTrend) function transform(state, trend::LinearTrend)
let t = min(state.t - trend.tstart, trend.tstop), let t = min(state.t - trend.tstart, trend.tstop),
β = trend.slope, β = trend.slope / trend.period,
α = trend.intercept; α = trend.intercept;
min(max(β*t + α, trend.minval), trend.maxval) min(max(β*t + α, trend.minval), trend.maxval)
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment