Skip to content

Commit

Permalink
Merge pull request #306 from mabarnes/final_transfer_version
Browse files Browse the repository at this point in the history
Final transfer version
  • Loading branch information
johnomotani authored Jan 18, 2025
2 parents 8f0ae96 + af475cc commit 5d4c9a3
Show file tree
Hide file tree
Showing 925 changed files with 82,082 additions and 663 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: julia-actions/setup-julia@latest
with:
version: '1.10'
- uses: julia-actions/cache@v2
#- uses: julia-actions/cache@v2
- name: Install dependencies
run: |
# Version 3.9.0 of matplotlib causes an error with PyPlot.jl, so pin
Expand Down
6 changes: 6 additions & 0 deletions docs/src/zz_collision_frequencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
`collision_frequencies`
=================

```@autodocs
Modules = [moment_kinetics.collision_frequencies]
```
2 changes: 1 addition & 1 deletion examples/gk-ions/2D-periodic-gk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ discretization = "chebyshev_pseudospectral"
n_ion_species = 1
n_neutral_species = 0
electron_physics = "boltzmann_electron_response"
gyrokinetic_ions = true
ion_physics = "gyrokinetic_ions"
T_e = 1.0
T_wall = 1.0

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion moment_kinetics/debug_test/gyroaverage_inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_input = OptionsDict(
"output" => OptionsDict("run_name" => "gyroaverage"),
"composition" => OptionsDict("n_ion_species" => 1,
"n_neutral_species" => 0,
"gyrokinetic_ions" => true,
"ion_physics" => "gyrokinetic_ions",
"T_e" => 1.0,
"T_wall" => 1.0),
"evolve_moments" => OptionsDict("density" => false,
Expand Down
118 changes: 118 additions & 0 deletions moment_kinetics/src/collision_frequencies.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
module collision_frequencies

export get_collision_frequency_ii, get_collision_frequency_ee, get_collision_frequency_ei

using ..reference_parameters: get_reference_collision_frequency_ii,
get_reference_collision_frequency_ee,
get_reference_collision_frequency_ei
using ..reference_parameters: setup_reference_parameters

"""
get_collision_frequency_ii(collisions, n, vth)
Calculate the ion-ion collision frequency, depending on the settings/parameters in
`collisions`, for the given density `n` and thermal speed `vth`.
`n` and `vth` may be scalars or arrays, but should have shapes that can be broadcasted
together.
"""
function get_collision_frequency_ii(collisions, n, vth)
# extract krook options from collisions struct
colk = collisions.krook
nuii0 = colk.nuii0
frequency_option = colk.frequency_option
if frequency_option ("reference_parameters", "collisionality_scan")
return @. nuii0 * n * vth^(-3)
elseif frequency_option == "manual"
# Include 0.0*n so that the result gets promoted to an array if n is an array,
# which hopefully means this function will have a fixed return type given the
# types of the arguments (we don't want to be 'type unstable' for array inputs by
# returning a scalar from this branch but an array from the "reference_parameters"
# branch).
return @. nuii0 + 0.0 * n
elseif frequency_option == "none"
# Include 0.0*n so that the result gets promoted to an array if n is an array,
# which hopefully means this function will have a fixed return type given the
# types of the arguments (we don't want to be 'type unstable' for array inputs by
# returning a scalar from this branch but an array from the "reference_parameters"
# branch).
return @. 0.0 * n
else
error("Unrecognised option [krook_collisions] "
* "frequency_option=$(frequency_option)")
end
end

"""
get_collision_frequency_ee(collisions, n, vthe)
Calculate the electron-electron collision frequency, depending on the settings/parameters
in `collisions`, for the given density `n` and electron thermal speed `vthe`.
`n` and `vthe` may be scalars or arrays, but should have shapes that can be broadcasted
together.
"""
function get_collision_frequency_ee(collisions, n, vthe)
# extract krook options from collisions struct
colk = collisions.krook
nuee0 = colk.nuee0
frequency_option = colk.frequency_option
if frequency_option == "reference_parameters"
return @. nuee0 * n * vthe^(-3)
elseif frequency_option == "manual"
# Include 0.0*n so that the result gets promoted to an array if n is an array,
# which hopefully means this function will have a fixed return type given the
# types of the arguments (we don't want to be 'type unstable' for array inputs by
# returning a scalar from this branch but an array from the "reference_parameters"
# branch).
return @. nuee0 + 0.0 * n
elseif frequency_option == "none"
# Include 0.0*n so that the result gets promoted to an array if n is an array,
# which hopefully means this function will have a fixed return type given the
# types of the arguments (we don't want to be 'type unstable' for array inputs by
# returning a scalar from this branch but an array from the "reference_parameters"
# branch).
return @. 0.0 * n
else
error("Unrecognised option [krook_collisions] "
* "frequency_option=$(frequency_option)")
end
end

"""
get_collision_frequency_ei(collisions, n, vthe)
Calculate the electron-electron collision frequency, depending on the settings/parameters
in `collisions`, for the given density `n` and electron thermal speed `vthe`.
`n` and `vthe` may be scalars or arrays, but should have shapes that can be broadcasted
together.
"""
function get_collision_frequency_ei(collisions, n, vthe)
# extract krook options from collisions struct
colk = collisions.krook
nuei0 = colk.nuei0
frequency_option = colk.frequency_option
if frequency_option == "reference_parameters"
return @. nuei0 * n * vthe^(-3)
elseif frequency_option == "manual"
# Include 0.0*n so that the result gets promoted to an array if n is an array,
# which hopefully means this function will have a fixed return type given the
# types of the arguments (we don't want to be 'type unstable' for array inputs by
# returning a scalar from this branch but an array from the "reference_parameters"
# branch).
return @. nuei0 + 0.0 * n
elseif frequency_option == "none"
# Include 0.0*n so that the result gets promoted to an array if n is an array,
# which hopefully means this function will have a fixed return type given the
# types of the arguments (we don't want to be 'type unstable' for array inputs by
# returning a scalar from this branch but an array from the "reference_parameters"
# branch).
return @. 0.0 * n
else
error("Unrecognised option [krook_collisions] "
* "frequency_option=$(frequency_option)")
end
end

end
6 changes: 3 additions & 3 deletions moment_kinetics/src/electron_kinetic_equation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ using ..external_sources: total_external_electron_sources!,
add_total_external_electron_source_to_v_only_Jacobian!,
add_total_external_electron_source_to_z_only_Jacobian!
using ..file_io: get_electron_io_info, write_electron_state, finish_electron_io
using ..krook_collisions: electron_krook_collisions!, get_collision_frequency_ee,
get_collision_frequency_ei,
add_electron_krook_collisions_to_Jacobian!,
using ..collision_frequencies: get_collision_frequency_ee,
get_collision_frequency_ei
using ..krook_collisions: electron_krook_collisions!, add_electron_krook_collisions_to_Jacobian!,
add_electron_krook_collisions_to_v_only_Jacobian!,
add_electron_krook_collisions_to_z_only_Jacobian!
using ..timer_utils
Expand Down
2 changes: 1 addition & 1 deletion moment_kinetics/src/em_fields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function update_phi!(fields, fvec, vperp, z, r, composition, collisions, moments
end

# get gyroaveraged field arrays for distribution function advance
gkions = composition.gyrokinetic_ions
gkions = composition.ion_physics == gyrokinetic_ions
if gkions
gyroaverage_field!(fields.gphi,fields.phi,gyroavs,vperp,z,r,composition)
gyroaverage_field!(fields.gEz,fields.Ez,gyroavs,vperp,z,r,composition)
Expand Down
Loading

0 comments on commit 5d4c9a3

Please sign in to comment.