Skip to content

Commit 33d6032

Browse files
Merge pull request #3593 from CliMA/dy/steady_state_tests
Add tests and plots for steady-state velocity
2 parents b1dd16b + 3d8806f commit 33d6032

29 files changed

+1048
-224
lines changed

.buildkite/ci_driver.jl

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ sol_res = CA.solve_atmos!(simulation)
2828
(; p) = integrator
2929

3030
import ClimaCore
31-
import ClimaCore: Topologies, Quadratures, Spaces
31+
import ClimaCore: Topologies, Quadratures, Spaces, Fields
3232
import ClimaComms
3333
using SciMLBase
3434
using PrettyTables
@@ -38,6 +38,8 @@ using ClimaTimeSteppers
3838
using Test
3939
import Tar
4040
import Base.Filesystem: rm
41+
import Statistics: mean
42+
import LinearAlgebra: norm_sqr
4143
include(joinpath(pkgdir(CA), "post_processing", "ci_plots.jl"))
4244

4345
ref_job_id = config.parsed_args["reference_job_id"]
@@ -108,6 +110,58 @@ end
108110
# Write diagnostics that are in DictWriter to text files
109111
CA.write_diagnostics_as_txt(simulation)
110112

113+
if config.parsed_args["check_steady_state"]
114+
Y_end = integrator.sol.u[end]
115+
t_end = integrator.sol.t[end]
116+
(; steady_state_velocity, params) = integrator.p
117+
(; zd_rayleigh) = params
118+
FT = eltype(Y_end)
119+
120+
@info "Comparing velocity fields to predicted steady state at t = $t_end"
121+
ᶜu_normsqr = norm_sqr.(steady_state_velocity.ᶜu)
122+
ᶠu_normsqr = norm_sqr.(steady_state_velocity.ᶠu)
123+
ᶜuₕ_err_normsqr = norm_sqr.(Y_end.c.uₕ .- CA.C12.(steady_state_velocity.ᶜu))
124+
ᶠu₃_err_normsqr = norm_sqr.(Y_end.f.u₃ .- CA.C3.(steady_state_velocity.ᶠu))
125+
126+
# Average all errors below the sponge layer.
127+
ᶜsponge_mask = FT.(Fields.coordinate_field(Y_end.c).z .< zd_rayleigh)
128+
ᶠsponge_mask = FT.(Fields.coordinate_field(Y_end.f).z .< zd_rayleigh)
129+
ᶜu_rms = sqrt(sum(ᶜu_normsqr .* ᶜsponge_mask) / sum(ᶜsponge_mask))
130+
ᶠu_rms = sqrt(sum(ᶠu_normsqr .* ᶠsponge_mask) / sum(ᶠsponge_mask))
131+
ᶜuₕ_rmse = sqrt(sum(ᶜuₕ_err_normsqr .* ᶜsponge_mask) / sum(ᶜsponge_mask))
132+
ᶠu₃_rmse = sqrt(sum(ᶠu₃_err_normsqr .* ᶠsponge_mask) / sum(ᶠsponge_mask))
133+
ᶜuₕ_rel_err = ᶜuₕ_rmse / ᶜu_rms
134+
ᶠu₃_rel_err = ᶠu₃_rmse / ᶠu_rms
135+
136+
# Average the errors on several levels close to the surface.
137+
n_levels = 3
138+
level_uₕ_rel_errs = map(1:n_levels) do level
139+
level_u_rms = sqrt(mean(Fields.level(ᶜu_normsqr, level)))
140+
level_uₕ_rmse = sqrt(mean(Fields.level(ᶜuₕ_err_normsqr, level)))
141+
level_uₕ_rmse / level_u_rms
142+
end
143+
level_u₃_rel_errs = map((1:n_levels) .- Fields.half) do level
144+
level_u_rms = sqrt(mean(Fields.level(ᶠu_normsqr, level)))
145+
level_u₃_rmse = sqrt(mean(Fields.level(ᶠu₃_err_normsqr, level)))
146+
level_u₃_rmse / level_u_rms
147+
end
148+
149+
@info " Absolute RMSE of uₕ below sponge layer: $ᶜuₕ_rmse"
150+
@info " Absolute RMSE of u₃ below sponge layer: $ᶠu₃_rmse"
151+
@info " Relative RMSE of uₕ below sponge layer: $ᶜuₕ_rel_err"
152+
@info " Relative RMSE of u₃ below sponge layer: $ᶠu₃_rel_err"
153+
@info " Relative RMSE of uₕ on $n_levels levels closest to the surface:"
154+
@info " $level_uₕ_rel_errs"
155+
@info " Relative RMSE of u₃ on $n_levels levels closest to the surface:"
156+
@info " $level_u₃_rel_errs"
157+
158+
if t_end > 24 * 60 * 60
159+
# TODO: Float32 simulations currently show significant divergence of uₕ.
160+
@test ᶜuₕ_rel_err < (FT == Float32 ? 0.05 : 0.005)
161+
@test ᶠu₃_rel_err < 0.0005
162+
end
163+
end
164+
111165
# Conservation checks
112166
if config.parsed_args["check_conservation"]
113167
FT = Spaces.undertype(axes(sol.u[end].c.ρ))

.buildkite/pipeline.yml

Lines changed: 79 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,27 +178,94 @@ steps:
178178

179179
- group: "Plane Examples"
180180
steps:
181-
- label: ":computer: Agnesi linear hydrostatic mountain experiment (uniform)"
181+
182+
- label: ":computer: Density current experiment"
182183
command: >
183184
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
184-
--config_file $CONFIG_PATH/plane_agnesi_mountain_test_uniform.yml
185-
--job_id plane_agnesi_mountain_test_uniform
186-
artifact_paths: "plane_agnesi_mountain_test_uniform/output_active/*"
185+
--config_file $CONFIG_PATH/plane_density_current_test.yml
186+
--job_id plane_density_current_test
187+
artifact_paths: "plane_density_current_test/output_active/*"
187188

188-
- label: ":computer: Agnesi linear hydrostatic mountain experiment (stretched)"
189+
- group: "Analytic Tests"
190+
steps:
191+
- label: "GPU: No Topography Test (2D, Float64, Discrete Balance)"
189192
command: >
190193
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
191-
--config_file $CONFIG_PATH/plane_agnesi_mountain_test_stretched.yml
192-
--job_id plane_agnesi_mountain_test_stretched
193-
artifact_paths: "plane_agnesi_mountain_test_stretched/output_active/*"
194+
--config_file $CONFIG_PATH/plane_no_topography_float64_test.yml
195+
--job_id gpu_plane_no_topography_float64_test
196+
artifact_paths: "gpu_plane_no_topography_float64_test/output_active/*"
197+
env:
198+
CLIMACOMMS_DEVICE: "CUDA"
199+
agents:
200+
slurm_gpus: 1
194201

195-
- label: ":computer: Density current experiment"
202+
- label: "GPU: Cosine Hills Test (2D, Float64)"
196203
command: >
197204
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
198-
--config_file $CONFIG_PATH/plane_density_current_test.yml
199-
--job_id plane_density_current_test
200-
artifact_paths: "plane_density_current_test/output_active/*"
205+
--config_file $CONFIG_PATH/plane_cosine_hills_float64_test.yml
206+
--job_id gpu_plane_cosine_hills_float64_test
207+
artifact_paths: "gpu_plane_cosine_hills_float64_test/output_active/*"
208+
env:
209+
CLIMACOMMS_DEVICE: "CUDA"
210+
agents:
211+
slurm_gpus: 1
212+
213+
- label: "GPU: Cosine Hills Test (Extruded 2D, Float64)"
214+
command: >
215+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
216+
--config_file $CONFIG_PATH/extruded_plane_cosine_hills_float64_test.yml
217+
--job_id gpu_extruded_plane_cosine_hills_float64_test
218+
artifact_paths: "gpu_extruded_plane_cosine_hills_float64_test/output_active/*"
219+
env:
220+
CLIMACOMMS_DEVICE: "CUDA"
221+
agents:
222+
slurm_gpus: 1
223+
slurm_mem: 48GB
224+
225+
- label: "GPU: Cosine Hills Test (3D, Float64)"
226+
command: >
227+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
228+
--config_file $CONFIG_PATH/box_cosine_hills_float64_test.yml
229+
--job_id gpu_box_cosine_hills_float64_test
230+
artifact_paths: "gpu_box_cosine_hills_float64_test/output_active/*"
231+
env:
232+
CLIMACOMMS_DEVICE: "CUDA"
233+
agents:
234+
slurm_gpus: 1
235+
slurm_mem: 48GB
236+
237+
- label: "GPU: Agnesi Mountain Test (2D, Float64)"
238+
command: >
239+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
240+
--config_file $CONFIG_PATH/plane_agnesi_mountain_float64_test.yml
241+
--job_id gpu_plane_agnesi_mountain_float64_test
242+
artifact_paths: "gpu_plane_agnesi_mountain_float64_test/output_active/*"
243+
env:
244+
CLIMACOMMS_DEVICE: "CUDA"
245+
agents:
246+
slurm_gpus: 1
201247

