Commit 5c741f9f authored by Frederik Zahle's avatar Frederik Zahle
Browse files

Merge branch 'dp_conv' into 'master'

small fix to calculation of LE position in AirfoilShape

@maloros this at least fixes the test you made. could you also please check that the issue downstream in BECASWrapper is fixed?

See merge request !3
parents 44bcf0dc 7165c594
Pipeline #2192 passed with stage
in 39 seconds
......@@ -53,7 +53,7 @@ class AirfoilShape(Curve):
for i in range(self.nd):
self.TE[i] = np.average(self.points[[0, -1], i])
res = minimize(_sdist, (0.5), method='SLSQP', bounds=[(0, 1)])
res = minimize(_sdist, (0.5), method='SLSQP', bounds=[(0, 1)], tol=1.e-16)
self.sLE = res['x'][0]
self.iLE = np.where(np.abs(self.s - self.sLE) == np.abs(self.s - self.sLE).min())[0]
xLE = self._splines[0](self.sLE)
......
import unittest
import numpy as np
from PGL.components.airfoil import AirfoilShape
class AirfoilShapeTests(unittest.TestCase):
''' Tests for components.airfoil.py
'''
def setUp(self):
unittest.TestCase.setUp(self)
self.af = AirfoilShape()
self.af.initialize(points=np.loadtxt('data/ffaw3480.dat'))
self.dps_s01 = np.array([0.0, 0.25, 0.5, 0.75, 1.0])
def test_s_to_11_10(self):
dps_s11 = np.array([self.af.s_to_11(s) for s in self.dps_s01])
dps_s01n = np.array([self.af.s_to_01(s) for s in dps_s11])
self.assertEqual(np.testing.assert_allclose(dps_s01n, self.dps_s01, 1E-06), None)
def test_s_to_11_10_rotate(self):
afi = self.af.copy()
afi.rotate_z(-45.0)
dps_s11 = np.array([afi.s_to_11(s) for s in self.dps_s01])
afii = self.af.copy()
afii.rotate_z(+45.0)
dps_s01n = np.array([afii.s_to_01(s) for s in dps_s11])
self.assertEqual(np.testing.assert_allclose(dps_s01n, self.dps_s01, 1E-06), None)
def test_s_to_11_10_scale_equal(self):
afi = self.af.copy()
afi.scale(1.5)
points = afi.points
dps_s11 = np.array([afi.s_to_11(s) for s in self.dps_s01])
afii = self.af.copy()
afii.scale(1.5)
pointsn = afii.points
dps_s01n = np.array([afii.s_to_01(s) for s in dps_s11])
self.assertEqual(np.testing.assert_allclose(dps_s01n, self.dps_s01, 1E-06), None)
self.assertEqual(np.testing.assert_allclose(pointsn, points, 1E-06), None)
def test_s_to_11_10_scale_not_equal(self):
afi = self.af.copy()
afi.scale(1.1)
#points = afi.points
dps_s11 = np.array([afi.s_to_11(s) for s in self.dps_s01])
afii = self.af.copy()
afii.scale(1.5)
#pointsn = afii.points
dps_s01n = np.array([afii.s_to_01(s) for s in dps_s11])
self.assertEqual(np.testing.assert_allclose(dps_s01n, self.dps_s01, 1E-06), None)
#self.assertEqual(np.testing.assert_allclose(pointsn, points, 1E-06), None)
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