From d411310e45a370cfde872b25baa7a9f20bcf4966 Mon Sep 17 00:00:00 2001 From: Peter Scherpelz <31747262+peterscherpelz@users.noreply.github.com> Date: Wed, 22 Dec 2021 15:32:36 -0800 Subject: Change _libwarpx.py functions to LibWarpX class methods (#2696) * Initial attempt at moving function into LibWarpX * Bugfix - undefined structs in get_particle_theta This is untested, identified by IDE/visual inspection only * Unify newlines * Delete libwarpx.clight (duplicated picmi.py) See picmi.constants.c * Change function descriptive comment to docstring Also remove extra newline in __init__ beginning. * Replace pywarpx/_libwarpx calls appropriately * Fix atexit register of finalize function * Reorder WarpX.py imports for pre-commit * Use picmi.Simulation.extension = libwarpx alias This will hopefully preempt user script changes if we restructure things to allow multiple WarpX runs to be done within a single Python script. * Fix libwarpx ref in WarpX.getProbLo/getProbHi * Update get_particle_boundary_buffer doc reference --- .../restart/PICMI_inputs_runtime_component_analyze.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'Examples/Tests/restart/PICMI_inputs_runtime_component_analyze.py') diff --git a/Examples/Tests/restart/PICMI_inputs_runtime_component_analyze.py b/Examples/Tests/restart/PICMI_inputs_runtime_component_analyze.py index ffb820fed..1fa8862f0 100755 --- a/Examples/Tests/restart/PICMI_inputs_runtime_component_analyze.py +++ b/Examples/Tests/restart/PICMI_inputs_runtime_component_analyze.py @@ -7,7 +7,6 @@ import sys import numpy as np -import pywarpx from pywarpx import callbacks, picmi ########################## @@ -113,7 +112,7 @@ sim.initialize_warpx() ########################## -pywarpx.add_real_comp('electrons', 'newPid') +sim.extension.add_real_comp('electrons', 'newPid') def add_particles(): @@ -127,7 +126,7 @@ def add_particles(): w = np.ones(nps) * 2.0 newPid = 5.0 - pywarpx.add_particles( + sim.extension.add_particles( species_name='electrons', x=x, y=y, z=z, ux=ux, uy=uy, uz=uz, w=w, newPid=newPid ) @@ -138,18 +137,18 @@ callbacks.installbeforestep(add_particles) # simulation run ########################## -step_number = pywarpx.getistep(0) +step_number = sim.extension.getistep(0) sim.step(max_steps - 1 - step_number) ########################## # check that the new PIDs are properly set ########################## -assert(pywarpx.get_particle_count('electrons') == 90) -assert (pywarpx.get_particle_comp_index('electrons', 'w') == 0) -assert (pywarpx.get_particle_comp_index('electrons', 'newPid') == 4) +assert(sim.extension.get_particle_count('electrons') == 90) +assert (sim.extension.get_particle_comp_index('electrons', 'w') == 0) +assert (sim.extension.get_particle_comp_index('electrons', 'newPid') == 4) -new_pid_vals = pywarpx.get_particle_arrays( +new_pid_vals = sim.extension.get_particle_arrays( 'electrons', 'newPid', 0 ) for vals in new_pid_vals: -- cgit v1.2.3