1
1
#include < bout/fv_ops.hxx>
2
+ #include < vecops.hxx>
2
3
3
4
#include " ../include/diamagnetic_drift.hxx"
4
5
@@ -13,6 +14,10 @@ DiamagneticDrift::DiamagneticDrift(std::string name, Options& alloptions,
13
14
bndry_flux =
14
15
options[" bndry_flux" ].doc (" Allow fluxes through boundary?" ).withDefault <bool >(true );
15
16
17
+ diamag_form = options[" diamag_form" ]
18
+ .doc (" Form of diamagnetic drift: 0 = gradient; 1 = divergence" )
19
+ .withDefault (Field2D (1.0 ));
20
+
16
21
// Read curvature vector
17
22
Curlb_B.covariant = false ; // Contravariant
18
23
if (mesh->get (Curlb_B, " bxcv" )) {
@@ -41,6 +46,15 @@ DiamagneticDrift::DiamagneticDrift(std::string name, Options& alloptions,
41
46
Curlb_B.z *= SQ (Lnorm);
42
47
43
48
Curlb_B *= 2 . / mesh->getCoordinates ()->Bxy ;
49
+
50
+ // Set drift to zero through sheath boundaries.
51
+ // Flux through those cell faces should be set by sheath.
52
+ for (RangeIterator r = mesh->iterateBndryLowerY (); !r.isDone (); r++) {
53
+ Curlb_B.y (r.ind , mesh->ystart - 1 ) = -Curlb_B.y (r.ind , mesh->ystart );
54
+ }
55
+ for (RangeIterator r = mesh->iterateBndryUpperY (); !r.isDone (); r++) {
56
+ Curlb_B.y (r.ind , mesh->yend + 1 ) = -Curlb_B.y (r.ind , mesh->yend );
57
+ }
44
58
}
45
59
46
60
void DiamagneticDrift::transform (Options& state) {
@@ -62,17 +76,28 @@ void DiamagneticDrift::transform(Options& state) {
62
76
63
77
if (IS_SET (species[" density" ])) {
64
78
auto N = GET_VALUE (Field3D, species[" density" ]);
65
- subtract (species[" density_source" ], FV::Div_f_v (N, vD, bndry_flux));
79
+
80
+ // Divergence form: Div(n v_D)
81
+ Field3D div_form = FV::Div_f_v (N, vD, bndry_flux);
82
+ // Gradient form: Curlb_B dot Grad(N T / q)
83
+ Field3D grad_form = Curlb_B * Grad (N * T / q);
84
+
85
+ subtract (species[" density_source" ], diamag_form * div_form + (1 . - diamag_form) * grad_form);
66
86
}
67
87
68
88
if (IS_SET (species[" pressure" ])) {
69
89
auto P = get<Field3D>(species[" pressure" ]);
70
- subtract (species[" energy_source" ], (5 . / 2 ) * FV::Div_f_v (P, vD, bndry_flux));
90
+
91
+ Field3D div_form = FV::Div_f_v (P, vD, bndry_flux);
92
+ Field3D grad_form = Curlb_B * Grad (P * T / q);
93
+ subtract (species[" energy_source" ], (5 . / 2 ) * (diamag_form * div_form + (1 . - diamag_form) * grad_form));
71
94
}
72
95
73
96
if (IS_SET (species[" momentum" ])) {
74
97
auto NV = get<Field3D>(species[" momentum" ]);
75
- subtract (species[" momentum_source" ], FV::Div_f_v (NV, vD, bndry_flux));
98
+ Field3D div_form = FV::Div_f_v (NV, vD, bndry_flux);
99
+ Field3D grad_form = Curlb_B * Grad (NV * T / q);
100
+ subtract (species[" momentum_source" ], diamag_form * div_form + (1 . - diamag_form) * grad_form);
76
101
}
77
102
}
78
103
}
0 commit comments