Skip to content

Commit

Permalink
Update Particle Container to Pure SoA (#3850)
Browse files Browse the repository at this point in the history
* Update Particle Container to Pure SoA

Transition particle containers to pure SoA layouts.

* Python: Pure SoA Particle

* Update Particle Container to Pure SoA

Transition particle containers to pure SoA layouts.

* Python: Pure SoA Particle

* fix a couple of places where we underflow the particle idcpu

* fixed bad merge

* fix bad merge again

* Update Particle Container to Pure SoA

Transition particle containers to pure SoA layouts.

* Python: Pure SoA Particle

* skip positions for pure SoA plotfiles

* Update Particle Container to Pure SoA

Transition particle containers to pure SoA layouts.

Co-authored-by: Andrew Myers <atmyers@lbl.gov>

* Python: Pure SoA Particle

* correctly account for positions in restart

---------

Co-authored-by: Andrew Myers <atmyers2@gmail.com>
Co-authored-by: Andrew Myers <atmyers@lbl.gov>
  • Loading branch information
3 people authored Jan 28, 2024
1 parent c1533a9 commit 94ae119
Show file tree
Hide file tree
Showing 53 changed files with 661 additions and 709 deletions.
3 changes: 2 additions & 1 deletion Docs/source/usage/workflows/python_extend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ Particles can be added to the simulation at specific positions and with specific
.. autoclass:: pywarpx.particle_containers.ParticleContainerWrapper
:members:

The ``get_particle_structs()`` and ``get_particle_arrays()`` functions are called
The ``get_particle_real_arrays()``, ``get_particle_int_arrays()`` and
``get_particle_idcpu_arrays()`` functions are called
by several utility functions of the form ``get_particle_{comp_name}`` where
``comp_name`` is one of ``x``, ``y``, ``z``, ``r``, ``theta``, ``id``, ``cpu``,
``weight``, ``ux``, ``uy`` or ``uz``.
Expand Down
6 changes: 3 additions & 3 deletions Examples/Tests/particle_data_python/PICMI_inputs_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ def add_particles():
##########################

assert (elec_wrapper.nps == 270 / (2 - args.unique))
assert (elec_wrapper.particle_container.get_comp_index('w') == 0)
assert (elec_wrapper.particle_container.get_comp_index('newPid') == 4)
assert (elec_wrapper.particle_container.get_comp_index('w') == 2)
assert (elec_wrapper.particle_container.get_comp_index('newPid') == 6)

new_pid_vals = elec_wrapper.get_particle_arrays('newPid', 0)
new_pid_vals = elec_wrapper.get_particle_real_arrays('newPid', 0)
for vals in new_pid_vals:
assert np.allclose(vals, 5)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@
elec_count = elec_wrapper.nps

# check that the runtime attributes have the right indices
assert (elec_wrapper.particle_container.get_comp_index('prev_x') == 4)
assert (elec_wrapper.particle_container.get_comp_index('prev_z') == 5)
assert (elec_wrapper.particle_container.get_comp_index('prev_x') == 6)
assert (elec_wrapper.particle_container.get_comp_index('prev_z') == 7)

# sanity check that the prev_z values are reasonable and
# that the correct number of values are returned
prev_z_vals = elec_wrapper.get_particle_arrays('prev_z', 0)
prev_z_vals = elec_wrapper.get_particle_real_arrays('prev_z', 0)
running_count = 0

for z_vals in prev_z_vals:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ def add_particles():
##########################

assert electron_wrapper.nps == 90
assert electron_wrapper.particle_container.get_comp_index("w") == 0
assert electron_wrapper.particle_container.get_comp_index("newPid") == 4
assert electron_wrapper.particle_container.get_comp_index("w") == 2
assert electron_wrapper.particle_container.get_comp_index("newPid") == 6

new_pid_vals = electron_wrapper.get_particle_arrays("newPid", 0)
new_pid_vals = electron_wrapper.get_particle_real_arrays("newPid", 0)
for vals in new_pid_vals:
assert np.allclose(vals, 5)

Expand Down
Loading

0 comments on commit 94ae119

Please sign in to comment.