|
1 | 1 | """Classes and functions related to the interferometry lasers.""" |
2 | 2 |
|
| 3 | +from functools import partial |
| 4 | + |
3 | 5 | import matplotlib.pyplot as plt |
4 | 6 | import numpy as np |
5 | 7 | from matplotlib.colors import Colormap |
@@ -64,38 +66,62 @@ class IntensityProfile: |
64 | 66 |
|
65 | 67 | Attributes |
66 | 68 | ---------- |
67 | | - r_profile : float |
68 | | - 1/e² radius of the Gaussian intensity profile in m |
69 | | - center_rabi_freq : float |
70 | | - Rabi frequency at center of intensity profile in rad/s |
71 | 69 | r_beam : float or None |
72 | 70 | Beam radius in m. If set, Rabi frequency will be set to 0 outside of the beam. |
| 71 | + profile_func : function |
| 72 | + Function that calculates the Rabi frequency at a position of a Gaussian beam. |
73 | 73 | """ |
74 | 74 |
|
75 | | - def __init__(self, r_profile, center_rabi_freq, r_beam=None): |
76 | | - self.r_profile = r_profile |
77 | | - self.center_rabi_freq = center_rabi_freq |
| 75 | + def __init__(self, *, r_profile, center_rabi_freq, r_beam=None): |
78 | 76 | self.r_beam = r_beam |
| 77 | + self.profile_func = partial( |
| 78 | + self._gaussian_profile, |
| 79 | + r_profile=r_profile, |
| 80 | + center_rabi_freq=center_rabi_freq, |
| 81 | + ) |
79 | 82 |
|
80 | 83 | def get_rabi_freq(self, pos): |
81 | 84 | """ |
82 | 85 | Rabi frequency at a position of a Gaussian beam. |
83 | 86 |
|
84 | 87 | Parameters |
85 | 88 | ---------- |
86 | | - pos : (n × 2) array or (n × 3) array |
| 89 | + pos : (n x 2) array or (n x 3) array |
87 | 90 | positions of the n atoms in two or three dimensions (x, y, [z]). |
88 | 91 |
|
89 | 92 | Returns |
90 | 93 | ------- |
91 | 94 | rabi_freqs : array of float |
92 | | - the Rabi frequencies for the n positions. If ``r_beam`` is set, the Rabi |
| 95 | + the Rabi frequencies for the n positions. If `r_beam` is set, the Rabi |
93 | 96 | frequency will be set to 0 outside of the beam. |
94 | 97 | """ |
95 | | - r_sq = pos[:, 0] ** 2 + pos[:, 1] ** 2 |
96 | | - rabi_freqs = self.center_rabi_freq * np.exp(-2 * r_sq / (self.r_profile**2)) |
| 98 | + rabi_freqs = self.profile_func(pos) |
97 | 99 | if self.r_beam is not None: |
98 | | - rabi_freqs[r_sq > self.r_beam] = 0.0 |
| 100 | + rabi_freqs[pos[:, 0] ** 2 + pos[:, 1] ** 2 > self.r_beam] = 0.0 |
| 101 | + return rabi_freqs |
| 102 | + |
| 103 | + @staticmethod |
| 104 | + def _gaussian_profile(pos, r_profile: float, center_rabi_freq: float): |
| 105 | + """ |
| 106 | + Rabi frequency at a position of a Gaussian beam. |
| 107 | +
|
| 108 | + Parameters |
| 109 | + ---------- |
| 110 | + pos : (n x 2) array or (n x 3) array |
| 111 | + positions of the n atoms in two or three dimensions (x, y, [z]). |
| 112 | + r_profile : float |
| 113 | + 1/e² radius of the Gaussian intensity profile in m |
| 114 | + center_rabi_freq : float |
| 115 | + Rabi frequency at center of intensity profile in rad/s |
| 116 | +
|
| 117 | + Returns |
| 118 | + ------- |
| 119 | + rabi_freqs : array of float |
| 120 | + the Rabi frequencies for the n positions. If `r_beam` is set, the Rabi |
| 121 | + frequency will be set to 0 outside of the beam. |
| 122 | + """ |
| 123 | + r_sq = pos[:, 0] ** 2 + pos[:, 1] ** 2 |
| 124 | + rabi_freqs = center_rabi_freq * np.exp(-2 * r_sq / (r_profile**2)) |
99 | 125 | return rabi_freqs |
100 | 126 |
|
101 | 127 |
|
@@ -157,7 +183,7 @@ def get_value(self, pos: np.ndarray) -> np.ndarray: |
157 | 183 |
|
158 | 184 | Parameters |
159 | 185 | ---------- |
160 | | - pos : n × 3 array |
| 186 | + pos : n x 3 array |
161 | 187 | array of position vectors (x, y, z) where the wavefront is probed |
162 | 188 |
|
163 | 189 | Returns |
|
0 commit comments