From e6cd2bf5c2f7e6ffdb4dc2a1a5cec238a90c9415 Mon Sep 17 00:00:00 2001 From: Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com> Date: Wed, 21 Jul 2021 18:13:51 -0700 Subject: PICMI - Embedded boundary (#2104) * added functionality to picmi.py to allow an embedded boundary to be set from a python run script * added test: embedded sphere run from python (the test is the same as ElectrostaticSphereEB) * added a line to prepare_file_travis.py so that tests with USE_EB=True are not included in Python CI test list * fixed import path in analysis.py file for new test * added WarpX_EB flag to setup.py so that embedded boundary functionality can be included in pip installs of pywarpx --- Python/pywarpx/picmi.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Python/pywarpx/picmi.py') diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index 63c9143aa..570416aaf 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -715,6 +715,22 @@ class Mirror(picmistandard.PICMI_Mirror): pywarpx.warpx.mirror_z_npoints.append(self.number_of_cells) +class EmbeddedBoundary(picmistandard.base._ClassWithInit): + """Custom class to handle set up of embedded boundaries in WarpX. If + embedded boundary initialization is added to picmistandard this can be + changed to inherit that functionality.""" + + def __init__(self, implicit_function, potential=None, **kw): + self.implicit_function = implicit_function + self.potential = potential + + self.handle_init(kw) + + def initialize_inputs(self): + pywarpx.warpx.eb_implicit_function = self.implicit_function + pywarpx.warpx.__setattr__('eb_potential(t)', self.potential) + + class Simulation(picmistandard.PICMI_Simulation): def init(self, kw): @@ -735,6 +751,8 @@ class Simulation(picmistandard.PICMI_Simulation): self.use_fdtd_nci_corr = kw.pop('warpx_use_fdtd_nci_corr', None) self.amr_check_input = kw.pop('warpx_amr_check_input', None) + self.embedded_boundary = kw.pop('warpx_embedded_boundary', None) + self.inputs_initialized = False self.warpx_initialized = False @@ -795,6 +813,9 @@ class Simulation(picmistandard.PICMI_Simulation): self.injection_plane_positions[i], self.injection_plane_normal_vectors[i]) + if self.embedded_boundary is not None: + self.embedded_boundary.initialize_inputs() + for i in range(len(self.lasers)): self.lasers[i].initialize_inputs() self.laser_injection_methods[i].initialize_inputs(self.lasers[i]) -- cgit v1.2.3