Skip to content

Commit

Permalink
ENH: remove height arg from add_spherical_caps
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusStano committed Nov 13, 2023
1 parent 2d8a0b9 commit 4f25eaa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions rocketpy/motors/tank_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,28 +369,30 @@ def __init__(self, radius, height, spherical_caps=False, geometry_dict=dict()):
height : float
Height of the cylindrical tank, in meters.
spherical_caps : bool, optional
If True, the tank will have spherical caps. The height of the
tank is maintained. The default is False.
If True, the tank will have spherical caps at the top and bottom
with the same radius as the cylindrical part. If False, the tank
will have flat caps at the top and bottom. Defaults to False.
geometry_dict : dict, optional
Dictionary containing the geometry of the tank. See TankGeometry.
"""
super().__init__(geometry_dict)
self.height = height
self.has_caps = False
if spherical_caps:
self.add_geometry((-height / 2 + radius, height / 2 - radius), radius)
self.add_spherical_caps(height)
self.add_spherical_caps()
else:
self.add_geometry((-height / 2, height / 2), radius)

def add_spherical_caps(self, total_height):
def add_spherical_caps(self):
"""
Adds spherical caps to the tank. The caps are added at the bottom
and at the top of the tank. If the tank already has caps, it raises a
ValueError.
"""
if not self.has_caps:
radius = self.radius(0)
height = total_height
height = self.height
bottom_cap_range = (-height / 2, -height / 2 + radius)
upper_cap_range = (height / 2 - radius, height / 2)

Expand Down

0 comments on commit 4f25eaa

Please sign in to comment.