diff options
author | 2017-04-29 01:23:49 +0000 | |
---|---|---|
committer | 2017-04-29 01:23:49 +0000 | |
commit | 902894c1fbc3b4384fea8331f98cd59e3361d3e1 (patch) | |
tree | 835669672c87ca5e3112bb3f48a69abd564930ee /Python | |
parent | 422ee811252b4c572731d1fa9f6436fbda73cd6a (diff) | |
parent | ccfb202f7fa7bf733507d3509e93447ebe8e2748 (diff) | |
download | WarpX-902894c1fbc3b4384fea8331f98cd59e3361d3e1.tar.gz WarpX-902894c1fbc3b4384fea8331f98cd59e3361d3e1.tar.zst WarpX-902894c1fbc3b4384fea8331f98cd59e3361d3e1.zip |
Merged in pml (pull request #21)
Pml (don't merge)
Approved-by: Andrew Myers <atmyers2@gmail.com>
Diffstat (limited to 'Python')
-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): ''' |