aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/MultiParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Remi Lehe <remi.lehe@normalesup.org> 2020-01-24 11:03:48 -0800
committerGravatar GitHub <noreply@github.com> 2020-01-24 11:03:48 -0800
commita32b3292967b6b0ee766ad14303c6cd0f2369b04 (patch)
treef271f8104c0cc38784bbbe6cb3f8747d12cc3d32 /Source/Particles/MultiParticleContainer.cpp
parent50b7e6c7189e98241684212dbae37f85cb43a02f (diff)
parentc5d8298284709dbea9f2c764bf429872933de11c (diff)
downloadWarpX-a32b3292967b6b0ee766ad14303c6cd0f2369b04.tar.gz
WarpX-a32b3292967b6b0ee766ad14303c6cd0f2369b04.tar.zst
WarpX-a32b3292967b6b0ee766ad14303c6cd0f2369b04.zip
Merge pull request #609 from RevathiJambunathan/ParticlesEBParser
Externally applied E/B fields on the particles using parser
Diffstat (limited to 'Source/Particles/MultiParticleContainer.cpp')
-rw-r--r--Source/Particles/MultiParticleContainer.cpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp
index d84bc1afa..ab836ce9d 100644
--- a/Source/Particles/MultiParticleContainer.cpp
+++ b/Source/Particles/MultiParticleContainer.cpp
@@ -72,6 +72,93 @@ MultiParticleContainer::ReadParameters ()
{
ParmParse pp("particles");
+ // allocating and initializing default values of external fields for particles
+ m_E_external_particle.resize(3);
+ m_B_external_particle.resize(3);
+ // initialize E and B fields to 0.0
+ for (int idim = 0; idim < 3; ++idim) {
+ m_E_external_particle[idim] = 0.0;
+ m_B_external_particle[idim] = 0.0;
+ }
+ // default values of E_external_particle and B_external_particle
+ // are used to set the E and B field when "constant" or "parser"
+ // is not explicitly used in the input
+ pp.query("B_ext_particle_init_style", m_B_ext_particle_s);
+ std::transform(m_B_ext_particle_s.begin(),
+ m_B_ext_particle_s.end(),
+ m_B_ext_particle_s.begin(),
+ ::tolower);
+ pp.query("E_ext_particle_init_style", m_E_ext_particle_s);
+ std::transform(m_E_ext_particle_s.begin(),
+ m_E_ext_particle_s.end(),
+ m_E_ext_particle_s.begin(),
+ ::tolower);
+ // if the input string for B_external on particles is "constant"
+ // then the values for the external B on particles must
+ // be provided in the input file.
+ if (m_B_ext_particle_s == "constant")
+ pp.getarr("B_external_particle", m_B_external_particle);
+
+ // if the input string for E_external on particles is "constant"
+ // then the values for the external E on particles must
+ // be provided in the input file.
+ if (m_E_ext_particle_s == "constant")
+ pp.getarr("E_external_particle", m_E_external_particle);
+
+ // if the input string for B_ext_particle_s is
+ // "parse_b_ext_particle_function" then the mathematical expression
+ // for the Bx_, By_, Bz_external_particle_function(x,y,z)
+ // must be provided in the input file.
+ if (m_B_ext_particle_s == "parse_b_ext_particle_function") {
+ // store the mathematical expression as string
+ std::string str_Bx_ext_particle_function;
+ std::string str_By_ext_particle_function;
+ std::string str_Bz_ext_particle_function;
+ Store_parserString(pp, "Bx_external_particle_function(x,y,z,t)",
+ str_Bx_ext_particle_function);
+ Store_parserString(pp, "By_external_particle_function(x,y,z,t)",
+ str_By_ext_particle_function);
+ Store_parserString(pp, "Bz_external_particle_function(x,y,z,t)",
+ str_Bz_ext_particle_function);
+
+ // Parser for B_external on the particle
+ m_Bx_particle_parser.reset(new ParserWrapper(
+ makeParser(str_Bx_ext_particle_function)));
+ m_By_particle_parser.reset(new ParserWrapper(
+ makeParser(str_By_ext_particle_function)));
+ m_Bz_particle_parser.reset(new ParserWrapper(
+ makeParser(str_Bz_ext_particle_function)));
+
+ }
+
+ // if the input string for E_ext_particle_s is
+ // "parse_e_ext_particle_function" then the mathematical expression
+ // for the Ex_, Ey_, Ez_external_particle_function(x,y,z)
+ // must be provided in the input file.
+ if (m_E_ext_particle_s == "parse_e_ext_particle_function") {
+ // store the mathematical expression as string
+ std::string str_Ex_ext_particle_function;
+ std::string str_Ey_ext_particle_function;
+ std::string str_Ez_ext_particle_function;
+ Store_parserString(pp, "Ex_external_particle_function(x,y,z,t)",
+ str_Ex_ext_particle_function);
+ Store_parserString(pp, "Ey_external_particle_function(x,y,z,t)",
+ str_Ey_ext_particle_function);
+ Store_parserString(pp, "Ez_external_particle_function(x,y,z,t)",
+ str_Ez_ext_particle_function);
+ // Parser for E_external on the particle
+ m_Ex_particle_parser.reset(new ParserWrapper(
+ makeParser(str_Ex_ext_particle_function)));
+ m_Ey_particle_parser.reset(new ParserWrapper(
+ makeParser(str_Ey_ext_particle_function)));
+ m_Ez_particle_parser.reset(new ParserWrapper(
+ makeParser(str_Ez_ext_particle_function)));
+
+ }
+
+
+
+
pp.query("nspecies", nspecies);
BL_ASSERT(nspecies >= 0);