Skip to content

Commit

Permalink
Merge upstream with added cleanup (#52)
Browse files Browse the repository at this point in the history
* CI: Add Missing Python Analysis for EB Test (ECP-WarpX#2147)

* CI: Add Missing Python Analysis for EB Test

* Use 1 MPI Process for Azure

* a few _rt (ECP-WarpX#2146)

* PSATD: div Cleaning Implemented only with psatd.J_linear_in_time=1 (ECP-WarpX#2142)

* BTD: Don't Flush If Written (ECP-WarpX#2148)

Written BTD buffers for lab snapshot data are reset to zero size
(count). When we do the final write of all partly filled buffers
in `FilterComputePackFlushLastTimestep`, we should not write such
already completed backtransformed lab snapshots again.

* openPMD: `groupBased` Option Missing (ECP-WarpX#2149)

The `groupBased` iteration encoding (input: `g`) was not parsed.

* Remove predefined constants from example input files (ECP-WarpX#2153)

* BTD_ReducedSliceDiag: BTD Plotfiles (ECP-WarpX#2152)

By accident, the 2nd test did not use plotfile output.

* Allow extra particle attributes (besides ux, uy, uz and w) to be set at particle creation in AddNParticles() (ECP-WarpX#2115)

* exposes AddRealComp to Python to allow extra particle attributes to be added at runtime; also includes a new function to grab a particle data array from the name of the component rather than the index

* added functionality to AddNParticles() to allow extra particle attributes to also be set during particle creation

* added function to get index of a particle component given the PID name

* changed new get component index and get_particle_arrays_from_comp_name functions to take species name as argument rather than species id

* changed warpx_addRealComp to accept a species name as input and only add the new component for that species

* added a test of the pywarpx bridge to get particle data and add new particle attributes at runtime

* changed all particle interacting functions in libwarpx to use the species name rather than id, also changed the functions to get particle array data to use the component name rather than index

* updated test according to PR ECP-WarpX#2119 changes

* removed unneeded BL_ASSERT(nattr == 1) statement

* fixed bug in add_particles to correctly determine the number of extra attributes

* fixed bug in AddNParticles if fewer attribute values are passed than the number of extra arrays for the species

* use isinstance(attr, ndarray) rather than type(attr) is np.ndarray

* generalize_runtime_comps_io

* fix OpenPMD

* fix OpenPMD

* fix plot flags in WritePlotFile

* fix offset and comment

* changed extra pid test to not use an underscore in the pid name

* switched _libwarpx.py::add_particles to use kwargs to accept the weight and extra attribute arrays

* License update in test file

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* fix typo

* added a test with unique_particles=False

* Apply suggestions from code review

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* updated docstring and comments

Co-authored-by: atmyers <atmyers2@gmail.com>
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Add predefined density profile to parameters documentation (ECP-WarpX#2155)

* Release 21.08 (ECP-WarpX#2158)

* AMReX/PICSAR: 21.08
* WarpX: 21.08

* initialize guard cells for macroscopic properties (ECP-WarpX#2159)

* openPMD: Style Cleaning (Dec/Def) (ECP-WarpX#2160)

In our code base, definitions and declarations of functions need a
space after their name. This makes them easy to search for.

Ref.:
  https://warpx.readthedocs.io/en/21.08/developers/contributing.html#style-and-conventions

* openPMD: Use Steps if != BTD (ECP-WarpX#2157)

* openPMD: Use Steps if != BTD

For all but back-transformed diagnostics, we can use efficient,
temporally sequentially increasing writes to iteration numbers
for iterations.

This allows us to give a guarantee to HPC I/O libraries on how
to arrange data, e.g., we can use ADIOS2 BeginStep() and
EndStep().

This enables paths to:
- streaming workflows, such as ADIOS2 SST or SSC, where we stage data
  over the network instead of using files
  https://openpmd-api.readthedocs.io/en/0.14.0/usage/streaming.html

This mitigates:
- host-side memory aggregation for ADIOS2 with openPMD `groupBased`
  iteration encoding
  https://openpmd-api.readthedocs.io/en/0.14.0/backends/adios2.html#memory-usage

* openPMD: Open Iterations Explicitly

Explicitly open iterations. Usually, file-open operations are delayed
until the first load/storeChunk operation is flush-ed. In parallel
contexts where we might want to do only particle writes from a few
ranks but no field wries in the future, this will avoid that we run
into hangs from the non-collective nature of the first flush.

The Streaming API (i.e., Series::writeIterations()) will call this
method implicitly as well, but back-transformed diags (particles)
might still need this.

* openPMD: 0.13.0+

Needed for streaming API and collective open.

* openPMD: Missing Include (ECP-WarpX#2162)

Fix compile issue on Conda-Forge (Windows with Clang).

* PEC Analysis: Remove Unused Imports (ECP-WarpX#2165)

Fix a LGTM warning on unused imports in our PEC analysis scripts.

* BinaryCollision: use more general particle data structure (ECP-WarpX#2137)

* Added B field to plasma lens (ECP-WarpX#2163)

* Added B field to plasma lens

* Fix B field and updated CI test to include the B field

* Updated benchmark

* Fixed bug where specifying write_dir for particle diagnostic did not work (ECP-WarpX#2167)

* Add particle weight as an explicit argument for _libwarpx.py::add_particles() (ECP-WarpX#2161)

* added particle weight as an explicit argument for _libwarpx.py::add_particles()

* changes requested during code review

* RZ PSATD: Time Averaging for Multi-J Algorithm (ECP-WarpX#2141)

* RZ PSATD: Time Averaging for Multi-J Algorithm

* Fix Wrong Signs in Bm

* Use Time Averaging in CI Test, Update Benchmark

* Minor Fix

* Shift parsing of physical/mathematical constants from hard-coding to table lookup (ECP-WarpX#2128)

* Shift parsing of physical/mathematical constants from hard-coding to table lookup
* Make constants map local and static for now, until there's a reason for it to be accessible/modifiable
* Accept rewording
* Accept rewording

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>

* Moved some routines to .cpp file (ECP-WarpX#2168)

* In add_particles, used None for input parameter values (ECP-WarpX#2169)

* More cleanup of particle boundaries (ECP-WarpX#2171)

* Moved some routines to .cpp file

* Moved more stuff to a header file

* make parameter less prone to numerical issues in single precision (ECP-WarpX#2173)

* ES Solver: Fix SP Build (ECP-WarpX#2174)

Fix HIP:
```
/home/runner/work/WarpX/WarpX/Source/FieldSolver/ElectrostaticSolver.cpp:434:9: error: non-constant-expression cannot be narrowed from type 'double' to 'float' in initializer list [-Wc++11-narrowing]
        1.-beta[0]*beta[0], 1.-beta[1]*beta[1], 1.-beta[2]*beta[2])});
        ^~~~~~~~~~~~~~~~~~
/home/runner/work/WarpX/WarpX/build_sp/_deps/fetchedamrex-src/Src/Base/AMReX_SPACE.H:151:31: note: expanded from macro 'AMREX_D_DECL'
                              ^
/home/runner/work/WarpX/WarpX/Source/FieldSolver/ElectrostaticSolver.cpp:434:9: note: insert an explicit cast to silence this issue
        1.-beta[0]*beta[0], 1.-beta[1]*beta[1], 1.-beta[2]*beta[2])});
        ^~~~~~~~~~~~~~~~~~
```

* EB: RZ Warnings (ECP-WarpX#2176)

Not an implementation yet, just adding aborts and silencing warnings.

* fix typo (ECP-WarpX#2175)

* Fix: Performance Tests (Boundary) (ECP-WarpX#2178)

The performance tests were aborting since we changed the boundary
condition inputs last month. This fixes it.

* CI: Cover Performance Tests (ECP-WarpX#2179)

* CI: Cover Performance Tests

Make sure their syntax stays up-to-date.

* Performance Test in CI: Fake Output

Add "fake" output so we do not have unused variables when the tests
are run.

* reverted (or fixed) various unneccesary changes between ME fork and upstream/development

Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com>
Co-authored-by: MaxThevenet <maxence.thevenet@desy.de>
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com>
Co-authored-by: atmyers <atmyers2@gmail.com>
Co-authored-by: Revathi  Jambunathan <41089244+RevathiJambunathan@users.noreply.github.com>
Co-authored-by: David Grote <grote1@llnl.gov>
Co-authored-by: Kevin Z. Zhu <86268612+KZhu-ME@users.noreply.github.com>
Co-authored-by: Phil Miller <unmobile+gh@gmail.com>
Co-authored-by: Luca Fedeli <luca.fedeli@cea.fr>
  • Loading branch information
11 people authored Aug 11, 2021
1 parent fba4ed9 commit 784d537
Show file tree
Hide file tree
Showing 67 changed files with 792 additions and 384 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Preamble ####################################################################
#
cmake_minimum_required(VERSION 3.15.0)
project(WarpX VERSION 21.07)
project(WarpX VERSION 21.08)

include(${WarpX_SOURCE_DIR}/cmake/WarpXFunctions.cmake)

Expand Down Expand Up @@ -57,7 +57,7 @@ option(WarpX_MPI "Multi-node support (message-passing)" ON)
option(WarpX_OPENPMD "openPMD I/O (HDF5, ADIOS)" OFF)
option(WarpX_PSATD "spectral solver support" OFF)
option(WarpX_QED "QED support (requires PICSAR)" ON)
option(WarpX_QED_TABLE_GEN "QED table generation (requires PICSAR and Boost)" OFF)
option(WarpX_QED_TABLE_GEN "QED table generation (requires PICSAR and Boost)" OFF)
# TODO: sensei, legacy hdf5?

set(WarpX_DIMS_VALUES 2 3 RZ)
Expand Down
4 changes: 2 additions & 2 deletions Docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
# built documents.
#
# The short X.Y version.
version = u'21.07'
version = u'21.08'
# The full version, including alpha/beta/rc tags.
release = u'21.07'
release = u'21.08'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion Docs/source/developers/gnumake/openpmd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ therefore we recommend to use `spack <https://
spack.io>`__ in order to facilitate the installation.

More specifically, we recommend that you try installing the
`openPMD-api library 0.12.0a or newer <https://openpmd-api.readthedocs.io/en/0.12.0-alpha/>`_
`openPMD-api library 0.13.0 or newer <https://openpmd-api.readthedocs.io/en/0.13.0/>`_
using spack (first section below). If this fails, a back-up solution
is to install parallel HDF5 with spack, and then install the openPMD-api
library from source.
Expand Down
2 changes: 1 addition & 1 deletion Docs/source/install/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Optional dependencies include:
- `FFTW3 <http://www.fftw.org>`_: for spectral solver (PSATD) support
- `BLAS++ <https://bitbucket.org/icl/blaspp>`_ and `LAPACK++ <https://bitbucket.org/icl/lapackpp>`_: for spectral solver (PSATD) support in RZ geometry
- `Boost 1.66.0+ <https://www.boost.org/>`__: for QED lookup tables generation support
- `openPMD-api 0.12.0+ <https://github.com/openPMD/openPMD-api>`__: we automatically download and compile a copy of openPMD-api for openPMD I/O support
- `openPMD-api 0.13.0+ <https://github.com/openPMD/openPMD-api>`__: we automatically download and compile a copy of openPMD-api for openPMD I/O support

- see `optional I/O backends <https://github.com/openPMD/openPMD-api#dependencies>`__
- `CCache <https://ccache.dev>`__: to speed up rebuilds (needs 3.7.9+ for CUDA)
Expand Down
6 changes: 5 additions & 1 deletion Docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ Particle initialization
and ``<species_name>.xmax`` (and same in all directions). This requires additional
parameter ``<species_name>.density``. i.e., the plasma density in :math:`m^{-3}`.

* ``predefined``: Predefined density profile.
This requires additional parameters ``<species_name>.predefined_profile_name`` and ``<species_name>.predefined_profile_params``.
Currently, only a parabolic channel density profile is implemented.

* ``parse_density_function``: the density is given by a function in the input file.
It requires additional argument ``<species_name>.density_function(x,y,z)``, which is a
mathematical expression for the density of the species, e.g.
Expand Down Expand Up @@ -701,7 +705,7 @@ Particle initialization
``vzbar`` until it reaches ``zinject_plane``.

* ``species_name.predefined_profile_name`` (`string`)
Only read of ``<species_name>.electrons.profile`` is `predefined`.
Only read if ``<species_name>.profile`` is ``predefined``.

* If ``parabolic_channel``, the plasma profile is a parabolic profile with
cosine-like ramps at the beginning and the end of the profile.
Expand Down
1 change: 0 additions & 1 deletion Examples/Tests/PEC/analysis_pec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import yt
yt.funcs.mylog.setLevel(50)
import numpy as np
from scipy.constants import e, m_e, epsilon_0, c
sys.path.insert(1, '../../../../warpx/Regression/Checksum/')
import checksumAPI

Expand Down
1 change: 0 additions & 1 deletion Examples/Tests/PEC/analysis_pec_mr.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import yt
yt.funcs.mylog.setLevel(50)
import numpy as np
from scipy.constants import e, m_e, epsilon_0, c
sys.path.insert(1, '../../../../warpx/Regression/Checksum/')
import checksumAPI

Expand Down
2 changes: 1 addition & 1 deletion Examples/Tests/multi_J/inputs_rz
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ warpx.do_divb_cleaning = 1
warpx.do_multi_J = 1
warpx.do_multi_J_n_depositions = 2
psatd.J_linear_in_time = 1
psatd.do_time_averaging = 0
psatd.do_time_averaging = 1

# PSATD
psatd.update_with_rho = 1
Expand Down
18 changes: 11 additions & 7 deletions Examples/Tests/plasma_lens/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ def applylens(x0, vx0, vz0, lens_length, lens_strength):
vx1 = -w*A*np.sin(w*t + phi)
return x1, vx1

vel_z = eval(ds.parameters.get('my_constants.vel_z'))

plasma_lens_period = float(ds.parameters.get('particles.repeated_plasma_lens_period'))
plasma_lens_starts = [float(x) for x in ds.parameters.get('particles.repeated_plasma_lens_starts').split()]
plasma_lens_lengths = [float(x) for x in ds.parameters.get('particles.repeated_plasma_lens_lengths').split()]
plasma_lens_strengths = [eval(x) for x in ds.parameters.get('particles.repeated_plasma_lens_strengths').split()]
plasma_lens_strengths_E = [eval(x) for x in ds.parameters.get('particles.repeated_plasma_lens_strengths_E').split()]
plasma_lens_strengths_B = [eval(x) for x in ds.parameters.get('particles.repeated_plasma_lens_strengths_B').split()]

clight = c

Expand All @@ -81,8 +84,9 @@ def applylens(x0, vx0, vz0, lens_length, lens_strength):
tt = tt + dt
xx = xx + dt*ux
yy = yy + dt*uy
xx, ux = applylens(xx, ux, uz, plasma_lens_lengths[i], plasma_lens_strengths[i])
yy, uy = applylens(yy, uy, uz, plasma_lens_lengths[i], plasma_lens_strengths[i])
lens_strength = plasma_lens_strengths_E[i] + plasma_lens_strengths_B[i]*vel_z
xx, ux = applylens(xx, ux, uz, plasma_lens_lengths[i], lens_strength)
yy, uy = applylens(yy, uy, uz, plasma_lens_lengths[i], lens_strength)
dt = plasma_lens_lengths[i]/uz
tt = tt + dt
zz = z_lens + plasma_lens_lengths[i]
Expand All @@ -92,10 +96,10 @@ def applylens(x0, vx0, vz0, lens_length, lens_strength):
xx = xx + dt0*ux
yy = yy + dt1*uy

assert abs(xx - xx_sim) < 0.011, Exception('error in x particle position')
assert abs(yy - yy_sim) < 0.011, Exception('error in y particle position')
assert abs(ux - ux_sim) < 70., Exception('error in x particle velocity')
assert abs(uy - uy_sim) < 70., Exception('error in y particle velocity')
assert abs(np.abs((xx - xx_sim)/xx)) < 0.003, Exception('error in x particle position')
assert abs(np.abs((yy - yy_sim)/yy)) < 0.003, Exception('error in y particle position')
assert abs(np.abs((ux - ux_sim)/ux)) < 5.e-5, Exception('error in x particle velocity')
assert abs(np.abs((uy - uy_sim)/uy)) < 5.e-5, Exception('error in y particle velocity')

test_name = os.path.split(os.getcwd())[1]
checksumAPI.evaluate_checksum(test_name, filename)
Expand Down
14 changes: 9 additions & 5 deletions Examples/Tests/plasma_lens/inputs_3d
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,35 @@ boundary.particle_lo = absorbing absorbing absorbing
boundary.particle_hi = absorbing absorbing absorbing

warpx.do_pml = 0
warpx.const_dt = 1.e-6
warpx.const_dt = 1.e-7
warpx.do_electrostatic = labframe

# Algorithms
algo.particle_shape = 1

my_constants.vel_z = 0.2e6

# particles
particles.species_names = electrons

electrons.charge = -q_e
electrons.mass = m_e
electrons.injection_style = "MultipleParticles"
electrons.multiple_particles_pos_x = 0.5 0.
electrons.multiple_particles_pos_y = 0. 0.4
electrons.multiple_particles_pos_x = 0.05 0.
electrons.multiple_particles_pos_y = 0. 0.04
electrons.multiple_particles_pos_z = 0.05 0.05
electrons.multiple_particles_vel_x = 0. 0.
electrons.multiple_particles_vel_y = 0. 0.
electrons.multiple_particles_vel_z = 0.02e6/clight 0.02e6/clight
electrons.multiple_particles_vel_z = vel_z/clight vel_z/clight
electrons.multiple_particles_weight = 1. 1.

particles.E_ext_particle_init_style = repeated_plasma_lens
particles.B_ext_particle_init_style = repeated_plasma_lens
particles.repeated_plasma_lens_period = 0.5
particles.repeated_plasma_lens_starts = 0.1 0.11 0.12 0.13
particles.repeated_plasma_lens_lengths = 0.1 0.11 0.12 0.13
particles.repeated_plasma_lens_strengths = 0.07 0.06 0.06 0.03
particles.repeated_plasma_lens_strengths_E = 0.06 0.08 0.06 0.02
particles.repeated_plasma_lens_strengths_B = 0.08/vel_z 0.04/vel_z 0.06/vel_z 0.04/vel_z

# Diagnostics
diagnostics.diags_names = diag1
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
WarpX v21.07 Copyright (c) 2018-2021, The Regents of the University of California, through Lawrence Berkeley National Laboratory, and Lawrence Livermore National Security, LLC, for the operation of Lawrence Livermore National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.
WarpX v21.08 Copyright (c) 2018-2021, The Regents of the University of California, through Lawrence Berkeley National Laboratory, and Lawrence Livermore National Security, LLC, for the operation of Lawrence Livermore National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved.


Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
110 changes: 52 additions & 58 deletions Python/pywarpx/_libwarpx.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,9 @@ def _array1d_from_pointer(pointer, dtype, size):
libwarpx.warpx_getChargeDensityCP.restype = _LP_LP_c_real
libwarpx.warpx_getChargeDensityCPLoVects.restype = _LP_c_int
libwarpx.warpx_getChargeDensityFP.restype = _LP_LP_c_real
libwarpx.warpx_getGatheredChargeDensityFP.restype = _LP_LP_c_real
libwarpx.warpx_getChargeDensityFPLoVects.restype = _LP_c_int
libwarpx.warpx_getPhiFP.restype = _LP_LP_c_real
libwarpx.warpx_getGatheredChargeDensityFP.restype = _LP_LP_c_real
libwarpx.warpx_getGatheredPhiFP.restype = _LP_LP_c_real
libwarpx.warpx_setPhiGridFP.restype = None
libwarpx.warpx_getPointerFullPhiFP.restype = _LP_LP_c_real

libwarpx.warpx_getEx_nodal_flag.restype = _LP_c_int
Expand Down Expand Up @@ -376,7 +374,7 @@ def getCellSize(direction, level=0):
#
# libwarpx.warpx_ComputePMLFactors(lev, dt)

def add_particles(species_name, x=0., y=0., z=0., ux=0., uy=0., uz=0.,
def add_particles(species_name, x=None, y=None, z=None, ux=None, uy=None, uz=None, w=None,
unique_particles=True, **kwargs):
'''
Expand All @@ -388,11 +386,12 @@ def add_particles(species_name, x=0., y=0., z=0., ux=0., uy=0., uz=0.,
species_name : the species to add the particle to
x, y, z : arrays or scalars of the particle positions (default = 0.)
ux, uy, uz : arrays or scalars of the particle momenta (default = 0.)
w : array or scalar of particle weights (default = 0.)
unique_particles : whether the particles are unique or duplicated on
several processes. (default = True)
kwargs : dictionary containing an entry for the particle weights
(with keyword 'w') and all the extra particle attribute
arrays. If an attribute is not given it will be set to 0.
kwargs : dictionary containing an entry for all the extra particle
attribute arrays. If an attribute is not given it will be
set to 0.
'''

Expand All @@ -403,48 +402,69 @@ def add_particles(species_name, x=0., y=0., z=0., ux=0., uy=0., uz=0.,
lenux = np.size(ux)
lenuy = np.size(uy)
lenuz = np.size(uz)

if (lenx == 0 or leny == 0 or lenz == 0 or lenux == 0 or
lenuy == 0 or lenuz == 0):
return

maxlen = max(lenx, leny, lenz, lenux, lenuy, lenuz)
assert lenx==maxlen or lenx==1, "Length of x doesn't match len of others"
assert leny==maxlen or leny==1, "Length of y doesn't match len of others"
assert lenz==maxlen or lenz==1, "Length of z doesn't match len of others"
assert lenux==maxlen or lenux==1, "Length of ux doesn't match len of others"
assert lenuy==maxlen or lenuy==1, "Length of uy doesn't match len of others"
assert lenuz==maxlen or lenuz==1, "Length of uz doesn't match len of others"
lenw = np.size(w)

# --- Find the max length of the parameters supplied
maxlen = 0
if x is not None:
maxlen = max(maxlen, lenx)
if y is not None:
maxlen = max(maxlen, leny)
if z is not None:
maxlen = max(maxlen, lenz)
if ux is not None:
maxlen = max(maxlen, lenux)
if uy is not None:
maxlen = max(maxlen, lenuy)
if uz is not None:
maxlen = max(maxlen, lenuz)
if w is not None:
maxlen = max(maxlen, lenw)

# --- Make sure that the lengths of the input parameters are consistent
assert x is None or lenx==maxlen or lenx==1, "Length of x doesn't match len of others"
assert y is None or leny==maxlen or leny==1, "Length of y doesn't match len of others"
assert z is None or lenz==maxlen or lenz==1, "Length of z doesn't match len of others"
assert ux is None or lenux==maxlen or lenux==1, "Length of ux doesn't match len of others"
assert uy is None or lenuy==maxlen or lenuy==1, "Length of uy doesn't match len of others"
assert uz is None or lenuz==maxlen or lenuz==1, "Length of uz doesn't match len of others"
assert w is None or lenw==maxlen or lenw==1, "Length of w doesn't match len of others"
for key, val in kwargs.items():
assert np.size(val)==1 or len(val)==maxlen, f"Length of {key} doesn't match len of others"

# --- If the length of the input is zero, then quietly return
# --- This is not an error - it just means that no particles are to be injected.
if maxlen == 0:
return

# --- Broadcast scalars into appropriate length arrays
# --- If the parameter was not supplied, use the default value
if lenx == 1:
x = np.array(x)*np.ones(maxlen)
x = np.full(maxlen, (x or 0.), float)
if leny == 1:
y = np.array(y)*np.ones(maxlen)
y = np.full(maxlen, (y or 0.), float)
if lenz == 1:
z = np.array(z)*np.ones(maxlen)
z = np.full(maxlen, (z or 0.), float)
if lenux == 1:
ux = np.array(ux)*np.ones(maxlen)
ux = np.full(maxlen, (ux or 0.), float)
if lenuy == 1:
uy = np.array(uy)*np.ones(maxlen)
uy = np.full(maxlen, (uy or 0.), float)
if lenuz == 1:
uz = np.array(uz)*np.ones(maxlen,'d')

uz = np.full(maxlen, (uz or 0.), float)
if lenw == 1:
w = np.full(maxlen, (w or 0.), float)
for key, val in kwargs.items():
if np.size(val) == 1:
kwargs[key] = np.array(val)*np.ones(maxlen)
kwargs[key] = np.full(maxlen, val, float)

# --- The -3 is because the comps include the velocites
nattr = get_nattr_species(species_name) - 3
attr = np.zeros((maxlen, nattr))
attr[:,0] = w

for key, vals in kwargs.items():
if key == 'w':
attr[:,0] = vals
else:
# --- The -3 is because components 1 to 3 are velocities
attr[:,get_particle_comp_index(species_name, key)-3] = vals
# --- The -3 is because components 1 to 3 are velocities
attr[:,get_particle_comp_index(species_name, key)-3] = vals

libwarpx.warpx_addNParticles(
ctypes.c_char_p(species_name.encode('utf-8')), x.size,
Expand Down Expand Up @@ -1258,32 +1278,6 @@ def get_mesh_charge_density_fp(level, include_ghosts=True):
return _get_mesh_field_list(libwarpx.warpx_getChargeDensityFP, level, None, include_ghosts)


def get_mesh_phi_fp(level, include_ghosts=True):
'''
This returns a list of numpy arrays containing the mesh electrostatic
potential data on each grid for this process. This version returns the
density on the fine patch for the given level.
The data for the numpy arrays are not copied, but share the underlying
memory buffer with WarpX. The numpy arrays are fully writeable.
Parameters
----------
level : the AMR level to get the data for
include_ghosts : whether to include ghost zones or not
Returns
-------
A List of numpy arrays.
'''

return _get_mesh_field_list(libwarpx.warpx_getPhiFP, level, None, include_ghosts)


def get_pointer_full_phi_fp(level):
"""This returns the full phi grid multifab from warpx"""
return _get_mesh_field_list(libwarpx.warpx_getPointerFullPhiFP, level, None, True)
Expand Down
1 change: 0 additions & 1 deletion Python/pywarpx/picmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class constants:
m_p = 1.67262192369e-27
hbar = 1.054571817e-34
kb = 1.380649e-23
torr_SI = 133.322368421

picmistandard.register_constants(constants)

Expand Down
2 changes: 1 addition & 1 deletion Python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
package_data = {}

setup(name = 'pywarpx',
version = '21.07',
version = '21.08',
packages = ['pywarpx'],
package_dir = {'pywarpx': 'pywarpx'},
description = """Wrapper of WarpX""",
Expand Down
Loading

0 comments on commit 784d537

Please sign in to comment.