diff --git a/moment_kinetics/src/initial_conditions.jl b/moment_kinetics/src/initial_conditions.jl index 522710641..df191e544 100644 --- a/moment_kinetics/src/initial_conditions.jl +++ b/moment_kinetics/src/initial_conditions.jl @@ -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, diff --git a/moment_kinetics/src/input_structs.jl b/moment_kinetics/src/input_structs.jl index 2bf4cf57c..682830365 100644 --- a/moment_kinetics/src/input_structs.jl +++ b/moment_kinetics/src/input_structs.jl @@ -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 diff --git a/moment_kinetics/src/moment_kinetics_input.jl b/moment_kinetics/src/moment_kinetics_input.jl index 18e78aeb6..e1008bf0e 100644 --- a/moment_kinetics/src/moment_kinetics_input.jl +++ b/moment_kinetics/src/moment_kinetics_input.jl @@ -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, ) diff --git a/moment_kinetics/src/time_advance.jl b/moment_kinetics/src/time_advance.jl index 1ea997da5..77070dec8 100644 --- a/moment_kinetics/src/time_advance.jl +++ b/moment_kinetics/src/time_advance.jl @@ -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 @@ -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 @@ -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, @@ -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"]), @@ -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 @@ -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,