Skip to content

Commit

Permalink
Laser initialization in PICMI: allow negative focal distance and t_pe…
Browse files Browse the repository at this point in the history
…ak (ECP-WarpX#5164)

* PICMI: allow negative focal distance and t_peak

* Update calculation of the normal vector
  • Loading branch information
RemiLehe authored Aug 22, 2024
1 parent b05d918 commit 45b1d2f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions Python/pywarpx/picmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1986,22 +1986,23 @@ def laser_antenna_initialize_inputs(self, laser):
"specified antenna normal."
)
self.normal_vector = laser.laser.direction # The plane normal direction
# Ensure the normal vector is a unit vector
self.normal_vector /= np.linalg.norm(self.normal_vector)
if isinstance(laser, GaussianLaser):
# Focal distance from the antenna (in meters)
laser.laser.profile_focal_distance = np.sqrt(
(laser.focal_position[0] - self.position[0]) ** 2
+ (laser.focal_position[1] - self.position[1]) ** 2
+ (laser.focal_position[2] - self.position[2]) ** 2
# Focal displacement from the antenna (in meters)
laser.laser.profile_focal_distance = (
(laser.focal_position[0] - self.position[0]) * self.normal_vector[0]
+ (laser.focal_position[1] - self.position[1]) * self.normal_vector[1]
+ (laser.focal_position[2] - self.position[2]) * self.normal_vector[2]
)
# The time at which the laser reaches its peak (in seconds)
laser.laser.profile_t_peak = (
np.sqrt(
(self.position[0] - laser.centroid_position[0]) ** 2
+ (self.position[1] - laser.centroid_position[1]) ** 2
+ (self.position[2] - laser.centroid_position[2]) ** 2
)
/ constants.c
)
(self.position[0] - laser.centroid_position[0]) * self.normal_vector[0]
+ (self.position[1] - laser.centroid_position[1])
* self.normal_vector[1]
+ (self.position[2] - laser.centroid_position[2])
* self.normal_vector[2]
) / constants.c


class LoadInitialField(picmistandard.PICMI_LoadGriddedField):
Expand Down

0 comments on commit 45b1d2f

Please sign in to comment.