laserfields 0.4.1__tar.gz → 0.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: laserfields
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: Python library for describing time-dependent laserfields by Johannes Feist.
5
5
  Author-email: Johannes Feist <johannes.feist@gmail.com>
6
6
  Requires-Python: >=3.7
@@ -1,6 +1,6 @@
1
1
  """Python library for describing time-dependent laserfields by Johannes Feist."""
2
2
 
3
- __version__ = "0.4.1"
3
+ __version__ = "0.4.2"
4
4
 
5
5
  __all__ = [
6
6
  "intensity_Wcm2_to_Eau",
@@ -148,10 +148,15 @@ class GaussianLaserField(LaserField):
148
148
 
149
149
  def expiatbt2_intT(a, b, T):
150
150
  # returns the result of the integral Int(exp(i*(a*t+b*t**2)),{t,-T/2,T/2}) / sqrt(2*pi)
151
- if abs(b) * T**2 < 1e-8:
152
- # use first-order expansion for small b to avoid numerical divergence
153
- x1 = 2j * b / a**2
154
- x2 = x1 * cos(a * T / 2) + (1 - x1 + 0.25j * b * T**2) * sinc(a * T / (2 * π))
151
+ bTsq = b * T**2
152
+ if abs(bTsq) <= 1e-5:
153
+ aT = a * T
154
+ # use first-order expansion for small b to avoid numerical errors
155
+ # + 1e-250 to avoid division by zero
156
+ x1 = 2j * b / (a**2 + 1e-250)
157
+ x2 = x1 * cos(aT / 2) + (1 - x1 + 0.25j * bTsq) * sinc(aT / (2 * π))
158
+ # avoid numerical errors for small aT
159
+ x2 = np.where(abs(aT) < 1e-8, 1 + 1j/12 * bTsq - bTsq**2/160, x2)
155
160
  return x2 * T / sqrt(2 * π)
156
161
  zz1 = (1 + 1j) / 4
157
162
  z34 = (-1.0 + 1j) / sqrt(2) # == (-1)**(3/4)
@@ -109,13 +109,13 @@ def test_Teff():
109
109
  def test_fourier():
110
110
  # Test the Fourier transform of the laser fields
111
111
  # Compare the analytical Fourier transform with the numerical one (computed using FFT)
112
- for chirp in -1e-3, -1e-20, 0, 1e-20, 1e-3:
112
+ for chirp in -0.0011, -0.0009, -1e-3, -1e-20, 0, 1e-20, 1e-3, 0.0009, 0.0011:
113
113
  general_args = dict(is_vecpot=True, E0=1.5, ω0=0.12, t0=500.0, chirp=chirp, ϕ0=0.8 * np.pi)
114
114
  for lf in [
115
115
  GaussianLaserField(**general_args, σ=100.0),
116
- SinExpLaserField(**general_args, T=800.0, exponent=2),
117
- SinExpLaserField(**general_args, T=800.0, exponent=4),
118
- SinExpLaserField(**general_args, T=800.0, exponent=7),
116
+ SinExpLaserField(**general_args, T=100.0, exponent=2),
117
+ SinExpLaserField(**general_args, T=100.0, exponent=4),
118
+ SinExpLaserField(**general_args, T=100.0, exponent=7),
119
119
  LinearFlatTopLaserField(**general_args, Tflat=400.0, Tramp=150),
120
120
  Linear2FlatTopLaserField(**general_args, Tflat=400.0, Tramp=150),
121
121
  ]:
@@ -134,5 +134,5 @@ def test_fourier():
134
134
  # FFT acts as if ts[0] was t=0, shift to the correct value
135
135
  Eω2 *= np.exp(-1j * ts[0] * ωs)
136
136
 
137
- atol = 0.02 if isinstance(lf, LinearFlatTopLaserField) else 1e-4
137
+ atol = 0.02 if isinstance(lf, LinearFlatTopLaserField) else 1e-3
138
138
  assert np.allclose(Eω, Eω2, atol=atol), f"Failed for {lf.__class__.__name__} with chirp {chirp}"
File without changes
File without changes
File without changes
File without changes