# Load the blade configuration file IN_file = os.getcwd() + '/' + 'regression_blade.cfg' IN = ReadUserInput(IN_file) # (u,v) parametrization of the blade h = 1e-3 Nu, Nv = 500, 50 u = np.linspace(0.00 + h, 1.00 - h, Nu) v = np.linspace(0.00 + h, 1.00 - h, Nv) [u, v] = np.meshgrid(u, v) u = u.flatten() v = v.flatten() UV = np.concatenate((u[:, np.newaxis], v[:, np.newaxis]), axis=1) # Create the blade my_blade = Blade3D(IN, UV) my_blade.make_blade() # Get machine epsilon for double-precision floating-point arithmetics eps = np.finfo(np.float64).eps # -------------------------------------------------------------------------------------------------------------------- # # Main computations # -------------------------------------------------------------------------------------------------------------------- # # Normal vector computation normals_CS = my_blade.get_surface_normals(u, v, method='complex_step', step=1e-12) normals_FFD = my_blade.get_surface_normals(u, v,
def animate(self, _): """ Update the geometry of the interactive plot """ # Read the .cfg file and update the geometry while True: try: self.IN = ReadUserInput(self.IN['Config_Path']) self.blade_in = Blade3D(self.IN) self.blade_in.make_blade() self.surface_coordinates = self.blade_in.get_surface_coordinates( self.u, self.v) break except: print("The .cfg file could not be loaded, trying again...") time.sleep( 1.5) # Wait a moment in case the .cfg file is not found # Rename coordinates x_blade = np.real(self.surface_coordinates[0, :]) y_blade = np.real(self.surface_coordinates[1, :]) z_blade = np.real(self.surface_coordinates[2, :]) # Reshape to meshgrid format x = x_blade.reshape((self.Nv, self.Nu)) y = y_blade.reshape((self.Nv, self.Nu)) z = z_blade.reshape((self.Nv, self.Nu)) # Update the coordinate values if self.NDIM == 2: self.points_2D.set_xdata(x_blade) self.points_2D.set_ydata(y_blade) elif self.NDIM == 3: # Remove old plot (Matplotlib does not allow to update 3D plots) self.blade_surface.remove() for section in self.blade_sections: section.remove() # Plot the hub and shroud sections self.blade_sections = [None, None] for k, v in enumerate([0, 1]): u_plot = np.linspace(0, 1, 250) v_plot = v * np.ones((250, )) x, y, z = np.real( self.blade_in.get_surface_coordinates(u_plot, v_plot)) self.blade_sections[k], = self.ax_3D.plot(x, y, z) self.blade_sections[k].set_marker(" ") self.blade_sections[k].set_markersize(3.5) self.blade_sections[k].set_markeredgewidth(0.5) self.blade_sections[k].set_markeredgecolor("k") self.blade_sections[k].set_markerfacecolor("w") self.blade_sections[k].set_linestyle("-") self.blade_sections[k].set_color("k") self.blade_sections[k].set_linewidth(1.50) # Reshape to meshgrid format x = x_blade.reshape((self.Nv, self.Nu)) y = y_blade.reshape((self.Nv, self.Nu)) z = z_blade.reshape((self.Nv, self.Nu)) # Plot the blade surface self.blade_surface = self.ax_3D.plot_surface( x, y, z, color='blue', # edgecolor='k', linewidth=0.50, alpha=0.6, shade=False, antialiased=True, zorder=3) # self.blade_surface.set_3d_properties(z_blade) else: raise Exception('The number of dimensions must be "2" or "3"')
INFile = DIR + sys.argv[-1] except: INFile = DIR + 'blade.cfg' # Default File name try: IN = ReadUserInput(INFile) except: raise Exception( '\n\n\n' 'Something went wrong when reading the configuration file,exiting the program...' '\n\nTo call MakeBlade.py from terminal type:' '\n\tMakeBlade.py <configuration file name>') #---------------------------------------------------------------------------------------------# # Generation of blade profile #---------------------------------------------------------------------------------------------# t = time.time() blade_object = Blade3D(IN) blade_object.make_blade() print('The blade geometry was generated in %(my_time).5f seconds' % {'my_time': time.time() - t}) #---------------------------------------------------------------------------------------------# # Plot the blade profile #---------------------------------------------------------------------------------------------# plot_blade_object = BladePlot(blade_object) plot_blade_object.make_plots() #---------------------------------------------------------------------------------------------# # End of file #---------------------------------------------------------------------------------------------#
sys.path.append(BLADE_HOME + '/common/') from blade_3D import Blade3D from config import ReadUserInput # -------------------------------------------------------------------------------------------------------------------- # # Plot the influence of the design variables # -------------------------------------------------------------------------------------------------------------------- # # Create output directory if it does not exist os.system("rm -rf figures") os.mkdir(os.getcwd() + '/figures') # Compute the baseline geometry IN_file = os.getcwd() + '/' + 'LS89_2D_connecting_arcs.cfg' # IN_file = os.getcwd() + '/' + 'LS89_2D_camber_thickness.cfg' IN = ReadUserInput(IN_file) my_blade = Blade3D(IN) my_blade.make_blade() IN = my_blade.IN coordinates_baseline = copy.deepcopy(np.real(my_blade.surface_coordinates)) # Select what variables are analyzed # variable_names = my_blade.DVs_names_2D variable_names = my_blade.DVs_names # variable_names = ['stagger'] # Compute the geometry when each design variable is increased and decreased for k in variable_names: for i in range(len(IN[k])): # Increase the design variables by an arbitrary amount IN_bis = copy.deepcopy(IN)