248+
- label: "GPU: Schar Mountain Test (2D, Float64)"
249+
command: >
250+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
251+
--config_file $CONFIG_PATH/plane_schar_mountain_float64_test.yml
252+
--job_id gpu_plane_schar_mountain_float64_test
253+
artifact_paths: "gpu_plane_schar_mountain_float64_test/output_active/*"
254+
env:
255+
CLIMACOMMS_DEVICE: "CUDA"
256+
agents:
257+
slurm_gpus: 1
258+
259+
- label: "GPU: Schar Mountain Test (2D, Float32)"
260+
command: >
261+
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
262+
--config_file $CONFIG_PATH/plane_schar_mountain_float32_test.yml
263+
--job_id gpu_plane_schar_mountain_float32_test
264+
artifact_paths: "gpu_plane_schar_mountain_float32_test/output_active/*"
265+
env:
266+
CLIMACOMMS_DEVICE: "CUDA"
267+
agents:
268+
slurm_gpus: 1
202269

203270
- group: "Conservation check"
204271
steps:

config/default_configs/default_config.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ scalar_hyperdiffusion_coefficient:
3535
value: 1.5
3636
# Topography
3737
topography:
38-
help: "Define the surface elevation profile [`NoWarp` (default),`Earth`,`DCMIP200`,`Agnesi`, `Schar`, `Hughes2023`]"
38+
help: "Define the surface elevation profile [`NoWarp` (default), `Earth`, `DCMIP200`, `Hughes2023`, `Agnesi`, `Schar`, `Cosine2D`, `Cosine3D`]"
3939
value: "NoWarp"
4040
mesh_warp_type:
4141
help: "Sets the interior mesh warp method [`Linear`, `SLEVE`]"
@@ -182,7 +182,7 @@ surface_temperature:
182182
help: "Prescribed surface temperature functional form ['ZonallySymmetric' (default), 'ZonallyAsymmetric', 'RCEMIPII']"
183183
value: "ZonallySymmetric"
184184
initial_condition:
185-
help: "Initial condition [`DryBaroclinicWave`, `MoistBaroclinicWave`, `DecayingProfile`, `IsothermalProfile`, `Bomex`, `DryDensityCurrentProfile`, `AgnesiHProfile`, `ScharProfile`, `RisingThermalBubbleProfile`, `ISDAC`], or a file path for a NetCDF file (read documentation about requirements)."
185+
help: "Initial condition [`DryBaroclinicWave`, `MoistBaroclinicWave`, `ConstantBuoyancyFrequencyProfile`, `DecayingProfile`, `IsothermalProfile`, `Bomex`, `DryDensityCurrentProfile`, `RisingThermalBubbleProfile`, `ISDAC`], or a file path for a NetCDF file (read documentation about requirements)."
186186
value: "DecayingProfile"
187187
perturb_initstate:
188188
help: "Add a perturbation to the initial condition [`false`, `true` (default)]"
@@ -226,6 +226,9 @@ reproducibility_test:
226226
check_conservation:
227227
help: "Check conservation of mass and energy [`false` (default), `true`]"
228228
value: false
229+
check_steady_state:
230+
help: "Compare steady-state velocity to analytic solution; only available for certain choices of `topography` [`false` (default), `true`]"
231+
value: false
229232
ls_adv:
230233
help: "Large-scale advection [`nothing` (default), `Bomex`, `LifeCycleTan2018`, `Rico`, `ARM_SGP`, `GATE_III`]"
231234
value: ~
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
config: "box"
2+
FLOAT_TYPE: "Float64"
3+
initial_condition: "ConstantBuoyancyFrequencyProfile"
4+
topography: "Cosine3D"
5+
x_max: 100e3
6+
y_max: 25e3
7+
z_max: 21e3
8+
x_elem: 100
9+
y_elem: 25
10+
z_elem: 100
11+
dz_bottom: 10
12+
dt: "0.5secs" # CFL is slightly lower than for 2D case
13+
t_end: "30mins"
14+
rayleigh_sponge: true
15+
toml: [toml/steady_state_test.toml]
16+
check_steady_state: true
17+
output_default_diagnostics: false
18+
diagnostics:
19+
- short_name: [orog, ua, wa, uapredicted, wapredicted, uaerror, waerror]
20+
period: 1mins
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
config: "box"
2+
FLOAT_TYPE: "Float64"
3+
initial_condition: "ConstantBuoyancyFrequencyProfile"
4+
topography: "Cosine2D"
5+
x_max: 100e3
6+
y_max: 1e3
7+
z_max: 21e3
8+
x_elem: 100
9+
y_elem: 1
10+
z_elem: 100
11+
dz_bottom: 10
12+
dt: "0.5secs" # CFL is slightly lower than for 2D case
13+
t_end: "9hours"
14+
rayleigh_sponge: true
15+
toml: [toml/steady_state_test.toml]
16+
check_steady_state: true
17+
output_default_diagnostics: false
18+
diagnostics:
19+
- short_name: [orog, ua, wa, uapredicted, wapredicted, uaerror, waerror]
20+
period: 1hours
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
config: "plane"
2+
FLOAT_TYPE: "Float64"
3+
initial_condition: "ConstantBuoyancyFrequencyProfile"
4+
topography: "Agnesi"
5+
x_max: 100e3
6+
z_max: 21e3
7+
x_elem: 100
8+
z_elem: 100
9+
dz_bottom: 10
10+
dt: "0.7secs"
11+
t_end: "2days"
12+
rayleigh_sponge: true
13+
toml: [toml/steady_state_test.toml]
14+
check_steady_state: true
15+
output_default_diagnostics: false
16+
diagnostics:
17+
- short_name: [orog, ua, wa, uapredicted, wapredicted, uaerror, waerror]
18+
period: 1hours

