diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2019-06-17 16:03:12 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2019-06-17 16:03:12 +0200 |
commit | 071ca9989afa0cdfa29b95b026170b7aa9651f3d (patch) | |
tree | 7bcf2e01d9222262e70a92e039de46dd267e6aa6 /src/phys.py | |
parent | 14262a97c7697a34430379ddbf1d6f5b12ef729f (diff) |
Arbitrary phase retarders
Diffstat (limited to 'src/phys.py')
-rw-r--r-- | src/phys.py | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/src/phys.py b/src/phys.py index c47a497..8065d14 100644 --- a/src/phys.py +++ b/src/phys.py @@ -63,44 +63,31 @@ class Ellipse: self.theta = np.arcsin(V[3] / R) / 2 class Polarizer: - def __init__(self, type, delta=0): + def __init__(self, delta=0): self.name = "New element" # FIXME - self.type = type + self.phase_retardation = 0 self.angle = 0 self.delta = delta self.ref = False self.t1 = 1 self.t2 = 0 self.enable = True - self.set_type(type) - - def set_type(self, type): - if type == "linear": - self.M = np.array([[1, 0], [0, 0]]) - elif type == "quarterwave": - self.M = np.exp(-1j / 4 * np.pi) * \ - np.array([[1, 0], [0, 1j]]) - else: - raise ValueError("bad Polarizer type: %s" % type) - self.type = type def mul(self, state): # unpolarized light if state is None: - if self.type == "linear": + if self.t2 == 0: # FIXME: this is half-assed return np.dot(R(-self.angle - self.delta), \ np.array([[1], [0]])) * np.sqrt(self.t1) else: return None - if type == "linear": - A = np.sqrt(np.array([[self.t1, 0], [0, self.t2]])) - else: - A = np.sqrt(np.array([[self.t1, 0], [0, self.t1]])) - - M = np.matmul(R(-self.angle - self.delta), \ - np.matmul(np.matmul(self.M, A), R(self.angle + self.delta))) - return np.dot(M, state) + # FIXME: half-assed again + A = np.sqrt(np.array([[self.t1, 0], [0, self.t2]])) + M = np.array([[1, 0], [0, np.exp(1j * self.phase_retardation),]]) + MR = np.matmul(R(-self.angle - self.delta), \ + np.matmul(np.matmul(M, A), R(self.angle + self.delta))) + return np.dot(MR, state) class System: def __init__(self): |