def create_sample_profile(): """ xup_coordinates, yup_coordinates, xdown_coordinates, ydown_coordinates """ profile = pb.ProfileBase() profile.xup_coordinates = np.linspace(-1.0, 1.0, 5) profile.yup_coordinates = np.array([0.0, 0.75, 1.0, 0.75, 0.0]) profile.xdown_coordinates = np.linspace(-1.0, 1.0, 5) profile.ydown_coordinates = np.zeros(5) return profile
def create_sample_profile_3(): """ Coordinates of unit circle (i.e. x^2+y^2=1) """ profile = pb.ProfileBase() profile.xup_coordinates = np.linspace(-1.0, 1.0, num=250) profile.yup_coordinates = np.sqrt(1 - np.power(profile.xup_coordinates, 2)) profile.xdown_coordinates = np.linspace(-1.0, 1.0, num=250) profile.ydown_coordinates = -np.sqrt(1 - np.power(profile.xup_coordinates, 2)) return profile
def create_sample_profile_2(): """ xup_coordinates != xdown_coordinates elementwise """ profile = pb.ProfileBase() profile.xup_coordinates = np.linspace(-1.0, 1.0, 5) profile.yup_coordinates = np.array([0.0, 0.75, 1.0, 0.75, 0.0]) profile.xdown_coordinates = np.linspace(-1.0, 1.0, 5) profile.xdown_coordinates[2] = 0.1 profile.ydown_coordinates = np.zeros(5) return profile
def test_trailing_edge_init(self): profile = pb.ProfileBase() np.testing.assert_equal(profile.trailing_edge, np.zeros(2))
def test_trailing_edge_size(self): profile = pb.ProfileBase() assert profile.trailing_edge.size == 2
def test_leading_edge_size(self): profile = pb.ProfileBase() assert profile.leading_edge.size == 2
def test_camber_init(self): profile = pb.ProfileBase() assert profile.camber_line is None
def test_chord_init(self): profile = pb.ProfileBase() assert profile.chord_line is None
def test_ydown_init(self): profile = pb.ProfileBase() assert profile.ydown_coordinates is None
def test_xup_init(self): profile = pb.ProfileBase() assert profile.xup_coordinates is None
def test_scale_exceptions(self): profile = pb.ProfileBase() with self.assertRaises(TypeError): profile.scale()
def test_translate_exceptions(self): profile = pb.ProfileBase() with self.assertRaises(TypeError): profile.translate()
def test_rotate_exceptions_2(self): profile = pb.ProfileBase() with self.assertRaises(ValueError): profile.rotate(rad_angle=np.pi, deg_angle=180)
def test_interpolate_crds_exceptions_3(self): profile = pb.ProfileBase() with self.assertRaises(ValueError): profile.interpolate_coordinates(num=500, radius=-1.0)
def test_interpolate_crds_exceptions_1(self): profile = pb.ProfileBase() with self.assertRaises(TypeError): profile.interpolate_coordinates(num=500.5, radius=1.0)