aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/source/usage/parameters.rst2
-rw-r--r--Regression/Checksum/benchmarks_json/FluxInjection.json2
-rw-r--r--Source/Evolve/WarpXEvolve.cpp2
-rw-r--r--Source/Initialization/PlasmaInjector.H2
-rw-r--r--Source/Initialization/PlasmaInjector.cpp2
-rw-r--r--Source/Particles/MultiParticleContainer.H2
-rw-r--r--Source/Particles/MultiParticleContainer.cpp4
-rw-r--r--Source/Particles/PhysicalParticleContainer.H2
-rw-r--r--Source/Particles/PhysicalParticleContainer.cpp12
-rw-r--r--Source/Particles/WarpXParticleContainer.H2
10 files changed, 22 insertions, 10 deletions
diff --git a/Docs/source/usage/parameters.rst b/Docs/source/usage/parameters.rst
index 92bb030ca..9365bd35f 100644
--- a/Docs/source/usage/parameters.rst
+++ b/Docs/source/usage/parameters.rst
@@ -613,6 +613,8 @@ Particle initialization
``<species_name>.flux_normal_axis`` (`x`, `y`, or `z` for 3D, `x` or `z` for 2D, or `r` or `z` for RZ)
``<species_name>.flux_direction`` (`-1` or `+1`, direction of flux relative to the plane)
``<species_name>.num_particles_per_cell`` (`double`)
+ ``<species_name>.flux_tmin`` (`double`, Optional time at which the flux will be turned on. Ignored when negative.)
+ ``<species_name>.flux_tmax`` (`double`, Optional time at which the flux will be turned off. Ignored when negative.)
* ``none``: Do not inject macro-particles (for example, in a simulation that starts with neutral, ionizable atoms, one may want to create the electrons species -- where ionized electrons can be stored later on -- without injecting electron macro-particles).
diff --git a/Regression/Checksum/benchmarks_json/FluxInjection.json b/Regression/Checksum/benchmarks_json/FluxInjection.json
index 56718d772..b3645168f 100644
--- a/Regression/Checksum/benchmarks_json/FluxInjection.json
+++ b/Regression/Checksum/benchmarks_json/FluxInjection.json
@@ -13,4 +13,4 @@
"lev=0": {
"Bz": 2.20886367779576e-47
}
-} \ No newline at end of file
+}
diff --git a/Source/Evolve/WarpXEvolve.cpp b/Source/Evolve/WarpXEvolve.cpp
index 87aef375b..383fc05fc 100644
--- a/Source/Evolve/WarpXEvolve.cpp
+++ b/Source/Evolve/WarpXEvolve.cpp
@@ -259,7 +259,7 @@ WarpX::Evolve (int numsteps)
// We might need to move j because we are going to make a plotfile.
int num_moved = MoveWindow(step+1, move_j);
- mypc->ContinuousFluxInjection(dt[0]);
+ mypc->ContinuousFluxInjection(cur_time, dt[0]);
mypc->ApplyBoundaryConditions();
diff --git a/Source/Initialization/PlasmaInjector.H b/Source/Initialization/PlasmaInjector.H
index 0b53b49ee..d97f73250 100644
--- a/Source/Initialization/PlasmaInjector.H
+++ b/Source/Initialization/PlasmaInjector.H
@@ -107,6 +107,8 @@ public:
bool surface_flux = false; // inject from a surface
amrex::Real surface_flux_pos; // surface location
+ amrex::Real flux_tmin = -1.; // Time after which we start injecting particles
+ amrex::Real flux_tmax = -1.; // Time after which we stop injecting particles
// Flux normal axis represents the direction in which to emit particles
// When compiled in Cartesian geometry, 0 = x, 1 = y, 2 = z
// When compiled in cylindrical geometry, 0 = radial, 1 = azimuthal, 2 = z
diff --git a/Source/Initialization/PlasmaInjector.cpp b/Source/Initialization/PlasmaInjector.cpp
index 6026f28a6..233b4efc6 100644
--- a/Source/Initialization/PlasmaInjector.cpp
+++ b/Source/Initialization/PlasmaInjector.cpp
@@ -260,6 +260,8 @@ PlasmaInjector::PlasmaInjector (int ispecies, const std::string& name)
}
#endif
getWithParser(pp_species_name, "surface_flux_pos", surface_flux_pos);
+ queryWithParser(pp_species_name, "flux_tmin", flux_tmin);
+ queryWithParser(pp_species_name, "flux_tmax", flux_tmax);
std::string flux_normal_axis_string;
pp_species_name.get("flux_normal_axis", flux_normal_axis_string);
flux_normal_axis = -1;
diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H
index 00fb5e8f5..2a8aec140 100644
--- a/Source/Particles/MultiParticleContainer.H
+++ b/Source/Particles/MultiParticleContainer.H
@@ -285,7 +285,7 @@ public:
int doContinuousInjection() const;
// Inject particles from a surface during the simulation
- void ContinuousFluxInjection(amrex::Real dt) const;
+ void ContinuousFluxInjection(amrex::Real t, amrex::Real dt) const;
std::vector<std::string> GetSpeciesNames() const { return species_names; }
diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp
index 4a5b2ebd8..973cfb8bf 100644
--- a/Source/Particles/MultiParticleContainer.cpp
+++ b/Source/Particles/MultiParticleContainer.cpp
@@ -765,10 +765,10 @@ MultiParticleContainer::doContinuousInjection () const
* calls virtual function ContinuousFluxInjection.
*/
void
-MultiParticleContainer::ContinuousFluxInjection (amrex::Real dt) const
+MultiParticleContainer::ContinuousFluxInjection (amrex::Real t, amrex::Real dt) const
{
for (auto& pc : allcontainers){
- pc->ContinuousFluxInjection(dt);
+ pc->ContinuousFluxInjection(t, dt);
}
}
diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H
index a6a5729e7..3f3d2d83b 100644
--- a/Source/Particles/PhysicalParticleContainer.H
+++ b/Source/Particles/PhysicalParticleContainer.H
@@ -363,7 +363,7 @@ protected:
void ContinuousInjection (const amrex::RealBox& injection_box) override;
// Continuously inject a flux of particles from a defined surface
- void ContinuousFluxInjection (const amrex::Real dt) override;
+ void ContinuousFluxInjection (const amrex::Real t, const amrex::Real dt) override;
//This function return true if the PhysicalParticleContainer contains electrons
//or positrons, false otherwise
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp
index 27d94a5f1..1ee12b769 100644
--- a/Source/Particles/PhysicalParticleContainer.cpp
+++ b/Source/Particles/PhysicalParticleContainer.cpp
@@ -2518,10 +2518,16 @@ PhysicalParticleContainer::ContinuousInjection (const RealBox& injection_box)
/* \brief Inject a flux of particles during the simulation
*/
void
-PhysicalParticleContainer::ContinuousFluxInjection (amrex::Real dt)
+PhysicalParticleContainer::ContinuousFluxInjection (amrex::Real t, amrex::Real dt)
{
- if (plasma_injector->surface_flux) {
- AddPlasmaFlux(dt);
+ if (plasma_injector->surface_flux){
+ // Check the optional parameters for start and stop of injection
+ if ( ((plasma_injector->flux_tmin<0) || (t>=plasma_injector->flux_tmin)) &&
+ ((plasma_injector->flux_tmax<0) || (t< plasma_injector->flux_tmax)) ){
+
+ AddPlasmaFlux(dt);
+
+ }
}
}
diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H
index 8f098b49b..0f5b147ef 100644
--- a/Source/Particles/WarpXParticleContainer.H
+++ b/Source/Particles/WarpXParticleContainer.H
@@ -245,7 +245,7 @@ public:
virtual void UpdateContinuousInjectionPosition(amrex::Real /*dt*/) {}
// Inject a continuous flux of particles from a defined plane
- virtual void ContinuousFluxInjection(amrex::Real /*dt*/) {}
+ virtual void ContinuousFluxInjection(amrex::Real /*t*/, amrex::Real /*dt*/) {}
///
/// This returns the total charge for all the particles in this ParticleContainer.