aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx/picmi.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Python/pywarpx/picmi.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py
index 30dc3534c..fdfada4df 100644
--- a/Python/pywarpx/picmi.py
+++ b/Python/pywarpx/picmi.py
@@ -554,6 +554,62 @@ class LaserAntenna(picmistandard.PICMI_LaserAntenna):
laser.laser.profile_t_peak = (self.position[2] - laser.centroid_position[2])/constants.c # The time at which the laser reaches its peak (in seconds)
+class ConstantAppliedField(picmistandard.PICMI_ConstantAppliedField):
+ def initialize_inputs(self):
+ # Note that lower and upper_bound are not used by WarpX
+
+ if (self.Ex is not None or
+ self.Ey is not None or
+ self.Ez is not None):
+ pywarpx.particles.E_ext_particle_init_style = 'constant'
+ pywarpx.particles.E_external_particle = [self.Ex or 0., self.Ey or 0., self.Ez or 0.]
+
+ if (self.Bx is not None or
+ self.By is not None or
+ self.Bz is not None):
+ pywarpx.particles.B_ext_particle_init_style = 'constant'
+ pywarpx.particles.B_external_particle = [self.Bx or 0., self.By or 0., self.Bz or 0.]
+
+
+class AnalyticAppliedField(picmistandard.PICMI_AnalyticAppliedField):
+ def initialize_inputs(self):
+ # Note that lower and upper_bound are not used by WarpX
+ for k,v in self.user_defined_kw.items():
+ setattr(pywarpx.my_constants, k, v)
+
+ if (self.Ex_expression is not None or
+ self.Ey_expression is not None or
+ self.Ez_expression is not None):
+ pywarpx.particles.E_ext_particle_init_style = 'parse_e_ext_particle_function'
+ pywarpx.particles.__setattr__('Ex_external_particle_function(x,y,z,t)', self.Ex_expression)
+ pywarpx.particles.__setattr__('Ey_external_particle_function(x,y,z,t)', self.Ey_expression)
+ pywarpx.particles.__setattr__('Ez_external_particle_function(x,y,z,t)', self.Ez_expression)
+
+ if (self.Bx_expression is not None or
+ self.By_expression is not None or
+ self.Bz_expression is not None):
+ pywarpx.particles.B_ext_particle_init_style = 'parse_b_ext_particle_function'
+ pywarpx.particles.__setattr__('Bx_external_particle_function(x,y,z,t)', self.Bx_expression)
+ pywarpx.particles.__setattr__('By_external_particle_function(x,y,z,t)', self.By_expression)
+ pywarpx.particles.__setattr__('Bz_external_particle_function(x,y,z,t)', self.Bz_expression)
+
+
+class Mirror(picmistandard.PICMI_Mirror):
+ def initialize_inputs(self):
+ try:
+ pywarpx.warpx.num_mirrors
+ except AttributeError:
+ pywarpx.warpx.num_mirrors = 0
+ pywarpx.warpx.mirror_z = []
+ pywarpx.warpx.mirror_z_width = []
+ pywarpx.warpx.mirror_z_npoints = []
+
+ pywarpx.warpx.num_mirrors += 1
+ pywarpx.warpx.mirror_z.append(self.z_front_location)
+ pywarpx.warpx.mirror_z_width.append(self.depth)
+ pywarpx.warpx.mirror_z_npoints.append(self.number_of_cells)
+
+
class Simulation(picmistandard.PICMI_Simulation):
def init(self, kw):
@@ -624,6 +680,9 @@ class Simulation(picmistandard.PICMI_Simulation):
self.lasers[i].initialize_inputs()
self.laser_injection_methods[i].initialize_inputs(self.lasers[i])
+ for applied_field in self.applied_fields:
+ applied_field.initialize_inputs()
+
for diagnostic in self.diagnostics:
diagnostic.initialize_inputs()