Skip to content

Commit

Permalink
Try running most of CI with exact Jacobian
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisYatunin committed Mar 2, 2024
1 parent 85fd966 commit 9836897
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions config/default_configs/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ jvp_step_adjustment:
value: 1.0
use_exact_jacobian:
help: "Whether to solve the linear system using the exact Jacobian, which is computed with forward-mode automatic differentiation (default is `false`)"
value: false
value: true
n_steps_update_exact_jacobian:
help: "Number of timesteps between updates to the exact Jacobian (default is 0, which corresponds to updating the exact Jacobian on each Newton iteration)"
value: 100
debug_jacobian_approximation:
help: "Whether to check the accuracy of the Jacobian approximation against the exact Jacobian every `n_steps_update_exact_jacobian` timesteps (default is `false`)"
value: true
value: 0
debug_approximate_jacobian:
help: "Whether to check the accuracy of the approximate Jacobian against the exact Jacobian every `n_steps_update_exact_jacobian` timesteps (default is `false`)"
value: false
# Radiation
rad:
help: "Radiation model [`nothing` (default), `gray`, `clearsky`, `allsky`, `allskywithclear`]"
Expand Down
12 changes: 6 additions & 6 deletions src/prognostic_equations/implicit/debug_jacobian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jacobian_cache(mode::DebugJacobian, Y, p) = (;
x_error = similar(Y),
x_rel_error = similar(Y),
exact_jacobian_just_updated = Ref{Bool}(),
latest_t = Ref{typeof(p.t_end)}()
latest_t = Ref{typeof(p.t_end)}(),
)

always_update_exact_jacobian(mode::DebugJacobian) =
Expand All @@ -42,7 +42,7 @@ function factorize_exact_jacobian!(mode::DebugJacobian, cache, Y, p, dtγ, t)
t,
)
cache.exact_jacobian_just_updated[] = true
cahce.latest_t[] = p.t_end
cache.latest_t[] = t
end

approximate_jacobian!(mode::DebugJacobian, cache, Y, p, dtγ, t) =
Expand Down Expand Up @@ -88,10 +88,10 @@ invert_jacobian!(mode::DebugJacobian, cache, x, b) =
rms_rel_error = @allowscalar rms(cache.x_rel_error)
max_rel_error = @allowscalar maximum(cache.x_rel_error)
@info """Error of approximate implicit solve at t = $(cache.latest_t[]):
relative RMS error = $(@sprintf("%.3e", rel_rms_error))
relative max error = $(@sprintf("%.3e", rel_max_error))
RMS relative error = $(@sprintf("%.3e", rms_rel_error))
max relative error = $(@sprintf("%.3e", max_rel_error))"""
relative RMS error = $(@sprintf("%.3e", rel_rms_error))
relative max error = $(@sprintf("%.3e", rel_max_error))
RMS relative error = $(@sprintf("%.3e", rms_rel_error))
max relative error = $(@sprintf("%.3e", max_rel_error))"""
@assert rel_rms_error < 1 # TODO: Make this test more rigorous
elseif mode.use_exact_jacobian
invert_jacobian!(
Expand Down

0 comments on commit 9836897

Please sign in to comment.