Skip to content

Commit

Permalink
using enum instead of string
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Sep 28, 2024
1 parent 76e4c73 commit 587032f
Show file tree
Hide file tree
Showing 17 changed files with 701 additions and 689 deletions.
512 changes: 256 additions & 256 deletions docs/usage.rst

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions examples/spherical_tokamak_from_plasma_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
my_reactor = paramak.spherical_tokamak_from_plasma(
radial_builds=[
[
("gap", 10),
("layer", 50),
("layer", 15),
("gap", 50),
("plasma", 300),
("gap", 60),
("layer", 15),
("layer", 60),
("layer", 10),
(paramak.LayerType.GAP, 10),
(LayerType.SOLID, 50),
(LayerType.SOLID, 15),
(paramak.LayerType.GAP, 50),
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 15),
(LayerType.SOLID, 60),
(LayerType.SOLID, 10),
]
],
elongation=2,
Expand Down
22 changes: 11 additions & 11 deletions examples/spherical_tokamak_from_plasma_with_divertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
my_reactor = paramak.spherical_tokamak_from_plasma(
radial_builds=[
[
("gap", 10),
("layer", 50),
("layer", 15),
("gap", 50),
("plasma", 300),
("gap", 60),
("layer", 15),
("layer", 60),
("layer", 10),
(paramak.LayerType.GAP, 10),
(LayerType.SOLID, 50),
(LayerType.SOLID, 15),
(paramak.LayerType.GAP, 50),
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 15),
(LayerType.SOLID, 60),
(LayerType.SOLID, 10),
],
[("gap", 75), ("lower_divertor", 100)], # this divertor connects to the center column
[("gap", 120), ("upper_divertor", 140)], # this divertor has some blanket between the center colum and itself
[(paramak.LayerType.GAP, 75), ("lower_divertor", 100)], # this divertor connects to the center column
[(paramak.LayerType.GAP, 120), ("upper_divertor", 140)], # this divertor has some blanket between the center colum and itself
],
elongation=2,
triangularity=0.55,
Expand Down
18 changes: 9 additions & 9 deletions examples/spherical_tokamak_from_plasma_with_pf_magnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@

my_reactor = paramak.spherical_tokamak_from_plasma(
radial_builds=[
("gap", 10),
("layer", 50),
("layer", 15),
("gap", 50),
("plasma", 300),
("gap", 60),
("layer", 15),
("layer", 60),
("layer", 10),
(paramak.LayerType.GAP, 10),
(LayerType.SOLID, 50),
(LayerType.SOLID, 15),
(paramak.LayerType.GAP, 50),
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 15),
(LayerType.SOLID, 60),
(LayerType.SOLID, 10),
],
elongation=2,
triangularity=0.55,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
my_reactor = paramak.spherical_tokamak_from_plasma(
radial_builds=[
[
("gap", 10),
("layer", 50),
("layer", 15),
("gap", 50),
("plasma", 300),
("gap", 60),
("layer", 15),
("layer", 60),
("layer", 10),
(paramak.LayerType.GAP, 10),
(LayerType.SOLID, 50),
(LayerType.SOLID, 15),
(paramak.LayerType.GAP, 50),
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 15),
(LayerType.SOLID, 60),
(LayerType.SOLID, 10),
],
[("gap", 75), ("lower_divertor", 100)],
[(paramak.LayerType.GAP, 75), ("lower_divertor", 100)],
],
elongation=2,
triangularity=0.55,
Expand Down
18 changes: 9 additions & 9 deletions examples/spherical_tokamak_from_plasma_with_tf_magnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

