aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/PhysicalParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Ilian Kara-Mostefa <95044023+IlianCS@users.noreply.github.com> 2023-07-06 12:45:47 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-06 12:45:47 -0700
commitf28fe2fe7e979fc2bf72739b61e0f96b7b2686ee (patch)
tree1dbd9f57a325971c847ccf40b2f08a94344b7d7a /Source/Particles/PhysicalParticleContainer.cpp
parentf2597ba9832632d94a56d3c79a6e861b62ebe71f (diff)
downloadWarpX-f28fe2fe7e979fc2bf72739b61e0f96b7b2686ee.tar.gz
WarpX-f28fe2fe7e979fc2bf72739b61e0f96b7b2686ee.tar.zst
WarpX-f28fe2fe7e979fc2bf72739b61e0f96b7b2686ee.zip
Impose t_lab in Lorentz Transformation for externally loaded particles (#3996)
* Impose t_lab from the openPMD file, set t_lab=0 by default for handwritten species * Clear commented out print statement * Move x and y coordinates accordingly
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r--Source/Particles/PhysicalParticleContainer.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp
index 8dff41c05..56553575c 100644
--- a/Source/Particles/PhysicalParticleContainer.cpp
+++ b/Source/Particles/PhysicalParticleContainer.cpp
@@ -393,7 +393,7 @@ void PhysicalParticleContainer::InitData ()
}
void PhysicalParticleContainer::MapParticletoBoostedFrame (
- ParticleReal& x, ParticleReal& y, ParticleReal& z, ParticleReal& ux, ParticleReal& uy, ParticleReal& uz)
+ ParticleReal& x, ParticleReal& y, ParticleReal& z, ParticleReal& ux, ParticleReal& uy, ParticleReal& uz, ParticleReal t_lab)
{
// Map the particles from the lab frame to the boosted frame.
// This boosts the particle to the lab frame and calculates
@@ -402,8 +402,6 @@ void PhysicalParticleContainer::MapParticletoBoostedFrame (
// For now, start with the assumption that this will only happen
// at the start of the simulation.
- const ParticleReal t_lab = 0._prt;
-
const ParticleReal uz_boost = WarpX::gamma_boost*WarpX::beta_boost*PhysConst::c;
// tpr is the particle's time in the boosted frame
@@ -429,13 +427,14 @@ void PhysicalParticleContainer::MapParticletoBoostedFrame (
uz = -uz;
}
- // Move the particles to where they will be at t = 0 in the boosted frame
+ //Move the particles to where they will be at t = t0, the current simulation time in the boosted frame
+ constexpr int lev = 0;
+ const amrex::Real t0 = WarpX::GetInstance().gett_new(lev);
if (boost_adjust_transverse_positions) {
- x = xpr - tpr*vxpr;
- y = ypr - tpr*vypr;
+ x = xpr - (tpr-t0)*vxpr;
+ y = ypr - (tpr-t0)*vypr;
}
-
- z = zpr - tpr*vzpr;
+ z = zpr - (tpr-t0)*vzpr;
}
@@ -582,6 +581,7 @@ PhysicalParticleContainer::AddPlasmaFromFile(ParticleReal q_tot,
// assumption asserts: see PlasmaInjector
openPMD::Iteration it = series->iterations.begin()->second;
+ double const t_lab = it.time<double>() * it.timeUnitSI();
std::string const ps_name = it.particles.begin()->first;
openPMD::ParticleSpecies ps = it.particles.begin()->second;
@@ -649,7 +649,7 @@ PhysicalParticleContainer::AddPlasmaFromFile(ParticleReal q_tot,
CheckAndAddParticle(x, y, z, ux, uy, uz, weight,
particle_x, particle_y, particle_z,
particle_ux, particle_uy, particle_uz,
- particle_w);
+ particle_w, t_lab);
}
}
auto const np = particle_z.size();
@@ -795,10 +795,11 @@ PhysicalParticleContainer::CheckAndAddParticle (
Gpu::HostVector<ParticleReal>& particle_ux,
Gpu::HostVector<ParticleReal>& particle_uy,
Gpu::HostVector<ParticleReal>& particle_uz,
- Gpu::HostVector<ParticleReal>& particle_w)
+ Gpu::HostVector<ParticleReal>& particle_w,
+ ParticleReal t_lab)
{
if (WarpX::gamma_boost > 1.) {
- MapParticletoBoostedFrame(x, y, z, ux, uy, uz);
+ MapParticletoBoostedFrame(x, y, z, ux, uy, uz, t_lab);
}
particle_x.push_back(x);
particle_y.push_back(y);