diff options
author | 2017-06-06 14:25:53 -0700 | |
---|---|---|
committer | 2017-06-06 14:25:53 -0700 | |
commit | e06398df596b49a7a5f76a4d54d6873ffa35572c (patch) | |
tree | 4f584953e9c795e9f7ed5683f30f08e0672f4927 /Python | |
parent | 98d24e52a63d16a97301d742429e40982b12d106 (diff) | |
download | WarpX-e06398df596b49a7a5f76a4d54d6873ffa35572c.tar.gz WarpX-e06398df596b49a7a5f76a4d54d6873ffa35572c.tar.zst WarpX-e06398df596b49a7a5f76a4d54d6873ffa35572c.zip |
update python
Diffstat (limited to 'Python')
-rwxr-xr-x | Python/pywarpx/_libwarpx.py | 108 | ||||
-rw-r--r-- | Python/pywarpx/timestepper.py | 21 |
2 files changed, 65 insertions, 64 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py index ec87386a0..e552a2f58 100755 --- a/Python/pywarpx/_libwarpx.py +++ b/Python/pywarpx/_libwarpx.py @@ -86,14 +86,14 @@ 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_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, @@ -116,11 +116,13 @@ libwarpx.warpx_checkInt.restype = ctypes.c_int libwarpx.warpx_plotInt.restype = ctypes.c_int libwarpx.warpx_finestLevel.restype = ctypes.c_int -libwarpx.warpx_EvolveE.argtypes = [ctypes.c_int, ctypes.c_double] -libwarpx.warpx_EvolveB.argtypes = [ctypes.c_int, ctypes.c_double] -libwarpx.warpx_FillBoundaryE.argtypes = [ctypes.c_int, ctypes.c_bool] -libwarpx.warpx_FillBoundaryB.argtypes = [ctypes.c_int, ctypes.c_bool] -libwarpx.warpx_PushParticlesandDepose.argtypes = [ctypes.c_int, ctypes.c_double] +libwarpx.warpx_EvolveE.argtypes = [ctypes.c_double] +libwarpx.warpx_EvolveB.argtypes = [ctypes.c_double] +libwarpx.warpx_FillBoundaryE.argtypes = [] +libwarpx.warpx_FillBoundaryB.argtypes = [] +libwarpx.warpx_UpdateAuxilaryData.argtypes = [] +libwarpx.warpx_SyncCurrent.argtypes = [] +libwarpx.warpx_PushParticlesandDepose.argtypes = [ctypes.c_double] libwarpx.warpx_getistep.argtypes = [ctypes.c_int] libwarpx.warpx_setistep.argtypes = [ctypes.c_int, ctypes.c_int] libwarpx.warpx_gett_new.argtypes = [ctypes.c_int] @@ -187,46 +189,46 @@ 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 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=0, x=0., y=0., z=0., ux=0., uy=0., uz=0., attr=0., diff --git a/Python/pywarpx/timestepper.py b/Python/pywarpx/timestepper.py index ce0ed8c24..4f7e36209 100644 --- a/Python/pywarpx/timestepper.py +++ b/Python/pywarpx/timestepper.py @@ -21,30 +21,29 @@ class TimeStepper(object): #if (ParallelDescriptor::NProcs() > 1) # if (okToRegrid(step)) RegridBaseLevel(); - libwarpx.warpx_ComputeDt() dt = libwarpx.warpx_getdt(0) - # --- Advance level 0 by dt - lev = 0 - # --- At the beginning, we have B^{n-1/2} and E^{n}. # --- Particles have p^{n-1/2} and x^{n}. - libwarpx.warpx_EvolveB(lev, 0.5*dt) # We now B^{n} + libwarpx.warpx_FillBoundaryE() + libwarpx.warpx_EvolveB(0.5*dt) # We now B^{n} - libwarpx.warpx_FillBoundaryE(lev, False) - libwarpx.warpx_FillBoundaryB(lev, False) + libwarpx.warpx_FillBoundaryB() + libwarpx.warpx_UpdateAuxilaryData() # --- Evolve particles to p^{n+1/2} and x^{n+1} # --- Depose current, j^{n+1/2} - libwarpx.warpx_PushParticlesandDepose(lev, self.cur_time) + libwarpx.warpx_PushParticlesandDepose(self.cur_time) libwarpx.mypc_Redistribute() # Redistribute particles - libwarpx.warpx_EvolveB(lev, 0.5*dt) # We now B^{n+1/2} + libwarpx.warpx_FillBoundaryE() + libwarpx.warpx_EvolveB(0.5*dt) # We now B^{n+1/2} - libwarpx.warpx_FillBoundaryB(lev, True) + libwarpx.warpx_SyncCurrent() - libwarpx.warpx_EvolveE(lev, dt) # We now have E^{n+1} + libwarpx.warpx_FillBoundaryB() + libwarpx.warpx_EvolveE(dt) # We now have E^{n+1} self.istep += 1 |