Skip to content

Commit 4a70693

Browse files
committed
6f_landau: Changed the Sheath BC to make it more consistent with the older version of the model.
1 parent b3a97db commit 4a70693

1 file changed

Lines changed: 50 additions & 21 deletions

File tree

examples/6f_landau/6f_landau.cxx

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,9 @@ class Elm_6f : public PhysicsModel {
17841784

17851785
if (compress0) {
17861786
output.write("Including compression (Vipar) effects\n");
1787+
if (include_vipar) {
1788+
output.write("Including all compresssion (Vipar) effects\n");
1789+
}
17871790
Vipara = MU0 * KB * Nbar * density * Tebar * eV_K / (Bbar * Bbar);
17881791
Vepara = Bbar / (MU0 * Zi * ee * Nbar * density * Lbar * Va);
17891792
// Vepara = Bbar / (MU0 * ee * Nbar * density * Lbar * Va);
@@ -2568,7 +2571,7 @@ class Elm_6f : public PhysicsModel {
25682571
coord->g_23 = Btxy * hthe * Rxy / Bpxy;
25692572

25702573
// Calculate quantities from metric tensor
2571-
coord->geometry();
2574+
coord->geometry();
25722575

25732576
// Set B field vector
25742577
B0vec.covariant = false;
@@ -3451,12 +3454,10 @@ class Elm_6f : public PhysicsModel {
34513454

34523455
Coordinates* coord = mesh->getCoordinates();
34533456
// Ensure positivity of total variables
3454-
Ni = field_floor(Ni, N0, 1e-10);
3455-
Ti = field_floor(Ti, Ti0, 1e-10);
3456-
Te = field_floor(Te, Te0, 1e-10);
3457-
3458-
if (compress0 && include_vpar0){
3459-
Vipar = field_floor(Vipar, Vipar0, 1e-10);
3457+
if (nonlinear) {
3458+
Ni = field_floor(Ni, N0, 1e-10);
3459+
Ti = field_floor(Ti, Ti0, 1e-10);
3460+
Te = field_floor(Te, Te0, 1e-10);
34603461
}
34613462

34623463
// Perform communications
@@ -3662,7 +3663,7 @@ class Elm_6f : public PhysicsModel {
36623663
if (impurity_prof) {
36633664
nu_e = 2.91e-6 * LnLambda * (Ne_tmp * Nbar * density / 1.e6) * (pow(Te_tmp * Tebar, -1.5)); // nu_e in 1/S.
36643665
} else {
3665-
nu_e = 2.91e-6 * LnLambda * (N_tmp * Nbar * density / 1.e6) * (pow(Te_tmp * Tebar, -1.5)); // nu_e in 1/S.
3666+
nu_e = 2.91e-6 * LnLambda * (N_tmp * Nbar * density / 1.e6) * (pow(Te_tmp * Tebar, -1.5)); // nu_e in 1/S.
36663667
// nu_e.applyBoundary();
36673668
// mesh->communicate(nu_e);
36683669
}
@@ -3716,6 +3717,7 @@ class Elm_6f : public PhysicsModel {
37163717
}
37173718

37183719
if (diffusion_perp > 0.0) {
3720+
37193721
kappa_perp_i = 2.0 * vth_i * vth_i * nu_i / (omega_ci * omega_ci); // * 1.e4;
37203722
kappa_perp_e = 4.7 * vth_e * vth_e * nu_e / (omega_ce * omega_ce); // * 1.e4;
37213723

@@ -3746,6 +3748,7 @@ class Elm_6f : public PhysicsModel {
37463748
// Dri_neo.applyBoundary();
37473749
// xii_neo.applyBoundary();
37483750
}
3751+
37493752
if (neoclassic_e) {
37503753
rho_e = 2.38e-6 * sqrt(Te_tmp * Tebar) / B0 / Bbar;
37513754
xie_neo = (q95 * q95) / epsilon / sqrt(epsilon) * nu_e * rho_e * rho_e;
@@ -3950,7 +3953,6 @@ class Elm_6f : public PhysicsModel {
39503953

39513954
// SBC_Gradpar(U, zero, PF_limit, PF_limit_range);
39523955
SBC_Gradpar(Ni, zero, PF_limit, PF_limit_range);
3953-
SBC_Dirichlet(P, zero, PF_limit, PF_limit_range);
39543956
if (evolve_psi) {
39553957
SBC_Dirichlet(Psi, zero, PF_limit, PF_limit_range);
39563958
} else {
@@ -4369,7 +4371,6 @@ class Elm_6f : public PhysicsModel {
43694371
if (nonlinear) {
43704372
if (include_vpar0) {
43714373
Vepar = - Jpar / Ne_tmp * Vepara + N_tmp / Ne_tmp * Vipar + Ni / Ne_tmp * Vipar0 -Zi * Ni / Ne_tmp * Vepar0;
4372-
Vepar = field_floor(Vepar, Vepar0, 1e-10);
43734374
} else {
43744375
Vepar = Vipar - Jpar / Ne_tmp * Vepara;
43754376
}
@@ -5840,8 +5841,13 @@ class Elm_6f : public PhysicsModel {
58405841

58415842
void SBC_Dirichlet(Field3D &var, Field3D &value, bool PF_limit, BoutReal PF_limit_range) {
58425843
// set the boundary equall to the value next to the boundary
5843-
// SBC_yup_eq(var, value, PF_limit, PF_limit_range);
5844-
// SBC_ydown_eq(var, -value, PF_limit, PF_limit_range);
5844+
SBC_yup_eq(var, value, PF_limit, PF_limit_range);
5845+
SBC_ydown_eq(var, -value, PF_limit, PF_limit_range);
5846+
// SBC_ydown_eq(var, value, PF_limit, PF_limit_range);
5847+
}
5848+
5849+
// Boundary to specified Field3D object
5850+
void SBC_yup_eq(Field3D &var, const Field3D &value, bool PF_limit, BoutReal PF_limit_range) {
58455851

58465852
auto var_fa = toFieldAligned(var);
58475853
auto value_fa = toFieldAligned(value);
@@ -5877,6 +5883,15 @@ class Elm_6f : public PhysicsModel {
58775883
}
58785884
}
58795885

5886+
var = fromFieldAligned(var_fa);
5887+
// value = fromFieldAligned(value_fa);
5888+
}
5889+
5890+
void SBC_ydown_eq(Field3D &var, const Field3D &value, bool PF_limit, BoutReal PF_limit_range) {
5891+
5892+
auto var_fa = toFieldAligned(var);
5893+
auto value_fa = toFieldAligned(value);
5894+
58805895
// SBC_ydown_eq
58815896
for (RangeIterator xrdn = mesh->iterateBndryLowerY(); !xrdn.isDone(); xrdn++) {
58825897
xind = xrdn.ind;
@@ -5887,8 +5902,8 @@ class Elm_6f : public PhysicsModel {
58875902
for (int jz = 0; jz < mesh->LocalNz; jz++) {
58885903
// var_fa(xind, jy, jz) = - value_fa(xind, jy, jz);
58895904
// var_fa(xind, jy, jz) = - value_fa(xind, mesh->ystart, jz);
5890-
var_fa(xind, jy, jz) = value_fa(xind, mesh->ystart, jz);
58915905
// var_fa(xind, jy, jz) = -2.0 * value_fa(xind, mesh->ystart, jz) - var_fa(xind, mesh->ystart, jz);
5906+
var_fa(xind, jy, jz) = value_fa(xind, mesh->ystart, jz);
58925907
}
58935908
}
58945909

@@ -5904,23 +5919,27 @@ class Elm_6f : public PhysicsModel {
59045919
for (int jz = 0; jz < mesh->LocalNz; jz++) {
59055920
// var_fa(xind, jy, jz) = - value_fa(xind, jy, jz);
59065921
// var_fa(xind, jy, jz) = - value_fa(xind, mesh->ystart, jz);
5907-
var_fa(xind, jy, jz) = value_fa(xind, mesh->ystart, jz);
59085922
// var_fa(xind, jy, jz) = -2.0 * value_fa(xind, mesh->ystart, jz) - var_fa(xind, mesh->ystart, jz);
5923+
var_fa(xind, jy, jz) = value_fa(xind, mesh->ystart, jz);
59095924
}
59105925
}
59115926
}
59125927
}
59135928

59145929
var = fromFieldAligned(var_fa);
5915-
value = fromFieldAligned(value_fa);
5916-
5930+
// value = fromFieldAligned(value_fa);
59175931
}
59185932

59195933
// Boundary gradient to specified Field3D object
59205934
void SBC_Gradpar(Field3D &var, Field3D &value, bool PF_limit, BoutReal PF_limit_range) {
5921-
// SBC_yup_Grad_par(var, value, PF_limit, PF_limit_range);
5922-
// SBC_ydown_Grad_par(var, -value, PF_limit, PF_limit_range);
5935+
SBC_yup_Grad_par(var, value, PF_limit, PF_limit_range);
5936+
SBC_ydown_Grad_par(var, -value, PF_limit, PF_limit_range);
5937+
// SBC_ydown_Grad_par(var, value, PF_limit, PF_limit_range);
5938+
}
59235939

5940+
5941+
void SBC_yup_Grad_par(Field3D &var, const Field3D &value, bool PF_limit, BoutReal PF_limit_range) {
5942+
59245943
auto var_fa = toFieldAligned(var);
59255944
auto value_fa = toFieldAligned(value);
59265945

@@ -5955,6 +5974,18 @@ class Elm_6f : public PhysicsModel {
59555974
}
59565975
}
59575976

5977+
var = fromFieldAligned(var_fa);
5978+
// value = fromFieldAligned(value_fa);
5979+
5980+
}
5981+
5982+
void SBC_ydown_Grad_par(Field3D &var, const Field3D &value, bool PF_limit, BoutReal PF_limit_range) {
5983+
5984+
auto var_fa = toFieldAligned(var);
5985+
auto value_fa = toFieldAligned(value);
5986+
5987+
Coordinates* coord = mesh->getCoordinates();
5988+
59585989
// SBC_ydown_Grad_par
59595990
for (RangeIterator xrdn = mesh->iterateBndryLowerY(); !xrdn.isDone(); xrdn++) {
59605991
xind = xrdn.ind;
@@ -5985,10 +6016,8 @@ class Elm_6f : public PhysicsModel {
59856016
}
59866017
}
59876018

5988-
59896019
var = fromFieldAligned(var_fa);
5990-
value = fromFieldAligned(value_fa);
5991-
6020+
// value = fromFieldAligned(value_fa);
59926021
}
59936022

59946023
void SBC_FreeBoundary(Field3D &var, bool PF_limit, BoutReal PF_limit_range) {

0 commit comments

Comments
 (0)