Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
18ac63e
Div_a_Grad_perp_nonorthog function for testing
bendudson Nov 29, 2022
809ed4b
Clang formatting
bendudson Nov 29, 2022
8156075
neutral_mixed: Use Div_a_Grad_perp_nonorthog
bendudson Nov 29, 2022
910a0c4
Merge branch 'master' into nonorthogonal
bendudson Jul 20, 2023
aadc272
Attempt to port David Bold`s MMS test to Hermes-3.
mrhardman Nov 26, 2024
8f847a9
Read Rxy and Zxy from mesh file (hypnotoad), do not write 3D R Z to f…
mrhardman Dec 10, 2024
b0f380f
Merge branch 'master' into divops-mms-test
mrhardman Dec 10, 2024
f43cc54
Initial commit of files needed to port David Bold's MMS differential …
mrhardman Dec 17, 2024
fe91bd7
Changes to makes mms.py script run.
mrhardman Dec 17, 2024
cdb7be3
Reorganise and comment the mms.py test script.
mrhardman Dec 17, 2024
fdc7d1e
Reorganise and comment the mms.py test script, remove unused code.
mrhardman Dec 17, 2024
0b6b066
Reorganise the mms.py test script, rationalise plotting.
mrhardman Dec 17, 2024
427e76e
Add script to generate circular closed-field-line equilibria for the …
mrhardman Dec 19, 2024
a05eeed
Make test BOUT.inp file use a third circular equilibrium.
mrhardman Dec 19, 2024
4685453
Restore variable path input functionality, rename main function to mo…
mrhardman Dec 19, 2024
73e5c49
Rename variables to clarify meaning.
mrhardman Dec 19, 2024
fd9192d
Modify plot to show expected convergence order, calculate convergence…
mrhardman Dec 20, 2024
12488c3
Refactor plotting so that each test is a unique plot, experiment with…
mrhardman Dec 20, 2024
86aaa19
Comment out Poisson bracket tests for now from main.cxx.
mrhardman Dec 20, 2024
e020cd4
Make modifications to test the feasibility of MMS test in a slab with…
mrhardman Jan 13, 2025
7fa43c7
Reduce main.cxx for MMS test to the minimal code for a single operator
johnomotani Jan 13, 2025
11ba89e
Initial python script for running minimal MMS test, no plotting of re…
mrhardman Jan 14, 2025
7f55ffe
Start adding i/o result testing functionality.
mrhardman Jan 14, 2025
90677d8
Bare minimum script to compare analytical and numerical results, usin…
mrhardman Jan 15, 2025
071850d
Change syntax of open_boutdataset() to use xBOUT branch fix-gridless-…
mrhardman Jan 15, 2025
ef7aeeb
Make sure g** are taken from a single source, accomodate trivial agre…
mrhardman Jan 15, 2025
e674d04
Cut down seemingly unused options in BOUT.input.template.
mrhardman Jan 15, 2025
4b5c896
Support the ability to deal with polynomial test functions.
mrhardman Jan 15, 2025
b828e7f
Changes needed to get minimal MMS test to work, showing expected rate…
mrhardman Jan 16, 2025
a4a2da4
Include C language to permit compiling of C dependencies.
mrhardman Jan 17, 2025
e4b849e
Merge branch 'divops-mms-test-minimal' into nonorthogonal-divops-mms-…
mrhardman Jan 17, 2025
b010265
Add Div_a_Grad_perp_nonorthog to run-jobs.py and main.cxx to permit e…
mrhardman Jan 17, 2025
4f2025e
Correct label on plots
mrhardman Jan 17, 2025
3d11cb7
Bugfix: correct position of parenthesis in ddz affecting g13 term in …
mrhardman Jan 21, 2025
a151fd7
Test g11 to make sure it is calculated properly.
mrhardman Jan 21, 2025
2e5e827
Bugfix: correct indexing error in Y flux affecting g12 nonorthogonal …
mrhardman Jan 21, 2025
fc3d32b
Make coefficients differ from one another in analytical prescription.…
mrhardman Jan 21, 2025
0f488c9
Make sure a = a(x,y,z) is tested. MMS test currently passes.
mrhardman Jan 22, 2025
890a9b3
Start development of version of test for automated tests.
mrhardman Jan 22, 2025
0bac5f5
Add ability for tests/mms/main.cxx to loop over a list of operators, …
mrhardman Jan 22, 2025
4bbe4ec
Generalise main.cxx and run-jobs-2.py so that list of operators and s…
mrhardman Jan 22, 2025
1aef2ee
Send rate -> order in output message.
mrhardman Jan 23, 2025
8fcd604
Refactored MMS test to allow for different metrics to be tested on op…
mrhardman Jan 23, 2025
8aae139
Remove older revisions of test for clarity in ongoing development.
mrhardman Jan 23, 2025
101697e
Make sure to make root test directory.
mrhardman Jan 23, 2025
31e9af0
Correct minor typos.
mrhardman Jan 23, 2025
17238a6
Include differential operator tests in CMakelists.txt correctly
mrhardman Jan 23, 2025
4698c47
Make interactive plotting optional.
mrhardman Jan 23, 2025
da10095
Try to change .pip_install_for_tests.sh to make sure we have the late…
mrhardman Jan 24, 2025
62b9f4a
Some documentation for the tests.
mrhardman Jan 24, 2025
607780a
Make sure plots saved in appropriate directory.
mrhardman Jan 24, 2025
cd679c8
Remove unnecessary code for MMS tests in CMakelists.txt.
mrhardman Jan 27, 2025
ca23fb9
Update src/div_ops.cxx
mrhardman Jan 27, 2025
dd95973
Update src/div_ops.cxx
mrhardman Jan 27, 2025
ab2831e
Merge branch 'nonorthogonal-divops-mms-test-minimal' of https://githu…
mrhardman Jan 27, 2025
6b11132
Revert "Update src/div_ops.cxx "
mrhardman Jan 27, 2025
7bd1012
Use David Bold suggestion to streamline `.pip_install_for_tests.sh`.
mrhardman Jan 28, 2025
70a15e1
Update docs to make it clear that xBOUT needs to be installed from gi…
mrhardman Jan 28, 2025
05ef0a9
Note on debug flags for Spack notes.
mrhardman Jan 28, 2025
8ac40c7
Update src/classical_diffusion.cxx to use Div_a_Grad_perp_nonorthog().
mrhardman Feb 24, 2025
9ecddeb
Modify src/classical_diffusion.cxx to permit use diffusing neutral de…
mrhardman Feb 24, 2025
a85ca79
Initial attempt to merge, noting limitation of lack of flows diagnost…
mrhardman Mar 7, 2025
7bf3405
Changes to incorporate flow diagnostics into tests.
mrhardman Mar 11, 2025
b337a1c
Address issue #306.
Mar 13, 2025
690c1ff
Attempt to comment out terms not involving Div_a_Grad_perp_nonorthog().
mrhardman Mar 13, 2025
07a7b12
Manually set diagnostic fluxes to zero values to prevent error -- Err…
mrhardman Mar 14, 2025
bf6ec90
Link to latest next for BOUT-dev
mrhardman Mar 14, 2025
d7de1d3
Attempt to simply problem by making diffusion coeffs constant. Strang…
mrhardman Mar 14, 2025
49de072
Revert "Attempt to simply problem by making diffusion coeffs constant…
mrhardman Mar 14, 2025
17ffec0
Revert "Manually set diagnostic fluxes to zero values to prevent erro…
mrhardman Mar 17, 2025
be76c99
Revert "Attempt to comment out terms not involving Div_a_Grad_perp_no…
mrhardman Mar 17, 2025
d36e797
Add Div_par_K_Grad_par to differential operator test.
mrhardman Mar 28, 2025
79b76b6
Add Div_par to differential operator test.
mrhardman Mar 28, 2025
3b85531
Add Grad_par to differential operator test.
mrhardman Mar 31, 2025
5e5edf8
Add Div_par_fvv() to differential operator test. Convergence order ap…
mrhardman Mar 31, 2025
fb4c940
Make test take an extra variable in "differential_operator_list", the…
mrhardman Mar 31, 2025
14b14f1
Add FV::Div_par_mod() to differential operator test. Worth noting tha…
mrhardman Mar 31, 2025
06a8605
Initial work to make an MMS test of neutral_mixed based on calculatin…
mrhardman Mar 31, 2025
c0d3968
Add symbolic Nn, Pn, and sources to test script and BOUT.inp file. Co…
mrhardman Mar 31, 2025
6e48518
Extend neutral_mixed test functionality to makes plots of error.
mrhardman Apr 1, 2025
16e9a0d
Increase resolution to larger values.
mrhardman Apr 1, 2025
c0afe38
Add an override option for neutral collision frequency to make testin…
mrhardman Apr 1, 2025
03d7add
Make neutral_mixed MMS test 2D.
mrhardman Apr 2, 2025
9ba9502
Reduce tolerance rtol to ensure implicit timestepping iterative error…
mrhardman Apr 2, 2025
94943ac
Sanity check, test absolute difference in Nd and Pd as well as ddt() …
mrhardman Apr 2, 2025
9aef275
Add choice of density floor, logical for neutral conduction, 5/3 fact…
mrhardman Apr 2, 2025
610918e
Test only 1 RHS evaluation, no timestepping.
mrhardman Apr 2, 2025
05d4159
Make reference values unity.
mrhardman Apr 2, 2025
1711c4e
Print out RMS values of Nd Pd for sanity checks.
mrhardman Apr 2, 2025
ed805a9
Make sure metric is not normalised.
mrhardman Apr 4, 2025
7279498
Supply J and g_* coeffs explicitly.
mrhardman Apr 4, 2025
911ca20
Remove normalisations from sources.
mrhardman Apr 4, 2025
daa56c3
Fix typo using Nn rather than Pn for pressure evolution in diffusion …
mrhardman Apr 8, 2025
29e3241
Revert "Remove normalisations from sources."
mrhardman Apr 8, 2025
fe7446f
Give option to not normalise the input sources to neutral_mixed.cxx, …
mrhardman Apr 8, 2025
d7ec8ac
Make sure Pn and Nn satisfy neumann boundary condition in x.
mrhardman Apr 8, 2025
e5741be
Add facility for checking relative conservation, normalise the errors…
mrhardman Apr 8, 2025
91e4e56
Include NVd in MMS test of neutral mixed for conservation_test=False.
mrhardman Apr 8, 2025
5adc3ee
Test conservation of energy when NVd is evolved.
mrhardman Apr 8, 2025
a9232d2
Wrapper function to make clear how to switch between different test t…
mrhardman Apr 8, 2025
b1664a9
Changes to permit tests to run in sequence from a single python scrip…
mrhardman Apr 16, 2025
758ae1d
Add automatic test of the RHS of the time evolution equations for neu…
mrhardman Apr 16, 2025
9b21f53
Complete momentum source feature consistent with other options, so th…
mrhardman Apr 16, 2025
ac4f3c4
Attempt to avoid CI-test failure by using `launch()` function to run …
mrhardman Apr 16, 2025
f841004
Specify number of threads, include same functions as in other (integr…
mrhardman Apr 16, 2025
f041903
Corrected typo
cmacmackin Jul 28, 2025
9355515
Revert "Corrected typo"
cmacmackin Jul 28, 2025
661e8ad
Debugging CI failure
cmacmackin Jul 28, 2025
2843b15
Display output for CI debugging
cmacmackin Jul 29, 2025
b723bf3
Better error handling in MMS tests
cmacmackin Jul 29, 2025
3527d94
Switched solver to one available in CI
cmacmackin Jul 29, 2025
ff2180a
Print statements for debugging CI
cmacmackin Jul 30, 2025
9859f3c
Further debugging; plus speed up build in CI
cmacmackin Jul 31, 2025
75f460e
Try loading all BOUT data immediately
cmacmackin Aug 1, 2025
be8a557
Revert CI debugging work
cmacmackin Aug 1, 2025
dff393e
Load BOUT++ datasets eagerly
cmacmackin Aug 1, 2025
04dea52
Use parallel builds in CI
cmacmackin Aug 1, 2025
1e44233
Close datasets in response to @d7919.
mrhardman Aug 4, 2025
11f6930
Update tests/mms/main.cxx: @ZedThree suggestion.
mrhardman Aug 4, 2025
1e0d13b
@ZedThree comment, use fmt::format to reduce lines of code.
mrhardman Aug 4, 2025
a869e7c
Merge branch 'master' into nonorthogonal-divops-mms-test-minimal
mrhardman Dec 8, 2025
786ed71
Merge master into nonorthogonal-divops-mms-test-minimal.
mrhardman Jan 8, 2026
7c0458e
Attempt to restore div_ops MMS test to CI.
mrhardman Jan 9, 2026
0f9d6f4
Merge nonorthogonal-divops-mms-test-minimal to keep track of changes …
mrhardman Jan 9, 2026
9c54998
CRLF to LF line endings.
mrhardman Jan 9, 2026
0b6d06c
Attempt to install h5py manually to avoid HDF5 error on integration t…
mrhardman Jan 9, 2026
32c8536
Refactor mms tests to enhance similarity to mms functions from `boutd…
mrhardman Jan 9, 2026
e600761
Attempt to print package versions in a test failing on Actions.
mrhardman Jan 12, 2026
099f6ed
Attempt to pin xBOUT for CI tests to the version that is used by the …
mrhardman Jan 12, 2026
5127ae5
Attempt to pin xBOUT for CI tests to the version that is used by the …
mrhardman Jan 12, 2026
6704dd1
Merge branch 'nonorthogonal-debug' of github.com:boutproject/hermes-3…
mrhardman Jan 12, 2026
27e243f
Ensure dataset is closed in `tests/integrated/drift-wave/analysis.py`
mrhardman Jan 12, 2026
fffa411
Revert "Attempt to print package versions in a test failing on Actions."
mrhardman Jan 12, 2026
ab489e3
Revert "Attempt to install h5py manually to avoid HDF5 error on integ…
mrhardman Jan 12, 2026
17a9578
Remove unused code in `/tests/mms/perpendicular_laplacian.py`.
mrhardman Jan 12, 2026
28a2e4d
@ZedThree suggestions regarding job execution.
mrhardman Jan 14, 2026
ce7b5fb
Revert "@ZedThree suggestions regarding job execution."
mrhardman Jan 14, 2026
060c6b3
Use launch_safe() to run jobs.
mrhardman Jan 14, 2026
f6e4723
Merge pull request #327 from boutproject/nonorthogonal-debug
mrhardman Jan 14, 2026
e97c363
Remame `hermes_mms_tests` to `hermes_mms_operator_tests`, and `tests/…
mrhardman Jan 15, 2026
73c8879
Rename `rnn_override` to `collisionality_override`. Remove trailing w…
mrhardman Jan 15, 2026
696bac8
Result of `$ git-clang-format 053c9bb70b66ffd3ac603477f76c5866a0b9e33c`.
mrhardman Jan 15, 2026
633550d
Basic unit test of `neutral_mixed`, based on tests for `evolve_densit…
mrhardman Jan 16, 2026
087e602
Attempt to bring style of neutral_mixed.cxx in line with evolve_press…
mrhardman Jan 23, 2026
0eab680
Fix typo -> get velocity in local state for the `Vn` variable, not de…
mrhardman Jan 27, 2026
8d14014
Add some terse comments explaining the nature of the unit tests.
mrhardman Jan 27, 2026
e41bc2c
Merge pull request #480 from boutproject/neutral-mixed-style-and-unit…
mrhardman Jan 29, 2026
d5086d4
Merge branch 'master' into nonorthogonal-divops-mms-test-minimal
mrhardman Jan 29, 2026
2b3a1fc
Result of `git-clang-format 6704dd1e5bace43a27dc3f29781157a237aa428f`…
mrhardman Jan 29, 2026
49a5cce
Apply clang-format changes
mrhardman Jan 29, 2026
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
9 changes: 4 additions & 5 deletions .pip_install_for_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ do
fi
done

