Skip to content
Snippets Groups Projects
Commit 7df896b9 authored by Johannes Schumann's avatar Johannes Schumann
Browse files

Fix for spherical geometry

parent 8b89ac9a
No related branches found
No related tags found
No related merge requests found
Pipeline #20622 passed
......@@ -128,7 +128,7 @@ class SphericalVolume(DetectorVolume):
return 4 / 3 * np.pi * np.power(self._radius, 3)
def random_pos(self):
r = np.power(self._radius, 1 / 3)
r = self._radius * np.power(np.random.random(), 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))
......
......@@ -13,6 +13,7 @@ __status__ = "Development"
import unittest
from km3buu.geometry import *
import numpy as np
class TestGeneralGeometry(unittest.TestCase):
......@@ -38,6 +39,8 @@ class TestSphere(unittest.TestCase):
assert pos[0] < 22.0
assert pos[1] < 22.0
assert pos[2] < 22.0
radius = np.sqrt(np.sum(np.power((np.array(pos) - 2), 2)))
assert radius <= 20
class TestCan(unittest.TestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment