Skip to content

Commit fac2935

Browse files
authored
Add minimum timestep to simulator config (#120)
1 parent b94b552 commit fac2935

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/simulator/config.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Negative values disable output. The interpretation of this number is subject to
1515
# Convergence tests
1616
add_option!(cfg, :max_timestep_cuts, 5, "Max time step cuts in a single mini step before termination of simulation.", types = Int, values = 0:10000)
1717
add_option!(cfg, :max_timestep, Inf, "Max time step length.", types = Float64)
18+
add_option!(cfg, :min_timestep, 0.0, "Min time step length.", types = Float64)
1819
add_option!(cfg, :max_nonlinear_iterations, 15, "Max number of nonlinear iterations in a Newton solve before time-step is cut.", types = Int, values = 0:10000)
1920
add_option!(cfg, :min_nonlinear_iterations, 1, "Minimum number of nonlinear iterations in Newton solver.", description = "This number of Newtion iterations is always performed, even if all equations are converged.", types = Int, values = 0:10000)
2021
add_option!(cfg, :failure_cuts_timestep, false, "Cut the timestep if exceptions occur during step. If set to false, throw errors and terminate.", types = Bool)

src/simulator/timesteps.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function pick_timestep(sim, config, dt_prev, dT, forces, reports, current_report
2929
if dt > half_remain && dt < remaining_time
3030
dt = half_remain
3131
end
32-
dt = min(dt, config[:max_timestep])
32+
dt = clamp(dt, config[:min_timestep], config[:max_timestep])
3333
if config[:info_level] > 1
3434
ratio = dt/dt_prev
3535
if ratio > 5
@@ -49,6 +49,9 @@ function pick_timestep(sim, config, dt_prev, dT, forces, reports, current_report
4949
end
5050

5151
function cut_timestep(sim, config, dt, dT, forces, reports; step_index = NaN, cut_count = 0)
52+
if isapprox(dt, config[:min_timestep])
53+
return NaN
54+
end
5255
for sel in config[:timestep_selectors]
5356
candidate = pick_cut_timestep(sel, sim, config, dt, dT, forces, reports, cut_count)
5457
dt = min(dt, candidate)

0 commit comments

Comments
 (0)