result = paramak.spherical_tokamak_from_plasma(
radial_builds=[
("gap", 70),
("layer", 10),
("layer", 10),
("gap", 50),
("plasma", 300),
("gap", 60),
("layer", 10),
("layer", 60),
("layer", 10),
(paramak.LayerType.GAP, 70),
(LayerType.SOLID, 10),
(LayerType.SOLID, 10),
(paramak.LayerType.GAP, 50),
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 10),
(LayerType.SOLID, 60),
(LayerType.SOLID, 10),
],
elongation=2.5,
rotation_angle=180,
Expand Down
36 changes: 18 additions & 18 deletions examples/spherical_tokamak_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
my_reactor = paramak.spherical_tokamak(
radial_builds=[
[
("gap", 10),
("layer", 50),
("layer", 15),
("gap", 50),
("plasma", 300),
("gap", 60),
("layer", 40),
("layer", 60),
("layer", 10),
(paramak.LayerType.GAP, 10),
(LayerType.SOLID, 50),
(LayerType.SOLID, 15),
(paramak.LayerType.GAP, 50),
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 40),
(LayerType.SOLID, 60),
(LayerType.SOLID, 10),
]
],
vertical_build=[
("layer", 15),
("layer", 80),
("layer", 10),
("gap", 50),
("plasma", 700),
("gap", 60),
("layer", 10),
("layer", 40),
("layer", 15),
(LayerType.SOLID, 15),
(LayerType.SOLID, 80),
(LayerType.SOLID, 10),
(paramak.LayerType.GAP, 50),
(paramak.LayerType.PLASMA, 700),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 10),
(LayerType.SOLID, 40),
(LayerType.SOLID, 15),
],
rotation_angle=180,
triangularity=-0.55,
Expand Down
24 changes: 12 additions & 12 deletions examples/tokamak_from_plasma_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

my_reactor = paramak.tokamak_from_plasma(
radial_builds=[
("gap", 10),
("layer", 30),
("layer", 50),
("layer", 10),
("layer", 120),
("layer", 20),
("gap", 60),
("plasma", 300),
("gap", 60),
("layer", 20),
("layer", 120),
("layer", 10),
(paramak.LayerType.GAP, 10),
(LayerType.SOLID, 30),
(LayerType.SOLID, 50),
(LayerType.SOLID, 10),
(LayerType.SOLID, 120),
(LayerType.SOLID, 20),
(paramak.LayerType.GAP, 60),
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 20),
(LayerType.SOLID, 120),
(LayerType.SOLID, 10),
],
elongation=2,
triangularity=0.55,
Expand Down
26 changes: 13 additions & 13 deletions examples/tokamak_from_plasma_with_divertor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
my_reactor = paramak.tokamak(
radial_builds=[
[
("gap", 10),
("layer", 30),
("layer", 50),
("layer", 10),
("layer", 120),
("layer", 20),
("gap", 60),
("plasma", 300),
("gap", 60),
("layer", 20),
("layer", 120),
("layer", 10),
(paramak.LayerType.GAP, 10),
(LayerType.SOLID, 30),
(LayerType.SOLID, 50),
(LayerType.SOLID, 10),
(LayerType.SOLID, 120),
(LayerType.SOLID, 20),
(paramak.LayerType.GAP, 60),
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 20),
(LayerType.SOLID, 120),
(LayerType.SOLID, 10),
],
[("gap", 300), ("lower_divertor", 150)],
[(paramak.LayerType.GAP, 300), ("lower_divertor", 150)],
],
elongation=2,
triangularity=0.55,
Expand Down
42 changes: 21 additions & 21 deletions examples/tokamak_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@

my_reactor = paramak.tokamak(
radial_builds=[
("gap", 10),
("layer", 30),
("layer", 50),
("layer", 10),
("layer", 120),
("layer", 20),
("gap", 60),
("plasma", 300),
("gap", 60),
("layer", 20),
("layer", 120),
("layer", 10),
(paramak.LayerType.GAP, 10),
(LayerType.SOLID, 30),
(LayerType.SOLID, 50),
(LayerType.SOLID, 10),
(LayerType.SOLID, 120),
(LayerType.SOLID, 20),
(paramak.LayerType.GAP, 60),
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 20),
(LayerType.SOLID, 120),
(LayerType.SOLID, 10),
],
vertical_build=[
("layer", 15),
("layer", 80),
("layer", 10),
("gap", 50),
("plasma", 700),
("gap", 60),
("layer", 10),
("layer", 40),
("layer", 15),
(LayerType.SOLID, 15),
(LayerType.SOLID, 80),
(LayerType.SOLID, 10),
(paramak.LayerType.GAP, 50),
(paramak.LayerType.PLASMA, 700),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 10),
(LayerType.SOLID, 40),
(LayerType.SOLID, 15),
],
triangularity=0.55,
rotation_angle=180,
Expand Down
42 changes: 21 additions & 21 deletions examples/tokamak_with_pf_magnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@

