Repository: fusion-energy/paramak (language: python)

Issue:
moved gui dockerfile
just moving the dockerfile so that google cloud build can find it


Discussion / hints:

Fix patch:
diff --git a/docs/source/API-Reference.rst b/docs/source/API-Reference.rst
index b08b73cec..10f977b9f 100644
--- a/docs/source/API-Reference.rst
+++ b/docs/source/API-Reference.rst
@@ -1690,6 +1690,28 @@ RotatedIsoscelesTriangle
    :members:
    :show-inheritance:
 
+
+SphericalShell
+
+.. cadquery::
+   :select: cadquery_object
+   :gridsize: 0
+
+   import paramak
+   my_component = paramak.SphericalShell(
+      inner_radius = 5,
+      shell_thickness = 1,
+      rotation_angle=180,
+      workplane='XY'
+   )
+
+   cadquery_object = my_component.solid
+
+.. automodule:: paramak.parametric_components.spherical_shell
+   :members:
+   :show-inheritance:
+
+
 Parametric Reactors
 ===================
 
diff --git a/src/paramak/__init__.py b/src/paramak/__init__.py
index e0d89913b..ddcee1580 100644
--- a/src/paramak/__init__.py
+++ b/src/paramak/__init__.py
@@ -45,6 +45,7 @@
 from .parametric_shapes.sweep_straight_shape import SweepStraightShape
 from .parametric_shapes.sweep_circle_shape import SweepCircleShape
 
+from .parametric_components.spherical_shell import SphericalShell
 from .parametric_components.circular_port import CircularPort
 from .parametric_components.hexagon_pin import HexagonPin
 
@@ -177,6 +178,7 @@
     RotateSplineShape,
     RotateStraightShape,
     RotateCircleShape,
+    SphericalShell,
     SweepMixedShape,
     SweepSplineShape,
     SweepStraightShape,
diff --git a/src/paramak/parametric_components/spherical_shell.py b/src/paramak/parametric_components/spherical_shell.py
new file mode 100644
index 000000000..0f87e36fd
--- /dev/null
+++ b/src/paramak/parametric_components/spherical_shell.py
@@ -0,0 +1,95 @@
+from typing import Optional, Tuple
+
+from paramak import RotateMixedShape
+from paramak.utils import patch_workplane
+
+patch_workplane()
+
+
+class SphericalShell(RotateMixedShape):
+
+    """Create a 3d CadQuery solid spherical shell from an inner radius and a shell thickness
+
+    Args:
+        inner_radius: inner radius of the spherical shell (needs to be >= 0)
+        shell_thickness: thickness of the spherical shell (needs to be > 0)
+        rotation_angle: rotation_angle of solid created. a cut is performed
+            from rotation_angle to 360 degrees. Defaults to 360.
+        color: the color to use when exporting the shape to CAD formats that
+            support color. A tuple of three floats each ranging between 0
+            and 1. Defaults to (0.09,0.58,0.71)
+        name: the name of the shape, used to name files when exporting and
+            as a legend in plots. Defaults to 'sphericalshellshape'
+        translate: (optional) distance to translate / move the shape by. Specified as
+            a vector of (X,Y,Z) directions.
+    """
+
+    def __init__(
+        self,
+        inner_radius: float,
+        shell_thickness: float,
+        name: str = "sphericalshell",
+        color: Tuple[float, float, float, Optional[float]] = (
+            0.09,
+            0.58,
+            0.71,
+        ),
+        **kwargs
+    ):
+
+        super().__init__(color=color, name=name, **kwargs)
+
+        self.inner_radius = inner_radius
+        self.shell_thickness = shell_thickness
+        self.name = name
+        self.color = color
+
+    @property
+    def inner_radius(self):
+        return self._inner_radius
+
+    @inner_radius.setter
+    def inner_radius(self, value):
+        if value is None:
+            raise ValueError("Inner radius of SphericalShell cannot be None")
+        if value < 0:
+            raise ValueError("Inner radius of SphericalShell cannot be negative")
+        self._inner_radius = value
+
+    @property
+    def shell_thickness(self):
+        return self._shell_thickness
+
+    @shell_thickness.setter
+    def shell_thickness(self, value):
+        if value is None:
+            raise ValueError("Shell thickness of SphericalShell cannot be None")
+        if value <= 0:
+            raise ValueError("Shell thickness of SphericalShell needs to be > 0")
+        self._shell_thickness = value
+
+    def find_points(self):
+
+        if not 0 <= self.inner_radius:
+            raise ValueError("inner_radius must be 0 or greater.less than outer_radius.")
+
+        if not 0 < self.shell_thickness:
+            raise ValueError("shell_tickness must be greater than 0.")
+
+        if self.inner_radius == 0:
+            # solid sphere
+            self.points = [
+                (0, -self.shell_thickness, "straight"),
+                (0, self.shell_thickness, "circle"),
+                (self.shell_thickness, 0, "circle"),
+            ]
+        else:
+            # shell
+            self.points = [
+                (0, -self.inner_radius, "straight"),
+                (0, -self.inner_radius - self.shell_thickness, "circle"),
+                (self.inner_radius + self.shell_thickness, 0, "circle"),
+                (0, self.inner_radius + self.shell_thickness, "straight"),
+                (0, self.inner_radius, "circle"),
+                (self.inner_radius, 0, "circle"),
+            ]


Test patch:
diff --git a/tests/tests_units/test_parametric_components/test_spherical_shell.py b/tests/tests_units/test_parametric_components/test_spherical_shell.py
new file mode 100644
index 000000000..586b22580
--- /dev/null
+++ b/tests/tests_units/test_parametric_components/test_spherical_shell.py
@@ -0,0 +1,14 @@
+import unittest
+
+import paramak
+
+
+class TestSphericalShell(unittest.TestCase):
+    def setUp(self):
+        self.test_shape = paramak.SphericalShell(inner_radius=1, shell_thickness=0.2)
+
+    def test_creation(self):
+        """Creates a shape using the VacuumVessel parametric component and
+        checks that a cadquery solid is created."""
+
+        assert self.test_shape.solid is not None