diff options
author | 2017-03-28 11:11:12 -0700 | |
---|---|---|
committer | 2017-03-28 11:11:12 -0700 | |
commit | 85d6218a3a8838521c495c12bf00942085bc3c8c (patch) | |
tree | 190f2acc98019f325a0f595b54103a0eade478d3 | |
parent | 6151dc4888aa6c9571aaf06a89e795bb1f20caf7 (diff) | |
download | WarpX-85d6218a3a8838521c495c12bf00942085bc3c8c.tar.gz WarpX-85d6218a3a8838521c495c12bf00942085bc3c8c.tar.zst WarpX-85d6218a3a8838521c495c12bf00942085bc3c8c.zip |
updating the python-ctypes branch for recent changes in master
-rw-r--r-- | Exec/Langmuir/python/inputs | 27 | ||||
-rw-r--r-- | Python/ParticleProb.cpp | 17 | ||||
-rw-r--r-- | Python/pywarpx/AMReX.py | 3 | ||||
-rw-r--r-- | Python/pywarpx/Particles.py | 15 | ||||
-rw-r--r-- | Source/PhysicalParticleContainer.cpp | 8 | ||||
-rw-r--r-- | Source/PlasmaInjector.cpp | 29 | ||||
-rw-r--r-- | tests/Langmuir/langmuir.py | 3 | ||||
-rw-r--r-- | tests/Langmuir/langmuir_test.py | 3 |
8 files changed, 58 insertions, 47 deletions
diff --git a/Exec/Langmuir/python/inputs b/Exec/Langmuir/python/inputs index bca90c657..49b9f8e80 100644 --- a/Exec/Langmuir/python/inputs +++ b/Exec/Langmuir/python/inputs @@ -35,13 +35,22 @@ algo.particle_pusher = 0 warpx.cfl = 1.0 particles.nspecies = 1 +particles.species_names = electrons -langmuirwave.particle_xmin = -20.e-6 -langmuirwave.particle_xmax = 0.e-6 -langmuirwave.particle_ymin = -20.e-6 -langmuirwave.particle_ymax = 20.e-6 -langmuirwave.particle_zmin = -20.e-6 -langmuirwave.particle_zmax = 20.e-6 -langmuirwave.num_particles_per_cell = 10 -langmuirwave.n_e = 1.e25 # number of electrons per m^3 -langmuirwave.ux = 0.01 # ux = gamma*beta_x +electrons.charge = -q_e +electrons.mass = m_e +electrons.injection_style = "NDiagPerCell" + +electrons.xmin = -20.e-6 +electrons.xmax = 0.e-6 +electrons.ymin = -20.e-6 +electrons.ymax = 20.e-6 +electrons.zmin = -20.e-6 +electrons.zmax = 20.e-6 + +electrons.num_particles_per_cell = 10 +electrons.profile = constant +electrons.density = 1.e25 # number of electrons per m^3 + +electrons.momentum_distribution_type = "constant" +electrons.ux = 0.01 # ux = gamma*beta_x diff --git a/Python/ParticleProb.cpp b/Python/ParticleProb.cpp deleted file mode 100644 index 71a2118c9..000000000 --- a/Python/ParticleProb.cpp +++ /dev/null @@ -1,17 +0,0 @@ - -// -// Each problem must have its own version of PhysicalParticleContainer::InitData() -// to initialize the particle data. It must also initialize charge and mass. -// - -#include <ParticleContainer.H> -#include <WarpXConst.H> - -using namespace amrex; - -void -PhysicalParticleContainer::InitData() -{ - charge = -PhysConst::q_e; - mass = PhysConst::m_e; -} diff --git a/Python/pywarpx/AMReX.py b/Python/pywarpx/AMReX.py index e84c240af..0cf9290b8 100644 --- a/Python/pywarpx/AMReX.py +++ b/Python/pywarpx/AMReX.py @@ -6,7 +6,7 @@ from .Geometry import geometry from .Algo import algo from .Langmuirwave import langmuirwave from .Interpolation import interpolation -from .Particles import particles +from .Particles import particles, electrons import ctypes from ._libwarpx import libwarpx @@ -23,6 +23,7 @@ class AMReX(object): argv += langmuirwave.attrlist() argv += interpolation.attrlist() argv += particles.attrlist() + argv += electrons.attrlist() amrex_init(argv) diff --git a/Python/pywarpx/Particles.py b/Python/pywarpx/Particles.py index a11da823d..a166b029e 100644 --- a/Python/pywarpx/Particles.py +++ b/Python/pywarpx/Particles.py @@ -1,3 +1,18 @@ from .Bucket import Bucket particles = Bucket('particles') + +electrons = Bucket('electrons') +electrons.charge = "-q_e" +electrons.mass = "m_e" +electrons.injection_style = "python" + +positrons = Bucket('positrons') +positrons.charge = "q_e" +positrons.mass = "m_e" +positrons.injection_style = "python" + +protons = Bucket('protons') +protons.charge = "q_e" +protons.mass = "m_p" +protons.injection_style = "python" diff --git a/Source/PhysicalParticleContainer.cpp b/Source/PhysicalParticleContainer.cpp index d499f7dfb..007fe06ed 100644 --- a/Source/PhysicalParticleContainer.cpp +++ b/Source/PhysicalParticleContainer.cpp @@ -13,6 +13,8 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp species_name(name) { plasma_injector.reset(new PlasmaInjector(species_id, species_name)); + charge = plasma_injector->getCharge(); + mass = plasma_injector->getMass(); } void PhysicalParticleContainer::InitData() { @@ -32,9 +34,6 @@ void PhysicalParticleContainer::AddNRandomUniformPerCell (int lev, Box part_box) { BL_PROFILE("PhysicalParticleContainer::AddNRandomPerCell()"); - charge = plasma_injector->getCharge(); - mass = plasma_injector->getMass(); - const Geometry& geom = Geom(lev); const Real* dx = geom.CellSize(); @@ -112,9 +111,6 @@ void PhysicalParticleContainer::AddNDiagPerCell (int lev, Box part_box) { BL_PROFILE("PhysicalParticleContainer::AddNDiagPerCell()"); - charge = plasma_injector->getCharge(); - mass = plasma_injector->getMass(); - const Geometry& geom = Geom(lev); const Real* dx = geom.CellSize(); diff --git a/Source/PlasmaInjector.cpp b/Source/PlasmaInjector.cpp index 027bb5b57..82837730c 100644 --- a/Source/PlasmaInjector.cpp +++ b/Source/PlasmaInjector.cpp @@ -127,6 +127,21 @@ PlasmaInjector::PlasmaInjector(int ispecies, const std::string& name) pp.query("ymax", ymax); pp.query("zmax", zmax); + // get injection style + pp.get("injection_style", injection_style); + std::transform(injection_style.begin(), + injection_style.end(), + injection_style.begin(), + ::tolower); + if (injection_style == "python") { + return; + } + else if (not (injection_style == "nrandomnormal" or + injection_style == "nrandomuniformpercell" or + injection_style == "ndiagpercell")) { + StringParseAbortMessage("Injection style", injection_style); + } + // parse density information std::string rho_prof_s; pp.get("profile", rho_prof_s); @@ -173,20 +188,6 @@ PlasmaInjector::PlasmaInjector(int ispecies, const std::string& name) } else { StringParseAbortMessage("Momentum distribution type", mom_dist_s); } - - // get injection style - pp.get("injection_style", injection_style); - std::transform(injection_style.begin(), - injection_style.end(), - injection_style.begin(), - ::tolower); - if (injection_style == "nrandomnormal" or - injection_style == "nrandomuniformpercell" or - injection_style == "ndiagpercell") { - return; - } else { - StringParseAbortMessage("Injection style", injection_style); - } } void PlasmaInjector::getMomentum(vec3& u) { diff --git a/tests/Langmuir/langmuir.py b/tests/Langmuir/langmuir.py index 47ff1015f..f5e826d79 100644 --- a/tests/Langmuir/langmuir.py +++ b/tests/Langmuir/langmuir.py @@ -115,6 +115,9 @@ geometry.prob_hi = "%7.0e %7.0e %7.0e"%(xmax, ymax, zmax) # Verbosity warpx.verbose = 1 +particles.nspecies = 1 +particles.species_names = "electrons" + # Algorithms algo.current_deposition = 3 algo.charge_deposition = 0 diff --git a/tests/Langmuir/langmuir_test.py b/tests/Langmuir/langmuir_test.py index 5d9a583c5..b8af68024 100644 --- a/tests/Langmuir/langmuir_test.py +++ b/tests/Langmuir/langmuir_test.py @@ -125,6 +125,9 @@ algo.particle_pusher = 0 # CFL warpx.cfl = 1.0 +particles.nspecies = 1 +particles.species_names = "electrons" + # --- Initialize the simulation amrex = AMReX() amrex.init() |