Skip to content

Commit 334d165

Browse files
MNT: add error handling for static margin calculation
1 parent a60070e commit 334d165

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

rocketpy/rocket/rocket.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,17 @@ def evaluate_static_margin(self):
652652
self.static_margin.set_inputs("Time (s)")
653653
self.static_margin.set_outputs("Static Margin (c)")
654654
self.static_margin.set_title("Static Margin")
655-
self.static_margin.set_discrete(
656-
lower=0, upper=self.motor.burn_out_time, samples=200
657-
)
655+
656+
try:
657+
self.static_margin.set_discrete(
658+
lower=0, upper=self.motor.burn_out_time, samples=200
659+
)
660+
except ValueError as err:
661+
raise ValueError(
662+
"For some reason the static margin could not be properly calculated. "
663+
"Please check the center of mass and center of pressure functions "
664+
"and verify if they are well defined in the 0s to the burn out time range."
665+
) from err
658666
return self.static_margin
659667

660668
def evaluate_dry_inertias(self):

0 commit comments

Comments
 (0)