Skip to content

Commit 894d45c

Browse files
committed
Added assymetrical PSATD equations.
1 parent c281160 commit 894d45c

File tree

3 files changed

+62
-13
lines changed

3 files changed

+62
-13
lines changed

Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.H

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,15 @@ class PsatdAlgorithm : public SpectralBaseAlgorithm
129129

130130
// Centered modified finite-order k vectors
131131
KVectorComponent modified_kx_vec_centered;
132+
KVectorComponent modified_kx_q_vec_centered;
133+
132134
#if defined(WARPX_DIM_3D)
133135
KVectorComponent modified_ky_vec_centered;
136+
KVectorComponent modified_ky_q_vec_centered;
137+
134138
#endif
135139
KVectorComponent modified_kz_vec_centered;
140+
KVectorComponent modified_kz_q_vec_centered;
136141

137142
// Other member variables
138143
amrex::Vector<amrex::Real> m_v_galilean;

Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithm.cpp

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,28 @@ PsatdAlgorithm::PsatdAlgorithm(
4242
const bool dive_cleaning,
4343
const bool divb_cleaning)
4444
// Initializer list
45-
: SpectralBaseAlgorithm(spectral_kspace, dm, spectral_index, norder_x, norder_y, norder_z, nodal, fill_guards),
45+
: SpectralBaseAlgorithm(spectral_kspace, dm, spectral_index, norder_x, norder_y, norder_z,
46+
nodal, fill_guards),
4647
m_spectral_index(spectral_index),
4748
// Initialize the centered finite-order modified k vectors:
4849
// these are computed always with the assumption of centered grids
4950
// (argument nodal = true), for both nodal and staggered simulations
51+
// const int norder_x_q = 4
52+
// const int norder_y_q = 4
53+
// const int norder_z_q = 4
54+
5055
modified_kx_vec_centered(spectral_kspace.getModifiedKComponent(dm, 0, norder_x, true)),
56+
modified_kx_q_vec_centered(spectral_kspace.getModifiedKComponent(dm, 0, PhysConst::nom, true)),
57+
5158
#if defined(WARPX_DIM_3D)
5259
modified_ky_vec_centered(spectral_kspace.getModifiedKComponent(dm, 1, norder_y, true)),
5360
modified_kz_vec_centered(spectral_kspace.getModifiedKComponent(dm, 2, norder_z, true)),
61+
modified_ky_q_vec_centered(spectral_kspace.getModifiedKComponent(dm, 1, PhysConst::nom, true)),
62+
modified_kz_q_vec_centered(spectral_kspace.getModifiedKComponent(dm, 2, PhysConst::nom, true)),
5463
#else
5564
modified_kz_vec_centered(spectral_kspace.getModifiedKComponent(dm, 1, norder_z, true)),
65+
modified_kz_q_vec_centered(spectral_kspace.getModifiedKComponent(dm, 1, PhysConst::nom, true)),
66+
5667
#endif
5768
m_v_galilean(v_galilean),
5869
m_dt(dt),
@@ -164,10 +175,15 @@ PsatdAlgorithm::pushSpectralFields (SpectralFieldData& f) const
164175

165176
// Extract pointers for the k vectors
166177
const amrex::Real* modified_kx_arr = modified_kx_vec[mfi].dataPtr();
178+
const amrex::Real* modified_kx_q_arr = modified_kx_q_vec_centered[mfi].dataPtr();
179+
167180
#if defined(WARPX_DIM_3D)
168181
const amrex::Real* modified_ky_arr = modified_ky_vec[mfi].dataPtr();
182+
const amrex::Real* modified_ky_q_arr = modified_ky_q_vec_centered[mfi].dataPtr();
183+
169184
#endif
170185
const amrex::Real* modified_kz_arr = modified_kz_vec[mfi].dataPtr();
186+
const amrex::Real* modified_kz_q_arr = modified_kz_q_vec_centered[mfi].dataPtr();
171187

172188
// Loop over indices within one box
173189
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
@@ -201,12 +217,33 @@ PsatdAlgorithm::pushSpectralFields (SpectralFieldData& f) const
201217

202218
// k vector values
203219
const amrex::Real kx = modified_kx_arr[i];
220+
const amrex::Real kx_q = modified_kx_q_arr[i];
221+
const amrex::Real kx_r = kx*kx/kx_q;
222+
223+
204224
#if defined(WARPX_DIM_3D)
205225
const amrex::Real ky = modified_ky_arr[j];
226+
const amrex::Real ky_q = modified_ky_q_arr[j];
227+
const amrex::Real ky_r = ky*ky/ky_q
228+
229+
206230
const amrex::Real kz = modified_kz_arr[k];
231+
const amrex::Real kz_q = modified_kz_q_arr[k];
232+
const amrex::Real kz_r = kz*kz/kz_q
233+
234+
235+
207236
#else
208237
constexpr amrex::Real ky = 0._rt;
238+
constexpr amrex::Real ky_q = 0._rt;
239+
constexpr amrex::Real ky_r = 0._rt;
240+
241+
209242
const amrex::Real kz = modified_kz_arr[j];
243+
const amrex::Real kz_q = modified_kz_q_arr[j];
244+
const amrex::Real kz_r = kz*kz/kz_q;
245+
246+
210247
#endif
211248
// Physical constants and imaginary unit
212249
constexpr Real c2 = PhysConst::c * PhysConst::c;
@@ -244,37 +281,43 @@ PsatdAlgorithm::pushSpectralFields (SpectralFieldData& f) const
244281
// T2 = 1 always with standard PSATD (zero Galilean velocity)
245282

