aboutsummaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/pywarpx/HybridPICModel.py11
-rw-r--r--Python/pywarpx/WarpX.py2
-rw-r--r--Python/pywarpx/__init__.py1
-rwxr-xr-xPython/pywarpx/_libwarpx.py32
-rw-r--r--Python/pywarpx/fields.py21
-rw-r--r--Python/pywarpx/picmi.py58
6 files changed, 125 insertions, 0 deletions
diff --git a/Python/pywarpx/HybridPICModel.py b/Python/pywarpx/HybridPICModel.py
new file mode 100644
index 000000000..e21bba4a2
--- /dev/null
+++ b/Python/pywarpx/HybridPICModel.py
@@ -0,0 +1,11 @@
+# Copyright 2023 The WarpX Community
+#
+# This file is part of WarpX.
+#
+# Authors: Roelof Groenewald (TAE Technologies)
+#
+# License: BSD-3-Clause-LBNL
+
+from .Bucket import Bucket
+
+hybridpicmodel = Bucket('hybrid_pic_model')
diff --git a/Python/pywarpx/WarpX.py b/Python/pywarpx/WarpX.py
index e8c170a76..79b248617 100644
--- a/Python/pywarpx/WarpX.py
+++ b/Python/pywarpx/WarpX.py
@@ -18,6 +18,7 @@ from .Constants import my_constants
from .Diagnostics import diagnostics, reduced_diagnostics
from .EB2 import eb2
from .Geometry import geometry
+from .HybridPICModel import hybridpicmodel
from .Interpolation import interpolation
from .Langmuirwave import langmuirwave
from .Lasers import lasers, lasers_list
@@ -43,6 +44,7 @@ class WarpX(Bucket):
argv += amr.attrlist()
argv += amrex.attrlist()
argv += geometry.attrlist()
+ argv += hybridpicmodel.attrlist()
argv += boundary.attrlist()
argv += algo.attrlist()
argv += langmuirwave.attrlist()
diff --git a/Python/pywarpx/__init__.py b/Python/pywarpx/__init__.py
index 5000180f3..1e80ccfdf 100644
--- a/Python/pywarpx/__init__.py
+++ b/Python/pywarpx/__init__.py
@@ -13,6 +13,7 @@ from .Constants import my_constants
from .Diagnostics import diagnostics, reduced_diagnostics
from .EB2 import eb2
from .Geometry import geometry
+from .HybridPICModel import hybridpicmodel
from .Interpolation import interpolation
from .Langmuirwave import langmuirwave
from .Lasers import lasers
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
index 02ca22afb..ebd18e5ee 100755
--- a/Python/pywarpx/_libwarpx.py
+++ b/Python/pywarpx/_libwarpx.py
@@ -200,6 +200,7 @@ class LibWarpX():
self.libwarpx_so.warpx_getCurrentDensityCPLoVects_PML.restype = _LP_c_int
self.libwarpx_so.warpx_getCurrentDensityFP_PML.restype = _LP_LP_c_real
self.libwarpx_so.warpx_getCurrentDensityFPLoVects_PML.restype = _LP_c_int
+ self.libwarpx_so.warpx_getCurrentDensityFP_Ampere.restype = _LP_LP_c_real
self.libwarpx_so.warpx_getChargeDensityCP.restype = _LP_LP_c_real
self.libwarpx_so.warpx_getChargeDensityCPLoVects.restype = _LP_c_int
self.libwarpx_so.warpx_getChargeDensityFP.restype = _LP_LP_c_real
@@ -1711,6 +1712,37 @@ class LibWarpX():
except ValueError:
raise Exception('PML not initialized')
+ def get_mesh_current_density_fp_ampere(self, level, direction, include_ghosts=True):
+ '''
+
+ This returns a list of numpy arrays containing the mesh current density
+ data on each grid for this process calculated from the curl of B. This
+ quantity is calculated in the kinetic-fluid hybrid model to get the
+ electron current. This function returns the current density 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.
+
+ '''
+
+ try:
+ return self._get_mesh_field_list(self.libwarpx_so.warpx_getCurrentDensityFP_Ampere, level, direction, include_ghosts)
+ except ValueError:
+ raise Exception('Current multifab not allocated.')
+
def get_mesh_charge_density_cp(self, level, include_ghosts=True):
'''
diff --git a/Python/pywarpx/fields.py b/Python/pywarpx/fields.py
index 2577902c4..40ce6aa4a 100644
--- a/Python/pywarpx/fields.py
+++ b/Python/pywarpx/fields.py
@@ -897,6 +897,27 @@ def JzFPPMLWrapper(level=0, include_ghosts=False):
get_nodal_flag=libwarpx.get_Jz_nodal_flag,
level=level, include_ghosts=include_ghosts)
+def JxFPAmpereWrapper(level=0, include_ghosts=False):
+ return _MultiFABWrapper(direction=0,
+ get_lovects=libwarpx.get_mesh_current_density_fp_lovects,
+ get_fabs=libwarpx.get_mesh_current_density_fp_ampere,
+ get_nodal_flag=libwarpx.get_Jx_nodal_flag,
+ level=level, include_ghosts=include_ghosts)
+
+def JyFPAmpereWrapper(level=0, include_ghosts=False):
+ return _MultiFABWrapper(direction=1,
+ get_lovects=libwarpx.get_mesh_current_density_fp_lovects,
+ get_fabs=libwarpx.get_mesh_current_density_fp_ampere,
+ get_nodal_flag=libwarpx.get_Jy_nodal_flag,
+ level=level, include_ghosts=include_ghosts)
+
+def JzFPAmpereWrapper(level=0, include_ghosts=False):
+ return _MultiFABWrapper(direction=2,
+ get_lovects=libwarpx.get_mesh_current_density_fp_lovects,
+ get_fabs=libwarpx.get_mesh_current_density_fp_ampere,
+ get_nodal_flag=libwarpx.get_Jz_nodal_flag,
+ level=level, include_ghosts=include_ghosts)
+
def FFPPMLWrapper(level=0, include_ghosts=False):
return _MultiFABWrapper(direction=None,
get_lovects=libwarpx.get_mesh_F_fp_lovects_pml,
diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py
index 8e4860078..621757132 100644
--- a/Python/pywarpx/picmi.py
+++ b/Python/pywarpx/picmi.py
@@ -889,6 +889,7 @@ class Cartesian3DGrid(picmistandard.PICMI_Cartesian3DGrid):
else:
pywarpx.amr.max_level = 0
+
class ElectromagneticSolver(picmistandard.PICMI_ElectromagneticSolver):
"""
See `Input Parameters <https://warpx.readthedocs.io/en/latest/usage/parameters.html>`_ for more information.
@@ -998,6 +999,63 @@ class ElectromagneticSolver(picmistandard.PICMI_ElectromagneticSolver):
pywarpx.warpx.pml_has_particles = self.pml_has_particles
pywarpx.warpx.do_pml_j_damping = self.do_pml_j_damping
+
+class HybridPICSolver(picmistandard.base._ClassWithInit):
+ """
+ Hybrid-PIC solver based on Ohm's law.
+ See `Theory Section <https://warpx.readthedocs.io/en/latest/theory/kinetic_fluid_hybrid_model.html>`_ for more information.
+
+ Parameters
+ ----------
+ Te: float
+ Electron temperature in eV.
+
+ n0: float
+ Reference plasma density in m^-3.
+
+ gamma: float, default=3/2
+ Exponent in calculation of electron pressure.
+
+ n_floor: float, optional
+ Minimum density used in Ohm's law calculation.
+
+ plasma_resistivity: float or str
+ Value or expression to use for the plasma resistivity.
+
+ substeps: int, default=100
+ Number of substeps to take when updating the B-field.
+ """
+ def __init__(self, grid, Te=None, n0=None, gamma=None,
+ n_floor=None, plasma_resistivity=None, substeps=None, **kw):
+ self.grid = grid
+ self.method = "hybrid"
+
+ self.Te = Te
+ self.n0 = n0
+ self.gamma = gamma
+ self.n_floor = n_floor
+ self.plasma_resistivity = plasma_resistivity
+
+ self.substeps = substeps
+
+ self.handle_init(kw)
+
+ def initialize_inputs(self):
+
+ self.grid.initialize_inputs()
+
+ pywarpx.algo.maxwell_solver = self.method
+
+ pywarpx.hybridpicmodel.elec_temp = self.Te
+ pywarpx.hybridpicmodel.n0_ref = self.n0
+ pywarpx.hybridpicmodel.gamma = self.gamma
+ pywarpx.hybridpicmodel.n_floor = self.n_floor
+ pywarpx.hybridpicmodel.__setattr__(
+ 'plasma_resistivity(rho)', self.plasma_resistivity
+ )
+ pywarpx.hybridpicmodel.substeps = self.substeps
+
+
class ElectrostaticSolver(picmistandard.PICMI_ElectrostaticSolver):
"""
See `Input Parameters <https://warpx.readthedocs.io/en/latest/usage/parameters.html>`_ for more information.