diff options
author | 2022-06-01 19:56:18 -0700 | |
---|---|---|
committer | 2022-06-01 19:56:18 -0700 | |
commit | 81619e11b45c6621553e96601682c531c3cc49a3 (patch) | |
tree | 94b06eb1e8789113846a27432ae576581594c7b5 /Source | |
parent | 255fdb107f48d5a4cfbbc0c15c447ecb52b6f140 (diff) | |
download | WarpX-81619e11b45c6621553e96601682c531c3cc49a3.tar.gz WarpX-81619e11b45c6621553e96601682c531c3cc49a3.tar.zst WarpX-81619e11b45c6621553e96601682c531c3cc49a3.zip |
Change Default for `psatd.current_correction` (#3092)
* Change Default for `psatd.current_correction`
* Fix CI Tests
* Add Warning
* Update Documentation
* Current Correction Not Implemented for Multi-J
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Evolve/WarpXEvolve.cpp | 6 | ||||
-rw-r--r-- | Source/WarpX.H | 6 | ||||
-rw-r--r-- | Source/WarpX.cpp | 39 |
3 files changed, 37 insertions, 14 deletions
diff --git a/Source/Evolve/WarpXEvolve.cpp b/Source/Evolve/WarpXEvolve.cpp index c02c67cd2..4c7eec664 100644 --- a/Source/Evolve/WarpXEvolve.cpp +++ b/Source/Evolve/WarpXEvolve.cpp @@ -582,6 +582,12 @@ WarpX::OneStep_multiJ (const amrex::Real cur_time) PSATDForwardTransformRho(rho_fp, rho_cp, 0, 1); } + if (WarpX::current_correction) + { + amrex::Abort(Utils::TextMsg::Err( + "Current correction not implemented for multi-J algorithm.")); + } + // Advance E,B,F,G fields in time and update the average fields PSATDPushSpectralFields(); diff --git a/Source/WarpX.H b/Source/WarpX.H index 1233594c4..7f4787db1 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -243,9 +243,9 @@ public: //! and #current_centering_noz static bool do_current_centering; - //! If true, a correction is applied to the current in Fourier space, so that the continuity - //! equation is satisfied - bool current_correction = false; + //! If true, a correction is applied to the current in Fourier space, + // to satisfy the continuity equation and charge conservation + bool current_correction; //! If true, the PSATD update equation for E contains both J and rho //! (default is false for standard PSATD and true for Galilean PSATD) diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 3e7309fd5..a7d586711 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -1205,23 +1205,45 @@ WarpX::ReadParameters () queryWithParser(pp_psatd, "noz", noz_fft); } - if (!fft_periodic_single_box) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE(nox_fft > 0, "PSATD order must be finite unless psatd.periodic_single_box_fft is used"); WARPX_ALWAYS_ASSERT_WITH_MESSAGE(noy_fft > 0, "PSATD order must be finite unless psatd.periodic_single_box_fft is used"); WARPX_ALWAYS_ASSERT_WITH_MESSAGE(noz_fft > 0, "PSATD order must be finite unless psatd.periodic_single_box_fft is used"); } + // Current correction activated by default, unless a charge-conserving + // current deposition (Esirkepov, Vay) or the div(E) cleaning scheme + // are used + current_correction = true; + if (WarpX::current_deposition_algo == CurrentDepositionAlgo::Esirkepov || + WarpX::current_deposition_algo == CurrentDepositionAlgo::Vay || + WarpX::do_dive_cleaning) + { + current_correction = false; + } + + // TODO Remove this default when current correction will + // be implemented for the multi-J algorithm as well. + if (do_multi_J) current_correction = false; + pp_psatd.query("current_correction", current_correction); - pp_psatd.query("do_time_averaging", fft_do_time_averaging); - if (WarpX::current_correction == true) + if (current_correction == false && + current_deposition_algo != CurrentDepositionAlgo::Esirkepov && + current_deposition_algo != CurrentDepositionAlgo::Vay) { - WARPX_ALWAYS_ASSERT_WITH_MESSAGE( - fft_periodic_single_box == true, - "Option psatd.current_correction=1 must be used with psatd.periodic_single_box_fft=1."); + RecordWarning( + "Algorithms", + "The chosen current deposition algorithm does not guarantee" + " charge conservation, and no additional current correction" + " algorithm is activated in order to compensate for that." + " Lack of charge conservation may negatively affect the" + " results of the simulation.", + WarnPriority::low); } + pp_psatd.query("do_time_averaging", fft_do_time_averaging); + if (WarpX::current_deposition_algo == CurrentDepositionAlgo::Vay) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE( @@ -1305,11 +1327,6 @@ WarpX::ReadParameters () "Vay current deposition not implemented for Galilean algorithms" ); - WARPX_ALWAYS_ASSERT_WITH_MESSAGE( - (!current_correction) || v_galilean_is_zero || (!fft_do_time_averaging), - "Current correction not implemented for averaged Galilean algorithm" - ); - # ifdef WARPX_DIM_RZ update_with_rho = true; // Must be true for RZ PSATD # else |