def __init__(self, config, size_in=200, size_out=(200, 20, 3), suffix=''): super(PGLLoftedBladeSurface, self).__init__() self._dry_run = False if not _PGL_installed: self._dry_run = True self.add_param('blade_length', 1.) names = [ 's', 'x', 'y', 'z', 'rot_x', 'rot_y', 'rot_z', 'chord', 'rthick', 'p_le' ] for name in names: self.add_param(name + suffix, np.zeros(size_in)) self._suffix = suffix self.add_output('blade_surface' + suffix, np.zeros(size_out)) self.add_output('blade_surface_norm' + suffix, np.zeros(size_out)) # for i in range(size_in[1]): # self.add_param('base_af%02d' % i, np.zeros(size_in[0], 2)) # configuration variables for PGL's LoftedBladeSurface class self.config = {} self.config['base_airfoils'] = [] self.config['blend_var'] = np.array([]) self.config['user_surface'] = np.array([]) self.config['user_surface_file'] = '' self.config['user_surface_shape'] = () self.config['ni_chord'] = size_out[0] self.config['chord_nte'] = 0 self.config['redistribute_flag'] = False self.config['x_chordwise'] = np.array([]) self.config['minTE'] = 0. self.config['interp_type'] = 'rthick' self.config['surface_spline'] = 'pchip' self.config['dist_LE'] = np.array([]) self.config['gf_heights'] = np.array([]) for k, v in config.iteritems(): if k in self.config.keys(): self.config[k] = v else: print 'unknown config key %s' % k self.rot_order = np.array([2, 1, 0]) if not self._dry_run: self.pgl_surf = LoftedBladeSurface(**self.config) self._pgl_config_called = False
def __init__(self, config, size_in=200, size_out=(200, 20, 3), suffix=''): super(PGLLoftedBladeSurface, self).__init__() self._dry_run = False if not _PGL_installed: self._dry_run = True self.add_param('blade_length', 1.) names = ['s', 'x', 'y', 'z', 'rot_x', 'rot_y', 'rot_z', 'chord', 'rthick','p_le'] for name in names: self.add_param(name+suffix, np.zeros(size_in)) self._suffix = suffix self.add_output('blade_surface' + suffix, np.zeros(size_out)) self.add_output('blade_surface_norm' + suffix, np.zeros(size_out)) # for i in range(size_in[1]): # self.add_param('base_af%02d' % i, np.zeros(size_in[0], 2)) # configuration variables for PGL's LoftedBladeSurface class self.config = {} self.config['base_airfoils'] = [] self.config['blend_var'] = np.array([]) self.config['user_surface'] = np.array([]) self.config['user_surface_file'] = '' self.config['user_surface_shape'] = () self.config['ni_chord'] = size_out[0] self.config['chord_nte'] = 0 self.config['redistribute_flag'] = False self.config['x_chordwise'] = np.array([]) self.config['minTE'] = 0. self.config['interp_type'] = 'rthick' self.config['surface_spline'] = 'pchip' self.config['dist_LE'] = np.array([]) self.config['gf_heights'] = np.array([]) for k, v in config.iteritems(): if k in self.config.keys(): self.config[k] = v else: print 'unknown config key %s' % k self.rot_order = np.array([2,1,0]) if not self._dry_run: self.pgl_surf = LoftedBladeSurface(**self.config) self._pgl_config_called = False
def __init__(self, config, size_in=200, size_out=(200, 20, 3), suffix=""): super(PGLLoftedBladeSurface, self).__init__() self._dry_run = False if not _PGL_installed: self._dry_run = True self.add_param("blade_length", 1.0) names = ["s", "x", "y", "z", "rot_x", "rot_y", "rot_z", "chord", "rthick", "p_le"] for name in names: self.add_param(name + suffix, np.zeros(size_in)) self._suffix = suffix self.add_output("blade_surface" + suffix, np.zeros(size_out)) self.add_output("blade_surface_norm" + suffix, np.zeros(size_out)) # for i in range(size_in[1]): # self.add_param('base_af%02d' % i, np.zeros(size_in[0], 2)) # configuration variables for PGL's LoftedBladeSurface class self.config = {} self.config["base_airfoils"] = [] self.config["blend_var"] = np.array([]) self.config["user_surface"] = np.array([]) self.config["user_surface_file"] = "" self.config["user_surface_shape"] = () self.config["ni_chord"] = size_out[0] self.config["chord_nte"] = 0 self.config["redistribute_flag"] = False self.config["x_chordwise"] = np.array([]) self.config["minTE"] = 0.0 self.config["interp_type"] = "rthick" self.config["surface_spline"] = "pchip" self.config["dist_LE"] = np.array([]) self.config["gf_heights"] = np.array([]) for k, v in config.iteritems(): if k in self.config.keys(): self.config[k] = v else: print "unknown config key %s" % k self.rot_order = np.array([2, 1, 0]) if not self._dry_run: self.pgl_surf = LoftedBladeSurface(**self.config) self._pgl_config_called = False
class PGLLoftedBladeSurface(Component): """ class for generating a simple lofted blade surface based on a series of base airfoils and a planform definition using PGL.components.loftedblade.LoftedBladeSurface """ def __init__(self, config, size_in=200, size_out=(200, 20, 3), suffix=''): super(PGLLoftedBladeSurface, self).__init__() self._dry_run = False if not _PGL_installed: self._dry_run = True self.add_param('blade_length', 1.) names = ['s', 'x', 'y', 'z', 'rot_x', 'rot_y', 'rot_z', 'chord', 'rthick','p_le'] for name in names: self.add_param(name+suffix, np.zeros(size_in)) self._suffix = suffix self.add_output('blade_surface' + suffix, np.zeros(size_out)) self.add_output('blade_surface_norm' + suffix, np.zeros(size_out)) # for i in range(size_in[1]): # self.add_param('base_af%02d' % i, np.zeros(size_in[0], 2)) # configuration variables for PGL's LoftedBladeSurface class self.config = {} self.config['base_airfoils'] = [] self.config['blend_var'] = np.array([]) self.config['user_surface'] = np.array([]) self.config['user_surface_file'] = '' self.config['user_surface_shape'] = () self.config['ni_chord'] = size_out[0] self.config['chord_nte'] = 0 self.config['redistribute_flag'] = False self.config['x_chordwise'] = np.array([]) self.config['minTE'] = 0. self.config['interp_type'] = 'rthick' self.config['surface_spline'] = 'pchip' self.config['dist_LE'] = np.array([]) self.config['gf_heights'] = np.array([]) for k, v in config.iteritems(): if k in self.config.keys(): self.config[k] = v else: print 'unknown config key %s' % k self.rot_order = np.array([2,1,0]) if not self._dry_run: self.pgl_surf = LoftedBladeSurface(**self.config) self._pgl_config_called = False def _configure_interpolator(self): if self.config['base_airfoils'] == 0: raise RuntimeError('base_airfoils list is empty') if self.config['blend_var'].shape[0] == 0: raise RuntimeError('blend_var array is empty') self.pgl_surf.ni_chord = self.config['ni_chord'] self.pgl_surf.surface_spline = self.config['surface_spline'] self.pgl_surf.blend_var = self.config['blend_var'] self.pgl_surf.base_airfoils = self.config['base_airfoils'] self.pgl_surf.initialize_interpolator() self._pgl_config_called = True def solve_nonlinear(self, params, unknowns, resids): if self._dry_run: ni = params['s' + self._suffix].shape[0] surf = np.zeros([self.config['ni_chord'], ni, 3]) surf[:, :, 2] = params['s' + self._suffix] self.unknowns['blade_surface' + self._suffix] = surf self.unknowns['blade_surface_norm' + self._suffix] = surf return if not self._pgl_config_called: self._configure_interpolator() # we need to dig into the _ByObjWrapper val to get the array # values out pf = {} pf['s'] = params['s' + self._suffix] pf['x'] = params['x' + self._suffix] pf['y'] = params['y' + self._suffix] pf['z'] = params['z' + self._suffix] pf['rot_x'] = params['rot_x' + self._suffix] pf['rot_y'] = params['rot_y' + self._suffix] pf['rot_z'] = params['rot_z' + self._suffix] pf['chord'] = params['chord' + self._suffix] pf['rthick'] = params['rthick' + self._suffix] pf['p_le'] = params['p_le' + self._suffix] self.pgl_surf.pf = pf self.pgl_surf.build_blade() surf = self.pgl_surf.surface surfnorot = self.pgl_surf.surfnorot self.unknowns['blade_surface' + self._suffix] = surf self.unknowns['blade_surface_norm' + self._suffix] = surfnorot
read_bladestructure, \ write_bladestructure PATH = pkg_resources.resource_filename('fusedwind', 'turbine/test') # --- 2 --- # generate a lofted blade surface using PGL pf = read_blade_planform(os.path.join(PATH, 'data/DTU_10MW_RWT_blade_axis_prebend.dat')) s_st = np.linspace(0, 1, 20) pf = redistribute_planform(pf, s=s_st) d = LoftedBladeSurface() d.pf = pf # redistribute in the chordwise direction # with 200 nodes, open TE (chord_nte=0) # and open TE of cross sections with TE # thickness less 2 cm d.redistribute_flag = True d.chord_ni = 200 d.chord_nte = 0 d.minTE = 0.000232 # privide base airfoils as function of relative thickess d.blend_var = [0.241, 0.301, 0.36, 0.48, 1.0] for f in [os.path.join(PATH, 'data/ffaw3241.dat'), os.path.join(PATH, 'data/ffaw3301.dat'),
class PGLLoftedBladeSurface(Component): """ class for generating a simple lofted blade surface based on a series of base airfoils and a planform definition using PGL.components.loftedblade.LoftedBladeSurface """ def __init__(self, config, size_in=200, size_out=(200, 20, 3), suffix=""): super(PGLLoftedBladeSurface, self).__init__() self._dry_run = False if not _PGL_installed: self._dry_run = True self.add_param("blade_length", 1.0) names = ["s", "x", "y", "z", "rot_x", "rot_y", "rot_z", "chord", "rthick", "p_le"] for name in names: self.add_param(name + suffix, np.zeros(size_in)) self._suffix = suffix self.add_output("blade_surface" + suffix, np.zeros(size_out)) self.add_output("blade_surface_norm" + suffix, np.zeros(size_out)) # for i in range(size_in[1]): # self.add_param('base_af%02d' % i, np.zeros(size_in[0], 2)) # configuration variables for PGL's LoftedBladeSurface class self.config = {} self.config["base_airfoils"] = [] self.config["blend_var"] = np.array([]) self.config["user_surface"] = np.array([]) self.config["user_surface_file"] = "" self.config["user_surface_shape"] = () self.config["ni_chord"] = size_out[0] self.config["chord_nte"] = 0 self.config["redistribute_flag"] = False self.config["x_chordwise"] = np.array([]) self.config["minTE"] = 0.0 self.config["interp_type"] = "rthick" self.config["surface_spline"] = "pchip" self.config["dist_LE"] = np.array([]) self.config["gf_heights"] = np.array([]) for k, v in config.iteritems(): if k in self.config.keys(): self.config[k] = v else: print "unknown config key %s" % k self.rot_order = np.array([2, 1, 0]) if not self._dry_run: self.pgl_surf = LoftedBladeSurface(**self.config) self._pgl_config_called = False def _configure_interpolator(self): if self.config["base_airfoils"] == 0: raise RuntimeError("base_airfoils list is empty") if self.config["blend_var"].shape[0] == 0: raise RuntimeError("blend_var array is empty") self.pgl_surf.ni_chord = self.config["ni_chord"] self.pgl_surf.surface_spline = self.config["surface_spline"] self.pgl_surf.blend_var = self.config["blend_var"] self.pgl_surf.base_airfoils = self.config["base_airfoils"] self.pgl_surf.initialize_interpolator() self._pgl_config_called = True def solve_nonlinear(self, params, unknowns, resids): if self._dry_run: ni = params["s" + self._suffix].shape[0] surf = np.zeros([self.config["ni_chord"], ni, 3]) surf[:, :, 2] = params["s" + self._suffix] self.unknowns["blade_surface" + self._suffix] = surf self.unknowns["blade_surface_norm" + self._suffix] = surf return if not self._pgl_config_called: self._configure_interpolator() # we need to dig into the _ByObjWrapper val to get the array # values out pf = {} pf["s"] = params["s" + self._suffix] pf["x"] = params["x" + self._suffix] pf["y"] = params["y" + self._suffix] pf["z"] = params["z" + self._suffix] pf["rot_x"] = params["rot_x" + self._suffix] pf["rot_y"] = params["rot_y" + self._suffix] pf["rot_z"] = params["rot_z" + self._suffix] pf["chord"] = params["chord" + self._suffix] pf["rthick"] = params["rthick" + self._suffix] pf["p_le"] = params["p_le" + self._suffix] self.pgl_surf.pf = pf self.pgl_surf.build_blade() surf = self.pgl_surf.surface surfnorot = self.pgl_surf.surfnorot self.unknowns["blade_surface" + self._suffix] = surf self.unknowns["blade_surface_norm" + self._suffix] = surfnorot
class PGLLoftedBladeSurface(Component): """ class for generating a simple lofted blade surface based on a series of base airfoils and a planform definition using PGL.components.loftedblade.LoftedBladeSurface """ def __init__(self, config, size_in=200, size_out=(200, 20, 3), suffix=''): super(PGLLoftedBladeSurface, self).__init__() self._dry_run = False if not _PGL_installed: self._dry_run = True self.add_param('blade_length', 1.) names = [ 's', 'x', 'y', 'z', 'rot_x', 'rot_y', 'rot_z', 'chord', 'rthick', 'p_le' ] for name in names: self.add_param(name + suffix, np.zeros(size_in)) self._suffix = suffix self.add_output('blade_surface' + suffix, np.zeros(size_out)) self.add_output('blade_surface_norm' + suffix, np.zeros(size_out)) # for i in range(size_in[1]): # self.add_param('base_af%02d' % i, np.zeros(size_in[0], 2)) # configuration variables for PGL's LoftedBladeSurface class self.config = {} self.config['base_airfoils'] = [] self.config['blend_var'] = np.array([]) self.config['user_surface'] = np.array([]) self.config['user_surface_file'] = '' self.config['user_surface_shape'] = () self.config['ni_chord'] = size_out[0] self.config['chord_nte'] = 0 self.config['redistribute_flag'] = False self.config['x_chordwise'] = np.array([]) self.config['minTE'] = 0. self.config['interp_type'] = 'rthick' self.config['surface_spline'] = 'pchip' self.config['dist_LE'] = np.array([]) self.config['gf_heights'] = np.array([]) for k, v in config.iteritems(): if k in self.config.keys(): self.config[k] = v else: print 'unknown config key %s' % k self.rot_order = np.array([2, 1, 0]) if not self._dry_run: self.pgl_surf = LoftedBladeSurface(**self.config) self._pgl_config_called = False def _configure_interpolator(self): if self.config['base_airfoils'] == 0: raise RuntimeError('base_airfoils list is empty') if self.config['blend_var'].shape[0] == 0: raise RuntimeError('blend_var array is empty') self.pgl_surf.ni_chord = self.config['ni_chord'] self.pgl_surf.surface_spline = self.config['surface_spline'] self.pgl_surf.blend_var = self.config['blend_var'] self.pgl_surf.base_airfoils = self.config['base_airfoils'] self.pgl_surf.initialize_interpolator() self._pgl_config_called = True def solve_nonlinear(self, params, unknowns, resids): if self._dry_run: ni = params['s' + self._suffix].shape[0] surf = np.zeros([self.config['ni_chord'], ni, 3]) surf[:, :, 2] = params['s' + self._suffix] self.unknowns['blade_surface' + self._suffix] = surf self.unknowns['blade_surface_norm' + self._suffix] = surf return if not self._pgl_config_called: self._configure_interpolator() # we need to dig into the _ByObjWrapper val to get the array # values out pf = {} pf['s'] = params['s' + self._suffix] pf['x'] = params['x' + self._suffix] pf['y'] = params['y' + self._suffix] pf['z'] = params['z' + self._suffix] pf['rot_x'] = params['rot_x' + self._suffix] pf['rot_y'] = params['rot_y' + self._suffix] pf['rot_z'] = params['rot_z' + self._suffix] pf['chord'] = params['chord' + self._suffix] pf['rthick'] = params['rthick' + self._suffix] pf['p_le'] = params['p_le' + self._suffix] self.pgl_surf.pf = pf self.pgl_surf.build_blade() surf = self.pgl_surf.surface surfnorot = self.pgl_surf.surfnorot self.unknowns['blade_surface' + self._suffix] = surf self.unknowns['blade_surface_norm' + self._suffix] = surfnorot