diff options
author | 2023-02-22 15:37:06 -0800 | |
---|---|---|
committer | 2023-02-22 23:37:06 +0000 | |
commit | ce188a26a22c99f5c4b297c9ffab6fc3c5c0e180 (patch) | |
tree | 37fc08a79ede3d4214ddc06071539260c24ec45d /Python | |
parent | 1bf7133bb89aed59c84d13619bd061640e5451a6 (diff) | |
download | WarpX-ce188a26a22c99f5c4b297c9ffab6fc3c5c0e180.tar.gz WarpX-ce188a26a22c99f5c4b297c9ffab6fc3c5c0e180.tar.zst WarpX-ce188a26a22c99f5c4b297c9ffab6fc3c5c0e180.zip |
Reduced diagnostics: charge on the embedded boundary (#3648)
* Prepare structure to compute charge inside boundary
* Add calculation without embedded boundaries
* Use EB area fraction
* Skip cells that are not cut-cells
* Choose point outside of the EB
* Skip covered or regular boxes
* Only compile with EB and 3D support
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add test for charge on EB
* Add automated test
* Add automated Python test
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Avoid compilation error
* Enable PICMI test
* Rename ChargeInsideBoundary to ChargeOnEB
* Update comments
* Add parser for weighting
* Call weighting function
* Call weighting function
* Add documentation
* Update Python test
* Add Python test
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix compilation errors
* Fix access of attribute on GPU
* Use difference in surface area
* Pick smaller radius in test
This is in order to avoid the influence of the boundaries
* Update benchmark
* Update benchmark
* Properly add diagnostic
* Update radius in analysis
* Update analysis script
* Relax tolerance
* Fix tests
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update Python tests
* Apply suggestions from code review
Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com>
* Test one-eighth from Python
* Add one-eighth charge in tests
* Handle ChargeOnEB
* Remove bug when handling charge on eb
* Fix Python errors
* Fix Python issues
* Use more natural setting of tilebox
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com>
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pywarpx/picmi.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index 6a19de3f5..45dfaa3dd 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -2099,6 +2099,9 @@ class ReducedDiagnostic(picmistandard.base._ClassWithInit, WarpXDiagnosticBase): reduced_function: string For diagnostic type 'FieldReduction', the function of the fields to evaluate + weighting_function: string, optional + For diagnostic type 'ChargeOnEB', the function to weight contributions to the total charge + reduction_type: {'Maximum', 'Minimum', or 'Integral'} For diagnostic type 'FieldReduction', the type of reduction @@ -2153,11 +2156,11 @@ class ReducedDiagnostic(picmistandard.base._ClassWithInit, WarpXDiagnosticBase): self._simple_reduced_diagnostics = [ 'ParticleEnergy', 'ParticleMomentum', 'FieldEnergy', 'FieldMomentum', 'FieldMaximum', 'RhoMaximum', 'ParticleNumber', - 'LoadBalanceCosts', 'LoadBalanceEfficiency', + 'LoadBalanceCosts', 'LoadBalanceEfficiency' ] # The species diagnostics require a species to be provided self._species_reduced_diagnostics = [ - 'BeamRelevant', 'ParticleHistogram', 'ParticleExtrema', + 'BeamRelevant', 'ParticleHistogram', 'ParticleExtrema' ] if self.type in self._simple_reduced_diagnostics: @@ -2171,6 +2174,8 @@ class ReducedDiagnostic(picmistandard.base._ClassWithInit, WarpXDiagnosticBase): kw = self._handle_field_probe(**kw) elif self.type == "FieldReduction": kw = self._handle_field_reduction(**kw) + elif self.type == "ChargeOnEB": + kw = self._handle_charge_on_eb(**kw) else: raise RuntimeError( f"{self.type} reduced diagnostic is not yet supported " @@ -2249,6 +2254,19 @@ class ReducedDiagnostic(picmistandard.base._ClassWithInit, WarpXDiagnosticBase): return kw + def _handle_charge_on_eb(self, **kw): + weighting_function = kw.pop("weighting_function", None) + + self.__setattr__("weighting_function(x,y,z)", weighting_function) + + # Check the reduced function expression for constants + for k in list(kw.keys()): + if re.search(r'\b%s\b'%k, weighting_function): + self.user_defined_kw[k] = kw[k] + del kw[k] + + return kw + def initialize_inputs(self): self.add_diagnostic() |