Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inputs refactor and extra checking #247

Merged
merged 58 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e30e924
Get coordinate input from separate sections in input file
johnomotani Sep 6, 2024
cca406c
Add recursive_merge() function to merge nested Dicts
johnomotani Sep 7, 2024
644a215
Replace merge_dict_of_dicts() with recursive_merge()
johnomotani Sep 7, 2024
e95e9c0
Update inputs with new coordinate inputs structure
johnomotani Sep 6, 2024
be1cffb
Fix handling of periodic bc in gauss_legendre
johnomotani Sep 6, 2024
6a4e613
Comment out nelement_local in some recyclefraction examples
johnomotani Sep 7, 2024
1944de7
Remove spline_derivatives_test.jl script
johnomotani Sep 7, 2024
b06af35
Add Github workflow that checks the 'test_scripts' run without errors
johnomotani Sep 7, 2024
d006a8c
[em_fields] section in input
johnomotani Sep 8, 2024
855421c
[evolve_moments] section in input
johnomotani Sep 8, 2024
fc725ca
Remove modified default for neutral vz_dissipation in 1V case
johnomotani Sep 8, 2024
c79ccc5
Use set_defaults_and_check_section!() for numerical dissipation inputs
johnomotani Sep 8, 2024
f4ddc0e
[reactions] and [electron_fluid_collisions] sections in input
johnomotani Sep 8, 2024
554dc7e
Update performance-tests and publication_inputs with new input sections
johnomotani Sep 8, 2024
dfc1934
Move "run_name" and "base_directory" into [output] section
johnomotani Sep 8, 2024
6c147bc
Check that no unexpected section names were used in an input file
johnomotani Sep 9, 2024
94ef6c1
Fix override of "write_error_diagnostics" setting
johnomotani Sep 9, 2024
02e10d7
Remove/update unused options from inputs
johnomotani Sep 9, 2024
fcdbaf3
Rename `scan_input` variable to `input_dict` in mk_input()
johnomotani Sep 9, 2024
d5faab8
Fix ASCII I/O option
johnomotani Sep 9, 2024
f72d09d
Fix edge case for electron I/O counter
johnomotani Sep 9, 2024
0a983f9
Fix Dict type to OptionsDict in gyroaverage_tests.jl
johnomotani Sep 9, 2024
1521935
Reduce allowed filename length for HDF5 files
johnomotani Sep 9, 2024
9edfff3
Remove unused mutable structs from `input_structs`
johnomotani Sep 9, 2024
68449ed
fix grid_input
johnomotani Sep 9, 2024
b83b8db
Add new modules to docs
johnomotani Sep 9, 2024
20af36b
Alternative form of set_defaults_and_check_section!() for @kwdef struct
johnomotani Sep 10, 2024
3ad41d6
Move initial condition defaults to the @kwdef struct definition
johnomotani Sep 10, 2024
eb270a9
Remove unused external modules from test.
mrhardman Sep 11, 2024
5255900
Refactor 1D matrix assembly, make it clear that boundary conditions s…
mrhardman Sep 11, 2024
0d085d3
Fix default value for "vperp" coordinate
johnomotani Sep 11, 2024
17dff2d
Add define_test_coordinate() function
johnomotani Sep 11, 2024
4df2ea6
Test and correct boundary conditions for solving 1D ODE with Laplacia…
mrhardman Sep 11, 2024
6d50921
Avoid LU decomposition of singular matrix when no valid boundary cond…
mrhardman Sep 11, 2024
92f73f9
Fix periodic boundary conditions for weak-form second derivative
johnomotani Sep 11, 2024
e999753
Include a phase in periodic test functions in calculus_tests.jl
johnomotani Sep 11, 2024
ad9af46
Ensure second derivatives give exactly periodic results
johnomotani Sep 11, 2024
734ab81
Set L_matrix_with_bc to `nothing` when not implemented
johnomotani Sep 11, 2024
b76c05d
Try to rescue periodic ODE solver in latest changes by distinguishing…
mrhardman Sep 12, 2024
8b28629
Note that L_matrix_with_bc requires two boundary conditions. In the p…
mrhardman Sep 12, 2024
b6fac48
Remove distinction between periodic_bc_lhs and periodic_bc_rhs
johnomotani Sep 12, 2024
cd6a559
Merge pull request #249 from mabarnes/correct-1D-matrix-assembly
johnomotani Sep 15, 2024
cdf5b47
Merge branch 'master' into coordinates-input-refactor
johnomotani Sep 15, 2024
acfd618
Use explicitly defined structs for numerical dissipation parameters
johnomotani Sep 16, 2024
580e99a
Improve docstring for `define_coordinate()`
johnomotani Sep 16, 2024
e0b7614
Change default for charge exchange and ionization frequencies to 0
johnomotani Sep 16, 2024
eeac89d
Use explicitly defined structs for reactions, electron_fluid_collisions
johnomotani Sep 16, 2024
469c813
Move manufactured solutions input to setup_manufactured_solutions()
johnomotani Sep 16, 2024
5e8db09
Explicitly defined struct for em_fields_input
johnomotani Sep 16, 2024
0cafc56
Hard-code the name for the 'stop file'
johnomotani Sep 16, 2024
0cc7751
Explicitly defined struct for I/O input
johnomotani Sep 16, 2024
0458ab0
Remove outdated comment
johnomotani Sep 16, 2024
3cd263e
Use Julia-provided OpenMPI for CI test
johnomotani Sep 17, 2024
e7a908c
Remove NetCDF from parallel CI tests
johnomotani Sep 17, 2024
9903ca3
Save defaults from `@kwdef structs` in `options`
johnomotani Sep 17, 2024
60d9414
Fix formatting in setup_global_weak_form_matrix() docstring
johnomotani Sep 17, 2024
e7804d7
Make documentation builds strict on CI
johnomotani Sep 17, 2024
4d798ea
Merge branch 'master' into coordinates-input-refactor
johnomotani Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/debug_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
sed -i -e "s/_debug_level = get_options.*/_debug_level = 2/" moment_kinetics/src/debugging.jl

touch Project.toml
julia --project -O3 --check-bounds=yes -e 'using Pkg; Pkg.add(["MPI", "MPIPreferences", "PackageCompiler", "Symbolics"]); using MPIPreferences; MPIPreferences.use_system_binary()'
julia --project -O3 --check-bounds=yes -e 'using Pkg; Pkg.add(["MPI", "MPIPreferences", "PackageCompiler", "Symbolics"]); using MPIPreferences; MPIPreferences.use_jll_binary("OpenMPI_jll")'
julia --project -O3 --check-bounds=no -e 'using MPI; MPI.install_mpiexecjl(; destdir=".")'
julia --project -O3 --check-bounds=yes -e 'using Pkg; Pkg.develop(path="moment_kinetics/"); Pkg.precompile()'
julia --project -O3 --check-bounds=yes precompile.jl --debug 2

Expand All @@ -42,4 +43,4 @@ jobs:
# terrible performance when oversubscribing.
## Don't use --compiled-modules=no for now, as it currently breaks Symbolics.jl
#mpiexec -np 4 --mca rmaps_base_oversubscribe 1 julia --project --check-bounds=yes --compiled-modules=no moment_kinetics/debug_test/sound_wave_tests.jl --debug 2
mpiexec -np 4 --mca rmaps_base_oversubscribe 1 julia --project -Jmoment_kinetics.so -O3 --check-bounds=yes moment_kinetics/debug_test/runtests.jl --debug 2
./mpiexecjl -np 4 --mca rmaps_base_oversubscribe 1 julia --project -Jmoment_kinetics.so -O3 --check-bounds=yes moment_kinetics/debug_test/runtests.jl --debug 2
18 changes: 10 additions & 8 deletions .github/workflows/parallel_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ jobs:
- uses: julia-actions/cache@v1
- run: |
touch Project.toml
julia --project -O3 --check-bounds=no -e 'import Pkg; Pkg.add(["MPI", "MPIPreferences"]); using MPIPreferences; MPIPreferences.use_system_binary()'
julia --project -O3 --check-bounds=no -e 'import Pkg; Pkg.add(["NCDatasets", "Random", "SpecialFunctions", "Test"]); Pkg.develop(path="moment_kinetics/")'
julia --project -O3 --check-bounds=no -e 'import Pkg; Pkg.add(["MPI", "MPIPreferences"]); using MPIPreferences; MPIPreferences.use_jll_binary("OpenMPI_jll")'
julia --project -O3 --check-bounds=no -e 'using MPI; MPI.install_mpiexecjl(; destdir=".")'
julia --project -O3 --check-bounds=no -e 'import Pkg; Pkg.add(["Random", "SpecialFunctions", "Test"]); Pkg.develop(path="moment_kinetics/")'
julia --project -O3 --check-bounds=no -e 'import Pkg; Pkg.precompile()'
# Need to use openmpi so that the following arguments work:
# * `--mca rmaps_base_oversubscribe 1` allows oversubscription (more processes
# than physical cores).
# * `--mca mpi_yield_when_idle 1` changes a setting to prevent excessively
# terrible performance when oversubscribing.
mpiexec -np 3 --mca rmaps_base_oversubscribe 1 julia --project -O3 --check-bounds=no moment_kinetics/test/runtests.jl --debug 1 --force-optional-dependencies
mpiexec -np 4 --mca rmaps_base_oversubscribe 1 julia --project -O3 --check-bounds=no moment_kinetics/test/runtests.jl --debug 1 --force-optional-dependencies
mpiexec -np 2 --mca rmaps_base_oversubscribe 1 julia --project -O3 --check-bounds=no moment_kinetics/test/runtests.jl --debug 1 --long --force-optional-dependencies
./mpiexecjl -np 3 --mca rmaps_base_oversubscribe 1 julia --project -O3 --check-bounds=no moment_kinetics/test/runtests.jl --debug 1
./mpiexecjl -np 4 --mca rmaps_base_oversubscribe 1 julia --project -O3 --check-bounds=no moment_kinetics/test/runtests.jl --debug 1
./mpiexecjl -np 2 --mca rmaps_base_oversubscribe 1 julia --project -O3 --check-bounds=no moment_kinetics/test/runtests.jl --debug 1 --long
# Note: MPI.jl's default implementation is mpich, which has a similar option
# `--with-device=ch3:sock`, but that needs to be set when compiling mpich.
shell: bash
Expand All @@ -56,15 +57,16 @@ jobs:
- run: |
export MPILIBPATH=$(find /opt/homebrew/Cellar/open-mpi/ -name libmpi.dylib)
touch Project.toml
julia --project -O3 --check-bounds=no -e "import Pkg; Pkg.add([\"MPI\", \"MPIPreferences\"]); using MPIPreferences; MPIPreferences.use_system_binary(library_names=\"$MPILIBPATH\")"
julia --project -O3 --check-bounds=no -e 'import Pkg; Pkg.add(["NCDatasets", "Random", "SpecialFunctions", "Test"]); Pkg.develop(path="moment_kinetics/")'
julia --project -O3 --check-bounds=no -e 'import Pkg; Pkg.add(["MPI", "MPIPreferences"]); using MPIPreferences; MPIPreferences.use_jll_binary("OpenMPI_jll")'
julia --project -O3 --check-bounds=no -e 'using MPI; MPI.install_mpiexecjl(; destdir=".")'
julia --project -O3 --check-bounds=no -e 'import Pkg; Pkg.add(["Random", "SpecialFunctions", "Test"]); Pkg.develop(path="moment_kinetics/")'
julia --project -O3 --check-bounds=no -e 'import Pkg; Pkg.precompile()'
# Need to use openmpi so that the following arguments work:
# * `--mca rmaps_base_oversubscribe 1` allows oversubscription (more processes
# than physical cores).
# * `--mca mpi_yield_when_idle 1` changes a setting to prevent excessively
# terrible performance when oversubscribing.
mpiexec -np 4 --mca rmaps_base_oversubscribe 1 julia --project -O3 --check-bounds=no moment_kinetics/test/runtests.jl --debug 1 --force-optional-dependencies
./mpiexecjl -np 4 --mca rmaps_base_oversubscribe 1 julia --project -O3 --check-bounds=no moment_kinetics/test/runtests.jl --debug 1
# Note: MPI.jl's default implementation is mpich, which has a similar option
# `--with-device=ch3:sock`, but that needs to be set when compiling mpich.
shell: bash
25 changes: 25 additions & 0 deletions .github/workflows/test_scripts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Based on example from https://github.com/julia-actions/julia-runtest
name: Check test_scripts

