Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing bug in hyper-resistivity calculation which had missing terms i… #5638

43 changes: 34 additions & 9 deletions Source/FieldSolver/FiniteDifferenceSolver/HybridPICSolveE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,9 @@ void FiniteDifferenceSolver::HybridPICSolveECylindrical (

// Interpolate current to appropriate staggering to match E field
Real jtot_val = 0._rt;
Real jr_val = 0._rt;
if (solve_for_Faraday && resistivity_has_J_dependence) {
const Real jr_val = Interp(Jr, Jr_stag, Er_stag, coarsen, i, j, 0, 0);
jr_val = Interp(Jr, Jr_stag, Er_stag, coarsen, i, j, 0, 0);
const Real jt_val = Interp(Jt, Jt_stag, Er_stag, coarsen, i, j, 0, 0);
const Real jz_val = Interp(Jz, Jz_stag, Er_stag, coarsen, i, j, 0, 0);
jtot_val = std::sqrt(jr_val*jr_val + jt_val*jt_val + jz_val*jz_val);
Expand All @@ -613,7 +614,8 @@ void FiniteDifferenceSolver::HybridPICSolveECylindrical (
// r on cell-centered point (Jr is cell-centered in r)
Real const r = rmin + (i + 0.5_rt)*dr;

auto nabla2Jr = T_Algo::Dr_rDr_over_r(Jr, r, dr, coefs_r, n_coefs_r, i, j, 0, 0);
auto nabla2Jr = T_Algo::Dr_rDr_over_r(Jr, r, dr, coefs_r, n_coefs_r, i, j, 0, 0)
+ T_Algo::Dzz(Jr, coefs_z, n_coefs_z, i, j, 0, 0) - jr_val/(r*r);
Er(i, j, 0) -= eta_h * nabla2Jr;
}
},
Expand All @@ -633,13 +635,14 @@ void FiniteDifferenceSolver::HybridPICSolveECylindrical (
}

// Interpolate to get the appropriate charge density in space
Real rho_val = Interp(rho, nodal, Er_stag, coarsen, i, j, 0, 0);
Real rho_val = Interp(rho, nodal, Et_stag, coarsen, i, j, 0, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!


// Interpolate current to appropriate staggering to match E field
Real jtot_val = 0._rt;
Real jt_val = 0._rt;
if (solve_for_Faraday && resistivity_has_J_dependence) {
const Real jr_val = Interp(Jr, Jr_stag, Et_stag, coarsen, i, j, 0, 0);
const Real jt_val = Interp(Jt, Jt_stag, Et_stag, coarsen, i, j, 0, 0);
jt_val = Interp(Jt, Jt_stag, Et_stag, coarsen, i, j, 0, 0);
const Real jz_val = Interp(Jz, Jz_stag, Et_stag, coarsen, i, j, 0, 0);
jtot_val = std::sqrt(jr_val*jr_val + jt_val*jt_val + jz_val*jz_val);
}
Expand All @@ -659,7 +662,15 @@ void FiniteDifferenceSolver::HybridPICSolveECylindrical (
// Add resistivity only if E field value is used to update B
if (solve_for_Faraday) { Et(i, j, 0) += eta(rho_val, jtot_val) * Jt(i, j, 0); }

// Note: Hyper-resisitivity should be revisited here when modal decomposition is implemented
if (include_hyper_resistivity_term) {
// Do not apply hyper-resistivity at r=0
auto nabla2Jt = 0._rt;
if (r > 0.5_rt*dr) {
nabla2Jt = T_Algo::Dr_rDr_over_r(Jt, r, dr, coefs_r, n_coefs_r, i, j, 0, 0)
+ T_Algo::Dzz(Jt, coefs_z, n_coefs_z, i, j, 0, 0) - jt_val/(r*r);
}
Et(i, j, 0) -= eta_h * nabla2Jt;
}
},

// Ez calculation
Expand Down Expand Up @@ -697,7 +708,15 @@ void FiniteDifferenceSolver::HybridPICSolveECylindrical (
if (solve_for_Faraday) { Ez(i, j, 0) += eta(rho_val, jtot_val) * Jz(i, j, 0); }

if (include_hyper_resistivity_term) {
auto nabla2Jz = T_Algo::Dzz(Jz, coefs_z, n_coefs_z, i, j, 0, 0);
// r on nodal point (Jz is nodal in r)
Real const r = rmin + i*dr;

auto nabla2Jz = 0._rt;
if (r > 0.5_rt*dr) {
nabla2Jz = T_Algo::Dr_rDr_over_r(Jz, r, dr, coefs_r, n_coefs_r, i, j, 0, 0)
+ T_Algo::Dzz(Jz, coefs_z, n_coefs_z, i, j, 0, 0);
}

Ez(i, j, 0) -= eta_h * nabla2Jz;
}
}
Expand Down Expand Up @@ -918,7 +937,9 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian (
if (solve_for_Faraday) { Ex(i, j, k) += eta(rho_val, jtot_val) * Jx(i, j, k); }

if (include_hyper_resistivity_term) {
auto nabla2Jx = T_Algo::Dxx(Jx, coefs_x, n_coefs_x, i, j, k);
auto nabla2Jx = T_Algo::Dxx(Jx, coefs_x, n_coefs_x, i, j, k)
+ T_Algo::Dyy(Jx, coefs_y, n_coefs_y, i, j, k)
+ T_Algo::Dzz(Jx, coefs_z, n_coefs_z, i, j, k);
Ex(i, j, k) -= eta_h * nabla2Jx;
}
},
Expand Down Expand Up @@ -958,7 +979,9 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian (
if (solve_for_Faraday) { Ey(i, j, k) += eta(rho_val, jtot_val) * Jy(i, j, k); }

if (include_hyper_resistivity_term) {
auto nabla2Jy = T_Algo::Dyy(Jy, coefs_y, n_coefs_y, i, j, k);
auto nabla2Jy = T_Algo::Dxx(Jy, coefs_x, n_coefs_x, i, j, k)
+ T_Algo::Dyy(Jy, coefs_y, n_coefs_y, i, j, k)
+ T_Algo::Dzz(Jy, coefs_z, n_coefs_z, i, j, k);
Ey(i, j, k) -= eta_h * nabla2Jy;
}
},
Expand Down Expand Up @@ -998,7 +1021,9 @@ void FiniteDifferenceSolver::HybridPICSolveECartesian (
if (solve_for_Faraday) { Ez(i, j, k) += eta(rho_val, jtot_val) * Jz(i, j, k); }

if (include_hyper_resistivity_term) {
auto nabla2Jz = T_Algo::Dzz(Jz, coefs_z, n_coefs_z, i, j, k);
auto nabla2Jz = T_Algo::Dxx(Jz, coefs_x, n_coefs_x, i, j, k)
+ T_Algo::Dyy(Jz, coefs_y, n_coefs_y, i, j, k)
+ T_Algo::Dzz(Jz, coefs_z, n_coefs_z, i, j, k);
Ez(i, j, k) -= eta_h * nabla2Jz;
}
}
Expand Down
Loading