From 14a8c9bdb9f38b0515af122ab5b19be782bd75d5 Mon Sep 17 00:00:00 2001 From: Olga Shapoval Date: Fri, 1 Nov 2024 16:44:07 -0700 Subject: [PATCH 1/2] Refactoring of PICMI_UniformFluxDistribution and PICMI_AnalyticFluxDistribution classes --- PICMI_Python/particles.py | 77 +++------------------------------------ 1 file changed, 6 insertions(+), 71 deletions(-) diff --git a/PICMI_Python/particles.py b/PICMI_Python/particles.py index d5fc33c..aa07241 100644 --- a/PICMI_Python/particles.py +++ b/PICMI_Python/particles.py @@ -356,80 +356,13 @@ def __init__(self, self.handle_init(kw) -class PICMI_UniformFluxDistribution(_ClassWithInit): - """ - Describes a flux of particles following a provided analytic expression - - Parameters - ---------- - flux: float - Flux of particles [m^-2.s^-1] - - flux_normal_axis: string - x, y, or z for 3D, x or z for 2D, or r, t, or z in RZ geometry - - surface_flux_position: double - location of the injection plane [m] along the direction - specified by `flux_normal_axis` - - flux_direction: int - Direction of the flux relative to the plane: -1 or +1 - - lower_bound: vector of floats, optional - Lower bound of the distribution [m] - - upper_bound: vector of floats, optional - Upper bound of the distribution [m] - - rms_velocity: vector of floats, default=[0.,0.,0.] - Thermal velocity spread [m/s] - - directed_velocity: vector of floats, default=[0.,0.,0.] - Directed, average, proper velocity [m/s] - - flux_tmin: float, optional - Time at which the flux injection will be turned on. - - flux_tmax: float, optional - Time at which the flux injection will be turned off. - - gaussian_flux_momentum_distribution: bool, optional - If True, the momentum distribution is v*Gaussian, - in the direction normal to the plane. Otherwise, - the momentum distribution is simply Gaussian. - """ - - def __init__(self, flux, flux_normal_axis, - surface_flux_position, flux_direction, - lower_bound = [None,None,None], - upper_bound = [None,None,None], - rms_velocity = [0.,0.,0.], - directed_velocity = [0.,0.,0.], - flux_tmin = None, - flux_tmax = None, - gaussian_flux_momentum_distribution = None, - **kw): - self.flux = flux - self.flux_normal_axis = flux_normal_axis - self.surface_flux_position = surface_flux_position - self.flux_direction = flux_direction - self.lower_bound = lower_bound - self.upper_bound = upper_bound - self.rms_velocity = rms_velocity - self.directed_velocity = directed_velocity - self.flux_tmin = flux_tmin - self.flux_tmax = flux_tmax - self.gaussian_flux_momentum_distribution = gaussian_flux_momentum_distribution - - self.handle_init(kw) - class PICMI_AnalyticFluxDistribution(_ClassWithInit): """ Describes a flux of particles emitted from a plane Parameters ---------- - flux: string + flux: srting Analytic expression describing flux of particles [m^-2.s^-1] Expression should be in terms of the position and time, written as 'x', 'y', 'z', and 't'. @@ -467,7 +400,7 @@ class PICMI_AnalyticFluxDistribution(_ClassWithInit): the momentum distribution is simply Gaussian. """ - def __init__(self, flux_expression, flux_normal_axis, + def __init__(self, flux, flux_normal_axis, surface_flux_position, flux_direction, lower_bound = [None,None,None], upper_bound = [None,None,None], @@ -477,7 +410,7 @@ def __init__(self, flux_expression, flux_normal_axis, flux_tmax = None, gaussian_flux_momentum_distribution = None, **kw): - self.flux_expression = f'{flux_expression}'.replace('\n', '') + self.flux = f'{flux}'.replace('\n', '') self.flux_normal_axis = flux_normal_axis self.surface_flux_position = surface_flux_position self.flux_direction = flux_direction @@ -491,12 +424,14 @@ def __init__(self, flux_expression, flux_normal_axis, self.user_defined_kw = {} for k in list(kw.keys()): - if re.search(r'\b%s\b'%k, self.flux_expression): + if re.search(r'\b%s\b'%k, self.flux): self.user_defined_kw[k] = kw[k] del kw[k] self.handle_init(kw) +PICMI_UniformFluxDistribution = PICMI_AnalyticFluxDistribution + class PICMI_AnalyticDistribution(_ClassWithInit): """ Describes a plasma with density following a provided analytic expression From 1311c067da1795cdfb1e18c96f29b57b6ccf5fb2 Mon Sep 17 00:00:00 2001 From: Olga Shapoval Date: Fri, 8 Nov 2024 09:57:44 -0800 Subject: [PATCH 2/2] Fixed a typo --- PICMI_Python/particles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PICMI_Python/particles.py b/PICMI_Python/particles.py index aa07241..dc492c5 100644 --- a/PICMI_Python/particles.py +++ b/PICMI_Python/particles.py @@ -362,7 +362,7 @@ class PICMI_AnalyticFluxDistribution(_ClassWithInit): Parameters ---------- - flux: srting + flux: string Analytic expression describing flux of particles [m^-2.s^-1] Expression should be in terms of the position and time, written as 'x', 'y', 'z', and 't'.