Skip to content

Commit 9c80d4b

Browse files
dennisYatuninOlivia Alcabes
authored andcommitted
Add nonequilibrium blocks to Jacobian
1 parent 52734d3 commit 9c80d4b

23 files changed

+2705
-1392
lines changed

.buildkite/Manifest-v1.11.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ version = "0.5.17"
352352
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
353353

354354
[[deps.ClimaAtmos]]
355-
deps = ["Adapt", "ArgParse", "Artifacts", "AtmosphericProfilesLibrary", "ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "CloudMicrophysics", "Dates", "Insolation", "Interpolations", "LazyArtifacts", "LazyBroadcast", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "NullBroadcasts", "RRTMGP", "Random", "SciMLBase", "StaticArrays", "Statistics", "SurfaceFluxes", "Thermodynamics", "UnrolledUtilities", "YAML"]
355+
deps = ["Adapt", "ArgParse", "Artifacts", "AtmosphericProfilesLibrary", "ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "CloudMicrophysics", "Dates", "ForwardDiff", "Insolation", "Interpolations", "LazyArtifacts", "LazyBroadcast", "LinearAlgebra", "Logging", "NCDatasets", "NVTX", "NullBroadcasts", "RRTMGP", "Random", "SciMLBase", "StaticArrays", "Statistics", "SurfaceFluxes", "Thermodynamics", "UnrolledUtilities", "YAML"]
356356
path = ".."
357357
uuid = "b2c96348-7fb7-4fe0-8da9-78d88439e717"
358358
version = "0.30.0"

.buildkite/ci_driver.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import Base.Filesystem: rm
4141
import Statistics: mean
4242
import LinearAlgebra: norm_sqr
4343
include(joinpath(pkgdir(CA), "post_processing", "ci_plots.jl"))
44+
include(joinpath(pkgdir(CA), "post_processing", "jacobian_plots.jl"))
4445

4546
ref_job_id = config.parsed_args["reference_job_id"]
4647
reference_job_id = isnothing(ref_job_id) ? simulation.job_id : ref_job_id
@@ -187,6 +188,7 @@ if ClimaComms.iamroot(config.comms_ctx)
187188
"reproducibility_utils.jl",
188189
),
189190
)
191+
190192
@info "Plotting"
191193
paths = latest_comparable_dirs() # __build__ path (not job path)
192194
if isempty(paths)
@@ -218,6 +220,17 @@ if ClimaComms.iamroot(config.comms_ctx)
218220
end
219221
make_plots(Val(Symbol(reference_job_id)), paths)
220222
end
223+
if (
224+
isnothing(config.parsed_args["plot_jacobian"]) ?
225+
config.parsed_args["debug_approximate_jacobian"] :
226+
config.parsed_args["plot_jacobian"]
227+
)
228+
make_jacobian_plots(
229+
simulation.output_dir,
230+
integrator.u,
231+
float(integrator.dt),
232+
)
233+
end
221234
@info "Plotting done"
222235

223236
if islink(simulation.output_dir)

.buildkite/pipeline.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ steps:
3131

3232
- echo "--- Instantiate .buildkite"
3333
- "julia --project=.buildkite -e 'using Pkg; Pkg.instantiate(;verbose=true); Pkg.precompile(;strict=true); using CUDA; CUDA.precompile_runtime(); Pkg.status()'"
34+
- "julia --project=.buildkite -e 'using Pkg; Pkg.add(Pkg.PackageSpec(;name=\"ClimaCore\", rev=\"dy/disable_shmem\"))'"
35+
- "julia --project=.buildkite -e 'using Pkg; Pkg.add(Pkg.PackageSpec(;name=\"Thermodynamics\", rev=\"dy/more_autodiff_fixes\"))'"
36+
- "julia --project=.buildkite -e 'using Pkg; Pkg.add(Pkg.PackageSpec(;name=\"CloudMicrophysics\", rev=\"main\"))'"
3437

3538
agents:
3639
slurm_cpus_per_task: 8
@@ -119,7 +122,7 @@ steps:
119122
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
120123
--config_file $CONFIG_PATH/single_column_nonorographic_gravity_wave.yml
121124
--job_id single_column_nonorographic_gravity_wave
122-
artifact_paths: "single_column_nonorographic_gravity_wave/*"
125+
artifact_paths: "single_column_nonorographic_gravity_wave/output_active/*"
123126

124127
- group: "Column Examples"
125128
steps:
@@ -153,6 +156,8 @@ steps:
153156
--config_file $CONFIG_PATH/box_density_current_test.yml
154157
--job_id box_density_current_test
155158
artifact_paths: "box_density_current_test/output_active/*"
159+
agents:
160+
slurm_mem: 20GB
156161

