From 8f06a8ae6ce68116f4d69e208022e14e36dc7e5a Mon Sep 17 00:00:00 2001 From: Johannes Schumann <johannes.schumann@fau.de> Date: Sat, 3 Apr 2021 00:50:27 +0200 Subject: [PATCH] Naming and fixes --- km3buu/{detector.py => geometry.py} | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) rename km3buu/{detector.py => geometry.py} (80%) diff --git a/km3buu/detector.py b/km3buu/geometry.py similarity index 80% rename from km3buu/detector.py rename to km3buu/geometry.py index 5d32478..81286a3 100644 --- a/km3buu/detector.py +++ b/km3buu/geometry.py @@ -1,4 +1,4 @@ -# Filename: detector.py +# Filename: geometry.py """ Detector geometry related functionalities """ @@ -14,11 +14,12 @@ __status__ = "Development" import numpy as np from abc import ABC, abstractmethod -class DetectorGeometry(ABC): + +class DetectorVolume(ABC): """ Detector geometry class """ - def __init__(self) + def __init__(self): self._volume = -1.0 @abstractmethod @@ -44,7 +45,7 @@ class DetectorGeometry(ABC): return self._volume -class Can(DetectorGeometry): +class CanVolume(DetectorVolume): """ Cylindrical detector geometry @@ -63,9 +64,9 @@ class Can(DetectorGeometry): self._zmin = zmin self._zmax = zmax self._volume = self._calc_volume() - + def _calc_volume(self): - return np.pi * (self._zmax - self.zmax) * np.power(self._radius, 2) + return np.pi * (self._zmax - self._zmin) * np.power(self._radius, 2) def random_pos(self): r = self._radius * np.sqrt(np.random.uniform(0, 1)) @@ -76,7 +77,7 @@ class Can(DetectorGeometry): return (pos_x, pos_y, pos_z) -class Sphere(DetectorGeometry): +class SphericalVolume(DetectorVolume): """ Spherical detector geometry @@ -95,14 +96,14 @@ class Sphere(DetectorGeometry): self._volume = self._calc_volume() def _calc_volume(self): - return 4/3 * np.pi * np.power(self._radius) + return 4 / 3 * np.pi * np.power(self._radius, 3) def random_pos(self): - r = np.power(self._radius, 1/3) + r = np.power(self._radius, 1 / 3) phi = np.random.uniform(0, np.pi) - cosTheta = np.random.uniform(-1,1) - pos_x = r * np.cos(phi) * np.sqrt(1-np.power(cosTheta,2)) - pos_y = r * np.sin(phi) * np.sqrt(1-np.power(cosTheta,2)) + cosTheta = np.random.uniform(-1, 1) + pos_x = r * np.cos(phi) * np.sqrt(1 - np.power(cosTheta, 2)) + pos_y = r * np.sin(phi) * np.sqrt(1 - np.power(cosTheta, 2)) pos_z = r * cosTheta pos = (pos_x, pos_y, pos_z) - return tuple(np.add(center, pos)) + return tuple(np.add(self._center, pos)) -- GitLab