diff options
author | 2022-11-23 17:45:04 -0800 | |
---|---|---|
committer | 2022-11-24 01:45:04 +0000 | |
commit | 8978f6711d63b29709cd119afc3eadea7256bef2 (patch) | |
tree | 459e197da5ef2a5c1772edd90151b3bab567535b /Python/pywarpx/picmi.py | |
parent | 9ba3e9222c3e6c0f1e9fefdd527fe4e3dca2a212 (diff) | |
download | WarpX-8978f6711d63b29709cd119afc3eadea7256bef2.tar.gz WarpX-8978f6711d63b29709cd119afc3eadea7256bef2.tar.zst WarpX-8978f6711d63b29709cd119afc3eadea7256bef2.zip |
allow initial fields to be set through the picmi interface (#3536)
Diffstat (limited to '')
-rw-r--r-- | Python/pywarpx/picmi.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index 9399fd926..5a970ffdf 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -1084,6 +1084,35 @@ class LaserAntenna(picmistandard.PICMI_LaserAntenna): ) / constants.c +class AnalyticInitialField(picmistandard.PICMI_AnalyticAppliedField): + def init(self, kw): + self.mangle_dict = None + + def initialize_inputs(self): + # Note that lower and upper_bound are not used by WarpX + + if self.mangle_dict is None: + # Only do this once so that the same variables are used in this distribution + # is used multiple times + self.mangle_dict = pywarpx.my_constants.add_keywords(self.user_defined_kw) + + if (self.Ex_expression is not None or + self.Ey_expression is not None or + self.Ez_expression is not None): + pywarpx.warpx.E_ext_grid_init_style = 'parse_e_ext_grid_function' + for sdir, expression in zip(['x', 'y', 'z'], [self.Ex_expression, self.Ey_expression, self.Ez_expression]): + expression = pywarpx.my_constants.mangle_expression(expression, self.mangle_dict) + pywarpx.warpx.__setattr__(f'E{sdir}_external_grid_function(x,y,z)', expression) + + if (self.Bx_expression is not None or + self.By_expression is not None or + self.Bz_expression is not None): + pywarpx.warpx.B_ext_grid_init_style = 'parse_b_ext_grid_function' + for sdir, expression in zip(['x', 'y', 'z'], [self.Bx_expression, self.By_expression, self.Bz_expression]): + expression = pywarpx.my_constants.mangle_expression(expression, self.mangle_dict) + pywarpx.warpx.__setattr__(f'B{sdir}_external_grid_function(x,y,z)', expression) + + class ConstantAppliedField(picmistandard.PICMI_ConstantAppliedField): def initialize_inputs(self): # Note that lower and upper_bound are not used by WarpX |