Skip to content

Commit

Permalink
Updates to picmi, mostly related to fields, and add psatd
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote committed Jun 5, 2020
1 parent 19388ad commit 8b2e985
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
9 changes: 9 additions & 0 deletions Python/pywarpx/PSATD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2016 David Grote
#
# This file is part of WarpX.
#
# License: BSD-3-Clause-LBNL

from .Bucket import Bucket

psatd = Bucket('psatd')
2 changes: 2 additions & 0 deletions Python/pywarpx/WarpX.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .Lasers import lasers, lasers_list
from . import Particles
from .Particles import particles, particles_list
from .PSATD import psatd
from .Diagnostics import diagnostics


Expand All @@ -32,6 +33,7 @@ def create_argv_list(self):
argv += algo.attrlist()
argv += langmuirwave.attrlist()
argv += interpolation.attrlist()
argv += psatd.attrlist()

# --- Search through species_names and add any predefined particle objects in the list.
particles_list_names = [p.instancename for p in particles_list]
Expand Down
1 change: 1 addition & 0 deletions Python/pywarpx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
from .Langmuirwave import langmuirwave
from .Interpolation import interpolation
from .Particles import particles, electrons, positrons, protons, newspecies
from .PSATD import psatd
from .Lasers import lasers
from .Diagnostics import diagnostics
33 changes: 28 additions & 5 deletions Python/pywarpx/picmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def initialize_inputs(self):
pywarpx.warpx.moving_window_dir = 'x'
pywarpx.warpx.moving_window_v = self.moving_window_velocity[0]/constants.c # in units of the speed of light
if self.moving_window_velocity[1] != 0.:
pywarpx.warpx.moving_window_dir = 'y'
pywarpx.warpx.moving_window_dir = 'z'
pywarpx.warpx.moving_window_v = self.moving_window_velocity[1]/constants.c # in units of the speed of light

if self.refined_regions:
Expand Down Expand Up @@ -445,20 +445,40 @@ def initialize_inputs(self):

class ElectromagneticSolver(picmistandard.PICMI_ElectromagneticSolver):
def init(self, kw):
assert self.method is None or self.method in ['Yee', 'CKC'], Exception("Only 'Yee' and 'CKC' FDTD are supported")
assert self.method is None or self.method in ['Yee', 'CKC', 'PSATD'], Exception("Only 'Yee', 'CKC', and 'PSATD' are supported")

self.do_pml = kw.pop('warpx_do_pml', None)
self.pml_ncell = kw.pop('warpx_pml_ncell', None)

if self.method == 'PSATD':
self.periodic_single_box_fft = kw.pop('warpx_periodic_single_box_fft', None)
self.fftw_plan_measure = kw.pop('warpx_fftw_plan_measure', None)
self.do_current_correction = kw.pop('warpx_do_current_correction', None)

def initialize_inputs(self):

self.grid.initialize_inputs()

pywarpx.warpx.do_pml = self.do_pml
pywarpx.warpx.pml_ncell = self.pml_ncell
pywarpx.warpx.do_nodal = self.l_nodal

if self.method == 'PSATD':
pywarpx.psatd.periodic_single_box_fft = self.periodic_single_box_fft
pywarpx.psatd.fftw_plan_measure = self.fftw_plan_measure
pywarpx.psatd.do_current_correction = self.do_current_correction

# --- Same method names are used, though mapped to lower case.
pywarpx.algo.maxwell_fdtd_solver = self.method
if self.stencil_order is not None:
pywarpx.psatd.nox = self.stencil_order[0]
pywarpx.psatd.noy = self.stencil_order[1]
pywarpx.psatd.noz = self.stencil_order[2]

if self.galilean_velocity is not None:
pywarpx.psatd.v_galilean = np.array(self.galilean_velocity)/constants.c

else:
# --- Same method names are used, though mapped to lower case.
pywarpx.algo.maxwell_fdtd_solver = self.method

if self.cfl is not None:
pywarpx.warpx.cfl = self.cfl
Expand Down Expand Up @@ -530,6 +550,7 @@ def init(self, kw):
self.do_dynamic_scheduling = kw.pop('warpx_do_dynamic_scheduling', None)
self.load_balance_int = kw.pop('warpx_load_balance_int', None)
self.load_balance_with_sfc = kw.pop('warpx_load_balance_with_sfc', None)
self.use_fdtd_nci_corr = kw.pop('warpx_use_fdtd_nci_corr', None)

self.inputs_initialized = False
self.warpx_initialized = False
Expand All @@ -546,7 +567,7 @@ def initialize_inputs(self):

if self.gamma_boost is not None:
pywarpx.warpx.gamma_boost = self.gamma_boost
pywarpx.warpx.boost_direction = None
pywarpx.warpx.boost_direction = 'z'

pywarpx.algo.current_deposition = self.current_deposition_algo
pywarpx.algo.charge_deposition = self.charge_deposition_algo
Expand All @@ -560,6 +581,8 @@ def initialize_inputs(self):
pywarpx.warpx.load_balance_int = self.load_balance_int
pywarpx.warpx.load_balance_with_sfc = self.load_balance_with_sfc

pywarpx.particles.use_fdtd_nci_corr = self.use_fdtd_nci_corr

particle_shape = self.particle_shape
for s in self.species:
if s.particle_shape is not None:
Expand Down

0 comments on commit 8b2e985

Please sign in to comment.