Skip to content

Commit

Permalink
Add density min and max arguments to picmi.AnalyticDistribution (EC…
Browse files Browse the repository at this point in the history
…P-WarpX#5108)

* add density min and max arguments to `picmi.AnalyticDistribution`

* add docstring
  • Loading branch information
roelof-groenewald authored Aug 8, 2024
1 parent 7d40963 commit 13fa090
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Python/pywarpx/picmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ def set_species_attributes(self, species, layout, source_name):
species.add_new_group_attr(source_name, 'uy', self.directed_velocity[1]/constants.c)
species.add_new_group_attr(source_name, 'uz', self.directed_velocity[2]/constants.c)

if hasattr(self, 'density_min'):
species.add_new_group_attr(source_name, 'density_min', self.density_min)
if hasattr(self, 'density_max'):
species.add_new_group_attr(source_name, 'density_max', self.density_max)

def setup_parse_momentum_functions(self, species, source_name, expressions, suffix, defaults):
for sdir, idir in zip(['x', 'y', 'z'], [0, 1, 2]):
if expressions[idir] is not None:
Expand Down Expand Up @@ -555,6 +560,14 @@ class AnalyticDistribution(picmistandard.PICMI_AnalyticDistribution, DensityDist
Parameters
----------
warpx_density_min: float
Minimum plasma density. No particle is injected where the density is
below this value.
warpx_density_max: float
Maximum plasma density. The density at each point is the minimum between
the value given in the profile, and density_max.
warpx_momentum_spread_expressions: list of string
Analytic expressions describing the gamma*velocity spread for each axis [m/s].
Expressions should be in terms of the position, written as 'x', 'y', and 'z'.
Expand All @@ -563,6 +576,8 @@ class AnalyticDistribution(picmistandard.PICMI_AnalyticDistribution, DensityDist
"""
def init(self, kw):
self.density_min = kw.pop('warpx_density_min', None)
self.density_max = kw.pop('warpx_density_max', None)
self.momentum_spread_expressions = kw.pop('warpx_momentum_spread_expressions', [None, None, None])

def distribution_initialize_inputs(self, species_number, layout, species, density_scale, source_name):
Expand Down

0 comments on commit 13fa090

Please sign in to comment.