Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Rotate the mean camber line (MCL) and "upper minus mcl"
new_mcl_coordinates_after = np.transpose(
rotation_matrix @ np.transpose(mcl_coordinates_after - hinge_point)) + hinge_point
new_upper_minus_mcl_after = np.transpose(rotation_matrix @ np.transpose(upper_minus_mcl_after))
# Do blending
# Assemble airfoil
new_mcl_coordinates = np.vstack((mcl_coordinates_before, new_mcl_coordinates_after))
new_upper_minus_mcl = np.vstack((upper_minus_mcl_before, new_upper_minus_mcl_after))
upper_coordinates = np.flipud(new_mcl_coordinates + new_upper_minus_mcl)
lower_coordinates = new_mcl_coordinates - new_upper_minus_mcl
coordinates = np.vstack((upper_coordinates, lower_coordinates[1:, :]))
new_airfoil = Airfoil(name=self.name + " flapped", coordinates=coordinates, repanel=False)
return new_airfoil # TODO fix self-intersecting airfoils at high deflections
# Do the contraction
upper_minus_mcl_adjusted = self.upper_minus_mcl - self.upper_minus_mcl[-1, :] * np.expand_dims(scale_factor, 1)
# Recreate coordinates
upper_coordinates_adjusted = np.flipud(self.mcl_coordinates + upper_minus_mcl_adjusted)
lower_coordinates_adjusted = self.mcl_coordinates - upper_minus_mcl_adjusted
coordinates = np.vstack((
upper_coordinates_adjusted[:-1, :],
lower_coordinates_adjusted
))
# Make a new airfoil with the coordinates
name = self.name + ", with sharp TE"
new_airfoil = Airfoil(name=name, coordinates=coordinates, repanel=False)
return new_airfoil
# Generate a cosine-spaced list of points from 0 to 1
s = cosspace(n_points=n_points_per_side)
x_upper_func = sp_interp.PchipInterpolator(x=upper_distances_from_TE_normalized, y=upper_original_coors[:, 0])
y_upper_func = sp_interp.PchipInterpolator(x=upper_distances_from_TE_normalized, y=upper_original_coors[:, 1])
x_lower_func = sp_interp.PchipInterpolator(x=lower_distances_from_LE_normalized, y=lower_original_coors[:, 0])
y_lower_func = sp_interp.PchipInterpolator(x=lower_distances_from_LE_normalized, y=lower_original_coors[:, 1])
x_coors = np.hstack((x_upper_func(s), x_lower_func(s)[1:]))
y_coors = np.hstack((y_upper_func(s), y_lower_func(s)[1:]))
coordinates = np.column_stack((x_coors, y_coors))
# Make a new airfoil with the coordinates
name = self.name + ", repaneled to " + str(n_points_per_side) + " pts"
new_airfoil = Airfoil(name=name, coordinates=coordinates, repanel=False)
return new_airfoil
foil1 = copy.deepcopy(airfoil1)
foil2 = copy.deepcopy(airfoil2)
if blend_fraction == 0:
return foil1
if blend_fraction == 1:
return foil2
assert blend_fraction >= 0 and blend_fraction <= 1, "blend_fraction is out of the valid range of 0 to 1!"
# Repanel to ensure the same number of points and the same point distribution on both airfoils.
foil1 = foil1.get_repaneled_airfoil(n_points_per_side=200)
foil2 = foil2.get_repaneled_airfoil(n_points_per_side=200)
blended_coordinates = (1 - blend_fraction) * foil1.coordinates + blend_fraction * foil2.coordinates
new_airfoil = Airfoil(name="Blended Airfoils", coordinates=blended_coordinates)
return new_airfoil