246283
else {
284+
amrex::Print() << " kx | kx_q | kx_r = " << kx << '|' <<kx_q << '|' << kx_r <<'|' << "\n";
247285

286+
287+
Complex kq_dot_J = kx_q * Jx + ky_q * Jy + kz_q * Jz;
248288
Complex k_dot_J = kx * Jx + ky * Jy + kz * Jz;
289+
Complex kr_dot_J = kx_r * Jx + ky_r * Jy + kz_r * Jz;
290+
249291
Complex k_dot_E = kx * Ex_old + ky * Ey_old + kz * Ez_old;
292+
Complex kq_dot_E = kx_q * Ex_old + ky_q * Ey_old + kz_q * Ez_old;
250293

251294
fields(i,j,k,Idx.Ex) = T2 * C * Ex_old
252-
+ I * c2 * T2 * S_ck * (ky * Bz_old - kz * By_old)
253-
+ X4 * Jx + X2 * k_dot_E * kx + X3 * k_dot_J * kx;
295+
+ I * c2 * T2 * S_ck * (ky_q * Bz_old - kz_q * By_old)
296+
+ X4 * Jx + X2 * kq_dot_E * kx_r + X3 * kq_dot_J * kx_r;
254297

255298
fields(i,j,k,Idx.Ey) = T2 * C * Ey_old
256-
+ I * c2 * T2 * S_ck * (kz * Bx_old - kx * Bz_old)
257-
+ X4 * Jy + X2 * k_dot_E * ky + X3 * k_dot_J * ky;
299+
+ I * c2 * T2 * S_ck * (kz_q * Bx_old - kx_q * Bz_old)
300+
+ X4 * Jy + X2 * kq_dot_E * ky_r + X3 * kq_dot_J * ky_r;
258301

259302
fields(i,j,k,Idx.Ez) = T2 * C * Ez_old
260-
+ I * c2 * T2 * S_ck * (kx * By_old - ky * Bx_old)
261-
+ X4 * Jz + X2 * k_dot_E * kz + X3 * k_dot_J * kz;
303+
+ I * c2 * T2 * S_ck * (kx_q * By_old - ky_q * Bx_old)
304+
+ X4 * Jz + X2 * kq_dot_E * kz_r + X3 * kq_dot_J * kz_r;
262305
}
263306

264307
// Update equations for B
265308
// T2 = 1 always with standard PSATD (zero Galilean velocity)
266309

267310
fields(i,j,k,Idx.Bx) = T2 * C * Bx_old
268-
- I * T2 * S_ck * (ky * Ez_old - kz * Ey_old)
269-
+ I * X1 * (ky * Jz - kz * Jy);
311+
- I * T2 * S_ck * (ky_r * Ez_old - kz_r * Ey_old)
312+
+ I * X1 * (ky_r * Jz - kz_r * Jy);
270313

271314
fields(i,j,k,Idx.By) = T2 * C * By_old
272-
- I * T2 * S_ck * (kz * Ex_old - kx * Ez_old)
273-
+ I * X1 * (kz * Jx - kx * Jz);
315+
- I * T2 * S_ck * (kz_r * Ex_old - kx_r * Ez_old)
316+
+ I * X1 * (kz_r * Jx - kx_r * Jz);
274317

275318
fields(i,j,k,Idx.Bz) = T2 * C * Bz_old
276-
- I * T2 * S_ck * (kx * Ey_old - ky * Ex_old)
277-
+ I * X1 * (kx * Jy - ky * Jx);
319+
- I * T2 * S_ck * (kx_r * Ey_old - ky_r * Ex_old)
320+
+ I * X1 * (kx_r * Jy - ky_r * Jx);
278321

279322
if (dive_cleaning)
280323
{

Source/Utils/WarpXConst.H

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace MathConst
3030
// as the corresponding Python definitions
3131
namespace PhysConst
3232
{
33+
constexpr int nom = 8;
3334
static constexpr auto c = static_cast<amrex::Real>( 299'792'458. );
3435
static constexpr auto ep0 = static_cast<amrex::Real>( 8.8541878128e-12 );
3536
static constexpr auto mu0 = static_cast<amrex::Real>( 1.25663706212e-06 );

0 commit comments

Comments
 (0)