Skip to content

Commit

Permalink
Add kinetic electron case to precompilation runs inputs
Browse files Browse the repository at this point in the history
Also add a script to precompile specifically for kinetic electron runs.
  • Loading branch information
johnomotani committed Jun 12, 2024
1 parent d8cfa26 commit 3d3b87a
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 3 deletions.
16 changes: 16 additions & 0 deletions precompile-kinetic-electrons.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Pkg

# Activate the moment_kinetics package
Pkg.activate(".")

using PackageCompiler

# Create the sysimage 'moment_kinetics.so' in the base moment_kinetics source directory
# with both moment_kinetics and the dependencies listed above precompiled.
# Warning: editing the code will not affect what runs when using this .so, you
# need to re-precompile if you change anything.
create_sysimage(; sysimage_path="moment_kinetics.so",
precompile_execution_file="util/precompile_run_kinetic-electrons.jl",
include_transitive_dependencies=false, # This is needed to make MPI work, see https://github.com/JuliaParallel/MPI.jl/issues/518
sysimage_build_args=`-O3 --check-bounds=no`, # Assume if we are precompiling we want an optimized, production build
)
18 changes: 15 additions & 3 deletions util/precompile_run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ base_input = Dict("run_name" => "precompilation",
"vpa_ngrid" => 7,
"vpa_nelement" => 3,
"vpa_bc" => "zero",
"vpa_L" => 4.0,
"vpa_L" => 8.0,
"vpa_discretization" => "finite_difference",
"vzeta_ngrid" => 5,
"vzeta_nelement" => 3,
Expand All @@ -42,7 +42,7 @@ base_input = Dict("run_name" => "precompilation",
"vz_ngrid" => 7,
"vz_nelement" => 3,
"vz_bc" => "zero",
"vz_L" => 4.0,
"vz_L" => 8.0,
"vz_discretization" => "finite_difference",
"timestepping" => Dict{String,Any}("nstep" => 1))
cheb_input = merge(base_input, Dict("r_discretization" => "chebyshev_pseudospectral",
Expand Down Expand Up @@ -76,7 +76,19 @@ collisions_input = merge(wall_bc_cheb_input, Dict("n_neutral_species" => 0,
geo_input1 = merge(wall_bc_cheb_input, Dict("n_neutral_species" => 0,
"geometry" => Dict{String,Any}("option" => "1D-mirror", "DeltaB" => 0.5, "pitch" => 0.5, "rhostar" => 1.0)))

push!(inputs_list, collisions_input, geo_input1)
kinetic_electron_input = merge(cheb_input, Dict("evolve_moments_density" => true,
"evolve_moments_parallel_flow" => true,
"evolve_moments_parallel_pressure" => true,
"electron_physics" => "kinetic_electrons",
"electron_timestepping" => Dict{String,Any}("nstep" => 1,
"dt" => 2.0e-11,
"initialization_residual_value" => 1.0e10,
"converged_residual_value" => 1.0e10,
"rtol" => 1.0e10,
"no_restart" => true),
))

push!(inputs_list, collisions_input, geo_input1, kinetic_electron_input)

for input in inputs_list
run_moment_kinetics(input)
Expand Down
61 changes: 61 additions & 0 deletions util/precompile_run_kinetic-electrons.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# provide option of running from command line via 'julia moment_kinetics.jl'
using Pkg
Pkg.activate(".")

using moment_kinetics

# Create a temporary directory for test output
test_output_directory = tempname()
mkpath(test_output_directory)

input = Dict("run_name" => "precompilation",
"base_directory" => test_output_directory,
"dt" => 0.0,
"evolve_moments_density" => true,
"evolve_moments_parallel_flow" => true,
"evolve_moments_parallel_pressure" => true,
"electron_physics" => "kinetic_electrons",
"r_ngrid" => 1,
"r_nelement" => 1,
"r_bc" => "periodic",
"r_discretization" => "chebyshev_pseudospectral",
"z_ngrid" => 5,
"z_nelement" => 4,
"z_bc" => "wall",
"z_discretization" => "chebyshev_pseudospectral",
"vperp_ngrid" => 1,
"vperp_nelement" => 1,
"vperp_bc" => "zero",
"vperp_L" => 4.0,
"vperp_discretization" => "chebyshev_pseudospectral",
"vpa_ngrid" => 7,
"vpa_nelement" => 8,
"vpa_bc" => "zero",
"vpa_L" => 8.0,
"vpa_discretization" => "chebyshev_pseudospectral",
"vzeta_ngrid" => 1,
"vzeta_nelement" => 1,
"vzeta_bc" => "zero",
"vzeta_L" => 4.0,
"vzeta_discretization" => "chebyshev_pseudospectral",
"vr_ngrid" => 1,
"vr_nelement" => 1,
"vr_bc" => "zero",
"vr_L" => 4.0,
"vr_discretization" => "chebyshev_pseudospectral",
"vz_ngrid" => 7,
"vz_nelement" => 8,
"vz_bc" => "zero",
"vz_L" => 8.0,
"vz_discretization" => "chebyshev_pseudospectral",
"timestepping" => Dict{String,Any}("nstep" => 1,
"dt" => 2.0e-11),
"electron_timestepping" => Dict{String,Any}("nstep" => 1,
"dt" => 2.0e-11,
"initialization_residual_value" => 1.0e10,
"converged_residual_value" => 1.0e10,
"rtol" => 1.0e10,
"no_restart" => true))


run_moment_kinetics(input)

0 comments on commit 3d3b87a

Please sign in to comment.