157162
- label: ":computer: Box rcemipii with diagnostic edmf"
158163
command: >
@@ -168,7 +173,7 @@ steps:
168173
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
169174
--config_file $CONFIG_PATH/les_isdac_box.yml
170175
--job_id les_isdac_box
171-
artifact_paths: "les_isdac_box/*"
176+
artifact_paths: "les_isdac_box/output_active/*"
172177
env:
173178
CLIMACOMMS_DEVICE: "CUDA"
174179
agents:
@@ -859,7 +864,7 @@ steps:
859864
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
860865
--config_file $CONFIG_PATH/prognostic_edmfx_bomex_box.yml
861866
--job_id prognostic_edmfx_bomex_box
862-
artifact_paths: "prognostic_edmfx_bomex_box/*"
867+
artifact_paths: "prognostic_edmfx_bomex_box/output_active/*"
863868
agents:
864869
slurm_mem: 20GB
865870

@@ -885,7 +890,7 @@ steps:
885890
julia --color=yes --project=.buildkite .buildkite/ci_driver.jl
886891
--config_file $CONFIG_PATH/sphere_nonorographic_gravity_wave.yml
887892
--job_id sphere_nonorographic_gravity_wave
888-
artifact_paths: "sphere_nonorographic_gravity_wave/*"
893+
artifact_paths: "sphere_nonorographic_gravity_wave/output_active/*"
889894
env:
890895
CLIMACOMMS_DEVICE: "CUDA"
891896
agents:

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ ClimaTimeSteppers = "595c0a79-7f3d-439a-bc5a-b232dc3bde79"
1616
ClimaUtilities = "b3f4f4ca-9299-4f7f-bd9b-81e1242a7513"
1717
CloudMicrophysics = "6a9e3e04-43cd-43ba-94b9-e8782df3c71b"
1818
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
19+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1920
Insolation = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
2021
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
2122
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
@@ -48,6 +49,7 @@ ClimaTimeSteppers = "0.8.2"
4849
ClimaUtilities = "0.1.22"
4950
CloudMicrophysics = "0.22.9"
5051
Dates = "1"
52+
ForwardDiff = "0.10.36"
5153
Insolation = "0.9.2"
5254
Interpolations = "0.15.1"
5355
LazyArtifacts = "1"

config/default_configs/default_config.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ newton_rtol:
6262
surface_thermo_state_type:
6363
help: "Surface thermo state type [`GCMSurfaceThermoState` (default), `PrescribedThermoState`]"
6464
value: "GCMSurfaceThermoState"
65-
split_ode:
66-
help: "Use split of ODE problem. Examples: [`true` (implicit, default), `false` (explicit)]"
67-
value: true
6865
use_krylov_method:
6966
help: "Whether to use a Krylov method to solve the linear system in Newton's method (only for ClimaTimeSteppers.jl)"
7067
value: false
@@ -86,6 +83,24 @@ eisenstat_walker_forcing_alpha:
8683
jvp_step_adjustment:
8784
help: "Amount by which the step size of the forward difference approximation of the Jacobian-vector product in the Krylov method should be scaled (only used if `use_krylov_method` is `true`)"
8885
value: 1.0
86+
use_exact_jacobian:
87+
help: "Whether to solve the linear system using the exact Jacobian, which is computed with forward-mode automatic differentiation once per `dt_update_exact_jacobian` (default is `false`)"
88+
value: false
89+
debug_approximate_jacobian:
90+
help: "Whether to compare the approximate Jacobian against the exact Jacobian once per `dt_update_exact_jacobian` (default is `false`)"
91+
value: true # TODO: Change this to false
92+
only_debug_first_column_jacobian:
93+
help: "Whether to debug only the Jacobian in the first column when `debug_approximate_jacobian` is `true` and `use_exact_jacobian` is `false` (default is equal to `n_cols > 10000`)"
94+
value: ~
95+
plot_jacobian:
96+
help: "Whether to save and plot the Jacobian, and also the difference between the approximate Jacobian and exact Jacobian when `debug_approximate_jacobian` is `true` (default is equal to `debug_approximate_jacobian`)"
97+
value: ~
98+
dt_save_jacobian:
99+
help: "Time between snapshots of the Jacobian when `plot_jacobian` is `true` (default is equal to `t_span / 5`)"
100+
value: ~
101+
dt_update_exact_jacobian:
102+
help: "Time between updates to the exact Jacobian (when either `use_exact_jacobian` or `debug_approximate_jacobian` is `true`), with any value smaller than `dt` corresponding to an update before each linear solve (default is equal to `use_exact_jacobian ? 0 : dt_save_jacobian`)"
103+
value: ~
89104
# Radiation
90105
rad:
91106
help: "Radiation model [`nothing` (default), `gray`, `clearsky`, `allsky`, `allskywithclear`]"

docs/src/api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ ClimaAtmos.InitialConditions.Soares
4646
### Implicit Solver
4747

4848
```@docs
49+
ClimaAtmos.JacobianAlgorithm
50+
ClimaAtmos.ApproxJacobian
51+
ClimaAtmos.ExactJacobian
52+
ClimaAtmos.DebugJacobian
4953
ClimaAtmos.ImplicitEquationJacobian
5054
```
5155

0 commit comments

Comments
 (0)