Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AnalyticFluxDistribution class #5422

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
1d64d69
Added AnalyticFluxDistribution class
oshapoval Oct 28, 2024
4f7f98a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 29, 2024
0dc0f0b
Updated picmistandard to 0.32.0
oshapoval Oct 29, 2024
f8f2f0b
Merge branch 'add_analytic_flux_distribution' of https://github.com/o…
oshapoval Oct 29, 2024
6be6402
Updated AnalyticFluxDistribution class: enabled the flux variable to …
oshapoval Nov 2, 2024
0c5c764
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 2, 2024
7905c27
Merge remote-tracking branch 'origin/development' into add_analytic_f…
oshapoval Nov 8, 2024
3d1b6fd
Updated picmistandard to 0.33.0
oshapoval Nov 8, 2024
e2d9c22
Merge remote-tracking branch 'origin' into add_analytic_flux_distribu…
oshapoval Dec 2, 2024
0de3e53
Merge remote-tracking branch 'origin/development' into add_analytic_f…
oshapoval Dec 3, 2024
f908030
Added inject_from_embedded_boundary option to AnalyticFluxDistributio…
oshapoval Dec 4, 2024
335d64c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 4, 2024
1d1e6c3
Refactored code to avoid duplication by creating parent and subclass …
oshapoval Dec 7, 2024
4ccbb6d
Merge branch 'add_analytic_flux_distribution' of https://github.com/o…
oshapoval Dec 7, 2024
d594d71
Clean-up
oshapoval Dec 11, 2024
4e0e5fc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 11, 2024
b15246d
Because of the multiple inheritance, the init methods must be explici…
dpgrote Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions Docs/source/usage/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
35 changes: 35 additions & 0 deletions Python/pywarpx/picmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,41 @@ def distribution_initialize_inputs(
species.add_new_group_attr(source_name, "density", density_scale)


class AnalyticFluxDistribution(
Copy link
Member

@dpgrote dpgrote Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a different way to handle this? This is an exact duplicate of UniformFluxDistribution except for the one keyword argument flux_expression.
This could be simplified if the picmistandard class took the same argument, flux, as the uniform distribution, then one could do "UniformFluxDistribution = AnalyticFluxDistribution" and have only one version of the class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

Note that we also have two different classes for the volume injection: UniformDistribution and AnalyticDistribution, so we were trying to mirror the same setup here for UniformFluxDistribution and AnalyticFluxDistribution.

Do you think that your comment also applies to UniformDistribution and AnalyticDistribution?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out, I will refactor accordingly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UniformDistribution and AnalyticDistribution are quite a bit different from each other and it's probably too late to change that API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this PR ready? I still see the duplication of 'UniformFluxDistribution' - this is fine if that is the intent. Also, UniformFluxDistribution has the inject_from_embedded_boundary option - would that also be supported with the analytic distribution?

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
):
Expand Down
2 changes: 1 addition & 1 deletion Python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
2 changes: 1 addition & 1 deletion Tools/machines/karolina-it4i/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading