Skip to content

Commit

Permalink
Merge pull request #250 from mabarnes/multiple_sources
Browse files Browse the repository at this point in the history
Multiple source functionality
  • Loading branch information
johnomotani authored Sep 13, 2024
2 parents db370d1 + 5ecabac commit 3038940
Show file tree
Hide file tree
Showing 53 changed files with 1,248 additions and 923 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sd_mi = 0.5 # mD/malpha
sd_me = 0.000013616 # 0.25/1836.0 me/malpha
sd_q = 1.0

[ion_source]
[ion_source_1]
active=false
source_strength=0.0
source_T=0.005
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ sd_mi = 0.5 # mD/malpha
sd_me = 0.000013616 # 0.25/1836.0 me/malpha
sd_q = 1.0

[ion_source]
[ion_source_1]
active=true
source_strength=1.0
source_T=0.005
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ sd_mi = 0.5 # mD/malpha
sd_me = 0.000013616 # 0.25/1836.0 me/malpha
sd_q = 1.0

[ion_source]
[ion_source_1]
active=true
source_strength=1.0
source_T=0.005
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ steady_state_residual = true
converged_residual_value = 1.0e-3
#write_after_fixed_step_count = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ minimum_dt = 1.0e-9
initialization_residual_value = 2.5
converged_residual_value = 0.1 #1.0e-3

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ converged_residual_value = 1.0e-3
[krook_collisions]
use_krook = true

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
2 changes: 1 addition & 1 deletion examples/wall-bc/wall-bc_no-neutrals.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ nwrite = 5000
nwrite_dfns = 5000
split_operators = false

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
2 changes: 1 addition & 1 deletion examples/wall-bc/wall-bc_no-neutrals_split1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ nwrite = 5000
nwrite_dfns = 5000
split_operators = false

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
2 changes: 1 addition & 1 deletion examples/wall-bc/wall-bc_no-neutrals_split2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ nwrite = 5000
nwrite_dfns = 5000
split_operators = false

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
2 changes: 1 addition & 1 deletion examples/wall-bc/wall-bc_no-neutrals_split3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ nwrite = 5000
nwrite_dfns = 5000
split_operators = false

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
Expand Down
4 changes: 2 additions & 2 deletions examples/wall-bc/wall-bc_volumerecycle.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ nwrite = 10000
nwrite_dfns = 10000
split_operators = false

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
source_strength = 2.0
source_T = 2.0

[neutral_source]
[neutral_source_1]
active = true
source_type = "recycling"
recycling_controller_fraction = 0.25
Expand Down
4 changes: 2 additions & 2 deletions examples/wall-bc/wall-bc_volumerecycle_split1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ nwrite = 10000
nwrite_dfns = 10000
split_operators = false

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
source_strength = 2.0
source_T = 2.0

[neutral_source]
[neutral_source_1]
active = true
source_type = "recycling"
recycling_controller_fraction = 0.25
Expand Down
4 changes: 2 additions & 2 deletions examples/wall-bc/wall-bc_volumerecycle_split2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ nwrite = 10000
nwrite_dfns = 10000
split_operators = false

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
source_strength = 2.0
source_T = 2.0

[neutral_source]
[neutral_source_1]
active = true
source_type = "recycling"
recycling_controller_fraction = 0.25
Expand Down
4 changes: 2 additions & 2 deletions examples/wall-bc/wall-bc_volumerecycle_split3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ nwrite = 10000
nwrite_dfns = 10000
split_operators = false

[ion_source]
[ion_source_1]
active = true
z_profile = "gaussian"
z_width = 0.125
source_strength = 2.0
source_T = 2.0

