Skip to content

Commit

Permalink
improve tests stability
Browse files Browse the repository at this point in the history
  • Loading branch information
albangossard committed Jan 25, 2025
1 parent 1b5618b commit f495014
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
27 changes: 16 additions & 11 deletions test/PDE_UDE_solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ function pde_solve_test(; rtol::F, atol::F, save_refs::Bool=false, MB::Bool=fals
println("PDE solving with MB = $MB")
working_dir = joinpath(homedir(), "OGGM/Huginn_tests")

## Retrieving gdirs and climate for the following glaciers
## Fast version includes less glacier to reduce the amount of downloaded files and computation time on GitHub CI
if fast
rgi_ids = ["RGI60-11.03638", "RGI60-11.01450"] #, "RGI60-08.00213", "RGI60-04.04351", "RGI60-01.02170"]
else
rgi_ids = ["RGI60-11.03638", "RGI60-11.01450", "RGI60-08.00213", "RGI60-04.04351", "RGI60-01.02170",
"RGI60-02.05098", "RGI60-01.01104", "RGI60-01.09162", "RGI60-01.00570", "RGI60-04.07051",
"RGI60-07.00274", "RGI60-07.01323", "RGI60-01.17316"]
end

rgi_paths = get_rgi_paths()
# Filter out glaciers that are not used to avoid having references that depend on all the glaciers processed in Gungnir
rgi_paths = Dict(k => rgi_paths[k] for k in rgi_ids)

params = Huginn.Parameters(simulation = SimulationParameters(use_MB=MB,
velocities=false,
Expand All @@ -16,16 +28,6 @@ function pde_solve_test(; rtol::F, atol::F, save_refs::Bool=false, MB::Bool=fals
solver = SolverParameters(reltol=1e-12)
)

## Retrieving gdirs and climate for the following glaciers
## Fast version includes less glacier to reduce the amount of downloaded files and computation time on GitHub CI
if fast
rgi_ids = ["RGI60-11.03638", "RGI60-11.01450"] #, "RGI60-08.00213", "RGI60-04.04351", "RGI60-01.02170"]
else
rgi_ids = ["RGI60-11.03638", "RGI60-11.01450", "RGI60-08.00213", "RGI60-04.04351", "RGI60-01.02170",
"RGI60-02.05098", "RGI60-01.01104", "RGI60-01.09162", "RGI60-01.00570", "RGI60-04.07051",
"RGI60-07.00274", "RGI60-07.01323", "RGI60-01.17316"]
end

if MB
model = Huginn.Model(iceflow = SIA2Dmodel(params), mass_balance = TImodel1(params))
else
Expand Down Expand Up @@ -95,7 +97,11 @@ function TI_run_test!(save_refs::Bool = false; rtol::F, atol::F) where {F <: Abs

working_dir = joinpath(homedir(), "OGGM/Huginn_tests")

rgi_ids = ["RGI60-11.03638"]

rgi_paths = get_rgi_paths()
# Filter out glaciers that are not used to avoid having references that depend on all the glaciers processed in Gungnir
rgi_paths = Dict(k => rgi_paths[k] for k in rgi_ids)

params = Huginn.Parameters(simulation = SimulationParameters(use_MB=true,
velocities=false,
Expand All @@ -106,7 +112,6 @@ function TI_run_test!(save_refs::Bool = false; rtol::F, atol::F) where {F <: Abs
solver = SolverParameters(reltol=1e-8)
)
model = Huginn.Model(iceflow = SIA2Dmodel(params), mass_balance = TImodel1(params))
rgi_ids = ["RGI60-11.03638"]

glacier = initialize_glaciers(rgi_ids, params)[1]
initialize_iceflow_model!(model.iceflow, 1, glacier, params)
Expand Down
5 changes: 1 addition & 4 deletions test/halfar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ Arguments
"""
function unit_halfar_test(; A, n, t₀, t₁, Δx, Δy, nx, ny, h₀, r₀, rtol=0.02, atol=1.0, distance_to_border=3, save_plot=false, inplace=true)

rgi_paths = get_rgi_paths()

# Get parameters for a simulation
parameters = Huginn.Parameters(simulation=SimulationParameters(tspan=(t₀, t₁),
multiprocessing=false,
use_MB=false,
use_iceflow=true,
working_dir=Huginn.root_dir,
rgi_paths=rgi_paths),
working_dir=Huginn.root_dir),
physical=PhysicalParameters(),
solver=SolverParameters(reltol=1e-12))

Expand Down
9 changes: 3 additions & 6 deletions test/mass_conservation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ Arguments
"""
function unit_mass_test(; H₀, B, A, n, t_sim, Δx, Δy, rtol=0.02, save_plot=false)

rgi_paths = get_rgi_paths()

# Get parameters for a simulation
# Get parameters for a simulation
parameters = Huginn.Parameters(simulation=SimulationParameters(tspan=(0.0, t_sim),
use_MB=false,
use_iceflow=true,
rgi_paths=rgi_paths),
use_iceflow=true),
physical=PhysicalParameters(),
solver=SolverParameters(reltol=1e-12))

Expand All @@ -45,7 +42,7 @@ function unit_mass_test(; H₀, B, A, n, t_sim, Δx, Δy, rtol=0.02, save_plot=f
glaciers = Vector{Sleipnir.AbstractGlacier}([glacier])

prediction = Prediction(model, glaciers, parameters)
run!(prediction)
run!(prediction)

# Final solution
H₁_pred = prediction.results[1].H[end]
Expand Down

0 comments on commit f495014

Please sign in to comment.