@@ -29,6 +29,17 @@ def scalarProduct(self, a: typing.List[float], b: typing.List[float]) -> float:
2929
3030 return result
3131
32+ def crossProduct (self , a : typing .List [float ], b : typing .List [float ]) -> typing .List [float ]:
33+ assert len (a ) == len (b ) == 3 , "the cross product is only defined for 3d vectors"
34+ return [a [1 ] * b [2 ] - a [2 ] * b [1 ], a [2 ] * b [0 ] - a [0 ] * b [2 ], a [0 ] * b [1 ] - a [1 ] * b [0 ]]
35+
36+ def difference (self , a : typing .List [float ], b : typing .List [float ]) -> typing .List [float ]:
37+ assert len (a ) == len (b ), "the difference between two vectors is only defined if they have the same length"
38+ result = []
39+ for i in range (len (a )):
40+ result .append (a [i ] - b [i ])
41+ return result
42+
3243 @staticmethod
3344 def testRelativeError (trueValue , testValue , relativeErrorLimit ):
3445 return abs ((testValue - trueValue ) / trueValue ) < relativeErrorLimit
@@ -140,6 +151,14 @@ def get_as_pypicongpu(self) -> laser.GaussianLaser:
140151 1e-9 ,
141152 ), "polarization vector must be normalized"
142153
154+ # check that propagation_direction is parallel to the difference of focal_position and centroid_position
155+ diff_vec = self .difference (self .focal_position , self .centroid_position )
156+ cross_vec = self .crossProduct (diff_vec , self .propagation_direction )
157+ length_of_cross_product = self .scalarProduct (cross_vec , cross_vec )
158+
159+ assert length_of_cross_product < 1e-5 , "propagation_direction must connect centroid_position and focus_position"
160+ del (diff_vec , cross_vec , length_of_cross_product ) # clean up
161+
143162 pypicongpu_laser = laser .GaussianLaser ()
144163 pypicongpu_laser .wavelength = self .wavelength
145164 pypicongpu_laser .waist = self .waist
0 commit comments