# Install Hermes-3
git clone https://github.com/boutproject/xhermes.git
cd xhermes
pip3 install --user .
cd ..
# Install xBOUT to make sure we get latest master version
pip3 install --user git+https://github.com/boutproject/xBOUT.git@v0.3.7
# Install xHermes for Hermes-3 python
pip3 install --user git+https://github.com/boutproject/xhermes.git

22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,28 @@ if(HERMES_TESTS)
# Have hermes_unit_tests look for dynamic libs in ./ before searching elsewhere
set_target_properties(hermes_unit_tests PROPERTIES BUILD_RPATH "$ORIGIN")
endif()

# Method of manufactured solutions (MMS) tests of operators
option(HERMES_DIVOPS_MMS_TESTS "Build the differential operator MMS tests" ON)
if(HERMES_DIVOPS_MMS_TESTS)
#TEST_SOURCES=
add_executable(hermes_mms_operator_tests
tests/mms_operator/main.cxx)
#${TEST_SOURCES})
target_link_libraries(hermes_mms_operator_tests PRIVATE gtest bout++::bout++ hermes-3-lib)
add_test(NAME differential_operators_mms_orthogonal
WORKING_DIRECTORY tests/mms_operator/
COMMAND python3 orthogonal_test.py)
set_tests_properties(differential_operators_mms_orthogonal PROPERTIES LABELS integration)
add_test(NAME differential_operators_mms_nonorthogonal
WORKING_DIRECTORY tests/mms_operator/
COMMAND python3 nonorthogonal_test.py)
set_tests_properties(differential_operators_mms_nonorthogonal PROPERTIES LABELS integration)
add_test(NAME rhs_mms_neutral_mixed
WORKING_DIRECTORY tests/mms_operator/
COMMAND python3 neutral_mixed_ddt_test.py)
set_tests_properties(rhs_mms_neutral_mixed PROPERTIES LABELS integration)
endif()
endif()

