-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(0.95.3) Reset model clock and skip time_step!
ing if next actuation time is tiny
#3606
base: main
Are you sure you want to change the base?
Changes from 21 commits
29709d4
ed130ee
af8e6b2
b469a9b
d50db47
77b3211
efc4507
d6b0ca4
c40fa48
6aef5b7
fcc4a00
182bed2
218d803
e4aabf3
1879d47
8c8285f
36a2197
5b062d6
44efaab
80870de
6d0202b
4fee2b6
eaa200a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,18 +9,19 @@ import Oceananigans.TimeSteppers: reset! | |
default_progress(simulation) = nothing | ||
|
||
mutable struct Simulation{ML, DT, ST, DI, OW, CB} | ||
model :: ML | ||
Δt :: DT | ||
stop_iteration :: Float64 | ||
stop_time :: ST | ||
wall_time_limit :: Float64 | ||
diagnostics :: DI | ||
output_writers :: OW | ||
callbacks :: CB | ||
run_wall_time :: Float64 | ||
running :: Bool | ||
initialized :: Bool | ||
verbose :: Bool | ||
model :: ML | ||
Δt :: DT | ||
stop_iteration :: Float64 | ||
stop_time :: ST | ||
wall_time_limit :: Float64 | ||
diagnostics :: DI | ||
output_writers :: OW | ||
callbacks :: CB | ||
run_wall_time :: Float64 | ||
running :: Bool | ||
initialized :: Bool | ||
verbose :: Bool | ||
minimum_relative_step :: Float64 | ||
end | ||
|
||
""" | ||
|
@@ -44,12 +45,16 @@ Keyword arguments | |
|
||
- `wall_time_limit`: Stop the simulation if it's been running for longer than this many | ||
seconds of wall clock time. | ||
- `minimum_relative_step`: time steps smaller than `Δt * minimum_relative_step` will be skipped. | ||
This avoids extremely high values when writing the pressure to disk. | ||
Default value is 0. See github.com/CliMA/Oceananigans.jl/issues/3593 for details. | ||
""" | ||
function Simulation(model; Δt, | ||
verbose = true, | ||
stop_iteration = Inf, | ||
stop_time = Inf, | ||
wall_time_limit = Inf) | ||
wall_time_limit = Inf, | ||
minimum_relative_step = 0) | ||
tomchor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if stop_iteration == Inf && stop_time == Inf && wall_time_limit == Inf | ||
@warn "This simulation will run forever as stop iteration = stop time " * | ||
|
@@ -88,7 +93,8 @@ function Simulation(model; Δt, | |
0.0, | ||
false, | ||
false, | ||
verbose) | ||
verbose, | ||
Float64(minimum_relative_step)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why Float64? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was following the other floats in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably we should make it optional. |
||
end | ||
|
||
function Base.show(io::IO, s::Simulation) | ||
|
@@ -100,6 +106,7 @@ function Base.show(io::IO, s::Simulation) | |
"├── Stop time: $(prettytime(s.stop_time))", "\n", | ||
"├── Stop iteration: $(s.stop_iteration)", "\n", | ||
"├── Wall time limit: $(s.wall_time_limit)", "\n", | ||
"├── Minimum relative step: ", prettysummary(s.minimum_relative_step), "\n", | ||
"├── Callbacks: $(ordered_dict_show(s.callbacks, "│"))", "\n", | ||
"├── Output writers: $(ordered_dict_show(s.output_writers, "│"))", "\n", | ||
"└── Diagnostics: $(ordered_dict_show(s.diagnostics, "│"))") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI,
next_actuation_time(sim)
andsim.model.clock.time + Δt
are equivalent. I chose to use the former here to avoid errors related to the addition operation. But let me know if I should change it to just use the latter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't it complicate the code to define
next_actuation_time
in addition toaligned_time_step
? Things go wrong if you change one but not the other. It's usually best to have one "source" of reality / truth