Skip to content

Commit 12269a0

Browse files
Fixing bug in hyper-resistivity calculation which had missing terms i… (#5638)
…n vector laplacian evaluation. Additioanally fixing a staggering bug for density calculation in RZ. --------- Signed-off-by: S. Eric Clark <[email protected]> Co-authored-by: Roelof Groenewald <[email protected]>
1 parent 93466dd commit 12269a0

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

Examples/Tests/ohm_solver_em_modes/analysis_rz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,5 @@ def process(it):
179179
amps = np.abs(F_kw[2, 1, len(kz) // 2 - 2 : len(kz) // 2 + 2])
180180
print("Amplitude sample: ", amps)
181181
assert np.allclose(
182-
amps, np.array([61.02377286, 19.80026021, 100.47687017, 10.83331295])
182+
amps, np.array([59.23850009, 19.26746169, 92.65794174, 10.83627164])
183183
)
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"lev=0": {},
33
"ions": {
4-
"particle_momentum_x": 5.0438993756415296e-17,
5-
"particle_momentum_y": 5.0444406612873916e-17,
6-
"particle_momentum_z": 5.0519292431385393e-17,
7-
"particle_position_x": 143164.41713467025,
8-
"particle_position_y": 143166.51845281923,
9-
"particle_theta": 2573261.8729711357,
10-
"particle_weight": 8.128680645366887e+18
4+
"particle_momentum_x": 5.043784704795177e-17,
5+
"particle_momentum_y": 5.0444695502620235e-17,
6+
"particle_momentum_z": 5.05193106847111e-17,
7+
"particle_position_x": 143164.53685279266,
8+
"particle_position_y": 143166.5185853012,
9+
"particle_theta": 2573262.446840369,
10+
"particle_weight": 8.128680645366886e+18
1111
}
1212
}

Source/FieldSolver/FiniteDifferenceSolver/HybridPICSolveE.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,10 @@ void FiniteDifferenceSolver::HybridPICSolveECylindrical (
611611

612612
if (include_hyper_resistivity_term) {
613613
// r on cell-centered point (Jr is cell-centered in r)
614-
Real const r = rmin + (i + 0.5_rt)*dr;
615-
616-
auto nabla2Jr = T_Algo::Dr_rDr_over_r(Jr, r, dr, coefs_r, n_coefs_r, i, j, 0, 0);
614+
const Real r = rmin + (i + 0.5_rt)*dr;
615+
const Real jr_val = Interp(Jr, Jr_stag, Er_stag, coarsen, i, j, 0, 0);
616+
auto nabla2Jr = T_Algo::Dr_rDr_over_r(Jr, r, dr, coefs_r, n_coefs_r, i, j, 0, 0)
617+
+ T_Algo::Dzz(Jr, coefs_z, n_coefs_z, i, j, 0, 0) - jr_val/(r*r);
617618
Er(i, j, 0) -= eta_h * nabla2Jr;
618619
}
619620
},
@@ -633,7 +634,7 @@ void FiniteDifferenceSolver::HybridPICSolveECylindrical (
633634
}
634635

635636
// Interpolate to get the appropriate charge density in space
636-
Real rho_val = Interp(rho, nodal, Er_stag, coarsen, i, j, 0, 0);
637+
Real rho_val = Interp(rho, nodal, Et_stag, coarsen, i, j, 0, 0);
637638

638639
// Interpolate current to appropriate staggering to match E field
639640
Real jtot_val = 0._rt;
@@ -659,7 +660,13 @@ void FiniteDifferenceSolver::HybridPICSolveECylindrical (
659660
// Add resistivity only if E field value is used to update B
660661
if (solve_for_Faraday) { Et(i, j, 0) += eta(rho_val, jtot_val) * Jt(i, j, 0); }
661662

662-
// Note: Hyper-resisitivity should be revisited here when modal decomposition is implemented
663+
if (include_hyper_resistivity_term) {
664+
const Real jt_val = Interp(Jt, Jt_stag, Et_stag, coarsen, i, j, 0, 0);
665+
auto nabla2Jt = T_Algo::Dr_rDr_over_r(Jt, r, dr, coefs_r, n_coefs_r, i, j, 0, 0)
666+
+ T_Algo::Dzz(Jt, coefs_z, n_coefs_z, i, j, 0, 0) - jt_val/(r*r);
667+
668+
Et(i, j, 0) -= eta_h * nabla2Jt;
669+
}
663670
},
664671

665672
// Ez calculation
@@ -697,7 +704,14 @@ void FiniteDifferenceSolver::HybridPICSolveECylindrical (
697704
if (solve_for_Faraday) { Ez(i, j, 0) += eta(rho_val, jtot_val) * Jz(i, j, 0); }
698705

699706
if (include_hyper_resistivity_term) {
707+
// r on nodal point (Jz is nodal in r)
708+
Real const r = rmin + i*dr;
709+
700710
auto nabla2Jz = T_Algo::Dzz(Jz, coefs_z, n_coefs_z, i, j, 0, 0);
711+
if (r > 0.5_rt*dr) {
712+
nabla2Jz += T_Algo::Dr_rDr_over_r(Jz, r, dr, coefs_r, n_coefs_r, i, j, 0, 0);
713+
}
714+
701715
Ez(i, j, 0) -= eta_h * nabla2Jz;
702716
}
703717
}
@@ -918,7 +932,9 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian (
918932
if (solve_for_Faraday) { Ex(i, j, k) += eta(rho_val, jtot_val) * Jx(i, j, k); }
919933

920934
if (include_hyper_resistivity_term) {
921-
auto nabla2Jx = T_Algo::Dxx(Jx, coefs_x, n_coefs_x, i, j, k);
935+
auto nabla2Jx = T_Algo::Dxx(Jx, coefs_x, n_coefs_x, i, j, k)
936+
+ T_Algo::Dyy(Jx, coefs_y, n_coefs_y, i, j, k)
937+
+ T_Algo::Dzz(Jx, coefs_z, n_coefs_z, i, j, k);
922938
Ex(i, j, k) -= eta_h * nabla2Jx;
923939
}
924940
},
@@ -958,7 +974,9 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian (
958974
if (solve_for_Faraday) { Ey(i, j, k) += eta(rho_val, jtot_val) * Jy(i, j, k); }
959975

960976
if (include_hyper_resistivity_term) {
961-
auto nabla2Jy = T_Algo::Dyy(Jy, coefs_y, n_coefs_y, i, j, k);
977+
auto nabla2Jy = T_Algo::Dxx(Jy, coefs_x, n_coefs_x, i, j, k)
978+
+ T_Algo::Dyy(Jy, coefs_y, n_coefs_y, i, j, k)
979+
+ T_Algo::Dzz(Jy, coefs_z, n_coefs_z, i, j, k);
962980
Ey(i, j, k) -= eta_h * nabla2Jy;
963981
}
964982
},
@@ -998,7 +1016,9 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian (
9981016
if (solve_for_Faraday) { Ez(i, j, k) += eta(rho_val, jtot_val) * Jz(i, j, k); }
9991017

10001018
if (include_hyper_resistivity_term) {
1001-
auto nabla2Jz = T_Algo::Dzz(Jz, coefs_z, n_coefs_z, i, j, k);
1019+
auto nabla2Jz = T_Algo::Dxx(Jz, coefs_x, n_coefs_x, i, j, k)
1020+
+ T_Algo::Dyy(Jz, coefs_y, n_coefs_y, i, j, k)
1021+
+ T_Algo::Dzz(Jz, coefs_z, n_coefs_z, i, j, k);
10021022
Ez(i, j, k) -= eta_h * nabla2Jz;
10031023
}
10041024
}

0 commit comments

Comments
 (0)