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

Krook 'collisions' #127

Merged
merged 53 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
bffaea3
Move generic settings definition functions to input_structs.jl
johnomotani Aug 26, 2023
6293496
Move define_coordinate() calls into mk_input()
johnomotani Aug 26, 2023
fdac38e
Add module with physical constants, mk_input return reference_parameters
johnomotani Aug 27, 2023
df1bd5b
Function to print some dimensional parameters of a simulation
johnomotani Sep 30, 2022
33584ea
Script to compare collision frequencies to numerical dissipation
johnomotani Mar 20, 2023
8d8bcd4
Krook collision operator for ion-ion Coulomb collisions
johnomotani Oct 4, 2022
94e1408
Implement "split 2" and "split 3" test for NonlinearSoundWaveTests
johnomotani Sep 21, 2023
fcdd763
Add regression test for Krook collision operator
johnomotani Sep 22, 2023
9b21e09
Handle 2V case in Krook collision operator
johnomotani Sep 22, 2023
cf8a956
Restrict check for 1V in Krook collisions to moment-kinetic cases
johnomotani Sep 25, 2023
49f41f8
Move handling of reference parameters into separate module
johnomotani Sep 25, 2023
7019804
Merge branch 'master' into Krook-collisions
johnomotani Sep 25, 2023
030fbe7
Ported capability to compare upar and ppar to expectations from MMS t…
mrhardman May 17, 2023
6a9664d
Clean up manufactured solutions input
johnomotani Sep 27, 2023
02ded9a
Put 'show_element_boundaries' in postproc input for manufactured_solns
johnomotani Sep 27, 2023
bf27259
Make MMS plots for ion parallel flow and parallel pressure
johnomotani Sep 27, 2023
a1a17ec
Skip MMS plots of Er for 1D cases
johnomotani Sep 27, 2023
b539670
Fix slicing of distribution functions in MMS plots
johnomotani Sep 27, 2023
f181300
Fix post processing script consistent with updated composition struct.
mrhardman Sep 28, 2023
d91c618
Addition of factor to compensate for the pressure normalisation conve…
mrhardman Sep 29, 2023
1932bf5
Porting of commit cd07a26. Refactoring of the update_derived_moments …
mrhardman May 12, 2023
fa27970
Cherry-pick of commit 8632cf7 to add perpendicular pressure to the bo…
mrhardman May 17, 2023
82de4c4
Attempt to cherry-pick the features from 6bd406e. Some bugs remain wh…
mrhardman May 18, 2023
ed979ad
Include factor of 2 for expected vth in test_velocity_integrals.jl
johnomotani Oct 24, 2023
5bd78ec
Increase Lvpa and Lvperp in test_velocity_integrals.jl
johnomotani Oct 24, 2023
4e7dccb
Correct file_io so that perpendicular pressure is correctly saved to …
mrhardman Oct 24, 2023
b7a7620
Fix file name for output plots
mrhardman Oct 24, 2023
88ad6d0
Attempt to port manufactured solutions test for Krook operator to new…
mrhardman Oct 25, 2023
ba4d733
Put rfac preceding the numerical dissipation term in r to prevent usa…
mrhardman Oct 25, 2023
e37a0a5
Clean up comment
mrhardman Oct 30, 2023
6823546
Modifications to port Krook operator manufactured solutions test to t…
mrhardman Oct 30, 2023
09cb8fb
Allow 2V Krook operator providing that split moments are not used.
mrhardman Oct 30, 2023
58e7c8e
Correct update_moments! to use the update_vth! function so that the t…
mrhardman Oct 30, 2023
6132fc6
Example input files for MMS test with Krook operator (spatially const…
mrhardman Oct 30, 2023
1885c79
Change input options for Krook so that default is to not use the Kroo…
mrhardman Oct 30, 2023
5647180
Fix figure saving for 1D plot in makie_post_processing
johnomotani Oct 30, 2023
7ed8a1c
Pass nvperp to manufactured solutions funcs in makie_post_processing
johnomotani Oct 30, 2023
a6771e5
Convert test_velocity_integrals.jl to a CI test
johnomotani Oct 30, 2023
5130cf8
Merge branch 'master' into Krook-collisions-MMS-port
johnomotani Oct 30, 2023
a8e314d
Merge branch 'Krook-collisions' into Krook-collisions-MMS-port
johnomotani Oct 30, 2023
6884d86
Deactivate Krook collisions by default
johnomotani Oct 30, 2023
92a4e29
Pass 'element_spacing_option' to coords in velocity_integral_tests.jl
johnomotani Oct 30, 2023
afe3709
Better values for MPI variables when ignore_MPI=true in mk_input()
johnomotani Sep 29, 2023
5d5ddaf
Tidy up comments
johnomotani Oct 30, 2023
8a5e298
Make clearer that Ti_over_Tref is not normalised temperature
johnomotani Oct 30, 2023
4c9e810
Krook MMS test inputs use spatially-varying collision frequency
johnomotani Oct 30, 2023
49e33d1
Merge pull request #141 from mabarnes/Krook-collisions-MMS-port
johnomotani Oct 30, 2023
1654f7c
Make clearer that T_over_Tref is not normalised temperature
johnomotani Oct 30, 2023
45fd04f
Define Krook collision frequency in terms of cref rather than Tref
johnomotani Oct 31, 2023
37856fa
Move calculation of Krook collision frequency to a function
johnomotani Oct 31, 2023
eff2647
Make plots of collision frequency if Krook collisions are used
johnomotani Oct 31, 2023
326efbb
Fix coordinate creation in makie_post_processing
johnomotani Oct 31, 2023
c7735e1
Handle derived variables in get_variable() in makie_post_processing
johnomotani Oct 31, 2023
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
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
julia = "1.7.0"
6 changes: 6 additions & 0 deletions docs/src/utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
`utils`
===============

```@autodocs
Modules = [moment_kinetics.utils]
```
94 changes: 94 additions & 0 deletions runs/1D-wall_MMS_new_nel_r_1_z_16_vpa_16_vperp_1_krook.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
n_ion_species = 1
n_neutral_species = 0
electron_physics = "boltzmann_electron_response"
#electron_physics = "boltzmann_electron_response_with_simple_sheath"
evolve_moments_density = false
evolve_moments_parallel_flow = false
evolve_moments_parallel_pressure = false
evolve_moments_conservation = false
force_Er_zero_at_wall = false #true
Er_constant = 0.0
T_e = 1.0
T_wall = 1.0
rhostar = 1.0
initial_density1 = 0.5
initial_temperature1 = 1.0
initial_density2 = 0.5
initial_temperature2 = 1.0
z_IC_option1 = "sinusoid"
z_IC_density_amplitude1 = 0.001
z_IC_density_phase1 = 0.0
z_IC_upar_amplitude1 = 0.0
z_IC_upar_phase1 = 0.0
z_IC_temperature_amplitude1 = 0.0
z_IC_temperature_phase1 = 0.0
z_IC_option2 = "sinusoid"
z_IC_density_amplitude2 = 0.001
z_IC_density_phase2 = 0.0
z_IC_upar_amplitude2 = 0.0
z_IC_upar_phase2 = 0.0
z_IC_temperature_amplitude2 = 0.0
z_IC_temperature_phase2 = 0.0
charge_exchange_frequency = 0.0
ionization_frequency = 0.0
krook_collisions_option = "reference_parameters"
nuii_krook = 1.0
nstep = 2000
dt = 0.0005
nwrite = 200
nwrite_dfns = 200
use_semi_lagrange = false
n_rk_stages = 4
split_operators = false
z_ngrid = 17
z_nelement = 16
z_nelement_local = 16
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 = 17
vpa_nelement = 16
vpa_L = 12.0
vpa_bc = "zero"
vpa_discretization = "chebyshev_pseudospectral"
vperp_ngrid = 1
vperp_nelement = 1
vperp_L = 6.0
vperp_bc = "periodic"
vperp_discretization = "chebyshev_pseudospectral"

vz_ngrid = 17
vz_nelement = 4
vz_L = 12.0
vz_bc = "periodic"
vz_discretization = "chebyshev_pseudospectral"

vr_ngrid = 17
vr_nelement = 4
vr_L = 12.0
vr_bc = "periodic"
vr_discretization = "chebyshev_pseudospectral"

vzeta_ngrid = 17
vzeta_nelement = 4
vzeta_L = 12.0
vzeta_bc = "periodic"
vzeta_discretization = "chebyshev_pseudospectral"

[manufactured_solns]
use_for_advance=true
use_for_init=true
# constant to be used to control Ez divergence in MMS tests
epsilon_offset=0.1
# bool to control if dfni is a function of vpa or vpabar in MMS test
use_vpabar_in_mms_dfni=true
alpha_switch=1.0
type="default"
[numerical_dissipation]
vpa_dissipation_coefficient = -1.0
z_dissipation_coefficient = -1.0
r_dissipation_coefficient = -1.0
94 changes: 94 additions & 0 deletions runs/1D-wall_MMS_new_nel_r_1_z_16_vpa_8_vperp_8_krook.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
n_ion_species = 1
n_neutral_species = 0
electron_physics = "boltzmann_electron_response"
#electron_physics = "boltzmann_electron_response_with_simple_sheath"
evolve_moments_density = false
evolve_moments_parallel_flow = false
evolve_moments_parallel_pressure = false
evolve_moments_conservation = false
force_Er_zero_at_wall = false #true
Er_constant = 0.0
T_e = 1.0
T_wall = 1.0
rhostar = 1.0
initial_density1 = 0.5
initial_temperature1 = 1.0
initial_density2 = 0.5
initial_temperature2 = 1.0
z_IC_option1 = "sinusoid"
z_IC_density_amplitude1 = 0.001
z_IC_density_phase1 = 0.0
z_IC_upar_amplitude1 = 0.0
z_IC_upar_phase1 = 0.0
z_IC_temperature_amplitude1 = 0.0
z_IC_temperature_phase1 = 0.0
z_IC_option2 = "sinusoid"
z_IC_density_amplitude2 = 0.001
z_IC_density_phase2 = 0.0
z_IC_upar_amplitude2 = 0.0
z_IC_upar_phase2 = 0.0
z_IC_temperature_amplitude2 = 0.0
z_IC_temperature_phase2 = 0.0
charge_exchange_frequency = 0.0
ionization_frequency = 0.0
krook_collisions_option = "reference_parameters"
nuii_krook = 1.0
nstep = 2000
dt = 0.0005
nwrite = 200
nwrite_dfns = 200
use_semi_lagrange = false
n_rk_stages = 4
split_operators = false
z_ngrid = 17
z_nelement = 16
z_nelement_local = 16
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 = 17
vpa_nelement = 8
vpa_L = 12.0
vpa_bc = "zero"
vpa_discretization = "chebyshev_pseudospectral"
vperp_ngrid = 17
vperp_nelement = 8
vperp_L = 6.0
vperp_bc = "periodic"
vperp_discretization = "chebyshev_pseudospectral"

vz_ngrid = 17
vz_nelement = 4
vz_L = 12.0
vz_bc = "periodic"
vz_discretization = "chebyshev_pseudospectral"

vr_ngrid = 17
vr_nelement = 4
vr_L = 12.0
vr_bc = "periodic"
vr_discretization = "chebyshev_pseudospectral"

vzeta_ngrid = 17
vzeta_nelement = 4
vzeta_L = 12.0
vzeta_bc = "periodic"
vzeta_discretization = "chebyshev_pseudospectral"

[manufactured_solns]
use_for_advance=true
use_for_init=true
# constant to be used to control Ez divergence in MMS tests
epsilon_offset=0.1
# bool to control if dfni is a function of vpa or vpabar in MMS test
use_vpabar_in_mms_dfni=true
alpha_switch=1.0
type="default"
[numerical_dissipation]
vpa_dissipation_coefficient = -1.0
z_dissipation_coefficient = -1.0
r_dissipation_coefficient = -1.0
33 changes: 33 additions & 0 deletions src/constants.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Some physical constants
"""
module constants

export epsilon0, mu0
export electron_mass
export proton_charge, proton_mass
export deuteron_mass
export amu

# https://physics.nist.gov/cgi-bin/cuu/Value?ep0
const epsilon0 = 8.8541878128e-12 # F m^-1

# https://physics.nist.gov/cgi-bin/cuu/Value?mu0
const mu0 = 1.25663706212e-6 # N A^-2

# https://physics.nist.gov/cgi-bin/cuu/Value?me
const electron_mass = 9.109383701e-31 # kg

# https://physics.nist.gov/cgi-bin/cuu/Value?e
const proton_charge = 1.602176634e-19 # C

# https://physics.nist.gov/cgi-bin/cuu/Value?mp
const proton_mass = 1.67262192369e-27 # kg

# https://physics.nist.gov/cgi-bin/cuu/Value?md
const deuteron_mass = 3.3435837724e-27

# https://physics.nist.gov/cgi-bin/cuu/Value?ukg
const amu = 1.66053906660e-27

end
30 changes: 26 additions & 4 deletions src/file_io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ struct io_moments_info{Tfile, Ttime, Tphi, Tmomi, Tmomn}
parallel_flow::Tmomi
# handle for the charged species parallel pressure
parallel_pressure::Tmomi
# handle for the charged species perpendicular pressure
perpendicular_pressure::Tmomi
# handle for the charged species parallel heat flux
parallel_heat_flux::Tmomi
# handle for the charged species thermal speed
Expand Down Expand Up @@ -591,6 +593,13 @@ function define_dynamic_moment_variables!(fid, n_ion_species, n_neutral_species,
parallel_io=parallel_io,
description="charged species parallel pressure",
units="n_ref*T_ref")

# io_pperp is the handle for the ion parallel pressure
io_pperp = create_dynamic_variable!(dynamic, "perpendicular_pressure", mk_float, z, r;
n_ion_species=n_ion_species,
parallel_io=parallel_io,
description="charged species perpendicular pressure",
units="n_ref*T_ref")

# io_qpar is the handle for the ion parallel heat flux
io_qpar = create_dynamic_variable!(dynamic, "parallel_heat_flux", mk_float, z, r;
Expand Down Expand Up @@ -642,7 +651,7 @@ function define_dynamic_moment_variables!(fid, n_ion_species, n_neutral_species,
units="c_ref")

return io_moments_info(fid, io_time, io_phi, io_Er, io_Ez, io_density, io_upar,
io_ppar, io_qpar, io_vth, io_density_neutral, io_uz_neutral,
io_ppar, io_pperp, io_qpar, io_vth, io_density_neutral, io_uz_neutral,
io_pz_neutral, io_qz_neutral, io_thermal_speed_neutral,
parallel_io)
end
Expand Down Expand Up @@ -780,7 +789,8 @@ function reopen_moments_io(file_info)
end
return io_moments_info(fid, getvar("time"), getvar("phi"), getvar("Er"),
getvar("Ez"), getvar("density"), getvar("parallel_flow"),
getvar("parallel_pressure"), getvar("parallel_heat_flux"),
getvar("parallel_pressure"), getvar("perpendicular_pressure"),
getvar("parallel_heat_flux"),
getvar("thermal_speed"), getvar("density_neutral"),
getvar("uz_neutral"), getvar("pz_neutral"),
getvar("qz_neutral"), getvar("thermal_speed_neutral"),
Expand Down Expand Up @@ -865,6 +875,7 @@ function reopen_dfns_io(file_info)
io_moments = io_moments_info(fid, getvar("time"), getvar("phi"), getvar("Er"),
getvar("Ez"), getvar("density"),
getvar("parallel_flow"), getvar("parallel_pressure"),
getvar("perpendicular_pressure"),
getvar("parallel_heat_flux"),
getvar("thermal_speed"), getvar("density_neutral"),
getvar("uz_neutral"), getvar("pz_neutral"),
Expand Down Expand Up @@ -920,6 +931,8 @@ function write_moments_data_to_binary(moments, fields, t, n_ion_species,
n_ion_species)
append_to_dynamic_var(io_moments.parallel_pressure, moments.charged.ppar, t_idx,
z, r, n_ion_species)
append_to_dynamic_var(io_moments.perpendicular_pressure, moments.charged.pperp, t_idx,
z, r, n_ion_species)
append_to_dynamic_var(io_moments.parallel_heat_flux, moments.charged.qpar, t_idx,
z, r, n_ion_species)
append_to_dynamic_var(io_moments.thermal_speed, moments.charged.vth, t_idx, z, r,
Expand Down Expand Up @@ -1008,6 +1021,8 @@ end
t_idx, z, r, n_ion_species)
append_to_dynamic_var(io_moments.parallel_pressure, moments.charged.ppar.data,
t_idx, z, r, n_ion_species)
append_to_dynamic_var(io_moments.perpendicular_pressure.data, moments.charged.pperp,
t_idx, z, r, n_ion_species)
append_to_dynamic_var(io_moments.parallel_heat_flux,
moments.charged.qpar.data, t_idx, z, r, n_ion_species)
append_to_dynamic_var(io_moments.thermal_speed, moments.charged.vth.data,
Expand Down Expand Up @@ -1271,7 +1286,7 @@ all the arrays have the same length, with an entry for each call to `debug_dump(
function debug_dump end
function debug_dump(vz::coordinate, vr::coordinate, vzeta::coordinate, vpa::coordinate,
vperp::coordinate, z::coordinate, r::coordinate, t::mk_float;
ff=nothing, dens=nothing, upar=nothing, ppar=nothing, qpar=nothing,
ff=nothing, dens=nothing, upar=nothing, ppar=nothing, pperp=nothing, qpar=nothing,
vth=nothing,
ff_neutral=nothing, dens_neutral=nothing, uz_neutral=nothing,
#ur_neutral=nothing, uzeta_neutral=nothing,
Expand Down Expand Up @@ -1370,6 +1385,11 @@ function debug_dump(vz::coordinate, vr::coordinate, vzeta::coordinate, vpa::coor
else
debug_output_file.moments.parallel_pressure[:,:,:,debug_output_counter[]] = ppar
end
if pperp === nothing
debug_output_file.moments.perpendicular_pressure[:,:,:,debug_output_counter[]] = 0.0
else
debug_output_file.moments.perpendicular_pressure[:,:,:,debug_output_counter[]] = pperp
end
if qpar === nothing
debug_output_file.moments.parallel_heat_flux[:,:,:,debug_output_counter[]] = 0.0
else
Expand Down Expand Up @@ -1446,13 +1466,15 @@ function debug_dump(fvec::Union{scratch_pdf,Nothing},
density = nothing
upar = nothing
ppar = nothing
pperp = nothing
pdf_neutral = nothing
density_neutral = nothing
else
pdf = fvec.pdf
density = fvec.density
upar = fvec.upar
ppar = fvec.ppar
pperp = fvec.pperp
pdf_neutral = fvec.pdf_neutral
density_neutral = fvec.density_neutral
end
Expand All @@ -1466,7 +1488,7 @@ function debug_dump(fvec::Union{scratch_pdf,Nothing},
Ez = fields.Ez
end
return debug_dump(vz, vr, vzeta, vpa, vperp, z, r, t; ff=pdf, dens=density, upar=upar,
ppar=ppar, ff_neutral=pdf_neutral, dens_neutral=density_neutral,
ppar=ppar, pperp=pperp, ff_neutral=pdf_neutral, dens_neutral=density_neutral,
phi=phi, Er=Er, Ez=Ez, t, istage=istage, label=label)
end

Expand Down
Loading
Loading