on: [push, pull_request, workflow_dispatch]

jobs:
examples:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
fail-fast: false
timeout-minutes: 35

steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
with:
version: '1.10'
- uses: julia-actions/cache@v1
- name: Test test_scripts
run: |
touch Project.toml
julia -O3 --project -e 'import Pkg; Pkg.develop(path="moment_kinetics/"); Pkg.add(["FastGaussQuadrature", "LaTeXStrings", "LegendrePolynomials", "Measures", "MPI", "Plots", "SpecialFunctions"]); Pkg.precompile()'
julia -O3 --project -e 'include("test_scripts/2D_FEM_assembly_test.jl"); run_assembly_test(); include("test_scripts/chebyshev_radau_test.jl"); chebyshevradau_test(); include("test_scripts/fkpl_direct_integration_test.jl"); test_rosenbluth_potentials_direct_integration(); include("test_scripts/GaussLobattoLegendre_test.jl"); gausslegendre_test(); include("test_scripts/gyroaverage_test.jl"); gyroaverage_test()'
11 changes: 10 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ Pkg.instantiate()
using Documenter
using moment_kinetics, makie_post_processing, plots_post_processing

if get(ENV, "CI", nothing) == "true"
# On the CI, run in strict mode to turn warnings into errors, so that we don't deploy
# documentation with formatting bugs.
strict = true
else
strict = false
end

