From 0bd39dc4022856aba91fbd2762c321765111baf8 Mon Sep 17 00:00:00 2001 From: Hannes <157805253+Yamneznim@users.noreply.github.com> Date: Thu, 7 May 2026 16:08:07 +0200 Subject: [PATCH] Update geometry.py Updated geometry.py, so that the value of c only gets changed if necessary for kappa>0. Also the sign of c is kept. Thus allowing the definition of concave lenses. --- tracepy/geometry.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tracepy/geometry.py b/tracepy/geometry.py index c295d00..b4ab5f0 100644 --- a/tracepy/geometry.py +++ b/tracepy/geometry.py @@ -86,8 +86,12 @@ def check_params(self) -> None: if self.kappa is None: raise Exception("Specify a kappa for this conic.") elif self.kappa > 0: - print("Warning: Specified c value is not used when kappa>0") - self.c = np.sqrt(1 / (self.kappa * pow(self.Diam / 2., 2))) + if pow(self.Diam / 2., 2) > 1/(self.kappa*pow(self.c, 2)): + print("Warning: Specified c value had to be changed in accordance with the conditions of the conic euqation.") + if self.c > 0: + self.c = np.sqrt(1 / (self.kappa * pow(self.Diam / 2., 2))) + elif self.c < 0: + self.c = -np.sqrt(1 / (self.kappa * pow(self.Diam / 2., 2))) elif self.c == 0 and self.kappa is None: # Used for planes, does not affect calculations. self.kappa = 1. @@ -212,4 +216,4 @@ def conics_plot(self, point: np.ndarray) -> np.ndarray: if self.kappa is None: raise ValueError("kappa must not be None for conic plot calculations") function[~nan_idx] = self.c * pow(rho, 2) / (1 + pow((1 - self.kappa * pow(self.c, 2) * pow(rho, 2)), 0.5)) - return function \ No newline at end of file + return function