[neutral_source]
[neutral_source_1]
active = true
source_type = "recycling"
recycling_controller_fraction = 0.25
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ using moment_kinetics.load_data: close_run_info, get_run_info_no_setup, get_vari
neutral_moment_variables, all_moment_variables,
ion_dfn_variables, electron_dfn_variables,
neutral_dfn_variables, all_dfn_variables, ion_variables,
neutral_variables, all_variables
neutral_variables, all_variables, ion_source_variables,
neutral_source_variables, electron_source_variables
using moment_kinetics.initial_conditions: vpagrid_to_dzdt
using .shared_utils: calculate_and_write_frequencies
using moment_kinetics.type_definitions: mk_float, mk_int
Expand Down Expand Up @@ -233,14 +234,6 @@ function makie_post_process(run_dir::Union{String,Tuple},
# Plots from moment variables
#############################

moment_variable_list = tuple(em_variables..., ion_moment_variables...)
if has_electrons
moment_variable_list = tuple(moment_variable_list..., electron_moment_variables...)
end
if has_neutrals
moment_variable_list = tuple(moment_variable_list..., neutral_moment_variables...)
end

if any(ri !== nothing for ri ∈ run_info_moments)
has_moments = true

Expand Down Expand Up @@ -276,7 +269,7 @@ function makie_post_process(run_dir::Union{String,Tuple},
end

do_steady_state_residuals = any(input_dict[v]["steady_state_residual"]
for v ∈ moment_variable_list)
for v ∈ all_moment_variables)
if do_steady_state_residuals
textoutput_files = Tuple(ri.run_prefix * "_residuals.txt"
for ri in run_info if ri !== nothing)
Expand All @@ -299,7 +292,7 @@ function makie_post_process(run_dir::Union{String,Tuple},
steady_state_residual_fig_axes = nothing
end

for variable_name ∈ moment_variable_list
for variable_name ∈ all_moment_variables
plots_for_variable(run_info, variable_name; plot_prefix=plot_prefix,
has_rdim=has_rdim, has_zdim=has_zdim, is_1V=is_1V,
steady_state_residual_fig_axes=steady_state_residual_fig_axes)
Expand Down Expand Up @@ -1030,8 +1023,18 @@ function plots_for_variable(run_info, variable_name; plot_prefix, has_rdim=true,
elseif variable_name ∈ neutral_moment_variables ||
variable_name ∈ neutral_dfn_variables
species_indices = 1:maximum(ri.n_neutral_species for ri ∈ run_info)
else
elseif variable_name ∈ ion_moment_variables ||
variable_name ∈ ion_dfn_variables
species_indices = 1:maximum(ri.n_ion_species for ri ∈ run_info)
elseif variable_name in ion_source_variables
species_indices = 1:maximum(length(ri.external_source_settings.ion) for ri ∈ run_info)
elseif variable_name in electron_source_variables
species_indices = 1:maximum(length(ri.external_source_settings.electron) for ri ∈ run_info)
elseif variable_name in neutral_source_variables
species_indices = 1:maximum(length(ri.external_source_settings.neutral) for ri ∈ run_info)
else
species_indices = 1:1
#error("variable_name=$variable_name not found in any defined group")
end
for is ∈ species_indices
if is !== nothing
Expand Down
2 changes: 1 addition & 1 deletion moment_kinetics/debug_test/kinetic_electron_inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test_input = OptionsDict("composition" => OptionsDict("n_ion_species" => 1,
"vz_L" => 6.0,
"vz_bc" => "zero",
"vz_discretization" => "chebyshev_pseudospectral",
"ion_source" => OptionsDict("active" => true,
"ion_source_1" => OptionsDict("active" => true,
"z_profile" => "gaussian",
"z_width" => 0.125,
"source_strength" => 2.0,
Expand Down
2 changes: 1 addition & 1 deletion moment_kinetics/debug_test/recycling_fraction_inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test_input = OptionsDict("composition" => OptionsDict("n_ion_species" => 1,
"vz_L" => 6.0,
"vz_bc" => "zero",
"vz_discretization" => "chebyshev_pseudospectral",
"ion_source" => OptionsDict("active" => true,
"ion_source_1" => OptionsDict("active" => true,
"z_profile" => "gaussian",
"z_width" => 0.125,
"source_strength" => 2.0,
Expand Down
Loading

0 comments on commit 3038940

Please sign in to comment.