diff options
Diffstat (limited to 'Examples')
9 files changed, 45 insertions, 54 deletions
diff --git a/Examples/Modules/ParticleBoundaryProcess/PICMI_inputs_reflection.py b/Examples/Modules/ParticleBoundaryProcess/PICMI_inputs_reflection.py index c9903ad22..d7d023ef6 100755 --- a/Examples/Modules/ParticleBoundaryProcess/PICMI_inputs_reflection.py +++ b/Examples/Modules/ParticleBoundaryProcess/PICMI_inputs_reflection.py @@ -2,7 +2,6 @@ # # --- Input file to test particle reflection off an absorbing boundary -import pywarpx from pywarpx import picmi constants = picmi.constants @@ -115,20 +114,20 @@ sim.step(max_steps) # buffer functions as intended ################################################ -n = pywarpx.get_particle_boundary_buffer_size("electrons", 'z_hi') +n = sim.extension.get_particle_boundary_buffer_size("electrons", 'z_hi') print("Number of electrons in upper buffer:", n) assert n == 63 -n = pywarpx.get_particle_boundary_buffer_size("electrons", 'z_lo') +n = sim.extension.get_particle_boundary_buffer_size("electrons", 'z_lo') print("Number of electrons in lower buffer:", n) assert n == 67 -scraped_steps = pywarpx.get_particle_boundary_buffer("electrons", 'z_hi', 'step_scraped', 0) +scraped_steps = sim.extension.get_particle_boundary_buffer("electrons", 'z_hi', 'step_scraped', 0) for arr in scraped_steps: # print(arr) assert all(arr == 4) -scraped_steps = pywarpx.get_particle_boundary_buffer("electrons", 'z_lo', 'step_scraped', 0) +scraped_steps = sim.extension.get_particle_boundary_buffer("electrons", 'z_lo', 'step_scraped', 0) for arr in scraped_steps: # print(arr) assert all(arr == 8) diff --git a/Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py b/Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py index 90f526e4b..8009da0cc 100755 --- a/Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py +++ b/Examples/Modules/ParticleBoundaryScrape/PICMI_inputs_scrape.py @@ -3,7 +3,6 @@ # --- Input file to test the particle scraper and the Python wrappers # --- to access the buffer of scraped particles. -import pywarpx from pywarpx import picmi ########################## @@ -117,25 +116,25 @@ sim.step(max_steps) from mpi4py import MPI as mpi -my_id = pywarpx.getMyProc() +my_id = sim.extension.getMyProc() -n = pywarpx.get_particle_boundary_buffer_size("electrons", 'eb') +n = sim.extension.get_particle_boundary_buffer_size("electrons", 'eb') print(f"Number of electrons in buffer (proc #{my_id}): {n}") assert n == 612 -scraped_steps = pywarpx.get_particle_boundary_buffer("electrons", 'eb', 'step_scraped', 0) +scraped_steps = sim.extension.get_particle_boundary_buffer("electrons", 'eb', 'step_scraped', 0) for arr in scraped_steps: assert all(arr > 40) -weights = pywarpx.get_particle_boundary_buffer("electrons", 'eb', 'w', 0) +weights = sim.extension.get_particle_boundary_buffer("electrons", 'eb', 'w', 0) n = sum(len(arr) for arr in weights) print(f"Number of electrons in this proc's buffer (proc #{my_id}): {n}") n_sum = mpi.COMM_WORLD.allreduce(n, op=mpi.SUM) assert n_sum == 612 # clear the particle buffer -pywarpx.clearParticleBoundaryBuffer() +sim.extension.clearParticleBoundaryBuffer() # confirm that the buffer was cleared -n = pywarpx.get_particle_boundary_buffer_size("electrons", 'eb') +n = sim.extension.get_particle_boundary_buffer_size("electrons", 'eb') print(f"Number of electrons in buffer (proc #{my_id}): {n}") assert n == 0 diff --git a/Examples/Modules/embedded_boundary_python_API/PICMI_inputs_EB_API.py b/Examples/Modules/embedded_boundary_python_API/PICMI_inputs_EB_API.py index 6dea197d3..4619defe1 100755 --- a/Examples/Modules/embedded_boundary_python_API/PICMI_inputs_EB_API.py +++ b/Examples/Modules/embedded_boundary_python_API/PICMI_inputs_EB_API.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 import numpy as np -import pywarpx from pywarpx import fields, picmi max_steps = 1 @@ -84,10 +83,10 @@ sim.initialize_inputs() sim.step(1) -print("======== Testing pywarpx.get_mesh_edge_lengths =========") +print("======== Testing sim.extension.get_mesh_edge_lengths =========") -ly_slice_x = np.array(pywarpx.get_mesh_edge_lengths(0,1,include_ghosts=False)[0])[int(nx/2),:,:] -lz_slice_x = np.array(pywarpx.get_mesh_edge_lengths(0,2,include_ghosts=False)[0])[int(nx/2),:,:] +ly_slice_x = np.array(sim.extension.get_mesh_edge_lengths(0,1,include_ghosts=False)[0])[int(nx/2),:,:] +lz_slice_x = np.array(sim.extension.get_mesh_edge_lengths(0,2,include_ghosts=False)[0])[int(nx/2),:,:] n_edge_y_lo = int((ny - 30)/2) n_edge_y_hi = int(ny - (ny - 30)/2) @@ -105,8 +104,8 @@ print("Perimeter of the middle x-slice:", perimeter_slice_x) assert np.isclose(perimeter_slice_x, perimeter_slice_x_true, rtol=1e-05, atol=1e-08) -lx_slice_y = np.array(pywarpx.get_mesh_edge_lengths(0,0,include_ghosts=False)[0])[:,int(ny/2),:] -lz_slice_y = np.array(pywarpx.get_mesh_edge_lengths(0,2,include_ghosts=False)[0])[:,int(ny/2),:] +lx_slice_y = np.array(sim.extension.get_mesh_edge_lengths(0,0,include_ghosts=False)[0])[:,int(ny/2),:] +lz_slice_y = np.array(sim.extension.get_mesh_edge_lengths(0,2,include_ghosts=False)[0])[:,int(ny/2),:] n_edge_x_lo = int((nx - 30)/2) n_edge_x_hi = int(nx - (nx - 30)/2) @@ -125,8 +124,8 @@ print("Perimeter of the middle y-slice:", perimeter_slice_y) assert np.isclose(perimeter_slice_y, perimeter_slice_y_true, rtol=1e-05, atol=1e-08) -lx_slice_z = np.array(pywarpx.get_mesh_edge_lengths(0,0,include_ghosts=False)[0])[:,:,int(nz/2)] -ly_slice_z = np.array(pywarpx.get_mesh_edge_lengths(0,1,include_ghosts=False)[0])[:,:,int(nz/2)] +lx_slice_z = np.array(sim.extension.get_mesh_edge_lengths(0,0,include_ghosts=False)[0])[:,:,int(nz/2)] +ly_slice_z = np.array(sim.extension.get_mesh_edge_lengths(0,1,include_ghosts=False)[0])[:,:,int(nz/2)] n_edge_x_lo = int((nx - 30)/2) n_edge_x_hi = int(nx - (nx - 30)/2) @@ -143,9 +142,9 @@ perimeter_slice_z_true = L_cavity*4 print("Perimeter of the middle z-slice:", perimeter_slice_z) assert np.isclose(perimeter_slice_z, perimeter_slice_z_true, rtol=1e-05, atol=1e-08) -print("======== Testing pywarpx.get_mesh_face_areas =========") +print("======== Testing sim.extension.get_mesh_face_areas =========") -Sx_slice = np.sum(np.array(pywarpx.get_mesh_face_areas(0,0,include_ghosts=False)[0])[int(nx/2),:,:]) +Sx_slice = np.sum(np.array(sim.extension.get_mesh_face_areas(0,0,include_ghosts=False)[0])[int(nx/2),:,:]) dx = (xmax-xmin)/nx Ax = dx*dx Sx_slice_true = L_cavity*L_cavity - 2*Ax @@ -153,7 +152,7 @@ print("Area of the middle x-slice:", Sx_slice) assert np.isclose(Sx_slice, Sx_slice_true, rtol=1e-05, atol=1e-08) -Sy_slice = np.sum(np.array(pywarpx.get_mesh_face_areas(0,1,include_ghosts=False)[0])[:,int(ny/2),:]) +Sy_slice = np.sum(np.array(sim.extension.get_mesh_face_areas(0,1,include_ghosts=False)[0])[:,int(ny/2),:]) dy = (ymax-ymin)/ny Ay = dy*dy Sy_slice_true = L_cavity*L_cavity - 2*Ay @@ -161,7 +160,7 @@ print("Area of the middle y-slice:", Sx_slice) assert np.isclose(Sy_slice, Sy_slice_true, rtol=1e-05, atol=1e-08) -Sz_slice = np.sum(np.array(pywarpx.get_mesh_face_areas(0,2,include_ghosts=False)[0])[:,:,int(nz/2)]) +Sz_slice = np.sum(np.array(sim.extension.get_mesh_face_areas(0,2,include_ghosts=False)[0])[:,:,int(nz/2)]) dz = (zmax-zmin)/nz Az = dz*dz Sz_slice_true = L_cavity*L_cavity - 2*Az diff --git a/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_2d.py b/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_2d.py index 7afbf8ccc..8b4a625ef 100755 --- a/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_2d.py +++ b/Examples/Physics_applications/capacitive_discharge/PICMI_inputs_2d.py @@ -6,7 +6,6 @@ # --- used for the field solve step. import numpy as np -import pywarpx from pywarpx import callbacks, fields, picmi from scipy.sparse import csc_matrix from scipy.sparse import linalg as sla @@ -177,7 +176,7 @@ class PoissonSolverPseudo1D(picmi.ElectrostaticSolver): calculating phi from rho.""" right_voltage = eval( self.right_voltage, - {'t':pywarpx.gett_new(0), 'sin':np.sin, 'pi':np.pi} + {'t':sim.extension.gett_new(0), 'sin':np.sin, 'pi':np.pi} ) left_voltage = 0.0 diff --git a/Examples/Tests/Langmuir/PICMI_inputs_langmuir_rz_multimode_analyze.py b/Examples/Tests/Langmuir/PICMI_inputs_langmuir_rz_multimode_analyze.py index dae0ba40d..6217b8546 100755 --- a/Examples/Tests/Langmuir/PICMI_inputs_langmuir_rz_multimode_analyze.py +++ b/Examples/Tests/Langmuir/PICMI_inputs_langmuir_rz_multimode_analyze.py @@ -9,7 +9,6 @@ import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import numpy as np -import pywarpx from pywarpx import fields, picmi constants = picmi.constants @@ -178,7 +177,7 @@ def calcEz( z, r, k0, w0, wp, t, epsilons) : return( Ez_array ) # Current time of the simulation -t0 = pywarpx.gett_new(0) +t0 = sim.extension.gett_new(0) # Get the raw field data. Note that these are the real and imaginary # parts of the fields for each azimuthal mode. diff --git a/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py b/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py index 6df8d676c..ff3c0704b 100755 --- a/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py +++ b/Examples/Tests/ParticleDataPython/PICMI_inputs_2d.py @@ -3,7 +3,6 @@ import argparse import sys import numpy as np -import pywarpx from pywarpx import callbacks, picmi # Create the parser and add the argument @@ -107,9 +106,9 @@ sim.initialize_warpx() ########################## -pywarpx.add_real_comp('electrons', 'newPid') +sim.extension.add_real_comp('electrons', 'newPid') -my_id = pywarpx.getMyProc() +my_id = sim.extension.getMyProc() def add_particles(): @@ -123,7 +122,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, unique_particles=args.unique ) @@ -141,11 +140,11 @@ sim.step(max_steps - 1) # are properly set ########################## -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) +assert (sim.extension.get_particle_count('electrons') == 270 / (2 - args.unique)) +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: diff --git a/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py b/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py index d71aa3fea..9cfe669ce 100755 --- a/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py +++ b/Examples/Tests/ParticleDataPython/PICMI_inputs_prev_pos_2d.py @@ -3,7 +3,6 @@ # --- Input file to test the saving of old particle positions import numpy as np -import pywarpx from pywarpx import picmi constants = picmi.constants @@ -110,10 +109,10 @@ sim.step(max_steps - 1) # exist ########################## -assert (pywarpx.get_particle_comp_index('electrons', 'prev_x') > 0) -assert (pywarpx.get_particle_comp_index('electrons', 'prev_z') > 0) +assert (sim.extension.get_particle_comp_index('electrons', 'prev_x') > 0) +assert (sim.extension.get_particle_comp_index('electrons', 'prev_z') > 0) -prev_z_vals = pywarpx.get_particle_arrays( +prev_z_vals = sim.extension.get_particle_arrays( 'electrons', 'prev_z', 0 ) for z_vals in prev_z_vals: diff --git a/Examples/Tests/pass_mpi_communicator/PICMI_inputs_2d.py b/Examples/Tests/pass_mpi_communicator/PICMI_inputs_2d.py index fbb108a0e..b97905ee0 100755 --- a/Examples/Tests/pass_mpi_communicator/PICMI_inputs_2d.py +++ b/Examples/Tests/pass_mpi_communicator/PICMI_inputs_2d.py @@ -6,7 +6,6 @@ # --- if the correct amount of processors are initialized in AMReX. from mpi4py import MPI -import pywarpx from pywarpx import picmi constants = picmi.constants @@ -128,14 +127,14 @@ new_comm_size = new_comm.size if color == 0: # verify that communicator contains correct number of procs (1) - assert pywarpx.getNProcs() == comm_world_size - 1 - assert pywarpx.getNProcs() == new_comm_size + assert sim.extension.getNProcs() == comm_world_size - 1 + assert sim.extension.getNProcs() == new_comm_size else: # verify that amrex initialized with 1 fewer proc than comm world - assert pywarpx.getNProcs() == comm_world_size - 1 - assert pywarpx.getNProcs() == new_comm_size + assert sim.extension.getNProcs() == comm_world_size - 1 + assert sim.extension.getNProcs() == new_comm_size # verify that amrex proc ranks are offset by -1 from # world comm proc ranks - assert pywarpx.getMyProc() == rank - 1 + assert sim.extension.getMyProc() == rank - 1 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: |