Coverage for gpaw/tddft/laser.py: 81%

16 statements  

« prev     ^ index     » next       coverage.py v7.7.1, created at 2025-07-20 00:19 +0000

1"""Different kinds of laser pulses. 

2""" 

3 

4import numpy as np 

5 

6########################### 

7# Main class 

8########################### 

9 

10 

11class LaserField: 

12 """ 

13 

14 """ 

15 def __init__(self): 

16 pass 

17 

18 def strength(self, t): 

19 return np.array([0.0, 0.0, 0.0]) 

20 

21 

22class CWField(LaserField): 

23 """ 

24 Continuously oscillating laser field which is switch on linearly. 

25 

26 Parameters: 

27 e0 field strength (in atomic units) 

28 w field frequency (in atomic units) 

29 ts switch on time (in atomic units) 

30 """ 

31 def __init__(self, e0, w, ts): 

32 # FIXME: use eV, ang and attosec 

33 # attosec_to_autime, autime_to_attosec, \ 

34 # eV_to_aufrequency, aufrequency_to_eV 

35 self.e0 = e0 

36 self.w = w 

37 self.ts = ts 

38 

39 def strength(self, t): 

40 if t < self.ts: 

41 c = self.e0 * (t / self.ts) * np.sin(self.w * t) 

42 else: 

43 c = self.e0 * np.sin(self.w * t) 

44 return np.array([0.0, 0.0, c])