aboutsummaryrefslogtreecommitdiff
path: root/Source/Evolve/WarpXEvolve.cpp
diff options
context:
space:
mode:
authorGravatar Edoardo Zoni <59625522+EZoni@users.noreply.github.com> 2020-07-20 08:33:30 -0700
committerGravatar GitHub <noreply@github.com> 2020-07-20 08:33:30 -0700
commit4dcee1f248e18c5a16da5beec287c119258d416e (patch)
treeea88325a6f6954548730a95a38e9794896659529 /Source/Evolve/WarpXEvolve.cpp
parent9e98fed183c135292c549deaaa2e40fed691ec34 (diff)
downloadWarpX-4dcee1f248e18c5a16da5beec287c119258d416e.tar.gz
WarpX-4dcee1f248e18c5a16da5beec287c119258d416e.tar.zst
WarpX-4dcee1f248e18c5a16da5beec287c119258d416e.zip
Vay current deposition (#1051)
* Added stub for current correction in RZ spectral solver * Start implementation of Vay deposition * Continue implementation of Vay deposition * Correct deposition of D * Add phase shift for staggered currents * Small clean-up * Fix units in deposition of D * Implement average of cumulative sum (needs bug fix) * Start fixing bug in average of cumulative sum * Still debugging * Cumulative sums should be correct now * Subtract averages of cumulative sums: - current implementation: cumulative sums, inverse Fourier transform, subtraction of averages - needs to be tested (including units of D after Vay deposition) - needs to be shortened (too many loops over boxes and ParallelFors) * [skip CI] Clean up and fix units * Still fixing units * [skip CI] Remove temporarily averages of cumulative sums * [skip CI] Remove distinction between staggered and nodal * Vay and Esirkepov similar results on periodic single box: TODO: - debug (charge not conserved); - try using compute_shifted_shape_factor as in Esirkepov deposition; - clean up; - try on multiple boxes and with correction of mode at 0 frequency. * [skip CI] Clean up * Fix bug in 3D deposition * [skip CI] Clean up * Fix 2D and 3D implementation: - simulation results agree between direct and Vay deposition in both 2D and 3D - Travis CI tests should pass except for check of charge conservation (debug) * Small clean-up * Fix bug when compiling in RZ geometry * Add benchmark json files (will be reset later) * Do not set zero current at zero frequency * [skip CI] Revert last commit and clean up * Fix small bug after reverting commit * Set nodal test first on Travis * Fix benchmark for nodal test in 3D * Fix particle output for nodal test in 3D * Fix bugs due to staggering * Rename current nodal Travis tests * Add Travis tests staggered in 2D and 3D * Further clean-up after bug fix * Abort when using Vay deposition with domain decomposition * Add optional argument of index type to forward FFT * Fourier shifts can be private members as before * Small clean-up * Clean up and improve Doxygen documentation * Fix small bug in analysis script for 2D tests * Fix tests (remove E and B fields from particle diags) * Add option to fill guard cells and docs * Fix value of last guard cell by enforcing periodicity * Revert changes merged from #1121 * Clean up style * Improve docs * Fix forgotten alignment * Improve docs * Make base class functions VayDeposition pure Co-authored-by: Dave Grote <dpgrote@lbl.gov>
Diffstat (limited to 'Source/Evolve/WarpXEvolve.cpp')
-rw-r--r--Source/Evolve/WarpXEvolve.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/Source/Evolve/WarpXEvolve.cpp b/Source/Evolve/WarpXEvolve.cpp
index 674680773..fda7100d4 100644
--- a/Source/Evolve/WarpXEvolve.cpp
+++ b/Source/Evolve/WarpXEvolve.cpp
@@ -296,6 +296,9 @@ WarpX::OneStep_nosub (Real cur_time)
if ( !fft_periodic_single_box && current_correction )
amrex::Abort("\nCurrent correction does not guarantee charge conservation with local FFTs over guard cells:\n"
"set psatd.periodic_single_box_fft=1 too, in order to guarantee charge conservation");
+ if ( !fft_periodic_single_box && (WarpX::current_deposition_algo == CurrentDepositionAlgo::Vay) )
+ amrex::Abort("\nVay current deposition does not guarantee charge conservation with local FFTs over guard cells:\n"
+ "set psatd.periodic_single_box_fft=1 too, in order to guarantee charge conservation");
#endif
#ifdef WARPX_QED
@@ -310,6 +313,8 @@ WarpX::OneStep_nosub (Real cur_time)
// without guard cells, apply this after calling SyncCurrent
#ifdef WARPX_USE_PSATD
if ( fft_periodic_single_box && current_correction ) CurrentCorrection();
+ if ( fft_periodic_single_box && (WarpX::current_deposition_algo == CurrentDepositionAlgo::Vay) )
+ VayDeposition();
#endif
@@ -792,19 +797,28 @@ WarpX::applyMirrors(Real time){
}
}
+// Apply current correction in Fourier space
#ifdef WARPX_USE_PSATD
void
WarpX::CurrentCorrection ()
{
for ( int lev = 0; lev <= finest_level; ++lev )
{
- // Apply correction on fine patch
spectral_solver_fp[lev]->CurrentCorrection( current_fp[lev], rho_fp[lev] );
- if ( spectral_solver_cp[lev] )
- {
- // Apply correction on coarse patch
- spectral_solver_cp[lev]->CurrentCorrection( current_cp[lev], rho_cp[lev] );
- }
+ if ( spectral_solver_cp[lev] ) spectral_solver_cp[lev]->CurrentCorrection( current_cp[lev], rho_cp[lev] );
+ }
+}
+#endif
+
+// Compute current from Vay deposition in Fourier space
+#ifdef WARPX_USE_PSATD
+void
+WarpX::VayDeposition ()
+{
+ for (int lev = 0; lev <= finest_level; ++lev)
+ {
+ spectral_solver_fp[lev]->VayDeposition(current_fp[lev]);
+ if (spectral_solver_cp[lev]) spectral_solver_cp[lev]->VayDeposition(current_cp[lev]);
}
}
#endif