aboutsummaryrefslogtreecommitdiff
path: root/Examples/Modules/embedded_boundary_python_API
diff options
context:
space:
mode:
authorGravatar Peter Scherpelz <31747262+peterscherpelz@users.noreply.github.com> 2021-12-22 15:32:36 -0800
committerGravatar GitHub <noreply@github.com> 2021-12-22 23:32:36 +0000
commitd411310e45a370cfde872b25baa7a9f20bcf4966 (patch)
treecbb12f8fc9ba701a9d2a08701aaf46a99ea9ba31 /Examples/Modules/embedded_boundary_python_API
parentf73b3cd49c430c59b6750d5e65dfd19dcf44c752 (diff)
downloadWarpX-d411310e45a370cfde872b25baa7a9f20bcf4966.tar.gz
WarpX-d411310e45a370cfde872b25baa7a9f20bcf4966.tar.zst
WarpX-d411310e45a370cfde872b25baa7a9f20bcf4966.zip
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
Diffstat (limited to 'Examples/Modules/embedded_boundary_python_API')
-rwxr-xr-xExamples/Modules/embedded_boundary_python_API/PICMI_inputs_EB_API.py23
1 files changed, 11 insertions, 12 deletions
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