diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pywarpx/WarpXPIC.py | 64 | ||||
-rw-r--r-- | Python/pywarpx/timestepper.py | 81 |
2 files changed, 0 insertions, 145 deletions
diff --git a/Python/pywarpx/WarpXPIC.py b/Python/pywarpx/WarpXPIC.py deleted file mode 100644 index a2efaffbd..000000000 --- a/Python/pywarpx/WarpXPIC.py +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2017 David Grote -# -# This file is part of WarpX. -# -# License: BSD-3-Clause-LBNL - -# The WarpXPIC class is the beginnings of an implementation of a standard interface -# for running PIC codes. This is the run time equivalent to the PICMI standard. -# This standard would specify the API for calling the various pieces of typical -# time step loops, for example get_self_fields and put_Efields. Ideally, a user -# could write a loop using the standard and, importing one of compliant codes, be -# able to run a customized PIC simulation with that code. - -from warp.run_modes.timestepper import PICAPI - -from ._libwarpx import libwarpx - - -class WarpXPIC(PICAPI): - - def get_time(self): - return libwarpx.libwarpx_so.warpx_gett_new(0) - - def set_time(self, time): - for i in range(libwarpx.libwarpx_so.warpx_finestLevel()+1): - libwarpx.libwarpx_so.warpx_sett_new(i, time) - - def get_step_size(self): - libwarpx.libwarpx_so.warpx_ComputeDt() - return libwarpx.libwarpx_so.warpx_getdt(0) - - def get_step_number(self): - return libwarpx.libwarpx_so.warpx_getistep(0) - - def set_step_number(self, it): - for i in range(libwarpx.libwarpx_so.warpx_finestLevel()+1): - libwarpx.libwarpx_so.warpx_setistep(i, it) - - def push_positions(self, dt): - libwarpx.libwarpx_so.warpx_PushX(0, dt) - - def push_velocities_withE(self, dt): - libwarpx.libwarpx_so.warpx_EPushV(0, dt) - - def push_velocities_withB(self, dt): - libwarpx.libwarpx_so.warpx_BPushV(0, dt) - - def get_self_fields(self): - libwarpx.libwarpx_so.warpx_FieldGather(0) - - def calculate_source(self): - libwarpx.libwarpx_so.warpx_CurrentDeposition(0) - - def push_Efields(self, dt): - libwarpx.libwarpx_so.warpx_EvolveE(0, dt) - libwarpx.libwarpx_so.warpx_FillBoundaryE(0, True) - - def push_Bfields(self, dt): - libwarpx.libwarpx_so.warpx_EvolveB(0, dt) - libwarpx.libwarpx_so.warpx_FillBoundaryB(0, True) - - def apply_particle_boundary_conditions(self): - libwarpx.libwarpx_so.mypc_Redistribute() # Redistribute particles - libwarpx.libwarpx_so.warpx_MoveWindow(self.istep,True) # !!! not the correct place yet diff --git a/Python/pywarpx/timestepper.py b/Python/pywarpx/timestepper.py deleted file mode 100644 index de341097a..000000000 --- a/Python/pywarpx/timestepper.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2017-2021 Andrew Myers, David Grote, Weiqun Zhang -# -# -# This file is part of WarpX. -# -# License: BSD-3-Clause-LBNL - -# This is intended to be a Python level example of how one might write a customized -# time stepping loop. This would replace the functionality of the WarpX::Evolve routine. -# Wrappers are available for the major pieces of a time step and they would be called -# here in the appropriate order. -# Note that this is intended to be an example only and may not be functional. The -# onestep routine as written here is out of date and is not consistent with WarpX::Evolve. - -from . import callbacks, libwarpx - - -class TimeStepper(object): - - def step(self, nsteps=1): - for i in range(nsteps): - self.onestep() - - def onestep(self): - - callbacks._beforestep() - - self.cur_time = libwarpx.libwarpx_so.warpx_gett_new(0) - self.istep = libwarpx.libwarpx_so.warpx_getistep(0) - - #if mpi.rank == 0: - print("\nSTEP %d starts ..."%(self.istep + 1)) - - #if (ParallelDescriptor::NProcs() > 1) - # if (okToRegrid(step)) RegridBaseLevel(); - - dt = libwarpx.libwarpx_so.warpx_getdt(0) - - # --- At the beginning, we have B^{n-1/2} and E^{n}. - # --- Particles have p^{n-1/2} and x^{n}. - libwarpx.libwarpx_so.warpx_FillBoundaryE() - libwarpx.libwarpx_so.warpx_EvolveB(0.5*dt,1) # We now B^{n} - - libwarpx.libwarpx_so.warpx_FillBoundaryB() - libwarpx.libwarpx_so.warpx_UpdateAuxilaryData() - - # --- Evolve particles to p^{n+1/2} and x^{n+1} - # --- Depose current, j^{n+1/2} - callbacks._particleinjection() - callbacks._particlescraper() - callbacks._beforedeposition() - libwarpx.libwarpx_so.warpx_PushParticlesandDepose(self.cur_time) - callbacks._afterdeposition() - - libwarpx.libwarpx_so.mypc_Redistribute() # Redistribute particles - - libwarpx.libwarpx_so.warpx_FillBoundaryE() - libwarpx.libwarpx_so.warpx_EvolveB(0.5*dt,2) # We now B^{n+1/2} - - libwarpx.libwarpx_so.warpx_SyncCurrent() - - libwarpx.libwarpx_so.warpx_FillBoundaryB() - callbacks._beforeEsolve() - libwarpx.libwarpx_so.warpx_EvolveE(dt,0) # We now have E^{n+1} - callbacks._afterEsolve() - - self.istep += 1 - - self.cur_time += dt - - libwarpx.libwarpx_so.warpx_MoveWindow(self.istep,True); - - #if mpi.rank == 0: - print("STEP %d ends. TIME = %e DT = %e"%(self.istep, self.cur_time, dt)) - - # --- Sync up time - for i in range(libwarpx.libwarpx_so.warpx_finestLevel()+1): - libwarpx.libwarpx_so.warpx_sett_new(i, self.cur_time) - libwarpx.libwarpx_so.warpx_setistep(i, self.istep) - - callbacks._afterstep() |