makedocs(
sitename = "moment_kinetics",
format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"),
modules = [moment_kinetics, makie_post_processing, plots_post_processing]
modules = [moment_kinetics, makie_post_processing, plots_post_processing],
strict = strict,
)

if get(ENV, "CI", nothing) == "true"
Expand Down
14 changes: 14 additions & 0 deletions docs/src/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ julia> run_moment_kinetics("input.toml")
It might be convenient to add `using Revise` to your `startup.jl` file (`~/julia/config/startup.jl`) so it's always loaded.


## Input options and defaults

The input is read from a `.toml` file. It is also written to the output HDF5
(or NetCDF) file, after all defaults are applied, both as a TOML-formatted
String and as a tree of HDF5 variables.

!!! warning
Neither TOML nor HDF5 have a 'null' type, so there is no convenient way to
store Julia's `nothing` when writing to TOML or HDF5. Therefore `nothing`
should not be used as a default for any input option. If the code should
use `nothing` as a default for some setting, that is fine, but must be done
after the input is read, and not stored in the `input_dict`.


## Array types

Most arrays in `moment_kinetics` are declared using a custom array type
Expand Down
6 changes: 6 additions & 0 deletions docs/src/zz_electron_fluid_equations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
`electron_fluid_equations`
==========================

```@autodocs
Modules = [moment_kinetics.electron_fluid_equations]
```
6 changes: 6 additions & 0 deletions docs/src/zz_electron_kinetic_equation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
`electron_kinetic_equation`
===========================

```@autodocs
Modules = [moment_kinetics.electron_kinetic_equation]
```
6 changes: 6 additions & 0 deletions docs/src/zz_electron_vpa_advection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
`electron_vpa_advection`
========================

```@autodocs
Modules = [moment_kinetics.electron_vpa_advection]
```
6 changes: 6 additions & 0 deletions docs/src/zz_electron_z_advection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
`electron_z_advection`
======================

```@autodocs
Modules = [moment_kinetics.electron_z_advection]
```
6 changes: 6 additions & 0 deletions docs/src/zz_maxwell_diffusion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
`maxwell_diffusion`
===================

```@autodocs
Modules = [moment_kinetics.maxwell_diffusion]
```
6 changes: 6 additions & 0 deletions docs/src/zz_nonlinear_solvers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
`nonlinear_solvers`
===================

```@autodocs
Modules = [moment_kinetics.nonlinear_solvers]
```
6 changes: 6 additions & 0 deletions docs/src/zz_species_input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
`species_input`
===============

```@autodocs
Modules = [moment_kinetics.species_input]
```
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
evolve_moments_density = false
evolve_moments_parallel_flow = false
evolve_moments_parallel_pressure = false
evolve_moments_conservation = false
charge_exchange_frequency = 0.0
ionization_frequency = 1.0
constant_ionization_rate = true
[ion_source_1]
z_profile = "constant"
source_strength = 1.0
source_T = 0.25

z_ngrid = 5
z_nelement = 16
#z_nelement_local = 2
z_bc = "wall"
z_element_spacing_option = "sqrt"
z_discretization = "chebyshev_pseudospectral"
r_ngrid = 1
r_nelement = 1
r_nelement_local = 1
r_bc = "periodic"
r_discretization = "chebyshev_pseudospectral"
vpa_ngrid = 6
vpa_nelement = 15
vpa_L = 6.0
vpa_bc = "zero"
#vpa_discretization = "chebyshev_pseudospectral"
vpa_discretization = "gausslegendre_pseudospectral"
vperp_ngrid = 5
vperp_nelement = 4
vperp_L = 3.0
#vperp_bc = "periodic"
#vperp_discretization = "finite_difference"
#vperp_discretization = "chebyshev_pseudospectral"
vperp_discretization = "gausslegendre_pseudospectral"
[evolve_moments]
density = false
parallel_flow = false
parallel_pressure = false
moments_conservation = false

[z]
ngrid = 5
nelement = 16
#nelement_local = 2
bc = "wall"
element_spacing_option = "sqrt"
discretization = "chebyshev_pseudospectral"

