aboutsummaryrefslogtreecommitdiff
path: root/Examples/Modules/embedded_boundary_python_API
diff options
context:
space:
mode:
authorGravatar David Grote <grote1@llnl.gov> 2021-12-16 10:12:57 -0800
committerGravatar GitHub <noreply@github.com> 2021-12-16 10:12:57 -0800
commit746ddc2ae871e70cd50940c2cca03a17a9b7ec1a (patch)
tree37ba15e42ada9f89378894156214ab7b05699e66 /Examples/Modules/embedded_boundary_python_API
parentb0b03f6bc5e7768c4ecbcb4e4a2c505d9e4aad91 (diff)
downloadWarpX-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/Modules/embedded_boundary_python_API')
-rwxr-xr-xExamples/Modules/embedded_boundary_python_API/PICMI_inputs_EB_API.py26
1 files changed, 13 insertions, 13 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 e350ce414..b0653ae01 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,7 +1,7 @@
#!/usr/bin/env python3
-
-from pywarpx import picmi, _libwarpx, fields
import numpy as np
+import pywarpx
+from pywarpx import picmi, fields
max_steps = 1
unit = 1e-3
@@ -84,10 +84,10 @@ sim.initialize_inputs()
sim.step(1)
-print("======== Testing _libwarpx.get_mesh_edge_lengths =========")
+print("======== Testing pywarpx.get_mesh_edge_lengths =========")
-ly_slice_x = np.array(_libwarpx.get_mesh_edge_lengths(0,1,include_ghosts=False)[0])[int(nx/2),:,:]
-lz_slice_x = np.array(_libwarpx.get_mesh_edge_lengths(0,2,include_ghosts=False)[0])[int(nx/2),:,:]
+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),:,:]
n_edge_y_lo = int((ny - 30)/2)
n_edge_y_hi = int(ny - (ny - 30)/2)
@@ -105,8 +105,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(_libwarpx.get_mesh_edge_lengths(0,0,include_ghosts=False)[0])[:,int(ny/2),:]
-lz_slice_y = np.array(_libwarpx.get_mesh_edge_lengths(0,2,include_ghosts=False)[0])[:,int(ny/2),:]
+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),:]
n_edge_x_lo = int((nx - 30)/2)
n_edge_x_hi = int(nx - (nx - 30)/2)
@@ -125,8 +125,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(_libwarpx.get_mesh_edge_lengths(0,0,include_ghosts=False)[0])[:,:,int(nz/2)]
-ly_slice_z = np.array(_libwarpx.get_mesh_edge_lengths(0,1,include_ghosts=False)[0])[:,:,int(nz/2)]
+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)]
n_edge_x_lo = int((nx - 30)/2)
n_edge_x_hi = int(nx - (nx - 30)/2)
@@ -143,9 +143,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 _libwarpx.get_mesh_face_areas =========")
+print("======== Testing pywarpx.get_mesh_face_areas =========")
-Sx_slice = np.sum(np.array(_libwarpx.get_mesh_face_areas(0,0,include_ghosts=False)[0])[int(nx/2),:,:])
+Sx_slice = np.sum(np.array(pywarpx.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 +153,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(_libwarpx.get_mesh_face_areas(0,1,include_ghosts=False)[0])[:,int(ny/2),:])
+Sy_slice = np.sum(np.array(pywarpx.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 +161,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(_libwarpx.get_mesh_face_areas(0,2,include_ghosts=False)[0])[:,:,int(nz/2)])
+Sz_slice = np.sum(np.array(pywarpx.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