aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/PhysicalParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar MaxThevenet <maxence.thevenet@desy.de> 2021-07-13 03:24:51 +0200
committerGravatar GitHub <noreply@github.com> 2021-07-12 18:24:51 -0700
commit02e3b8cce573fb54253b10fc9104695d9c24b188 (patch)
treef0a0d1707cfdecc9ca655bb6d3bc8166fb2e1fc8 /Source/Particles/PhysicalParticleContainer.cpp
parent2107beb1926c66fee40d7bceca98eafafcf9e680 (diff)
downloadWarpX-02e3b8cce573fb54253b10fc9104695d9c24b188.tar.gz
WarpX-02e3b8cce573fb54253b10fc9104695d9c24b188.tar.zst
WarpX-02e3b8cce573fb54253b10fc9104695d9c24b188.zip
Random azimuthal position for particles (#2029)
* option to randomize azimuthal coordinate of plasma particles * typo * do not capture this * add documentation * default for random azimuth is true * Update Source/Particles/WarpXParticleContainer.H * changes from code review * minor doc, and avoid calling the RNG in Cartesian geometry * minor doc * reset non-psatd benchmarks * deactivate random azimuth for RZ PSATD CI * Reset benchmark * Reset Benchmark of Python_Langmuir_rz_multimode Co-authored-by: Remi Lehe <remi.lehe@normalesup.org> Co-authored-by: Edoardo Zoni <ezoni@lbl.gov>
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r--Source/Particles/PhysicalParticleContainer.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp
index 3f1c37dc6..de97d79ea 100644
--- a/Source/Particles/PhysicalParticleContainer.cpp
+++ b/Source/Particles/PhysicalParticleContainer.cpp
@@ -173,6 +173,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp
pp_species_name.query("boost_adjust_transverse_positions", boost_adjust_transverse_positions);
pp_species_name.query("do_backward_propagation", do_backward_propagation);
+ pp_species_name.query("random_theta", m_rz_random_theta);
// Initialize splitting
pp_species_name.query("do_splitting", do_splitting);
@@ -844,11 +845,16 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
// The invalid ones are given negative ID and are deleted during the
// next redistribute.
const auto poffset = offset.data();
+ const bool rz_random_theta = m_rz_random_theta;
amrex::ParallelForRNG(overlap_box,
[=] AMREX_GPU_DEVICE (int i, int j, int k, amrex::RandomEngine const& engine) noexcept
{
IntVect iv = IntVect(AMREX_D_DECL(i, j, k));
const auto index = overlap_box.index(iv);
+#ifdef WARPX_DIM_RZ
+ Real theta_offset = 0._rt;
+ if (rz_random_theta) theta_offset = amrex::Random(engine) * 2._rt * MathConst::pi;
+#endif
for (int i_part = 0; i_part < pcounts[index]; ++i_part)
{
long ip = poffset[index] + i_part;
@@ -887,7 +893,7 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
// choose it randomly.
theta = 2._rt*MathConst::pi*amrex::Random(engine);
} else {
- theta = 2._rt*MathConst::pi*r.y;
+ theta = 2._rt*MathConst::pi*r.y + theta_offset;
}
pos.x = xb*std::cos(theta);
pos.y = xb*std::sin(theta);