Skip to content

Commit

Permalink
Add option that can be set to enable inclusion of wall bc in precon
Browse files Browse the repository at this point in the history
Adding the wall boundary condition to the preconditioner matrix (at
least in the form implemented so far) does not seem to speed up
convergence significantly, so make it a feature that can be optionally
enabled.
  • Loading branch information
johnomotani committed Dec 7, 2024
1 parent 67a7c5d commit 34dc561
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
10 changes: 6 additions & 4 deletions moment_kinetics/src/electron_kinetic_equation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4674,11 +4674,13 @@ Fill a pre-allocated matrix with the Jacobian matrix for electron kinetic equati
add_ion_dt_forcing_of_electron_ppar_to_Jacobian!(
jacobian_matrix, z, dt, ion_dt, ir, include; ppar_offset=pdf_size)
end
add_wall_boundary_condition_to_Jacobian!(
jacobian_matrix, phi, f, ppar, vth, upar, z, vperp, vpa, vperp_spectral,
vpa_spectral, vpa_advect, moments,
num_diss_params.electron.vpa_dissipation_coefficient, me, ir;
if t_params.include_wall_bc_in_preconditioner
add_wall_boundary_condition_to_Jacobian!(
jacobian_matrix, phi, f, ppar, vth, upar, z, vperp, vpa, vperp_spectral,
vpa_spectral, vpa_advect, moments,
num_diss_params.electron.vpa_dissipation_coefficient, me, ir;
ppar_offset=pdf_size)
end

return nothing
end
Expand Down
1 change: 1 addition & 0 deletions moment_kinetics/src/input_structs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct time_info{Terrorsum <: Real, T_debug_output, T_electron, Trkimp, Timpzero
cap_factor_ion_dt::mk_float
max_pseudotimesteps::mk_int
max_pseudotime::mk_float
include_wall_bc_in_preconditioner::Bool
write_after_fixed_step_count::Bool
error_sum_zero::Terrorsum
split_operators::Bool
Expand Down
1 change: 1 addition & 0 deletions moment_kinetics/src/moment_kinetics_input.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ function mk_input(input_dict=OptionsDict(); save_inputs_to_txt=false, ignore_MPI
cap_factor_ion_dt=10.0,
max_pseudotimesteps=1000,
max_pseudotime=1.0e-2,
include_wall_bc_in_preconditioner=false,
no_restart=false,
debug_io=false,
)
Expand Down
9 changes: 6 additions & 3 deletions moment_kinetics/src/time_advance.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ function setup_time_info(t_input, n_variables, code_time, dt_reload,
cap_factor_ion_dt = mk_float(t_input["cap_factor_ion_dt"])
max_pseudotimesteps = t_input["max_pseudotimesteps"]
max_pseudotime = t_input["max_pseudotime"]
include_wall_bc_in_preconditioner = t_input["include_wall_bc_in_preconditioner"]
electron_t_params = nothing
elseif electron === false
debug_io = nothing
Expand All @@ -441,6 +442,7 @@ function setup_time_info(t_input, n_variables, code_time, dt_reload,
cap_factor_ion_dt = Inf
max_pseudotimesteps = -1
max_pseudotime = Inf
include_wall_bc_in_preconditioner = false
electron_t_params = nothing
else
debug_io = nothing
Expand Down Expand Up @@ -476,6 +478,7 @@ function setup_time_info(t_input, n_variables, code_time, dt_reload,
cap_factor_ion_dt = Inf
max_pseudotimesteps = -1
max_pseudotime = Inf
include_wall_bc_in_preconditioner = false
electron_t_params = electron
end
return time_info(n_variables, t_input["nstep"], end_time, t, dt, previous_dt,
Expand Down Expand Up @@ -503,9 +506,9 @@ function setup_time_info(t_input, n_variables, code_time, dt_reload,
mk_float(t_input["constraint_forcing_rate"]),
decrease_dt_iteration_threshold, increase_dt_iteration_threshold,
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(max_pseudotime), include_wall_bc_in_preconditioner,
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"]),
manufactured_solns_input.use_for_advance, t_input["stopfile_name"],
debug_io, electron_t_params)
Expand Down
1 change: 1 addition & 0 deletions moment_kinetics/test/jacobian_matrix_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ test_input = OptionsDict("output" => OptionsDict("run_name" => "jacobian_matrix"
"initialization_residual_value" => 2.5,
"converged_residual_value" => 1.0e-2,
"constraint_forcing_rate" => 2.321,
"include_wall_bc_in_preconditioner" => true,
),
"nonlinear_solver" => OptionsDict("nonlinear_max_iterations" => 100,
"rtol" => 1.0e-5,
Expand Down

0 comments on commit 34dc561

Please sign in to comment.