Skip to content

Commit

Permalink
Ensure r_le is always valid
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldevriesdarcorp committed Oct 11, 2019
1 parent b119c2c commit 69150d7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions af_opt/components/geom_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setup(self):
self.add_output("r_le", val=0.0)

def compute(self, inputs, outputs, discrete_inputs=None, discrete_outputs=None):
x, y_u, y_l, _, t = self.compute_coords(inputs, 500)
x, y_u, y_l, _, t = self.compute_coords(inputs)

outputs["t_c"] = np.max(t)
outputs["A_cs"] = np.trapz(t, x)
Expand All @@ -36,4 +36,7 @@ def compute(self, inputs, outputs, discrete_inputs=None, discrete_outputs=None):
d2y = np.gradient(dy)

curvature = np.abs(d2x * dy - dx * d2y) / (dx * dx + dy * dy) ** 1.5
outputs["r_le"] = 1.0 / curvature[x.size]
if np.isnan(curvature[x.size]) or np.isinf(curvature[x.size]) or curvature[x.size] == 0.0:
outputs["r_le"] = 0.0
else:
outputs["r_le"] = 1.0 / curvature[x.size]

0 comments on commit 69150d7

Please sign in to comment.