[r]
ngrid = 1
nelement = 1
nelement_local = 1
bc = "periodic"
discretization = "chebyshev_pseudospectral"

[vpa]
ngrid = 6
nelement = 15
L = 6.0
bc = "zero"
#discretization = "chebyshev_pseudospectral"
discretization = "gausslegendre_pseudospectral"

[vz]
ngrid = 6
nelement = 15
L = 6.0
bc = "zero"
#discretization = "chebyshev_pseudospectral"
discretization = "gausslegendre_pseudospectral"

[vperp]
ngrid = 5
nelement = 4
L = 3.0
#bc = "periodic"
#discretization = "finite_difference"
#discretization = "chebyshev_pseudospectral"
discretization = "gausslegendre_pseudospectral"

[composition]
n_ion_species = 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
# cheap input file for a 0D2V relaxation to a collisional Maxwellian distribution with self-ion collisions.
evolve_moments_density = false
evolve_moments_parallel_flow = false
evolve_moments_parallel_pressure = false
evolve_moments_conservation = false
[reactions]
charge_exchange_frequency = 0.0
ionization_frequency = 0.0
constant_ionization_rate = false

z_ngrid = 1
z_nelement = 1
z_nelement_local = 1
z_bc = "wall"
z_discretization = "chebyshev_pseudospectral"
r_ngrid = 1
r_nelement = 1
r_nelement_local = 1
r_bc = "periodic"
r_discretization = "chebyshev_pseudospectral"
vpa_ngrid = 5
vpa_nelement = 8
vpa_L = 6.0
vpa_bc = "zero"
vpa_discretization = "gausslegendre_pseudospectral"
vperp_ngrid = 5
vperp_nelement = 4
vperp_L = 3.0
vperp_discretization = "gausslegendre_pseudospectral"
vperp_bc = "zero"
[evolve_moments]
density = false
parallel_flow = false
parallel_pressure = false
moments_conservation = false

[z]
ngrid = 1
nelement = 1
nelement_local = 1
bc = "wall"
discretization = "chebyshev_pseudospectral"

[r]
ngrid = 1
nelement = 1
nelement_local = 1
bc = "periodic"
discretization = "chebyshev_pseudospectral"

[vpa]
ngrid = 5
nelement = 8
L = 6.0
bc = "zero"
discretization = "gausslegendre_pseudospectral"

[vperp]
ngrid = 5
nelement = 4
L = 3.0
discretization = "gausslegendre_pseudospectral"
bc = "zero"
# Fokker-Planck operator requires the "gausslegendre_pseudospectral
# options for the vpa and vperp grids

Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
# cheap input file for a 0D2V relaxation to a collisional Maxwellian distribution with self-ion collisions and collisions with fixed Maxwellian background of cold ions and electrons.
evolve_moments_density = false
evolve_moments_parallel_flow = false
evolve_moments_parallel_pressure = false
evolve_moments_conservation = false

[reactions]
charge_exchange_frequency = 0.0
ionization_frequency = 0.0
constant_ionization_rate = false

z_ngrid = 1
z_nelement = 1
z_nelement_local = 1
z_bc = "wall"
z_discretization = "chebyshev_pseudospectral"
r_ngrid = 1
r_nelement = 1
r_nelement_local = 1
r_bc = "periodic"
r_discretization = "chebyshev_pseudospectral"
vpa_ngrid = 5
vpa_nelement = 32
vpa_L = 3.0
vpa_bc = "zero"
vpa_discretization = "gausslegendre_pseudospectral"
vperp_ngrid = 5
vperp_nelement = 16
vperp_L = 1.5
vperp_discretization = "gausslegendre_pseudospectral"
vperp_bc = "zero"
[evolve_moments]
density = false
parallel_flow = false
parallel_pressure = false
moments_conservation = false

[z]
ngrid = 1
nelement = 1
nelement_local = 1
bc = "wall"
discretization = "chebyshev_pseudospectral"

[r]
ngrid = 1
nelement = 1
nelement_local = 1
bc = "periodic"
discretization = "chebyshev_pseudospectral"

[vpa]
ngrid = 5
nelement = 32
L = 3.0
bc = "zero"
discretization = "gausslegendre_pseudospectral"

[vperp]
ngrid = 5
nelement = 16
L = 1.5
discretization = "gausslegendre_pseudospectral"
bc = "zero"
# Fokker-Planck operator requires the "gausslegendre_pseudospectral
# options for the vpa and vperp grids

Expand Down
Loading
Loading