config/model_configs/plane_agnesi_mountain_test_stretched.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

config/model_configs/plane_agnesi_mountain_test_uniform.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
config: "plane"
2+
FLOAT_TYPE: "Float64"
3+
initial_condition: "ConstantBuoyancyFrequencyProfile"
4+
topography: "Cosine2D"
5+
x_max: 100e3
6+
z_max: 21e3
7+
x_elem: 100
8+
z_elem: 100
9+
dz_bottom: 10
10+
dt: "0.7secs"
11+
t_end: "2days"
12+
rayleigh_sponge: true
13+
toml: [toml/steady_state_test.toml]
14+
check_steady_state: true
15+
output_default_diagnostics: false
16+
diagnostics:
17+
- short_name: [orog, ua, wa, uapredicted, wapredicted, uaerror, waerror]
18+
period: 1hours
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
config: "plane"
2+
FLOAT_TYPE: "Float64"
3+
initial_condition: "ConstantBuoyancyFrequencyProfile"
4+
discrete_hydrostatic_balance: true
5+
x_max: 100e3
6+
z_max: 21e3
7+
x_elem: 100
8+
z_elem: 100
9+
dz_bottom: 10
10+
dt: "0.7secs"
11+
t_end: "2days"
12+
rayleigh_sponge: true
13+
toml: [toml/steady_state_test.toml]
14+
check_steady_state: true
15+
output_default_diagnostics: false
16+
diagnostics:
17+
- short_name: [orog, ua, wa, uapredicted, wapredicted, uaerror, waerror]
18+
period: 1hours

0 commit comments

Comments
 (0)