From 45f3f783e456ca4b3e8b1ca9b5f87ce39361f6b7 Mon Sep 17 00:00:00 2001
From: Lou Bernabeu <lou.bernabeu@student-cs.fr>
Date: Wed, 6 Jan 2021 11:13:51 +0100
Subject: [PATCH] removed __init__.py, corrected typos in elements.py

---
 __init__.py |  2 --
 __main__.py | 30 ++++++++++++++++++++++++++++++
 elements.py |  2 +-
 3 files changed, 31 insertions(+), 3 deletions(-)
 delete mode 100644 __init__.py

diff --git a/__init__.py b/__init__.py
deleted file mode 100644
index 9664db0..0000000
--- a/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-import numpy as np
-import cmath
diff --git a/__main__.py b/__main__.py
index 86d59a2..bc5b490 100644
--- a/__main__.py
+++ b/__main__.py
@@ -1,4 +1,34 @@
+import numpy as np
 import elements
 import graphics
 
 print("Hi World!")
+
+## Tests
+
+H = (1/np.sqrt(2))*np.array([[1, 1],[1, -1]], dtype='complex')
+H_rev = (1/np.sqrt(2))*np.array([[-1, 1],[1, 1]], dtype='complex')
+
+A = np.kron(H_rev, np.eye(2, dtype='complex')) # first beam splitter matrix
+B = np.kron(H, np.eye(2, dtype='complex')) # second beam splitter matrix
+
+X = np.array([[0, 1], [1, 0]], dtype='complex')
+Z = np.array([[1, 0], [0, -1]], dtype='complex')
+
+
+source = elements.Source(initial_vector = np.array([1.+0j, 0.]))
+
+BS1 = elements.BeamSplitter(previous = {"left": (source, "left"), "right": None}, matrix=A)
+
+X_left_1 = elements.Plate(previous = (BS1, "left"), jones_matrix=X)
+Z_left_2 = elements.Plate(previous = (X_left_1, "left"), jones_matrix = Z)
+
+
+Z_right_1 = elements.Plate(previous = (BS1, "right"), jones_matrix = Z)
+X_right_2 = elements.Plate(previous = (Z_right_1, "left"), jones_matrix = X)
+
+BS2 = elements.BeamSplitter(previous = {"left": (Z_left_2, "left"), "right": (X_right_2, "left")}, matrix = B)
+
+screen = elements.Screen(previous = (BS2, "left"))
+
+print(screen.out())
diff --git a/elements.py b/elements.py
index 2026c2b..a8cc8c4 100644
--- a/elements.py
+++ b/elements.py
@@ -58,7 +58,7 @@ class BeamSplitter(Element):
             left_input_state = left_input_element.out(left_input_element_output_side)
 
         if self.previous["right"] is None:
-            left_input_state = np.zeros((2,), dtype="complex") # if no input on the right, then |\psi> = 0
+            right_input_state = np.zeros((2,), dtype="complex") # if no input on the right, then |\psi> = 0
         else:
             right_input_element = self.previous["right"][0]
             right_input_element_output_side = self.previous["right"][1]
-- 
GitLab