Skip to content

Commit

Permalink
Fix capping of electron dt relative to ion_dt
Browse files Browse the repository at this point in the history
  • Loading branch information
johnomotani committed Sep 20, 2024
1 parent f06140c commit ff74a1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions moment_kinetics/src/electron_kinetic_equation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ function electron_backward_euler!(scratch, pdf, moments, phi, collisions, compos
t_params.previous_dt[] /= t_params.max_increase_factor
println(" -> ", t_params.previous_dt[])
#elseif nl_solver_params.max_linear_iterations_this_step[] < max(0.1 * nl_solver_params.nonlinear_max_iterations, 2)
elseif nl_solver_params.max_linear_iterations_this_step[] < 20 && t_params.previous_dt[] < cap_factor_ion_dt * ion_dt
elseif nl_solver_params.max_linear_iterations_this_step[] < 20 && (ion_dt === nothing || t_params.previous_dt[] < cap_factor_ion_dt * ion_dt)
# Only took a few iterations, so increase initial step size.
print("increasing previous_dt due to iteration count ", t_params.previous_dt[])
if ion_dt === nothing
Expand All @@ -1361,7 +1361,7 @@ function electron_backward_euler!(scratch, pdf, moments, phi, collisions, compos
if nl_solver_params.max_linear_iterations_this_step[] > 100 && t_params.dt[] > t_params.previous_dt[]
# Step succeeded, but took a lot of iterations so decrease step size.
t_params.dt[] /= t_params.max_increase_factor
elseif nl_solver_params.max_linear_iterations_this_step[] < 20 && t_params.dt[] < cap_factor_ion_dt * ion_dt
elseif nl_solver_params.max_linear_iterations_this_step[] < 20 && (ion_dt === nothing || t_params.dt[] < cap_factor_ion_dt * ion_dt)
# Only took a few iterations, so increase step size.
if ion_dt === nothing
t_params.dt[] *= t_params.max_increase_factor
Expand Down

0 comments on commit ff74a1a

Please sign in to comment.