diff options
author | 2021-12-16 10:12:57 -0800 | |
---|---|---|
committer | 2021-12-16 10:12:57 -0800 | |
commit | 746ddc2ae871e70cd50940c2cca03a17a9b7ec1a (patch) | |
tree | 37ba15e42ada9f89378894156214ab7b05699e66 /Examples/Tests/ParticleDataPython | |
parent | b0b03f6bc5e7768c4ecbcb4e4a2c505d9e4aad91 (diff) | |
download | WarpX-746ddc2ae871e70cd50940c2cca03a17a9b7ec1a.tar.gz WarpX-746ddc2ae871e70cd50940c2cca03a17a9b7ec1a.tar.zst WarpX-746ddc2ae871e70cd50940c2cca03a17a9b7ec1a.zip |
Wrap shared object in a class to control its loading (#2637)
* Wrap shared object in a class to control its loading
* Fix libwarpx attribute references
* Updated callbacks.py for updated libwarpx
* Removed the wx module plus other clean up
* Further revision of how to use the pywarpx module.
Now, _libwarpx should not be imported by external scripts except in special circumstances.
* Updated documentation
* Clean up end of line whitespace
* Added more wrapping routines plus some clean up
* Fixed use of pywarpx in two examples
* Fix for getistep
* Fixed for the EB Python interface
* Silence a warning for our wrapper
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Examples/Tests/ParticleDataPython')
-rwxr-xr-x | Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py | 22 | ||||
-rwxr-xr-x | Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py | 9 |
2 files changed, 14 insertions, 17 deletions
diff --git a/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py b/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py index 6ed144dbc..2162236eb 100755 --- a/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py +++ b/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py @@ -1,10 +1,9 @@ #!/usr/bin/env python3 - -from pywarpx import picmi -import numpy as np - import argparse import sys +import numpy as np +import pywarpx +from pywarpx import picmi, callbacks # Create the parser and add the argument parser = argparse.ArgumentParser() @@ -106,11 +105,10 @@ sim.initialize_warpx() # python particle data access ########################## -from pywarpx import _libwarpx, callbacks -_libwarpx.add_real_comp('electrons', 'newPid') +pywarpx.add_real_comp('electrons', 'newPid') -my_id = _libwarpx.libwarpx.warpx_getMyProc() +my_id = pywarpx.getMyProc() def add_particles(): @@ -124,7 +122,7 @@ def add_particles(): w = np.ones(nps) * 2.0 newPid = 5.0 - _libwarpx.add_particles( + pywarpx.add_particles( species_name='electrons', x=x, y=y, z=z, ux=ux, uy=uy, uz=uz, w=w, newPid=newPid, unique_particles=args.unique ) @@ -142,11 +140,11 @@ sim.step(max_steps - 1) # are properly set ########################## -assert (_libwarpx.get_particle_count('electrons') == 270 / (2 - args.unique)) -assert (_libwarpx.get_particle_comp_index('electrons', 'w') == 0) -assert (_libwarpx.get_particle_comp_index('electrons', 'newPid') == 4) +assert (pywarpx.get_particle_count('electrons') == 270 / (2 - args.unique)) +assert (pywarpx.get_particle_comp_index('electrons', 'w') == 0) +assert (pywarpx.get_particle_comp_index('electrons', 'newPid') == 4) -new_pid_vals = _libwarpx.get_particle_arrays( +new_pid_vals = pywarpx.get_particle_arrays( 'electrons', 'newPid', 0 ) for vals in new_pid_vals: diff --git a/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py b/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py index d8e37140f..d71aa3fea 100755 --- a/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py +++ b/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py @@ -3,6 +3,7 @@ # --- Input file to test the saving of old particle positions import numpy as np +import pywarpx from pywarpx import picmi constants = picmi.constants @@ -109,12 +110,10 @@ sim.step(max_steps - 1) # exist ########################## -from pywarpx import _libwarpx +assert (pywarpx.get_particle_comp_index('electrons', 'prev_x') > 0) +assert (pywarpx.get_particle_comp_index('electrons', 'prev_z') > 0) -assert (_libwarpx.get_particle_comp_index('electrons', 'prev_x') > 0) -assert (_libwarpx.get_particle_comp_index('electrons', 'prev_z') > 0) - -prev_z_vals = _libwarpx.get_particle_arrays( +prev_z_vals = pywarpx.get_particle_arrays( 'electrons', 'prev_z', 0 ) for z_vals in prev_z_vals: |