Skip to content

Commit 3e13a20

Browse files
committed
Merge branch 'master' into lithium
2 parents 5015258 + 46719f5 commit 3e13a20

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

include/classical_diffusion.hxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ private:
1515

1616
bool diagnose; ///< Output additional diagnostics?
1717
Field3D Dn; ///< Particle diffusion coefficient
18+
BoutReal custom_D; ///< User-set particle diffusion coefficient override
1819
};
1920

2021
namespace {

src/classical_diffusion.cxx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ClassicalDiffusion::ClassicalDiffusion(std::string name, Options& alloptions, So
99
Bsq = SQ(bout::globals::mesh->getCoordinates()->Bxy);
1010

1111
diagnose = options["diagnose"].doc("Output additional diagnostics?").withDefault<bool>(false);
12+
custom_D = options["custom_D"].doc("Custom diffusion coefficient override. -1: Off, calculate D normally").withDefault<BoutReal>(-1);
1213
}
1314

1415
void ClassicalDiffusion::transform(Options &state) {
@@ -35,11 +36,21 @@ void ClassicalDiffusion::transform(Options &state) {
3536
auto& electrons = allspecies["e"];
3637
const auto me = get<BoutReal>(electrons["AA"]);
3738
const Field3D Ne = GET_VALUE(Field3D, electrons["density"]);
38-
const Field3D nu_e = floor(GET_VALUE(Field3D, electrons["collision_frequency"]), 1e-10);
3939

4040
// Particle diffusion coefficient. Applied to all charged species
4141
// so that net transport is ambipolar
42-
Dn = floor(Ptotal, 1e-5) * me * nu_e / (floor(Ne, 1e-5) * Bsq);
42+
43+
if (custom_D > 0) { // User-set
44+
Dn = custom_D;
45+
} else { // Calculated from collisions
46+
const Field3D nu_e = floor(GET_VALUE(Field3D, electrons["collision_frequency"]), 1e-10);
47+
Dn = floor(Ptotal, 1e-5) * me * nu_e / (floor(Ne, 1e-5) * Bsq);
48+
}
49+
50+
// Set D to zero in all guard cells
51+
BOUT_FOR(i, Dn.getRegion("RGN_GUARDS")) {
52+
Dn[i] = 0.0;
53+
}
4354

4455
for (auto& kv : allspecies.getChildren()) {
4556
Options& species = allspecies[kv.first]; // Note: Need non-const
@@ -73,8 +84,11 @@ void ClassicalDiffusion::transform(Options &state) {
7384
const auto P = GET_VALUE(Field3D, species["pressure"]);
7485
const auto AA = GET_VALUE(BoutReal, species["AA"]);
7586

76-
const Field3D nu = floor(GET_VALUE(Field3D, species["collision_frequency"]), 1e-10);
77-
add(species["energy_source"], FV::Div_a_Grad_perp(2. * floor(P, 1e-5) * nu * AA / Bsq, T));
87+
// TODO: Figure out what to do with the below
88+
if(custom_D < 0) {
89+
const Field3D nu = floor(GET_VALUE(Field3D, species["collision_frequency"]), 1e-10);
90+
add(species["energy_source"], FV::Div_a_Grad_perp(2. * floor(P, 1e-5) * nu * AA / Bsq, T));
91+
}
7892
}
7993
}
8094
}

0 commit comments

Comments
 (0)