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
« prev ^ index » next coverage.py v7.7.1, created at 2025-07-20 00:19 +0000
1"""Different kinds of laser pulses.
2"""
4import numpy as np
6###########################
7# Main class
8###########################
11class LaserField:
12 """
14 """
15 def __init__(self):
16 pass
18 def strength(self, t):
19 return np.array([0.0, 0.0, 0.0])
22class CWField(LaserField):
23 """
24 Continuously oscillating laser field which is switch on linearly.
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
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])