From 1d64d6987fa5ddc17e55c51f8cc6d7487b1709a5 Mon Sep 17 00:00:00 2001 From: Olga Shapoval Date: Mon, 28 Oct 2024 15:27:12 -0700 Subject: [PATCH 01/12] Added AnalyticFluxDistribution class --- Docs/source/usage/python.rst | 4 ++++ Python/pywarpx/picmi.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/Docs/source/usage/python.rst b/Docs/source/usage/python.rst index 8b40684feb9..1af884b40e7 100644 --- a/Docs/source/usage/python.rst +++ b/Docs/source/usage/python.rst @@ -146,6 +146,10 @@ Particle distributions can be used for to initialize particles in a particle spe .. autoclass:: pywarpx.picmi.AnalyticDistribution +.. autoclass:: pywarpx.picmi.UniformFluxDistribution + +.. autoclass:: pywarpx.picmi.AnalyticFluxDistribution + .. autoclass:: pywarpx.picmi.ParticleListDistribution Particle layouts determine how to microscopically place macro particles in a grid cell. diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index c7a27f62df0..2a48a9ed89a 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -738,6 +738,39 @@ def distribution_initialize_inputs( if density_scale is not None: species.add_new_group_attr(source_name, "density", density_scale) +class AnalyticFluxDistribution( + picmistandard.PICMI_AnalyticFluxDistribution, DensityDistributionBase +): + def distribution_initialize_inputs( + self, species_number, layout, species, density_scale, source_name + ): + self.fill_in = False + self.set_mangle_dict() + self.set_species_attributes(species, layout, source_name) + + species.add_new_group_attr(source_name, "flux_profile", "constant") + species.add_new_group_attr(source_name, "flux", self.flux_expression) + if density_scale is not None: + species.add_new_group_attr(source_name, "flux", density_scale) + species.add_new_group_attr( + source_name, "flux_normal_axis", self.flux_normal_axis + ) + species.add_new_group_attr( + source_name, "surface_flux_pos", self.surface_flux_position + ) + species.add_new_group_attr(source_name, "flux_direction", self.flux_direction) + species.add_new_group_attr(source_name, "flux_tmin", self.flux_tmin) + species.add_new_group_attr(source_name, "flux_tmax", self.flux_tmax) + + # --- Use specific attributes for flux injection + species.add_new_group_attr(source_name, "injection_style", "nfluxpercell") + assert isinstance(layout, PseudoRandomLayout), Exception( + "UniformFluxDistribution only supports the PseudoRandomLayout in WarpX" + ) + if self.gaussian_flux_momentum_distribution: + species.add_new_group_attr( + source_name, "momentum_distribution_type", "gaussianflux" + ) class AnalyticDistribution( picmistandard.PICMI_AnalyticDistribution, DensityDistributionBase From 4f7f98adb0a741d5f05f3286742b974ee053f7a8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 05:29:59 +0000 Subject: [PATCH 02/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Python/pywarpx/picmi.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index 2a48a9ed89a..f590cd35eeb 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -738,6 +738,7 @@ def distribution_initialize_inputs( if density_scale is not None: species.add_new_group_attr(source_name, "density", density_scale) + class AnalyticFluxDistribution( picmistandard.PICMI_AnalyticFluxDistribution, DensityDistributionBase ): @@ -772,6 +773,7 @@ def distribution_initialize_inputs( source_name, "momentum_distribution_type", "gaussianflux" ) + class AnalyticDistribution( picmistandard.PICMI_AnalyticDistribution, DensityDistributionBase ): From 0dc0f0b1bfbea7c8d0adde2e725f14078546feb4 Mon Sep 17 00:00:00 2001 From: Olga Shapoval Date: Tue, 29 Oct 2024 10:31:22 -0700 Subject: [PATCH 03/12] Updated picmistandard to 0.32.0 --- Docs/requirements.txt | 2 +- Python/setup.py | 2 +- Tools/machines/karolina-it4i/install_dependencies.sh | 2 +- requirements.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Docs/requirements.txt b/Docs/requirements.txt index 7581638551e..0eeb250624c 100644 --- a/Docs/requirements.txt +++ b/Docs/requirements.txt @@ -13,7 +13,7 @@ openpmd-viewer # for checksumAPI # PICMI API docs # note: keep in sync with version in ../requirements.txt -picmistandard==0.31.0 +picmistandard==0.32.0 # for development against an unreleased PICMI version, use: # picmistandard @ git+https://github.com/picmi-standard/picmi.git#subdirectory=PICMI_Python diff --git a/Python/setup.py b/Python/setup.py index c0e38baced2..d2ce036e5b1 100644 --- a/Python/setup.py +++ b/Python/setup.py @@ -70,7 +70,7 @@ package_dir={"pywarpx": "pywarpx"}, description="""Wrapper of WarpX""", package_data=package_data, - install_requires=["numpy", "picmistandard==0.31.0", "periodictable"], + install_requires=["numpy", "picmistandard==0.32.0", "periodictable"], python_requires=">=3.8", zip_safe=False, ) diff --git a/Tools/machines/karolina-it4i/install_dependencies.sh b/Tools/machines/karolina-it4i/install_dependencies.sh index 9cc4f1ee144..aebaef2aa84 100755 --- a/Tools/machines/karolina-it4i/install_dependencies.sh +++ b/Tools/machines/karolina-it4i/install_dependencies.sh @@ -53,7 +53,7 @@ python -m pip install --user --upgrade matplotlib #python -m pip install --user --upgrade yt # install or update WarpX dependencies -python -m pip install --user --upgrade picmistandard==0.31.0 +python -m pip install --user --upgrade picmistandard==0.32.0 python -m pip install --user --upgrade lasy # optional: for optimas (based on libEnsemble & ax->botorch->gpytorch->pytorch) diff --git a/requirements.txt b/requirements.txt index 2c8b749abe0..71cd8c34c51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ periodictable~=1.5 # PICMI # note: don't forget to update the version in Docs/requirements.txt, too -picmistandard==0.31.0 +picmistandard==0.32.0 # for development against an unreleased PICMI version, use: #picmistandard @ git+https://github.com/picmi-standard/picmi.git#subdirectory=PICMI_Python From 6be64022755f3b688cdd90324fdc20d92257566c Mon Sep 17 00:00:00 2001 From: Olga Shapoval Date: Fri, 1 Nov 2024 17:04:26 -0700 Subject: [PATCH 04/12] Updated AnalyticFluxDistribution class: enabled the flux variable to be parsed as a function --- Python/pywarpx/picmi.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index f590cd35eeb..e550ab8e6e4 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -749,10 +749,26 @@ def distribution_initialize_inputs( self.set_mangle_dict() self.set_species_attributes(species, layout, source_name) - species.add_new_group_attr(source_name, "flux_profile", "constant") - species.add_new_group_attr(source_name, "flux", self.flux_expression) + species.add_new_group_attr(source_name, "flux_profile", "parse_flux_function") + if density_scale is not None: species.add_new_group_attr(source_name, "flux", density_scale) + + expression = pywarpx.my_constants.mangle_expression( + self.flux, self.mangle_dict + ) + if density_scale is None: + species.add_new_group_attr( + source_name, "flux_function(x,y,z,t)", expression + ) + else: + species.add_new_group_attr( + source_name, + "flux_function(x,y,z,t)", + "{}*({})".format(density_scale, expression), + ) + + species.add_new_group_attr( source_name, "flux_normal_axis", self.flux_normal_axis ) From 0c5c764f4bd0a6a726dc05036405c405fb5b4bfc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 2 Nov 2024 00:05:22 +0000 Subject: [PATCH 05/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Python/pywarpx/picmi.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index e550ab8e6e4..38f138dd5ba 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -754,9 +754,7 @@ def distribution_initialize_inputs( if density_scale is not None: species.add_new_group_attr(source_name, "flux", density_scale) - expression = pywarpx.my_constants.mangle_expression( - self.flux, self.mangle_dict - ) + expression = pywarpx.my_constants.mangle_expression(self.flux, self.mangle_dict) if density_scale is None: species.add_new_group_attr( source_name, "flux_function(x,y,z,t)", expression @@ -768,7 +766,6 @@ def distribution_initialize_inputs( "{}*({})".format(density_scale, expression), ) - species.add_new_group_attr( source_name, "flux_normal_axis", self.flux_normal_axis ) From 3d1b6fd81216fcf20c096c1ed6cec5eb839f48ca Mon Sep 17 00:00:00 2001 From: Olga Shapoval Date: Fri, 8 Nov 2024 15:52:06 -0800 Subject: [PATCH 06/12] Updated picmistandard to 0.33.0 --- Docs/requirements.txt | 2 +- Python/setup.py | 2 +- Tools/machines/karolina-it4i/install_dependencies.sh | 2 +- requirements.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Docs/requirements.txt b/Docs/requirements.txt index 0eeb250624c..14fafe406fb 100644 --- a/Docs/requirements.txt +++ b/Docs/requirements.txt @@ -13,7 +13,7 @@ openpmd-viewer # for checksumAPI # PICMI API docs # note: keep in sync with version in ../requirements.txt -picmistandard==0.32.0 +picmistandard==0.33.0 # for development against an unreleased PICMI version, use: # picmistandard @ git+https://github.com/picmi-standard/picmi.git#subdirectory=PICMI_Python diff --git a/Python/setup.py b/Python/setup.py index 1082804134d..50eb196a522 100644 --- a/Python/setup.py +++ b/Python/setup.py @@ -70,7 +70,7 @@ package_dir={"pywarpx": "pywarpx"}, description="""Wrapper of WarpX""", package_data=package_data, - install_requires=["numpy", "picmistandard==0.32.0", "periodictable"], + install_requires=["numpy", "picmistandard==0.33.0", "periodictable"], python_requires=">=3.8", zip_safe=False, ) diff --git a/Tools/machines/karolina-it4i/install_dependencies.sh b/Tools/machines/karolina-it4i/install_dependencies.sh index aebaef2aa84..33d8462b55f 100755 --- a/Tools/machines/karolina-it4i/install_dependencies.sh +++ b/Tools/machines/karolina-it4i/install_dependencies.sh @@ -53,7 +53,7 @@ python -m pip install --user --upgrade matplotlib #python -m pip install --user --upgrade yt # install or update WarpX dependencies -python -m pip install --user --upgrade picmistandard==0.32.0 +python -m pip install --user --upgrade picmistandard==0.33.0 python -m pip install --user --upgrade lasy # optional: for optimas (based on libEnsemble & ax->botorch->gpytorch->pytorch) diff --git a/requirements.txt b/requirements.txt index 71cd8c34c51..e44273328de 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ periodictable~=1.5 # PICMI # note: don't forget to update the version in Docs/requirements.txt, too -picmistandard==0.32.0 +picmistandard==0.33.0 # for development against an unreleased PICMI version, use: #picmistandard @ git+https://github.com/picmi-standard/picmi.git#subdirectory=PICMI_Python From f908030a34c2c691c9f65237b6c92cbf07ec0c04 Mon Sep 17 00:00:00 2001 From: Olga Shapoval Date: Wed, 4 Dec 2024 12:09:26 -0800 Subject: [PATCH 07/12] Added inject_from_embedded_boundary option to AnalyticFluxDistribution class --- Python/pywarpx/picmi.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index 77d335a6fa2..a256dbb7b91 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -756,6 +756,11 @@ def distribution_initialize_inputs( class AnalyticFluxDistribution( picmistandard.PICMI_AnalyticFluxDistribution, DensityDistributionBase ): + def init(self, kw): + self.inject_from_embedded_boundary = kw.pop( + "warpx_inject_from_embedded_boundary", False + ) + def distribution_initialize_inputs( self, species_number, layout, species, density_scale, source_name ): @@ -779,14 +784,20 @@ def distribution_initialize_inputs( "flux_function(x,y,z,t)", "{}*({})".format(density_scale, expression), ) + if not self.inject_from_embedded_boundary: + + species.add_new_group_attr( + source_name, "flux_normal_axis", self.flux_normal_axis + ) + species.add_new_group_attr( + source_name, "surface_flux_pos", self.surface_flux_position + ) + species.add_new_group_attr(source_name, "flux_direction", self.flux_direction) + else: + species.add_new_group_attr( + source_name, "inject_from_embedded_boundary", True + ) - species.add_new_group_attr( - source_name, "flux_normal_axis", self.flux_normal_axis - ) - species.add_new_group_attr( - source_name, "surface_flux_pos", self.surface_flux_position - ) - species.add_new_group_attr(source_name, "flux_direction", self.flux_direction) species.add_new_group_attr(source_name, "flux_tmin", self.flux_tmin) species.add_new_group_attr(source_name, "flux_tmax", self.flux_tmax) From 335d64c4609b5af1672cbae1ecbd026d19e578b6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 20:10:35 +0000 Subject: [PATCH 08/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Python/pywarpx/picmi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index a256dbb7b91..60bf9c75910 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -785,14 +785,15 @@ def distribution_initialize_inputs( "{}*({})".format(density_scale, expression), ) if not self.inject_from_embedded_boundary: - species.add_new_group_attr( source_name, "flux_normal_axis", self.flux_normal_axis ) species.add_new_group_attr( source_name, "surface_flux_pos", self.surface_flux_position ) - species.add_new_group_attr(source_name, "flux_direction", self.flux_direction) + species.add_new_group_attr( + source_name, "flux_direction", self.flux_direction + ) else: species.add_new_group_attr( source_name, "inject_from_embedded_boundary", True From 1d1e6c36f33acfeb9c4da7887efc7592cedcb689 Mon Sep 17 00:00:00 2001 From: Olga Shapoval Date: Fri, 6 Dec 2024 18:02:49 -0800 Subject: [PATCH 09/12] Refactored code to avoid duplication by creating parent and subclass structure --- Python/pywarpx/picmi.py | 98 ++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 64 deletions(-) diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index a256dbb7b91..ed016cc69fc 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -687,15 +687,34 @@ def setup_parse_momentum_functions( f"({expression})/{constants.c}", ) - -class UniformFluxDistribution( - picmistandard.PICMI_UniformFluxDistribution, DensityDistributionBase +class UniformDistribution( + picmistandard.PICMI_UniformDistribution, DensityDistributionBase ): + def distribution_initialize_inputs( + self, species_number, layout, species, density_scale, source_name + ): + self.set_mangle_dict() + self.set_species_attributes(species, layout, source_name) + + # --- Only constant density is supported by this class + species.add_new_group_attr(source_name, "profile", "constant") + species.add_new_group_attr(source_name, "density", self.density) + if density_scale is not None: + species.add_new_group_attr(source_name, "density", density_scale) + +class FluxDistributionBase(object): + """ This is a base class for both uniform and analytic flux distributions.""" + def init(self, kw): self.inject_from_embedded_boundary = kw.pop( "warpx_inject_from_embedded_boundary", False ) + def flux_profile_and_func_initialize(self, species, density_scale, source_name + ): + """ Initialize the flux profile and flux function.""" + pass + def distribution_initialize_inputs( self, species_number, layout, species, density_scale, source_name ): @@ -703,10 +722,7 @@ def distribution_initialize_inputs( self.set_mangle_dict() self.set_species_attributes(species, layout, source_name) - species.add_new_group_attr(source_name, "flux_profile", "constant") - species.add_new_group_attr(source_name, "flux", self.flux) - if density_scale is not None: - species.add_new_group_attr(source_name, "flux", density_scale) + self.flux_profile_and_func_initialize(species, density_scale, source_name) if not self.inject_from_embedded_boundary: species.add_new_group_attr( @@ -736,43 +752,14 @@ def distribution_initialize_inputs( source_name, "momentum_distribution_type", "gaussianflux" ) - -class UniformDistribution( - picmistandard.PICMI_UniformDistribution, DensityDistributionBase -): - def distribution_initialize_inputs( - self, species_number, layout, species, density_scale, source_name - ): - self.set_mangle_dict() - self.set_species_attributes(species, layout, source_name) - - # --- Only constant density is supported by this class - species.add_new_group_attr(source_name, "profile", "constant") - species.add_new_group_attr(source_name, "density", self.density) - if density_scale is not None: - species.add_new_group_attr(source_name, "density", density_scale) - - class AnalyticFluxDistribution( - picmistandard.PICMI_AnalyticFluxDistribution, DensityDistributionBase + picmistandard.PICMI_AnalyticFluxDistribution, FluxDistributionBase, DensityDistributionBase ): - def init(self, kw): - self.inject_from_embedded_boundary = kw.pop( - "warpx_inject_from_embedded_boundary", False - ) - - def distribution_initialize_inputs( - self, species_number, layout, species, density_scale, source_name + def flux_profile_and_func_initialize(self, species, density_scale, source_name ): - self.fill_in = False - self.set_mangle_dict() - self.set_species_attributes(species, layout, source_name) - species.add_new_group_attr(source_name, "flux_profile", "parse_flux_function") - if density_scale is not None: species.add_new_group_attr(source_name, "flux", density_scale) - expression = pywarpx.my_constants.mangle_expression(self.flux, self.mangle_dict) if density_scale is None: species.add_new_group_attr( @@ -784,33 +771,16 @@ def distribution_initialize_inputs( "flux_function(x,y,z,t)", "{}*({})".format(density_scale, expression), ) - if not self.inject_from_embedded_boundary: - - species.add_new_group_attr( - source_name, "flux_normal_axis", self.flux_normal_axis - ) - species.add_new_group_attr( - source_name, "surface_flux_pos", self.surface_flux_position - ) - species.add_new_group_attr(source_name, "flux_direction", self.flux_direction) - else: - species.add_new_group_attr( - source_name, "inject_from_embedded_boundary", True - ) - - species.add_new_group_attr(source_name, "flux_tmin", self.flux_tmin) - species.add_new_group_attr(source_name, "flux_tmax", self.flux_tmax) - - # --- Use specific attributes for flux injection - species.add_new_group_attr(source_name, "injection_style", "nfluxpercell") - assert isinstance(layout, PseudoRandomLayout), Exception( - "UniformFluxDistribution only supports the PseudoRandomLayout in WarpX" - ) - if self.gaussian_flux_momentum_distribution: - species.add_new_group_attr( - source_name, "momentum_distribution_type", "gaussianflux" - ) +class UniformFluxDistribution( + picmistandard.PICMI_UniformFluxDistribution, FluxDistributionBase, DensityDistributionBase +): + def flux_profile_and_func_initialize(self, species, density_scale, source_name + ): + species.add_new_group_attr(source_name, "flux_profile", "constant") + species.add_new_group_attr(source_name, "flux", self.flux) + if density_scale is not None: + species.add_new_group_attr(source_name, "flux", density_scale) class AnalyticDistribution( picmistandard.PICMI_AnalyticDistribution, DensityDistributionBase From d594d71bd4958305bf6e0c6fd6289833e6af4742 Mon Sep 17 00:00:00 2001 From: Olga Shapoval Date: Tue, 10 Dec 2024 18:48:28 -0800 Subject: [PATCH 10/12] Clean-up --- Python/pywarpx/picmi.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index ed016cc69fc..f1a8fde0dc8 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -710,9 +710,8 @@ def init(self, kw): "warpx_inject_from_embedded_boundary", False ) - def flux_profile_and_func_initialize(self, species, density_scale, source_name - ): - """ Initialize the flux profile and flux function.""" + def initialize_flux_profile_func(self, species, density_scale, source_name): + """ Initialize the flux profile and flux function.""" pass def distribution_initialize_inputs( @@ -722,7 +721,7 @@ def distribution_initialize_inputs( self.set_mangle_dict() self.set_species_attributes(species, layout, source_name) - self.flux_profile_and_func_initialize(species, density_scale, source_name) + self.initialize_flux_profile_func(species, density_scale, source_name) if not self.inject_from_embedded_boundary: species.add_new_group_attr( @@ -755,7 +754,7 @@ def distribution_initialize_inputs( class AnalyticFluxDistribution( picmistandard.PICMI_AnalyticFluxDistribution, FluxDistributionBase, DensityDistributionBase ): - def flux_profile_and_func_initialize(self, species, density_scale, source_name + def initialize_flux_profile_func(self, species, density_scale, source_name ): species.add_new_group_attr(source_name, "flux_profile", "parse_flux_function") if density_scale is not None: @@ -775,7 +774,7 @@ def flux_profile_and_func_initialize(self, species, density_scale, source_name class UniformFluxDistribution( picmistandard.PICMI_UniformFluxDistribution, FluxDistributionBase, DensityDistributionBase ): - def flux_profile_and_func_initialize(self, species, density_scale, source_name + def initialize_flux_profile_func(self, species, density_scale, source_name ): species.add_new_group_attr(source_name, "flux_profile", "constant") species.add_new_group_attr(source_name, "flux", self.flux) From 4e0e5fca5099961af9b79ef4b6c796b653384c0e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 02:49:02 +0000 Subject: [PATCH 11/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Python/pywarpx/picmi.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index f1a8fde0dc8..8811541749b 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -687,6 +687,7 @@ def setup_parse_momentum_functions( f"({expression})/{constants.c}", ) + class UniformDistribution( picmistandard.PICMI_UniformDistribution, DensityDistributionBase ): @@ -702,8 +703,9 @@ def distribution_initialize_inputs( if density_scale is not None: species.add_new_group_attr(source_name, "density", density_scale) + class FluxDistributionBase(object): - """ This is a base class for both uniform and analytic flux distributions.""" + """This is a base class for both uniform and analytic flux distributions.""" def init(self, kw): self.inject_from_embedded_boundary = kw.pop( @@ -711,7 +713,7 @@ def init(self, kw): ) def initialize_flux_profile_func(self, species, density_scale, source_name): - """ Initialize the flux profile and flux function.""" + """Initialize the flux profile and flux function.""" pass def distribution_initialize_inputs( @@ -751,11 +753,13 @@ def distribution_initialize_inputs( source_name, "momentum_distribution_type", "gaussianflux" ) + class AnalyticFluxDistribution( - picmistandard.PICMI_AnalyticFluxDistribution, FluxDistributionBase, DensityDistributionBase + picmistandard.PICMI_AnalyticFluxDistribution, + FluxDistributionBase, + DensityDistributionBase, ): - def initialize_flux_profile_func(self, species, density_scale, source_name - ): + def initialize_flux_profile_func(self, species, density_scale, source_name): species.add_new_group_attr(source_name, "flux_profile", "parse_flux_function") if density_scale is not None: species.add_new_group_attr(source_name, "flux", density_scale) @@ -771,16 +775,19 @@ def initialize_flux_profile_func(self, species, density_scale, source_name "{}*({})".format(density_scale, expression), ) + class UniformFluxDistribution( - picmistandard.PICMI_UniformFluxDistribution, FluxDistributionBase, DensityDistributionBase + picmistandard.PICMI_UniformFluxDistribution, + FluxDistributionBase, + DensityDistributionBase, ): - def initialize_flux_profile_func(self, species, density_scale, source_name - ): + def initialize_flux_profile_func(self, species, density_scale, source_name): species.add_new_group_attr(source_name, "flux_profile", "constant") species.add_new_group_attr(source_name, "flux", self.flux) if density_scale is not None: species.add_new_group_attr(source_name, "flux", density_scale) + class AnalyticDistribution( picmistandard.PICMI_AnalyticDistribution, DensityDistributionBase ): From b15246d41327f3638dcf49535379569b5e14caa8 Mon Sep 17 00:00:00 2001 From: David Grote Date: Thu, 12 Dec 2024 09:39:52 -0800 Subject: [PATCH 12/12] Because of the multiple inheritance, the init methods must be explicitly defined --- Python/pywarpx/picmi.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index 8811541749b..272d2d42e08 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -759,6 +759,18 @@ class AnalyticFluxDistribution( FluxDistributionBase, DensityDistributionBase, ): + """ + Parameters + ---------- + + warpx_inject_from_embedded_boundary: bool + When true, the flux is injected from the embedded boundaries instead + of a plane. + """ + + def init(self, kw): + FluxDistributionBase.init(self, kw) + def initialize_flux_profile_func(self, species, density_scale, source_name): species.add_new_group_attr(source_name, "flux_profile", "parse_flux_function") if density_scale is not None: @@ -781,6 +793,18 @@ class UniformFluxDistribution( FluxDistributionBase, DensityDistributionBase, ): + """ + Parameters + ---------- + + warpx_inject_from_embedded_boundary: bool + When true, the flux is injected from the embedded boundaries instead + of a plane. + """ + + def init(self, kw): + FluxDistributionBase.init(self, kw) + def initialize_flux_profile_func(self, species, density_scale, source_name): species.add_new_group_attr(source_name, "flux_profile", "constant") species.add_new_group_attr(source_name, "flux", self.flux)