diff options
author | 2017-04-26 17:43:35 -0700 | |
---|---|---|
committer | 2017-04-26 17:43:35 -0700 | |
commit | 4e4a6dff286e03675875296886ece284b3d694e2 (patch) | |
tree | 4d7cebf0e4cb5ef91c3c446a3c0f583dd56a1a32 /Python/pywarpx/_libwarpx.py | |
parent | 0722d7f8af87a169a217ff09c2e7ee8a51b74089 (diff) | |
download | WarpX-4e4a6dff286e03675875296886ece284b3d694e2.tar.gz WarpX-4e4a6dff286e03675875296886ece284b3d694e2.tar.zst WarpX-4e4a6dff286e03675875296886ece284b3d694e2.zip |
Add functions to the python wrappers to get / set the PML coefficients from Python.
Diffstat (limited to 'Python/pywarpx/_libwarpx.py')
-rwxr-xr-x | Python/pywarpx/_libwarpx.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py index 054d8b11f..07caa6763 100755 --- a/Python/pywarpx/_libwarpx.py +++ b/Python/pywarpx/_libwarpx.py @@ -19,6 +19,7 @@ def get_package_root(): return '' cur = os.path.dirname(cur) + libwarpx = ctypes.CDLL(os.path.join(get_package_root(), "libwarpx.so")) libc = ctypes.CDLL(find_library('c')) @@ -82,6 +83,15 @@ f.restype = LP_LP_c_double f = libwarpx.warpx_getCurrentDensity f.restype = LP_LP_c_double +f = libwarpx.warpx_getPMLSigma +f.restype = LP_c_double + +f = libwarpx.warpx_getPMLSigmaStar +f.restype = LP_c_double + +f = libwarpx.warpx_ComputePMLFactors +f.argtypes = (ctypes.c_int, ctypes.c_double) + f = libwarpx.warpx_addNParticles f.argtypes = (ctypes.c_int, ctypes.c_int, ndpointer(ctypes.c_double, flags="C_CONTIGUOUS"), @@ -153,6 +163,7 @@ def finalize(): libwarpx.warpx_finalize() libwarpx.amrex_finalize() + def evolve(num_steps=-1): ''' @@ -169,6 +180,48 @@ def evolve(num_steps=-1): libwarpx.warpx_evolve(num_steps); + +def get_sigma(direction): + ''' + + Return the 'sigma' PML coefficients for the electric field + in a given direction. + + ''' + + size = ctypes.c_int(0) + data = libwarpx.warpx_getPMLSigma(direction, ctypes.byref(size)) + arr = np.ctypeslib.as_array(data, (size.value,)) + arr.setflags(write=1) + return arr + + +def get_sigma_star(direction): + ''' + + Return the 'sigma*' PML coefficients for the magnetic field + in the given direction. + + ''' + + size = ctypes.c_int(0) + data = libwarpx.warpx_getPMLSigmaStar(direction, ctypes.byref(size)) + arr = np.ctypeslib.as_array(data, (size.value,)) + arr.setflags(write=1) + return arr + + +def compute_pml_factors(lev, dt): + ''' + + This recomputes the PML coefficients for a given level, using the + time step dt. This needs to be called after modifying the coefficients + from Python. + + ''' + + libwarpx.warpx_ComputePMLFactors(lev, dt) + def add_particles(species_number, x, y, z, ux, uy, uz, attr, unique_particles): ''' |