my_reactor = paramak.tokamak(
radial_builds=[
("gap", 10),
("layer", 30),
("layer", 50),
("layer", 10),
("layer", 120),
("layer", 20),
("gap", 60),
("plasma", 300),
("gap", 60),
("layer", 20),
("layer", 120),
("layer", 10),
(paramak.LayerType.GAP, 10),
(LayerType.SOLID, 30),
(LayerType.SOLID, 50),
(LayerType.SOLID, 10),
(LayerType.SOLID, 120),
(LayerType.SOLID, 20),
(paramak.LayerType.GAP, 60),
(paramak.LayerType.PLASMA, 300),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 20),
(LayerType.SOLID, 120),
(LayerType.SOLID, 10),
],
vertical_build=[
("layer", 15),
("layer", 80),
("layer", 10),
("gap", 50),
("plasma", 700),
("gap", 60),
("layer", 10),
("layer", 40),
("layer", 15),
(LayerType.SOLID, 15),
(LayerType.SOLID, 80),
(LayerType.SOLID, 10),
(paramak.LayerType.GAP, 50),
(paramak.LayerType.PLASMA, 700),
(paramak.LayerType.GAP, 60),
(LayerType.SOLID, 10),
(LayerType.SOLID, 40),
(LayerType.SOLID, 15),
],
triangularity=0.55,
rotation_angle=180,
Expand Down
2 changes: 1 addition & 1 deletion src/paramak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .workplanes.toroidal_field_coil_rectangle import toroidal_field_coil_rectangle
from .workplanes.u_shaped_dome import u_shaped_dome

# from .utils import *
from .utils import LayerType

__version__ = version("paramak")

Expand Down
11 changes: 6 additions & 5 deletions src/paramak/assemblies/spherical_tokamak.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
sum_up_to_gap_before_plasma,
sum_up_to_plasma,
sum_before_after_plasma,
LayerType
)
from ..workplanes.blanket_from_plasma import blanket_from_plasma
from ..workplanes.center_column_shield_cylinder import center_column_shield_cylinder
Expand All @@ -33,7 +34,7 @@ def create_blanket_layers_after_plasma(
lower_thicknees = vertical_build[plasma_index_vertical - 1 - i][1]
radial_thickness = item[1]

if item[0] == "gap":
if item[0] == LayerType.GAP:
cumulative_thickness_rb += radial_thickness
cumulative_thickness_uvb += upper_thicknees
cumulative_thickness_lvb += lower_thicknees
Expand Down Expand Up @@ -80,11 +81,11 @@ def create_center_column_shield_cylinders(radial_build, vertical_build, rotation
center_column_shield_height = sum([item[1] for item in vertical_build])

for index, item in enumerate(radial_build):
if item[0] == "plasma":
if item[0] == LayerType.PLASMA:
break
if item[0] == "gap" and radial_build[index + 1][0] == "plasma":
if item[0] == LayerType.GAP and radial_build[index + 1][0] == LayerType.PLASMA:
break
if item[0] == "gap":
if item[0] == LayerType.GAP:
total_sum += item[1]
continue

Expand Down Expand Up @@ -142,7 +143,7 @@ def spherical_tokamak_from_plasma(

plasma_height = 2 * minor_radius * elongation
# slice opperation reverses the list and removes the last value to avoid two plasmas
vertical_build = upper_vertical_build[::-1][:-1] + [("plasma", plasma_height)] + upper_vertical_build[1:]
vertical_build = upper_vertical_build[::-1][:-1] + [(LayerType.PLASMA, plasma_height)] + upper_vertical_build[1:]

return spherical_tokamak(
radial_builds=radial_builds,
Expand Down
Loading

0 comments on commit 587032f

Please sign in to comment.