# Compile-time options
Expand Down
5 changes: 5 additions & 0 deletions include/classical_diffusion.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ private:
Field3D Dn; ///< Particle diffusion coefficient
BoutReal custom_D; ///< User-set particle diffusion coefficient override

// Flow diagnostics
Field3D cls_pf_perp_xlow, cls_pf_perp_ylow;
Field3D cls_mf_perp_xlow, cls_mf_perp_ylow;
Field3D cls_nef_perp_xlow, cls_nef_perp_ylow;
Field3D cls_tef_perp_xlow, cls_tef_perp_ylow;
void transform_impl(GuardedOptions& state) override;
};

Expand Down
10 changes: 10 additions & 0 deletions include/div_ops.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ const Field3D Div_a_Grad_perp_upwind_flows(const Field3D& a, const Field3D& f,
const Field3D Div_par_K_Grad_par_mod(const Field3D& k, const Field3D& f, Field3D& flow_ylow,
bool bndry_flux = true);

/*!
* Div ( a Grad_perp(f) ) -- ∇⊥ ( a ⋅ ∇⊥ f) -- Vorticity
*
* This version includes corrections for non-orthogonal meshes
* in which the g12 and g13 components can be non-zero
* i.e. X-Y, X-Z and Y-Z coordinates can all be non-orthogonal.
*/
Field3D Div_a_Grad_perp_nonorthog(const Field3D& a, const Field3D& x, Field3D& flux_xlow,
Field3D& flux_ylow);

namespace FV {

/// Superbee limiter
Expand Down
14 changes: 9 additions & 5 deletions include/neutral_mixed.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct NeutralMixed : public Component {
/// @param options Top-level options. Settings will be taken from options[name]
/// @param solver Time-integration solver to be used
NeutralMixed(const std::string& name, Options& options, Solver *solver);

/// Use the final simulation state to update internal state
/// (e.g. time derivatives)
void finally(const Options &state) override;
Expand All @@ -30,7 +30,7 @@ struct NeutralMixed : public Component {
void precon(const Options &state, BoutReal gamma) override;
private:
std::string name; ///< Species name

Field3D Nn, Pn, NVn; // Density, pressure and parallel momentum
Field3D Vn; ///< Neutral parallel velocity
Field3D Tn; ///< Neutral temperature
Expand All @@ -45,6 +45,7 @@ private:
Field3D DnnNn, DnnPn, DnnTn, DnnNVn; ///< Used for operators
BoutReal flux_limit; ///< Diffusive flux limit
BoutReal diffusion_limit; ///< Maximum diffusion coefficient
BoutReal neutral_lmax;

bool sheath_ydown, sheath_yup;

Expand All @@ -53,20 +54,23 @@ private:
BoutReal pressure_floor; ///< Minimum Pn used when dividing Pn by Nn to get Tn.
bool freeze_low_density; ///< Freeze evolution in low density regions?


BoutReal collisionality_override; ///< Rnn input for testing
BoutReal density_norm, pressure_norm; ///< Normalisations
BoutReal momentum_norm; ///< Normalisations

bool neutral_viscosity; ///< include viscosity?
bool neutral_conduction; ///< Include heat conduction?
bool evolve_momentum; ///< Evolve parallel momentum?

bool normalise_sources; ///< Normalise input sources?

Field3D kappa_n, eta_n; ///< Neutral conduction and viscosity

bool precondition {true}; ///< Enable preconditioner?
bool precon_laplacexy {false}; ///< Use LaplaceXY?
bool lax_flux; ///< Use Lax flux for advection terms
std::unique_ptr<Laplacian> inv; ///< Laplacian inversion used for preconditioning

Field3D density_source, pressure_source; ///< External input source
Field3D density_source, pressure_source, momentum_source; ///< External input source
Field3D Sn, Sp, Snv; ///< Particle, pressure and momentum source
Field3D sound_speed; ///< Sound speed for use with Lax flux

Expand Down
73 changes: 42 additions & 31 deletions src/classical_diffusion.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "classical_diffusion.hxx"

#include "../include/div_ops.hxx"
#include <bout/fv_ops.hxx>

ClassicalDiffusion::ClassicalDiffusion(std::string name, Options& alloptions, Solver*)
Expand Down Expand Up @@ -36,29 +37,30 @@ void ClassicalDiffusion::transform_impl(GuardedOptions& state) {
// The only term here comes from the resistive drift

Field3D Ptotal = 0.0;
for (auto& kv : allspecies.getChildren()) {
const auto species = kv.second;
if (!(custom_D > 0)) {
for (auto& kv : allspecies.getChildren()) {
const auto species = kv.second;

if (!(species.isSet("charge") and species.isSet("pressure"))) {
continue; // Skip, go to next species
}
auto q = get<BoutReal>(species["charge"]);
if (fabs(q) < 1e-5) {
continue;
if (!(species.isSet("charge") and species.isSet("pressure"))) {
continue; // Skip, go to next species
}
auto q = get<BoutReal>(species["charge"]);
if (fabs(q) < 1e-5) {
continue;
}
Ptotal += GET_VALUE(Field3D, species["pressure"]);
}
Ptotal += GET_VALUE(Field3D, species["pressure"]);
}

auto electrons = allspecies["e"];
const auto me = get<BoutReal>(electrons["AA"]);
const Field3D Ne = GET_VALUE(Field3D, electrons["density"]);

// Particle diffusion coefficient. Applied to all charged species
// so that net transport is ambipolar

if (custom_D > 0) { // User-set
Dn = custom_D;
} else { // Calculated from collisions
auto electrons = allspecies["e"];
const auto me = get<BoutReal>(electrons["AA"]);
const Field3D Ne = GET_VALUE(Field3D, electrons["density"]);
const Field3D nu_e = floor(GET_VALUE(Field3D, electrons["collision_frequency"]), 1e-10);
Dn = floor(Ptotal, 1e-5) * me * nu_e / (floor(Ne, 1e-5) * Bsq);
}
Expand All @@ -70,40 +72,49 @@ void ClassicalDiffusion::transform_impl(GuardedOptions& state) {

for (auto kv : allspecies.getChildren()) {
GuardedOptions species = allspecies[kv.first]; // Note: Need non-const

if (!(species.isSet("charge") and species.isSet("density"))) {
continue; // Skip, go to next species
}
auto q = get<BoutReal>(species["charge"]);
if (fabs(q) < 1e-5) {
continue;
if (!(custom_D > 0)) {
if (!(species.isSet("charge") and species.isSet("density"))) {
continue; // Skip, go to next species
}
auto q = get<BoutReal>(species["charge"]);
if (fabs(q) < 1e-5) {
continue;
}
}

const auto N = GET_VALUE(Field3D, species["density"]);

add(species["density_source"], FV::Div_a_Grad_perp(Dn, N));
// add(species["density_source"], FV::Div_a_Grad_perp(Dn, N));
add(species["density_source"],
Div_a_Grad_perp_nonorthog(Dn, N, cls_pf_perp_xlow, cls_pf_perp_ylow));

if (IS_SET(species["velocity"])) {
const auto V = GET_VALUE(Field3D, species["velocity"]);
const auto AA = GET_VALUE(BoutReal, species["AA"]);

add(species["momentum_source"], FV::Div_a_Grad_perp(Dn * AA * V, N));
// add(species["momentum_source"], FV::Div_a_Grad_perp(Dn * AA * V, N));
add(species["momentum_source"],
Div_a_Grad_perp_nonorthog(Dn * AA * V, N, cls_mf_perp_xlow, cls_mf_perp_ylow));
}

if (IS_SET(species["temperature"])) {
const auto T = GET_VALUE(Field3D, species["temperature"]);
add(species["energy_source"], FV::Div_a_Grad_perp(Dn * (3. / 2) * T, N));

// Cross-field heat conduction
// kappa_perp = 2 * n * nu_ii * rho_i^2

const auto P = GET_VALUE(Field3D, species["pressure"]);
const auto AA = GET_VALUE(BoutReal, species["AA"]);
// add(species["energy_source"], FV::Div_a_Grad_perp(Dn * (3. / 2) * T, N));
add(species["energy_source"],
Div_a_Grad_perp_nonorthog(Dn * (3. / 2) * T, N, cls_nef_perp_xlow,
cls_nef_perp_ylow));

// TODO: Figure out what to do with the below
if(custom_D < 0) {
// Cross-field heat conduction
// kappa_perp = 2 * n * nu_ii * rho_i^2
const auto P = GET_VALUE(Field3D, species["pressure"]);
const auto AA = GET_VALUE(BoutReal, species["AA"]);
const Field3D nu = floor(GET_VALUE(Field3D, species["collision_frequency"]), 1e-10);
add(species["energy_source"], FV::Div_a_Grad_perp(2. * floor(P, 1e-5) * nu * AA / Bsq, T));
// add(species["energy_source"], FV::Div_a_Grad_perp(2. * floor(P, 1e-5) * nu * AA
// / Bsq, T));
add(species["energy_source"],
Div_a_Grad_perp_nonorthog(2. * floor(P, 1e-5) * nu * AA / Bsq, T,
cls_tef_perp_xlow, cls_tef_perp_ylow));
}
}
}
Expand Down
Loading