From f1fe4b72289c3448177e896faaaeb7ac22d72427 Mon Sep 17 00:00:00 2001
From: Sean Leavey <sean.leavey@gmail.com>
Date: Sun, 23 Oct 2016 15:29:02 +0100
Subject: [PATCH] Added check to make sure R, T and L add up to 1 for mirrors
 and beam splitters

---
 pykat/components.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/pykat/components.py b/pykat/components.py
index 07ecaa3..cc7488d 100644
--- a/pykat/components.py
+++ b/pykat/components.py
@@ -339,6 +339,10 @@ class AbstractMirrorComponent(Component):
         if R is not None: self.R.value = R
         if T is not None: self.T.value = T
         if L is not None: self.L.value = L
+        
+        # check energy conservation
+        if self.R.value + self.T.value + self.L.value != 1:
+            raise pkex.BasePyKatException("The specified R, T and L values (%f, %f and %f) violate energy conservation" % (self.R.value, self.T.value, self.L.value))
     
     @property
     def z(self): return self.__z
-- 
GitLab