From 4073384c7b66b1848bcc94e6c986f7d532c7da11 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Wed, 7 Dec 2022 15:40:02 -0800 Subject: PSATD: Implement First-Order Equations (#3466) * Implement First-Order PSATD Equations * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix Unused Parameter Warning * Fix RZ Build * Fix Normalization of G to Match PML * Add CI Test: 3D Uniform Plasma * Cleaning * Update 2D CI Checksums * Update 3D CI Checksums * Add F,G to CI Checksums of `uniform_plasma_multiJ` * Allow User to Choose First-Order v. Second-Order * Add WARPX_ALWAYS_ASSERT_WITH_MESSAGE * Rename New Class `PsatdAlgorithmFirstOrder` * Remove Inline Comment * Update RZ CI Checksums * Fix inline comment * Use auxiliary variables to avoid divisions * Use auxiliary variables to avoid divisions * Make `nci_psatd_stability` dir and merge inputs * Move all Galilean tests to `nci_psatd_stability` * Fix CI * Fix index for backward FFT of J Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../PsatdAlgorithmJConstantInTime.cpp | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp') diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp index 9d1fbf3e1..c52437bf8 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp @@ -190,9 +190,9 @@ PsatdAlgorithmJConstantInTime::pushSpectralFields (SpectralFieldData& f) const const Complex Bz_old = fields(i,j,k,Idx.Bz); // Shortcuts for the values of J - const Complex Jx = fields(i,j,k,Idx.Jx); - const Complex Jy = fields(i,j,k,Idx.Jy); - const Complex Jz = fields(i,j,k,Idx.Jz); + const Complex Jx = fields(i,j,k,Idx.Jx_mid); + const Complex Jy = fields(i,j,k,Idx.Jy_mid); + const Complex Jz = fields(i,j,k,Idx.Jz_mid); Complex F_old; if (dive_cleaning) @@ -751,9 +751,9 @@ void PsatdAlgorithmJConstantInTime::CurrentCorrection (SpectralFieldData& field_ ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { // Shortcuts for the values of J and rho - const Complex Jx = fields(i,j,k,Idx.Jx); - const Complex Jy = fields(i,j,k,Idx.Jy); - const Complex Jz = fields(i,j,k,Idx.Jz); + const Complex Jx = fields(i,j,k,Idx.Jx_mid); + const Complex Jy = fields(i,j,k,Idx.Jy_mid); + const Complex Jz = fields(i,j,k,Idx.Jz_mid); const Complex rho_old = fields(i,j,k,Idx.rho_old); const Complex rho_new = fields(i,j,k,Idx.rho_new); @@ -787,25 +787,25 @@ void PsatdAlgorithmJConstantInTime::CurrentCorrection (SpectralFieldData& field_ const Complex rho_old_mod = rho_old * amrex::exp(I * k_dot_vg * dt); const Complex den = 1._rt - amrex::exp(I * k_dot_vg * dt); - fields(i,j,k,Idx.Jx) = Jx - (k_dot_J - k_dot_vg * (rho_new - rho_old_mod) / den) + fields(i,j,k,Idx.Jx_mid) = Jx - (k_dot_J - k_dot_vg * (rho_new - rho_old_mod) / den) * kx / (k_norm * k_norm); - fields(i,j,k,Idx.Jy) = Jy - (k_dot_J - k_dot_vg * (rho_new - rho_old_mod) / den) + fields(i,j,k,Idx.Jy_mid) = Jy - (k_dot_J - k_dot_vg * (rho_new - rho_old_mod) / den) * ky / (k_norm * k_norm); - fields(i,j,k,Idx.Jz) = Jz - (k_dot_J - k_dot_vg * (rho_new - rho_old_mod) / den) + fields(i,j,k,Idx.Jz_mid) = Jz - (k_dot_J - k_dot_vg * (rho_new - rho_old_mod) / den) * kz / (k_norm * k_norm); } else { - fields(i,j,k,Idx.Jx) = Jx - (k_dot_J - I * (rho_new - rho_old) / dt) + fields(i,j,k,Idx.Jx_mid) = Jx - (k_dot_J - I * (rho_new - rho_old) / dt) * kx / (k_norm * k_norm); - fields(i,j,k,Idx.Jy) = Jy - (k_dot_J - I * (rho_new - rho_old) / dt) + fields(i,j,k,Idx.Jy_mid) = Jy - (k_dot_J - I * (rho_new - rho_old) / dt) * ky / (k_norm * k_norm); - fields(i,j,k,Idx.Jz) = Jz - (k_dot_J - I * (rho_new - rho_old) / dt) + fields(i,j,k,Idx.Jz_mid) = Jz - (k_dot_J - I * (rho_new - rho_old) / dt) * kz / (k_norm * k_norm); } } @@ -840,11 +840,11 @@ PsatdAlgorithmJConstantInTime::VayDeposition (SpectralFieldData& field_data) ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { // Shortcuts for the values of D - const Complex Dx = fields(i,j,k,Idx.Jx); + const Complex Dx = fields(i,j,k,Idx.Jx_mid); #if defined(WARPX_DIM_3D) - const Complex Dy = fields(i,j,k,Idx.Jy); + const Complex Dy = fields(i,j,k,Idx.Jy_mid); #endif - const Complex Dz = fields(i,j,k,Idx.Jz); + const Complex Dz = fields(i,j,k,Idx.Jz_mid); // Imaginary unit constexpr Complex I = Complex{0._rt, 1._rt}; @@ -859,18 +859,18 @@ PsatdAlgorithmJConstantInTime::VayDeposition (SpectralFieldData& field_data) #endif // Compute Jx - if (kx_mod != 0._rt) fields(i,j,k,Idx.Jx) = I * Dx / kx_mod; - else fields(i,j,k,Idx.Jx) = 0._rt; + if (kx_mod != 0._rt) fields(i,j,k,Idx.Jx_mid) = I * Dx / kx_mod; + else fields(i,j,k,Idx.Jx_mid) = 0._rt; #if defined(WARPX_DIM_3D) // Compute Jy - if (ky_mod != 0._rt) fields(i,j,k,Idx.Jy) = I * Dy / ky_mod; - else fields(i,j,k,Idx.Jy) = 0._rt; + if (ky_mod != 0._rt) fields(i,j,k,Idx.Jy_mid) = I * Dy / ky_mod; + else fields(i,j,k,Idx.Jy_mid) = 0._rt; #endif // Compute Jz - if (kz_mod != 0._rt) fields(i,j,k,Idx.Jz) = I * Dz / kz_mod; - else fields(i,j,k,Idx.Jz) = 0._rt; + if (kz_mod != 0._rt) fields(i,j,k,Idx.Jz_mid) = I * Dz / kz_mod; + else fields(i,j,k,Idx.Jz_mid) = 0._rt; }); } } -- cgit v1.2.3