aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx
diff options
context:
space:
mode:
Diffstat (limited to 'Python/pywarpx')
-rwxr-xr-xPython/pywarpx/_libwarpx.py70
-rw-r--r--Python/pywarpx/fields.py21
-rw-r--r--Python/pywarpx/picmi.py20
3 files changed, 108 insertions, 3 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
index 44426d624..c2c3a774b 100755
--- a/Python/pywarpx/_libwarpx.py
+++ b/Python/pywarpx/_libwarpx.py
@@ -206,6 +206,8 @@ class LibWarpX():
self.libwarpx_so.warpx_getChargeDensityFPLoVects.restype = _LP_c_int
self.libwarpx_so.warpx_getPhiFP.restype = _LP_LP_c_real
self.libwarpx_so.warpx_getPhiFPLoVects.restype = _LP_c_int
+ self.libwarpx_so.warpx_getVectorPotentialFP.restype = _LP_LP_c_real
+ self.libwarpx_so.warpx_getVectorPotentialFPLoVects.restype = _LP_c_int
self.libwarpx_so.warpx_getFfieldCP.restype = _LP_LP_c_real
self.libwarpx_so.warpx_getFfieldCPLoVects.restype = _LP_c_int
self.libwarpx_so.warpx_getFfieldFP.restype = _LP_LP_c_real
@@ -242,6 +244,9 @@ class LibWarpX():
self.libwarpx_so.warpx_getJx_nodal_flag.restype = _LP_c_int
self.libwarpx_so.warpx_getJy_nodal_flag.restype = _LP_c_int
self.libwarpx_so.warpx_getJz_nodal_flag.restype = _LP_c_int
+ self.libwarpx_so.warpx_getAx_nodal_flag.restype = _LP_c_int
+ self.libwarpx_so.warpx_getAy_nodal_flag.restype = _LP_c_int
+ self.libwarpx_so.warpx_getAz_nodal_flag.restype = _LP_c_int
self.libwarpx_so.warpx_getRho_nodal_flag.restype = _LP_c_int
self.libwarpx_so.warpx_getPhi_nodal_flag.restype = _LP_c_int
self.libwarpx_so.warpx_getF_nodal_flag.restype = _LP_c_int
@@ -1462,6 +1467,32 @@ class LibWarpX():
return self._get_mesh_field_list(self.libwarpx_so.warpx_getBfieldFP, level, direction, include_ghosts)
+ def get_mesh_vector_potential_fp(self, level, direction, include_ghosts=True):
+ '''
+
+ This returns a list of numpy arrays containing the mesh vector potential
+ data on each grid for this process. This version returns the field on
+ the fine patch for the given level.
+
+ The data for the numpy arrays are not copied, but share the underlying
+ memory buffer with WarpX. The numpy arrays are fully writeable.
+
+ Parameters
+ ----------
+
+ level : the AMR level to get the data for
+ direction : the component of the data you want
+ include_ghosts : whether to include ghost zones or not
+
+ Returns
+ -------
+
+ A List of numpy arrays.
+
+ '''
+
+ return self._get_mesh_field_list(self.libwarpx_so.warpx_getVectorPotentialFP, level, direction, include_ghosts)
+
def get_mesh_magnetic_field_cp_pml(self, level, direction, include_ghosts=True):
'''
@@ -2199,6 +2230,27 @@ class LibWarpX():
'''
return self._get_mesh_array_lovects(level, direction, include_ghosts, self.libwarpx_so.warpx_getBfieldFPLoVects)
+ def get_mesh_vector_potential_fp_lovects(self, level, direction, include_ghosts=True):
+ '''
+
+ This returns a list of the lo vectors of the arrays containing the mesh vector potential field
+ data on each grid for this process.
+
+ Parameters
+ ----------
+
+ level : the AMR level to get the data for
+ direction : the component of the data you want
+ include_ghosts : whether to include ghost zones or not
+
+ Returns
+ -------
+
+ A 2d numpy array of the lo vector for each grid with the shape (dims, number of grids)
+
+ '''
+ return self._get_mesh_array_lovects(level, direction, include_ghosts, self.libwarpx_so.warpx_getVectorPotentialFPLoVects)
+
def get_mesh_magnetic_field_cp_lovects_pml(self, level, direction, include_ghosts=True):
'''
@@ -2700,6 +2752,24 @@ class LibWarpX():
'''
return self._get_nodal_flag(self.libwarpx_so.warpx_getJz_nodal_flag)
+ def get_Ax_nodal_flag(self):
+ '''
+ This returns a 1d array of the nodal flags for Ax along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return self._get_nodal_flag(self.libwarpx_so.warpx_getAx_nodal_flag)
+
+ def get_Ay_nodal_flag(self):
+ '''
+ This returns a 1d array of the nodal flags for Ay along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return self._get_nodal_flag(self.libwarpx_so.warpx_getAy_nodal_flag)
+
+ def get_Az_nodal_flag(self):
+ '''
+ This returns a 1d array of the nodal flags for Az along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return self._get_nodal_flag(self.libwarpx_so.warpx_getAz_nodal_flag)
+
def get_Rho_nodal_flag(self):
'''
This returns a 1d array of the nodal flags for Rho along each direction. A 1 means node centered, and 0 cell centered.
diff --git a/Python/pywarpx/fields.py b/Python/pywarpx/fields.py
index 56ab6fd2e..2577902c4 100644
--- a/Python/pywarpx/fields.py
+++ b/Python/pywarpx/fields.py
@@ -669,6 +669,27 @@ def PhiFPWrapper(level=0, include_ghosts=False):
get_nodal_flag=libwarpx.get_Phi_nodal_flag,
level=level, include_ghosts=include_ghosts)
+def AxFPWrapper(level=0, include_ghosts=False):
+ return _MultiFABWrapper(direction=0,
+ get_lovects=libwarpx.get_mesh_vector_potential_fp_lovects,
+ get_fabs=libwarpx.get_mesh_vector_potential_fp,
+ get_nodal_flag=libwarpx.get_Ax_nodal_flag,
+ level=level, include_ghosts=include_ghosts)
+
+def AyFPWrapper(level=0, include_ghosts=False):
+ return _MultiFABWrapper(direction=1,
+ get_lovects=libwarpx.get_mesh_vector_potential_fp_lovects,
+ get_fabs=libwarpx.get_mesh_vector_potential_fp,
+ get_nodal_flag=libwarpx.get_Ay_nodal_flag,
+ level=level, include_ghosts=include_ghosts)
+
+def AzFPWrapper(level=0, include_ghosts=False):
+ return _MultiFABWrapper(direction=2,
+ get_lovects=libwarpx.get_mesh_vector_potential_fp_lovects,
+ get_fabs=libwarpx.get_mesh_vector_potential_fp,
+ get_nodal_flag=libwarpx.get_Az_nodal_flag,
+ level=level, include_ghosts=include_ghosts)
+
def FFPWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(direction=None,
get_lovects=libwarpx.get_mesh_F_fp_lovects,
diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py
index aac083af0..dff224d07 100644
--- a/Python/pywarpx/picmi.py
+++ b/Python/pywarpx/picmi.py
@@ -73,6 +73,10 @@ class Species(picmistandard.PICMI_Species):
Whether or not to deposit the charge and current density for
for this species
+ warpx_random_theta: bool, default=True
+ Whether or not to add random angle to the particles in theta
+ when in RZ mode.
+
warpx_reflection_model_xlo: string, default='0.'
Expression (in terms of the velocity "v") specifying the probability
that the particle will reflect on the lower x boundary
@@ -170,6 +174,7 @@ class Species(picmistandard.PICMI_Species):
self.self_fields_verbosity = kw.pop('warpx_self_fields_verbosity', None)
self.save_previous_position = kw.pop('warpx_save_previous_position', None)
self.do_not_deposit = kw.pop('warpx_do_not_deposit', None)
+ self.random_theta = kw.pop('warpx_random_theta', None)
# For particle reflection
self.reflection_model_xlo = kw.pop('warpx_reflection_model_xlo', None)
@@ -221,7 +226,8 @@ class Species(picmistandard.PICMI_Species):
save_particles_at_zhi = self.save_particles_at_zhi,
save_particles_at_eb = self.save_particles_at_eb,
save_previous_position = self.save_previous_position,
- do_not_deposit = self.do_not_deposit)
+ do_not_deposit = self.do_not_deposit,
+ random_theta = self.random_theta)
# add reflection models
self.species.add_new_attr("reflection_model_xlo(E)", self.reflection_model_xlo)
@@ -988,6 +994,7 @@ class ElectrostaticSolver(picmistandard.PICMI_ElectrostaticSolver):
self.relativistic = kw.pop('warpx_relativistic', False)
self.absolute_tolerance = kw.pop('warpx_absolute_tolerance', None)
self.self_fields_verbosity = kw.pop('warpx_self_fields_verbosity', None)
+ self.magnetostatic = kw.pop('warpx_magnetostatic', False)
def initialize_inputs(self):
@@ -996,7 +1003,10 @@ class ElectrostaticSolver(picmistandard.PICMI_ElectrostaticSolver):
if self.relativistic:
pywarpx.warpx.do_electrostatic = 'relativistic'
else:
- pywarpx.warpx.do_electrostatic = 'labframe'
+ if self.magnetostatic:
+ pywarpx.warpx.do_electrostatic = 'labframe-electromagnetostatic'
+ else:
+ pywarpx.warpx.do_electrostatic = 'labframe'
pywarpx.warpx.self_fields_required_precision = self.required_precision
pywarpx.warpx.self_fields_absolute_tolerance = self.absolute_tolerance
pywarpx.warpx.self_fields_max_iters = self.maximum_iterations
@@ -1748,7 +1758,11 @@ class FieldDiagnostic(picmistandard.PICMI_FieldDiagnostic, WarpXDiagnosticBase):
fields_to_plot.add('jx')
fields_to_plot.add('jy')
fields_to_plot.add('jz')
- elif dataname in ['Ex', 'Ey', 'Ez', 'Bx', 'By', 'Bz', 'rho', 'phi', 'F', 'proc_number', 'part_per_cell']:
+ elif dataname == 'A':
+ fields_to_plot.add('Ax')
+ fields_to_plot.add('Ay')
+ fields_to_plot.add('Az')
+ elif dataname in ['Ex', 'Ey', 'Ez', 'Bx', 'By', 'Bz', 'Ax', 'Ay', 'Az', 'rho', 'phi', 'F', 'proc_number', 'part_per_cell']:
fields_to_plot.add(dataname)
elif dataname in ['Jx', 'Jy', 'Jz']:
fields_to_plot.add(dataname.lower())