Skip to content

Commit

Permalink
Make maximum number of pseudotimesteps and maximum pseudotime settable
Browse files Browse the repository at this point in the history
Input parameters that control maximum number of pseudotimesteps and
maximum total pseudotime for each kinetic electron pseudotimestepping
loop.
  • Loading branch information
johnomotani committed Nov 25, 2024
1 parent 625141b commit e04355d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion moment_kinetics/src/initial_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ function initialize_electron_pdf!(scratch, scratch_electron, pdf, moments, field
##max_electron_pdf_iterations = 10000
#max_electron_sim_time = nothing
max_electron_pdf_iterations = nothing
max_electron_sim_time = 2.0
max_electron_sim_time = max(2.0, t_params.electron.max_pseudotime)
if t_params.electron.debug_io !== nothing
io_electron = setup_electron_io(t_params.electron.debug_io[1], vpa, vperp, z,
r, composition, collisions,
Expand Down
2 changes: 2 additions & 0 deletions moment_kinetics/src/input_structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ struct time_info{Terrorsum <: Real, T_debug_output, T_electron, Trkimp, Timpzero
decrease_dt_iteration_threshold::mk_int
increase_dt_iteration_threshold::mk_int
cap_factor_ion_dt::mk_float
max_pseudotimesteps::mk_int
max_pseudotime::mk_float
write_after_fixed_step_count::Bool
error_sum_zero::Terrorsum
split_operators::Bool
Expand Down
2 changes: 2 additions & 0 deletions moment_kinetics/src/moment_kinetics_input.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ function mk_input(input_dict=OptionsDict(); save_inputs_to_txt=false, ignore_MPI
decrease_dt_iteration_threshold=100,
increase_dt_iteration_threshold=20,
cap_factor_ion_dt=10.0,
max_pseudotimesteps=1000,
max_pseudotime=1.0e-2,
no_restart=false,
debug_io=false,
)
Expand Down
17 changes: 12 additions & 5 deletions moment_kinetics/src/time_advance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ function setup_time_info(t_input, n_variables, code_time, dt_reload,
decrease_dt_iteration_threshold = t_input["decrease_dt_iteration_threshold"]
increase_dt_iteration_threshold = t_input["increase_dt_iteration_threshold"]
cap_factor_ion_dt = mk_float(t_input["cap_factor_ion_dt"])
max_pseudotimesteps = t_input["max_pseudotimesteps"]
max_pseudotime = t_input["max_pseudotime"]
electron_t_params = nothing
elseif electron === false
debug_io = nothing
Expand All @@ -437,6 +439,8 @@ function setup_time_info(t_input, n_variables, code_time, dt_reload,
decrease_dt_iteration_threshold = -1
increase_dt_iteration_threshold = typemax(mk_int)
cap_factor_ion_dt = Inf
max_pseudotimesteps = -1
max_pseudotime = Inf
electron_t_params = nothing
else
debug_io = nothing
Expand Down Expand Up @@ -470,6 +474,8 @@ function setup_time_info(t_input, n_variables, code_time, dt_reload,
decrease_dt_iteration_threshold = -1
increase_dt_iteration_threshold = typemax(mk_int)
cap_factor_ion_dt = Inf
max_pseudotimesteps = -1
max_pseudotime = Inf
electron_t_params = electron
end
return time_info(n_variables, t_input["nstep"], end_time, t, dt, previous_dt,
Expand All @@ -495,7 +501,8 @@ function setup_time_info(t_input, n_variables, code_time, dt_reload,
electron_preconditioner_type,
mk_float(t_input["constraint_forcing_rate"]),
decrease_dt_iteration_threshold, increase_dt_iteration_threshold,
mk_float(cap_factor_ion_dt), t_input["write_after_fixed_step_count"],
mk_float(cap_factor_ion_dt), mk_int(max_pseudotimesteps),
mk_float(max_pseudotime), t_input["write_after_fixed_step_count"],
error_sum_zero, t_input["split_operators"],
t_input["steady_state_residual"],
mk_float(t_input["converged_residual_value"]),
Expand Down Expand Up @@ -2962,8 +2969,8 @@ end

n_rk_stages = t_params.n_rk_stages

max_electron_pdf_iterations = 1000
max_electron_sim_time = 1.0e-3
max_electron_pdf_iterations = t_params.electron.max_pseudotimesteps
max_electron_sim_time = t_params.electron.max_pseudotime

first_scratch = scratch[1]
@loop_s_r_z_vperp_vpa is ir iz ivperp ivpa begin
Expand Down Expand Up @@ -3554,8 +3561,8 @@ end
t_params.electron, t_params.dt[],
nl_solver_params.electron_advance)
elseif t_params.implicit_electron_ppar
max_electron_pdf_iterations = 1000
max_electron_sim_time = 1.0e-3
max_electron_pdf_iterations = t_params.electron.max_pseudotimesteps
max_electron_sim_time = t_params.electron.max_pseudotime
electron_success = update_electron_pdf!(scratch_electron, pdf.electron.norm,
moments, fields.phi, r, z, vperp, vpa,
z_spectral, vperp_spectral, vpa_spectral,
Expand Down

0 comments on commit e04355d

Please sign in to comment.