Skip to content

Commit

Permalink
added major and minor radius attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Dec 15, 2024
1 parent 055a539 commit 4873af2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
21 changes: 16 additions & 5 deletions src/paramak/assemblies/assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,32 @@
class Assembly(cq.Assembly):
"""Nested assembly of Workplane and Shape objects defining their relative positions."""

def remove(self, name:str):
new_assembly = Assembly()
part_found=False
def __init__(self, elongation=None, triangularity=None, major_radius=None, minor_radius=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.elongation = elongation
self.triangularity = triangularity
self.major_radius = major_radius
self.minor_radius = minor_radius

def remove(self, name: str):
new_assembly = Assembly(
elongation=self.elongation,
triangularity=self.triangularity,
major_radius=self.major_radius,
minor_radius=self.minor_radius
)
part_found = False
for part in self:
if part[1].endswith(f'/{name}'):
part_found = True
# print('removing' , part)
else:
# print('adding' , part)
new_assembly.add(part[0], name=part[1], color=part[3], loc=part[2])
if part_found == False:
if not part_found:
warnings.warn(f'Part with name {name} not found')
return new_assembly


def names(self):
names = []
for part in self:
Expand Down
3 changes: 3 additions & 0 deletions src/paramak/assemblies/spherical_tokamak.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,7 @@ def spherical_tokamak(

my_assembly.elongation = elongation
my_assembly.triangularity = triangularity
my_assembly.major_radius = major_radius
my_assembly.minor_radius = minor_radius

return my_assembly
5 changes: 5 additions & 0 deletions src/paramak/assemblies/tokamak.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,9 @@ def tokamak(

my_assembly.add(plasma, name="plasma", color=cq.Color(*colors.get("plasma", (0.5,0.5,0.5))))

my_assembly.elongation = elongation
my_assembly.triangularity = triangularity
my_assembly.major_radius = major_radius
my_assembly.minor_radius = minor_radius

return my_assembly
6 changes: 4 additions & 2 deletions tests/test_assemblies/test_spherical_tokamak.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_transport_with_magnets(rotation_angle):
[10, 15],
[20, 50],
[20, 50],
[(500, 300), (610, 100)],
[(500, 300), (590, 100)],
):
poloidal_field_coils.append(
paramak.poloidal_field_coil(
Expand Down Expand Up @@ -155,4 +155,6 @@ def test_attributes():
)

assert my_reactor.elongation == 2
assert my_reactor.triangularity == 0.55
assert my_reactor.triangularity == 0.55
assert my_reactor.major_radius == 275
assert my_reactor.minor_radius == 150

0 comments on commit 4873af2

Please sign in to comment.