Commit b7c9b104 authored by Frederik Zahle's avatar Frederik Zahle

fix interp_x for negative diffs in xp

parent ba8f027c
Pipeline #12185 passed with stages
in 6 minutes and 26 seconds
......@@ -298,7 +298,8 @@ class AirfoilShape(Curve):
y = self.s[iTEl:iLE][::-1]
else:
y = self.s[iTEl:iLE]
spl = NaturalCubicSpline(s, y)
ix = np.where(np.diff(s)>0)[0]
spl = NaturalCubicSpline(s[ix], y[ix])
return spl(x)
if side == 'upper':
......@@ -309,7 +310,8 @@ class AirfoilShape(Curve):
y = self.s[iLE:iTEu][::-1]
else:
y = self.s[iLE:iTEu]
spl = NaturalCubicSpline(s, y)
ix = np.where(np.diff(s)>0)[0]
spl = NaturalCubicSpline(s[ix], y[ix])
return spl(x)
class BlendAirfoilShapes(object):
......
......@@ -95,6 +95,17 @@ class AirfoilShapeTests2(unittest.TestCase):
[1, 0.01, 30]])
self.assertEqual(np.testing.assert_allclose(af.ds, ds, 1E-06), None)
def test_interp_x(self):
af = AirfoilShape(points=np.loadtxt('data/ffaw3241.dat'))
s = af.interp_x(0.3, 'upper')
self.assertAlmostEqual(s, 0.662865208113911, places=5)
ps = np.loadtxt('data/ffaw3241.dat')
ps[:, 0] *= -1.
af = AirfoilShape(points=ps)
s = af.interp_x(0.3, 'upper')
self.assertAlmostEqual(s, 0.49896127212155866, places=5)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment