def test_Wing_param_build_wing(self): wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) try: wing_param.build_wing() ok = True except: ok = False assert (ok)
def test_Wing_param_build_wing(self): wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) try: wing_param.build_wing() ok=True except: ok=False assert(ok)
def __config_param(self): input_keys=self.__config_dict.keys() geom_type_key=self.__tag+'.param.geom_type' if geom_type_key in input_keys: geom_type = self.__config_dict[geom_type_key] else: geom_type= 'Broken' n_sect_key=self.__tag+'.param.n_sect' if n_sect_key in input_keys: n_sect = self.__config_dict[n_sect_key] else: n_sect = 20 self.__wing_param = Wing_param(self.__tag+'.param',geom_type=geom_type,n_sect=n_sect) self.__wing_param.set_AoA_id(self.__AoA_id) self.__wing_param.config_from_dict(self.__OC, self.__config_dict)
def __set_wing_param_values(self, wing_param_name='test_param'): """Method for wing parameters variables setting @param wing_param_name : wing parametrization names """ self.__wing_param = Wing_param(wing_param_name, geom_type='Broken', n_sect=self.N * 2) self.__wing_param.build_wing() for i in xrange(self.N): self.__wing_param.set_value('rtwist%s' % i, 0.) for param in Wing_param.DISCRETE_ATTRIBUTES_LIST: self.__wing_param.set_value(param, getattr(self, param))
class DLLMWrapper(): ERROR_MSG = 'ERROR in DLLMWrapper.' WARNING_MSG = 'WARNING in DLLMWrapper.' POS_SOLVER = ['Solver','TargetCl','TargetLift'] POS_FMT = ['list','numpy'] def __init__(self, tag): """ Wrapper for the DLLM solver """ self.__tag = tag self.__OC = None # Operating condition self.__wing_param = None # Wing_param class self.__DLLM_solver = None # DLLM Solver class self.__config_dict = None self.__out_format = 'list' self.__grad_format = 'list' self.__AoA_id = 'AoA' self.__F_list = None self.__F_list_grad = None #-- Accessors def get_OC(self): return self.__OC def get_wing_param(self): return self.__wing_param def get_DLLM_solver(self): return self.__DLLM_solver def get_tags_x0_and_bounds(self): tags=self.__wing_param.get_dv_id_list() x0=self.__wing_param.get_dv_array() bounds=self.__wing_param.get_bounds_array() return tags,x0,bounds def get_x0_and_bounds(self): x0=self.__wing_param.get_dv_array() bounds=self.__wing_param.get_bounds_array() return x0,bounds def get_x0(self): return self.get_x() def get_x(self): x=self.__wing_param.get_dv_array() return x def get_F_list_names(self): return self.__DLLM_solver.get_F_list_names() def get_F_list(self): return self.__F_list def get_F_list_grad(self): return self.__F_list_grad def get_F_list_and_grad(self): return self.__F_list, self.__F_list_grad #-- Setters def set_AoA_id(self, AoA_id): self.__AoA_id = AoA_id def set_out_format(self, format): WARNING_MSG=self.WARNING_MSG+'set_out_format: ' if format not in self.POS_FMT: print WARNING_MSG+'format = '+str(format)+' not in '+str(self.POS_FMT)+'. Set to default out format = list' format='list' self.__out_format = format def set_grad_format(self, format): WARNING_MSG=self.WARNING_MSG+'set_grad_format: ' if format not in self.POS_FMT: print WARNING_MSG+'format = '+str(format)+' not in '+str(self.POS_FMT)+'. Set to default grad format = list' format='list' self.__grad_format = format #-- Public methods def configure(self, config_dict): self.__config_dict = config_dict self.__config_OC() self.__config_param() self.__config_DLLM() def run(self, x): self.__wing_param.update_from_x_list(x) self.__DLLM_solver.set_wing_param(self.__wing_param) F_list=self.analysis() return F_list def run_grad(self, x): self.__wing_param.update_from_x_list(x) self.__DLLM_solver.set_wing_param(self.__wing_param) F_list_grad=self.analysis_grad() return F_list_grad def run_and_grad(self, x): self.__wing_param.update_from_x_list(x) self.__DLLM_solver.set_wing_param(self.__wing_param) F_list,F_list_grad = self.analysis_and_grad() return F_list,F_list_grad def analysis(self): print self.__wing_param self.__DLLM_solver.run_direct() self.__DLLM_solver.run_post() F_list = self.__DLLM_solver.get_F_list() if self.__out_format == 'list': F_list=F_list.tolist() self.__F_list = F_list return F_list def analysis_grad(self): print self.__wing_param self.__DLLM_solver.run_direct() self.__DLLM_solver.run_post() self.__DLLM_solver.run_adjoint() F_list_grad=self.__DLLM_solver.get_dF_list_dchi() if self.__grad_format == 'numpy': F_list_grad=numpy.array(F_list_grad) self.__F_list_grad = F_list_grad return F_list_grad def analysis_and_grad(self): print self.__wing_param self.__DLLM_solver.run_direct() self.__DLLM_solver.run_post() self.__DLLM_solver.run_adjoint() F_list = self.__DLLM_solver.get_F_list() F_list_grad=self.__DLLM_solver.get_dF_list_dchi() if self.__out_format == 'list': F_list=F_list.tolist() if self.__grad_format == 'numpy': F_list_grad=numpy.array(F_list_grad) self.__F_list = F_list self.__F_list_grad = F_list_grad return F_list,F_list_grad def export_results(self): fid=open(self.__tag+'.res.dat','w') res=[self.__F_list,self.__F_list_grad] cPickle.dump(res, fid) fid.close() def import_results(self): fid=open(self.__tag+'.res.dat','r') res=cPickle.load(fid) fid.close() self.__F_list=res[0] self.__F_list_grad=res[1] #-- Private methods def __config_OC(self): self.__OC = OperatingCondition(self.__tag+'.OC') self.__OC.config_from_dict(self.__config_dict) def __config_param(self): input_keys=self.__config_dict.keys() geom_type_key=self.__tag+'.param.geom_type' if geom_type_key in input_keys: geom_type = self.__config_dict[geom_type_key] else: geom_type= 'Broken' n_sect_key=self.__tag+'.param.n_sect' if n_sect_key in input_keys: n_sect = self.__config_dict[n_sect_key] else: n_sect = 20 self.__wing_param = Wing_param(self.__tag+'.param',geom_type=geom_type,n_sect=n_sect) self.__wing_param.set_AoA_id(self.__AoA_id) self.__wing_param.config_from_dict(self.__OC, self.__config_dict) def __config_DLLM(self): WARNING_MSG=self.WARNING_MSG+'__config_DLLM: ' input_keys=self.__config_dict.keys() type_key = self.__tag+'.DLLM.type' type = self.__config_dict[type_key] if type not in self.POS_SOLVER: print WARNING_MSG+'solver_type = '+str(solve_type)+' not in '+str(self.POS_SOLVER)+'. Set to default solver_type = Solver' type='Solver' if type == 'Solver': self.__DLLM_solver = DLLMSolver(self.__tag,self.__wing_param,self.__OC) elif type == 'TargetCl': self.__DLLM_solver = DLLMTargetCl(self.__tag,self.__wing_param,self.__OC) target_Cl_key = self.__tag+'.DLLM.target_Cl' target_Cl = self.__config_dict[target_Cl_key] self.__DLLM_solver.set_target_Cl(target_Cl) elif type == 'TargetLift': self.__DLLM_solver = DLLMTargetLift(self.__tag,self.__wing_param,self.__OC) target_Lift_key = self.__tag+'.DLLM.target_Lift' target_Lift = self.__config_dict[target_Lift_key] self.__DLLM_solver.set_target_Lift(target_Lift) method_key = self.__tag+'.DLLM.method' if method_key in input_keys: method = self.__config_dict[method_key] self.__DLLM_solver.set_method(method) relax_factor_key = self.__tag+'.DLLM.relax_factor' if relax_factor_key in input_keys: relax_factor = self.__config_dict[relax_factor_key] self.__DLLM_solver.set_relax_factor(relax_factor) stop_residual_key = self.__tag+'.DLLM.stop_residual' if stop_residual_key in input_keys: stop_residual = self.__config_dict[stop_residual_key] self.__DLLM_solver.set_stop_residual(stop_residual) max_iterations_key = self.__tag+'.DLLM.max_iterations' if max_iterations_key in input_keys: max_iterations = self.__config_dict[max_iterations_key] self.__DLLM_solver.set_max_iterations(max_iterations) gamma_file_name_key = self.__tag+'.DLLM.gamma_file_name' if gamma_file_name_key in input_keys: gamma_file_name = self.__config_dict[gamma_file_name_key] self.__DLLM_solver.set_gamma_file_name(gamma_file_name) F_list_names_key = self.__tag+'.DLLM.F_list_names' if F_list_names_key in input_keys: F_list_names = self.__config_dict[F_list_names_key] self.__DLLM_solver.set_F_list_names(F_list_names)
from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMTargetCl import DLLMTargetCl from MDOTools.OC.operating_condition import OperatingCondition import numpy import sys OC=OperatingCondition('cond1') OC.set_Mach(0.8) OC.set_AoA(3.5) OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',34.1) wing_param.set_value('sweep',34.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',6.1) wing_param.set_value('break_chord',4.6) wing_param.set_value('tip_chord',1.5) wing_param.set_value('root_height',1.28) wing_param.set_value('break_height',0.97) wing_param.set_value('tip_height',0.33) wing_param.convert_to_design_variable('span',(10.,50.)) wing_param.convert_to_design_variable('sweep',(0.,40.)) wing_param.convert_to_design_variable('break_percent',(20.,40.)) wing_param.convert_to_design_variable('root_chord',(5.,7.)) wing_param.convert_to_design_variable('break_chord',(3.,5.))
class DLLMWrapper(): ERROR_MSG = 'ERROR in DLLMWrapper.' WARNING_MSG = 'WARNING in DLLMWrapper.' POS_SOLVER = ['Solver','TargetCl','TargetLift'] POS_FMT = ['list','numpy'] def __init__(self, tag): """ Wrapper for the DLLM solver """ self.__tag = tag self.__OC = None # Operating condition self.__wing_param = None # Wing_param class self.__DLLM_solver = None # DLLM Solver class self.__config_dict = None self.__out_format = 'list' self.__grad_format = 'list' self.__AoA_id = 'AoA' self.__F_list = None self.__F_list_grad = None #-- Accessors def get_OC(self): return self.__OC def get_wing_param(self): return self.__wing_param def get_DLLM_solver(self): return self.__DLLM_solver def get_tags_x0_and_bounds(self): tags=self.__wing_param.get_dv_id_list() x0=self.__wing_param.get_dv_array() bounds=self.__wing_param.get_bounds_array() return tags,x0,bounds def get_x0_and_bounds(self): x0=self.__wing_param.get_dv_array() bounds=self.__wing_param.get_bounds_array() return x0,bounds def get_x0(self): return self.get_x() def get_x(self): x=self.__wing_param.get_dv_array() return x def get_F_list_names(self): return self.__DLLM_solver.get_F_list_names() def get_F_list(self): return self.__F_list def get_F_list_grad(self): return self.__F_list_grad def get_F_list_and_grad(self): return self.__F_list, self.__F_list_grad #-- Setters def set_AoA_id(self, AoA_id): self.__AoA_id = AoA_id def set_out_format(self, format): WARNING_MSG=self.WARNING_MSG+'set_out_format: ' if format not in self.POS_FMT: print WARNING_MSG+'format = '+str(format)+' not in '+str(self.POS_FMT)+'. Set to default out format = list' format='list' self.__out_format = format def set_grad_format(self, format): WARNING_MSG=self.WARNING_MSG+'set_grad_format: ' if format not in self.POS_FMT: print WARNING_MSG+'format = '+str(format)+' not in '+str(self.POS_FMT)+'. Set to default grad format = list' format='list' self.__grad_format = format #-- Public methods def configure(self, config_dict): self.__config_dict = config_dict self.__config_OC() self.__config_param() self.__config_DLLM() def run(self, x): self.__wing_param.update_from_x_list(x) self.__DLLM_solver.set_wing_param(self.__wing_param) F_list=self.analysis() return F_list def run_grad(self, x): self.__wing_param.update_from_x_list(x) self.__DLLM_solver.set_wing_param(self.__wing_param) F_list_grad=self.analysis_grad() return F_list_grad def run_and_grad(self, x): self.__wing_param.update_from_x_list(x) self.__DLLM_solver.set_wing_param(self.__wing_param) F_list,F_list_grad = self.analysis_and_grad() return F_list,F_list_grad def analysis(self): print self.__wing_param self.__DLLM_solver.run_direct() self.__DLLM_solver.run_post() F_list = self.__DLLM_solver.get_F_list() if self.__out_format == 'list': F_list=F_list.tolist() self.__F_list = F_list return F_list def analysis_grad(self): print self.__wing_param self.__DLLM_solver.run_direct() self.__DLLM_solver.run_post() self.__DLLM_solver.run_adjoint() F_list_grad=self.__DLLM_solver.get_dF_list_dchi() if self.__grad_format == 'numpy': F_list_grad=numpy.array(F_list_grad) self.__F_list_grad = F_list_grad return F_list_grad def analysis_and_grad(self): print self.__wing_param self.__DLLM_solver.run_direct() self.__DLLM_solver.run_post() self.__DLLM_solver.run_adjoint() F_list = self.__DLLM_solver.get_F_list() F_list_grad=self.__DLLM_solver.get_dF_list_dchi() if self.__out_format == 'list': F_list=F_list.tolist() if self.__grad_format == 'numpy': F_list_grad=numpy.array(F_list_grad) self.__F_list = F_list self.__F_list_grad = F_list_grad return F_list,F_list_grad def export_results(self): fid=open(self.__tag+'.res.dat','w') res=[self.__F_list,self.__F_list_grad] cPickle.dump(res, fid) fid.close() def import_results(self): fid=open(self.__tag+'.res.dat','r') res=cPickle.load(fid) fid.close() self.__F_list=res[0] self.__F_list_grad=res[1] #-- Private methods def __config_OC(self): self.__OC = OperatingCondition(self.__tag+'.OC') self.__OC.config_from_dict(self.__config_dict) def __config_param(self): input_keys=self.__config_dict.keys() geom_type_key=self.__tag+'.param.geom_type' if geom_type_key in input_keys: geom_type = self.__config_dict[geom_type_key] else: geom_type= 'Broken' n_sect_key=self.__tag+'.param.n_sect' if n_sect_key in input_keys: n_sect = self.__config_dict[n_sect_key] else: n_sect = 20 self.__wing_param = Wing_param(self.__tag+'.param',geom_type=geom_type,n_sect=n_sect) self.__wing_param.set_AoA_id(self.__AoA_id) self.__wing_param.config_from_dict(self.__OC, self.__config_dict) def __config_DLLM(self): WARNING_MSG=self.WARNING_MSG+'__config_DLLM: ' input_keys=self.__config_dict.keys() type_key = self.__tag+'.DLLM.type' type = self.__config_dict[type_key] if type not in self.POS_SOLVER: print WARNING_MSG+'solver_type = '+str(type)+' not in '+str(self.POS_SOLVER)+'. Set to default solver_type = Solver' type='Solver' if type == 'Solver': self.__DLLM_solver = DLLMSolver(self.__tag,self.__wing_param,self.__OC) elif type == 'TargetCl': self.__DLLM_solver = DLLMTargetCl(self.__tag,self.__wing_param,self.__OC) target_Cl_key = self.__tag+'.DLLM.target_Cl' target_Cl = self.__config_dict[target_Cl_key] self.__DLLM_solver.set_target_Cl(target_Cl) elif type == 'TargetLift': self.__DLLM_solver = DLLMTargetLift(self.__tag,self.__wing_param,self.__OC) target_Lift_key = self.__tag+'.DLLM.target_Lift' target_Lift = self.__config_dict[target_Lift_key] self.__DLLM_solver.set_target_Lift(target_Lift) method_key = self.__tag+'.DLLM.method' if method_key in input_keys: method = self.__config_dict[method_key] self.__DLLM_solver.set_method(method) relax_factor_key = self.__tag+'.DLLM.relax_factor' if relax_factor_key in input_keys: relax_factor = self.__config_dict[relax_factor_key] self.__DLLM_solver.set_relax_factor(relax_factor) stop_residual_key = self.__tag+'.DLLM.stop_residual' if stop_residual_key in input_keys: stop_residual = self.__config_dict[stop_residual_key] self.__DLLM_solver.set_stop_residual(stop_residual) max_iterations_key = self.__tag+'.DLLM.max_iterations' if max_iterations_key in input_keys: max_iterations = self.__config_dict[max_iterations_key] self.__DLLM_solver.set_max_iterations(max_iterations) gamma_file_name_key = self.__tag+'.DLLM.gamma_file_name' if gamma_file_name_key in input_keys: gamma_file_name = self.__config_dict[gamma_file_name_key] self.__DLLM_solver.set_gamma_file_name(gamma_file_name) F_list_names_key = self.__tag+'.DLLM.F_list_names' if F_list_names_key in input_keys: F_list_names = self.__config_dict[F_list_names_key] self.__DLLM_solver.set_F_list_names(F_list_names)
from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMSolver import DLLMSolver from MDOTools.ValidGrad.FDValidGrad import FDValidGrad from MDOTools.OC.operating_condition import OperatingCondition import numpy OC=OperatingCondition('cond1') OC.set_Mach(0.6) #.7 OC.set_AoA(6.0) #3. OC.set_altitude(10000.) #5000 OC.set_T0_deg(20.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',34.1) wing_param.set_value('sweep',32.) #32. wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',5.4)#6.1 wing_param.set_value('break_chord',4.6)#4.6 wing_param.set_value('tip_chord',1.2)#1.5 wing_param.set_value('root_height',.98)#1.28 wing_param.set_value('break_height',0.7)#0.97 wing_param.set_value('tip_height',0.18)#0.33 wing_param.convert_to_design_variable('span',(10.,50.)) wing_param.convert_to_design_variable('sweep',(0.,40.)) wing_param.convert_to_design_variable('break_percent',(20.,40.)) wing_param.convert_to_design_variable('root_chord',(5.,7.)) wing_param.convert_to_design_variable('break_chord',(3.,5.))
def __init_wing_param(self): OC=OperatingCondition('cond1') OC.set_Mach(0.7) OC.set_AoA(3.0) OC.set_altitude(5000.) OC.set_T0_deg(20.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',34.1) wing_param.set_value('sweep',32.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',6.1) wing_param.set_value('break_chord',4.6) wing_param.set_value('tip_chord',1.5) wing_param.set_value('root_height',1.28) wing_param.set_value('break_height',0.97) wing_param.set_value('tip_height',0.33) wing_param.convert_to_design_variable('span',(10.,50.)) wing_param.convert_to_design_variable('sweep',(0.,40.)) wing_param.convert_to_design_variable('break_percent',(20.,40.)) wing_param.convert_to_design_variable('root_chord',(5.,7.)) wing_param.convert_to_design_variable('break_chord',(3.,5.)) wing_param.convert_to_design_variable('tip_chord',(1.,2.)) wing_param.convert_to_design_variable('root_height',(1.,1.5)) wing_param.convert_to_design_variable('break_height',(0.8,1.2)) wing_param.convert_to_design_variable('tip_height',(0.2,0.5)) wing_param.build_linear_airfoil(OC, AoA0=-2., Cm0=-0.1, set_as_ref=True) wing_param.build_airfoils_from_ref() wing_param.update() return wing_param
def test_Wing_param_convert(self): wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',34.1) wing_param.set_value('sweep',32.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',6.1) wing_param.set_value('break_chord',4.6) wing_param.set_value('tip_chord',1.5) wing_param.set_value('root_height',1.28) wing_param.set_value('break_height',0.97) wing_param.set_value('tip_height',0.33) try: wing_param.convert_to_design_variable('span',(10.,50.)) wing_param.convert_to_design_variable('sweep',(0.,40.)) wing_param.convert_to_design_variable('break_percent',(20.,40.)) wing_param.convert_to_design_variable('root_chord',(5.,7.)) wing_param.convert_to_design_variable('break_chord',(3.,5.)) wing_param.convert_to_design_variable('tip_chord',(1.,2.)) wing_param.convert_to_design_variable('root_height',(1.,1.5)) wing_param.convert_to_design_variable('break_height',(0.8,1.2)) wing_param.convert_to_design_variable('tip_height',(0.2,0.5)) ok=True except: ok=False assert(ok)
# # http://github.com/TBD # from DLLM.DLLMGeom.wing_param import Wing_param from MDOTools.OC.operating_condition import OperatingCondition import numpy import string OC=OperatingCondition('cond1') OC.set_altitude(3000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',34.1) wing_param.set_value('sweep',0.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',6.1) wing_param.set_value('break_chord',4.6) wing_param.set_value('tip_chord',1.5) wing_param.set_value('root_height',1.28) wing_param.set_value('break_height',0.97) wing_param.set_value('tip_height',0.33) wing_param.build_linear_airfoil(OC, AoA0=0., Cm0=-0.1, set_as_ref=True) wing_param.build_airfoils_from_ref() wing_param.update() airfoils=wing_param.get_linked_airfoils()
# # Imports from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMSolver import DLLMSolver from MDOTools.OC.operating_condition import OperatingCondition OC = OperatingCondition("cond1") OC.set_Mach(0.8) OC.set_AoA(3.5) OC.set_altitude(10000.0) OC.set_T0_deg(15.0) OC.set_P0(101325.0) OC.set_humidity(0.0) OC.compute_atmosphere() wing_param = Wing_param("test_param", geom_type="Broken", n_sect=20) wing_param.build_wing() wing_param.set_value("span", 34.1) # 34.1 wing_param.set_value("sweep", 34.0) wing_param.set_value("break_percent", 23.0) # 33. wing_param.set_value("root_chord", 5.4) # 6.1 wing_param.set_value("break_chord", 4.6) wing_param.set_value("tip_chord", 1.2) # 1.5 wing_param.set_value("root_height", 0.98) wing_param.set_value("break_height", 0.70) wing_param.set_value("tip_height", 0.18) wing_param.convert_to_design_variable("span", (10.0, 50.0)) wing_param.convert_to_design_variable("sweep", (0.0, 40.0)) wing_param.convert_to_design_variable("break_percent", (20.0, 40.0)) wing_param.convert_to_design_variable("root_chord", (5.0, 7.0)) wing_param.convert_to_design_variable("break_chord", (3.0, 5.0))
class DLLMOpenMDAOComponent(Component): # set up interface to the framework # pylint: disable-msg=E1101 # Outputs of lifting line problem """OpenMDAO component for DLLM implementation """ Lift = Float(iotype='out', desc='Lift') Drag = Float(iotype='out', desc='Drag') Drag_Pressure = Float(iotype='out', desc='Drag_Pressure') Drag_Induced = Float(iotype='out', desc='Drag_Induced') Drag_Wave = Float(iotype='out', desc='Drag_Wave') Drag_Friction = Float(iotype='out', desc='Drag_Friction') Cd = Float(iotype='out', desc='Cd') Cdp = Float(iotype='out', desc='Cdp') Cdi = Float(iotype='out', desc='Cdi') Cdw = Float(iotype='out', desc='Cdw') Cdf = Float(iotype='out', desc='Cdf') Cl = Float(iotype='out', desc='Cl') LoD = Float(iotype='out', desc='LoD') Sref = Float(iotype='out', desc='Sref') # Design variables of lifting line problem rtwist = Array([], desc='rtwist', iotype="in") span = Float(desc='span', default_value=34., iotype="in") sweep = Float(desc='sweep', default_value=34., iotype="in") break_percent = Float(desc='break_percent', default_value=33., iotype="in") root_chord = Float(desc='root_chord', default_value=6.1, iotype="in") break_chord = Float(desc='break_chord', default_value=4.6, iotype="in") tip_chord = Float(desc='tip_chord', default_value=1.5, iotype="in") root_height = Float(desc='root_height', default_value=1.28, iotype="in") break_height = Float(desc='break_height', default_value=0.97, iotype="in") tip_height = Float(desc='tip_height', default_value=0.33, iotype="in") # Operating conditions variables Mach = Float(iotype='in', default_value=0.7, desc='Mach') altitude = Float(iotype='in', default_value=10000., desc='Altitude') T0 = Float(iotype='in',default_value=OperatingCondition.T0, desc='Ground ISA ref Temperature') P0 = Float(iotype='in',default_value=OperatingCondition.P0, desc='Ground ISA ref Pressure') def __init__(self,Target_Lift, N = 10, verbose=0): """Initialization of DLLM component. DLLM component use target lift capability of DLLM kernel @param Target_Lift : the targeted lift value (float) @param N : integer. Number of discrete section on 1/2 wing @param verbose : integer : verbosity level """ try : float(Target_Lift) except: raise ValueError('You MUST define a float target lift value, get '+str(Target_Lift)+' instead.') self.Target_Lift = Target_Lift self.N = N self.OC = None self.rtwist = np.zeros(N) self.__display_wing_param = True self.__verbose = verbose self.__wing_param = None super(DLLMOpenMDAOComponent, self).__init__() self.OC = OperatingCondition(tag='DLLMOC', atmospheric_model='ISA') self.__set_OC_values() self.__set_wing_param() self.__DLLM = DLLMTargetLift('test', self.__wing_param, self.OC, verbose=self.__verbose) self.__DLLM.set_target_Lift(Target_Lift) self.__DLLM.run_direct() self.__DLLM.run_post() def __set_wing_param(self, wing_param_name='test_param'): """Method for wing parameters setting : design variables initial values and bounds @param wing_param_name : wing parametrization names """ self.__set_wing_param_values(wing_param_name=wing_param_name) self.__set_wing_param_bounds() self.__wing_param.build_linear_airfoil(self.OC, AoA0=-2., Cm0=-0.1, set_as_ref=True) self.__wing_param.build_airfoils_from_ref() self.__wing_param.update() if self.__display_wing_param: self.__display_wing_param = False print self.__wing_param def __set_wing_param_values(self, wing_param_name='test_param'): """Method for wing parameters variables setting @param wing_param_name : wing parametrization names """ self.__wing_param = Wing_param(wing_param_name, geom_type='Broken', n_sect=self.N * 2) self.__wing_param.build_wing() for i in xrange(self.N): self.__wing_param.set_value('rtwist%s' % i, 0.) for param in Wing_param.DISCRETE_ATTRIBUTES_LIST: self.__wing_param.set_value(param, getattr(self, param)) def __set_wing_param_bounds(self): """Method for desing variables bounds settings Values are set to inf/-inf in DLLM component and their 'real' bounds are defined when optimization problem is set """ for i in xrange(self.N): self.__wing_param.convert_to_design_variable( 'rtwist%s' % i, (-float('inf'), float('inf'))) for param in Wing_param.DISCRETE_ATTRIBUTES_LIST: self.__wing_param.convert_to_design_variable(param, (-float('inf'), float('inf'))) return def __set_OC_values(self): """ Set default operating conditions""" self.OC.set_Mach(self.Mach) self.OC.set_altitude(self.altitude) self.OC.set_T0(self.T0) self.OC.set_P0(self.P0) self.OC.set_humidity(0.) self.OC.compute_atmosphere() def __update_wing_parame_values(self): for dv_id in self.__wing_param.get_dv_id_list(): if dv_id.startswith('rtwist'): i_twist = int(dv_id.replace('rtwist', '')) self.__wing_param.set_value(dv_id, self.rtwist[i_twist]) else: self.__wing_param.set_value(dv_id,getattr(self,dv_id)) self.__wing_param.build_linear_airfoil(self.OC, AoA0=-2., Cm0=-0.1, set_as_ref=True) self.__set_wing_param_bounds() self.__wing_param.build_airfoils_from_ref() self.__wing_param.update() return def execute(self): """ Perform a DLLM computation with the """ self.__update_wing_parame_values() self.__set_OC_values() self.__DLLM.set_target_Lift(self.Target_Lift) self.__DLLM.run_direct() self.__DLLM.run_post() output = self.__DLLM.get_F_list() for f, f_name in zip(output, self.__DLLM.get_F_list_names()): setattr(self, f_name, f) def list_deriv_vars(self): """specify the inputs and outputs where derivatives are defined Specific treatment for twist : defined as rtwist0, rtwist1,... in DLLM but as an array rtwist in openmdao component""" out_dvid = [] for dv_id in self.__wing_param.get_dv_id_list(): if dv_id.startswith('rtwist0'): out_dvid.append('rtwist') elif not dv_id.startswith('rtwist'): out_dvid.append(dv_id) return tuple(out_dvid), tuple(self.__DLLM.get_F_list_names()) def provideJ(self): """Calculate the Jacobian according inputs and outputs""" self.__DLLM.run_adjoint() return np.array(self.__DLLM.get_dF_list_dchi()) def get_F_list(self): return self.__DLLM.get_F_list() def get_F_list_names(self): return self.__DLLM.get_F_list_names() def get_dv_array(self): return self.__wing_param.get_dv_array() def get_dv_id_list(self): return self.__wing_param.get_dv_id_list() def get_dv_info_list(self): return self.__wing_param.get_dv_info_list() def get_dv_value(self,dv_id): return self.get_dv_array()[self.get_dv_id_list().index(dv_id)]
from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMSolver import DLLMSolver from MDOTools.ValidGrad.FDValidGrad import FDValidGrad from MDOTools.OC.operating_condition import OperatingCondition import numpy OC = OperatingCondition('cond1') OC.set_Mach(0.6) #.7 OC.set_AoA(6.0) #3. OC.set_altitude(10000.) #5000 OC.set_T0_deg(20.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) wing_param.build_wing() wing_param.set_value('span', 34.1) wing_param.set_value('sweep', 32.) #32. wing_param.set_value('break_percent', 33.) wing_param.set_value('root_chord', 5.4) #6.1 wing_param.set_value('break_chord', 4.6) #4.6 wing_param.set_value('tip_chord', 1.2) #1.5 wing_param.set_value('root_height', .98) #1.28 wing_param.set_value('break_height', 0.7) #0.97 wing_param.set_value('tip_height', 0.18) #0.33 wing_param.convert_to_design_variable('span', (10., 50.)) wing_param.convert_to_design_variable('sweep', (0., 40.)) wing_param.convert_to_design_variable('break_percent', (20., 40.)) wing_param.convert_to_design_variable('root_chord', (5., 7.)) wing_param.convert_to_design_variable('break_chord', (3., 5.))
from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMSolver import DLLMSolver from MDOTools.ValidGrad.FDValidGrad import FDValidGrad from MDOTools.OC.operating_condition import OperatingCondition import numpy OC=OperatingCondition('cond1') OC.set_Mach(0.8) OC.set_AoA(3.5) OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',34.1) wing_param.set_value('sweep',34.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',6.1) wing_param.set_value('break_chord',4.6) wing_param.set_value('tip_chord',1.5) wing_param.set_value('root_height',1.28) wing_param.set_value('break_height',0.97) wing_param.set_value('tip_height',0.33) wing_param.convert_to_design_variable('span',(10.,50.)) wing_param.convert_to_design_variable('sweep',(0.,40.)) wing_param.convert_to_design_variable('break_percent',(20.,40.)) wing_param.convert_to_design_variable('root_chord',(5.,7.)) wing_param.convert_to_design_variable('break_chord',(3.,5.))
import string OC=OperatingCondition('cond1',atmospheric_model='simple') #OC.set_Mach(0.8) #OC.set_Mach(0.6) #OC.set_AoA(3.5) AoA_list = [float(xx) for xx in range(0, 10)] Mach_list = [float(xx)/10. for xx in range(3, 9)] Mach_list = [0.3,0.6,0.8] OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',2.392) #wing_param.set_value('sweep',34.) wing_param.set_value('sweep',26.7) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',0.806) wing_param.set_value('break_chord',0.689) wing_param.set_value('tip_chord',0.451) #wing_param.set_value('root_height',1.28) wing_param.set_value('root_height',0.0782) #wing_param.set_value('break_height',0.97) wing_param.set_value('break_height',0.0668) #wing_param.set_value('tip_height',0.33) wing_param.set_value('tip_height',0.0438) #wing_param.convert_to_design_variable('span',10.,50.)
# # http://github.com/TBD # from DLLM.DLLMGeom.wing_param import Wing_param from MDOTools.OC.operating_condition import OperatingCondition import numpy import string OC = OperatingCondition("cond1") OC.set_altitude(3000.0) OC.set_T0_deg(15.0) OC.set_P0(101325.0) OC.set_humidity(0.0) wing_param = Wing_param("test_param", geom_type="Broken", n_sect=20) wing_param.build_wing() wing_param.set_value("span", 34.1) wing_param.set_value("sweep", 0.0) wing_param.set_value("break_percent", 33.0) wing_param.set_value("root_chord", 6.1) wing_param.set_value("break_chord", 4.6) wing_param.set_value("tip_chord", 1.5) wing_param.set_value("root_height", 1.28) wing_param.set_value("break_height", 0.97) wing_param.set_value("tip_height", 0.33) wing_param.build_linear_airfoil(OC, AoA0=0.0, Cm0=-0.1, set_as_ref=True) wing_param.build_airfoils_from_ref() wing_param.update() airfoils = wing_param.get_linked_airfoils()
# from DLLM.DLLMGeom.wing_param import Wing_param from MDOTools.OC.operating_condition import OperatingCondition import numpy import string OC=OperatingCondition('cond1') OC.set_altitude(3000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) nsect=50 wing_param=Wing_param('test_param',geom_type='Elliptic',n_sect=nsect) wing_param.set_distrib_type('cos_law') wing_param.build_wing() wing_param.set_value('span',40.) wing_param.set_value('root_chord',4.) wing_param.set_value('root_height',0.0) wing_param.set_value('tip_height',0.0) wing_param.build_linear_airfoil(OC, AoA0=0., Cm0=-0.1, set_as_ref=True) wing_param.build_airfoils_from_ref() wing_param.update() airfoils=wing_param.get_linked_airfoils() Cla=airfoils[24].ClAlpha(0.0,0.3) print "Cla=",Cla
OC=OperatingCondition('cond1') #OC.set_Mach(0.8) #OC.set_Mach(0.6) #OC.set_AoA(3.5) AoA_list = [float(xx) for xx in range(0, 10)] #AoA_list=[9.] #Mach_list = [float(xx)/10. for xx in range(3, 9)] Mach_list = [0.2]#,0.6,0.8] OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) wing_param=Wing_param('test_param',geom_type='Broken',n_sect=50) wing_param.set_distrib_type('cos_law') wing_param.build_wing() wing_param.set_value('span',30.) #wing_param.set_value('sweep',34.) wing_param.set_value('sweep',0.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',1.) wing_param.set_value('break_chord',1.) wing_param.set_value('tip_chord',1.) #wing_param.set_value('root_height',1.28) wing_param.set_value('root_height',0.0) #wing_param.set_value('break_height',0.97) wing_param.set_value('break_height',0.0) #wing_param.set_value('tip_height',0.33) wing_param.set_value('tip_height',0.0)
def test_Wing_param_set_value(self): """ test set value for Wing_param """ wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() try: wing_param.set_value('span',34.1) wing_param.set_value('sweep',32.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',6.1) wing_param.set_value('break_chord',4.6) wing_param.set_value('tip_chord',1.5) wing_param.set_value('root_height',1.28) wing_param.set_value('break_height',0.97) wing_param.set_value('tip_height',0.33) ok=True except: ok=False assert(ok)
# from DLLM.DLLMGeom.wing_param import Wing_param from MDOTools.OC.operating_condition import OperatingCondition import numpy import string OC=OperatingCondition('cond1') OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) nsect=50 wing_param=Wing_param('test_param',geom_type='Broken',n_sect=nsect) wing_param.build_wing() wing_param.set_value('span',30.) #wing_param.set_value('sweep',34.) wing_param.set_value('sweep',0.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',1.0) wing_param.set_value('break_chord',1.0) wing_param.set_value('tip_chord',1.0) #wing_param.set_value('root_height',1.28) wing_param.set_value('root_height',0.1) #wing_param.set_value('break_height',0.97) wing_param.set_value('break_height',0.1) #wing_param.set_value('tip_height',0.33) wing_param.set_value('tip_height',0.1) #wing_param.convert_to_design_variable('span',10.,50.)
def test_Wing_param_convert(self): wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) wing_param.build_wing() wing_param.set_value('span', 34.1) wing_param.set_value('sweep', 32.) wing_param.set_value('break_percent', 33.) wing_param.set_value('root_chord', 6.1) wing_param.set_value('break_chord', 4.6) wing_param.set_value('tip_chord', 1.5) wing_param.set_value('root_height', 1.28) wing_param.set_value('break_height', 0.97) wing_param.set_value('tip_height', 0.33) try: wing_param.convert_to_design_variable('span', (10., 50.)) wing_param.convert_to_design_variable('sweep', (0., 40.)) wing_param.convert_to_design_variable('break_percent', (20., 40.)) wing_param.convert_to_design_variable('root_chord', (5., 7.)) wing_param.convert_to_design_variable('break_chord', (3., 5.)) wing_param.convert_to_design_variable('tip_chord', (1., 2.)) wing_param.convert_to_design_variable('root_height', (1., 1.5)) wing_param.convert_to_design_variable('break_height', (0.8, 1.2)) wing_param.convert_to_design_variable('tip_height', (0.2, 0.5)) ok = True except: ok = False assert (ok)
def test_Wing_param_update(self): OC=self.__init_OC() wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',34.1) wing_param.set_value('sweep',32.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',6.1) wing_param.set_value('break_chord',4.6) wing_param.set_value('tip_chord',1.5) wing_param.set_value('root_height',1.28) wing_param.set_value('break_height',0.97) wing_param.set_value('tip_height',0.33) wing_param.convert_to_design_variable('span',(10.,50.)) wing_param.convert_to_design_variable('sweep',(0.,40.)) wing_param.convert_to_design_variable('break_percent',(20.,40.)) wing_param.convert_to_design_variable('root_chord',(5.,7.)) wing_param.convert_to_design_variable('break_chord',(3.,5.)) wing_param.convert_to_design_variable('tip_chord',(1.,2.)) wing_param.convert_to_design_variable('root_height',(1.,1.5)) wing_param.convert_to_design_variable('break_height',(0.8,1.2)) wing_param.convert_to_design_variable('tip_height',(0.2,0.5)) wing_param.build_linear_airfoil(OC, AoA0=-2., Cm0=-0.1, set_as_ref=True) wing_param.build_airfoils_from_ref() try: wing_param.update() ok=True except: ok=False assert(ok)
def __init_wing_param(self): OC = OperatingCondition('cond1') OC.set_Mach(0.7) OC.set_AoA(3.0) OC.set_altitude(5000.) OC.set_T0_deg(20.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) wing_param.build_wing() wing_param.set_value('span', 34.1) wing_param.set_value('sweep', 32.) wing_param.set_value('break_percent', 33.) wing_param.set_value('root_chord', 6.1) wing_param.set_value('break_chord', 4.6) wing_param.set_value('tip_chord', 1.5) wing_param.set_value('root_height', 1.28) wing_param.set_value('break_height', 0.97) wing_param.set_value('tip_height', 0.33) wing_param.convert_to_design_variable('span', (10., 50.)) wing_param.convert_to_design_variable('sweep', (0., 40.)) wing_param.convert_to_design_variable('break_percent', (20., 40.)) wing_param.convert_to_design_variable('root_chord', (5., 7.)) wing_param.convert_to_design_variable('break_chord', (3., 5.)) wing_param.convert_to_design_variable('tip_chord', (1., 2.)) wing_param.convert_to_design_variable('root_height', (1., 1.5)) wing_param.convert_to_design_variable('break_height', (0.8, 1.2)) wing_param.convert_to_design_variable('tip_height', (0.2, 0.5)) wing_param.build_linear_airfoil(OC, AoA0=-2., Cm0=-0.1, set_as_ref=True) wing_param.build_airfoils_from_ref() wing_param.update() return wing_param
# # Imports from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMSolver import DLLMSolver from MDOTools.OC.operating_condition import OperatingCondition OC=OperatingCondition('cond1') OC.set_Mach(0.3) OC.set_AoA(4.) OC.set_altitude(1000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',2.392) #34.1 wing_param.set_value('sweep',26.7) wing_param.set_value('break_percent',33.) #33. wing_param.set_value('root_chord',0.806) #6.1 wing_param.set_value('break_chord',0.689) wing_param.set_value('tip_chord',0.451) #1.5 wing_param.set_value('root_height',0.0782) wing_param.set_value('break_height',0.0668) wing_param.set_value('tip_height',0.0438) wing_param.convert_to_design_variable('span',(10.,50.)) wing_param.convert_to_design_variable('sweep',(0.,40.)) wing_param.convert_to_design_variable('break_percent',(20.,40.)) wing_param.convert_to_design_variable('root_chord',(5.,7.)) wing_param.convert_to_design_variable('break_chord',(3.,5.))
OC = OperatingCondition('cond1') #OC.set_Mach(0.8) #OC.set_Mach(0.6) #OC.set_AoA(3.5) AoA_list = [float(xx) for xx in range(0, 10)] AoA_list = [9.] #Mach_list = [float(xx)/10. for xx in range(3, 9)] Mach_list = [0.2] #,0.6,0.8] OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) wing_param = Wing_param('test_param', geom_type='Rectangular', n_sect=50) wing_param.build_wing() wing_param.set_value('span', 40.) #wing_param.set_value('sweep',34.) wing_param.set_value('sweep', 0.) wing_param.set_value('root_chord', 1.0) wing_param.set_value('root_height', 0.1) wing_param.set_value('tip_height', 0.1) wing_param.build_linear_airfoil(OC, AoA0=0., Cm0=-0.1, Ka=0.75, set_as_ref=True) #wing_param.build_meta_airfoil(OC, '../ONERA_D.xml', relative_thickness=.09, camber=0, Sref=1., Lref=1., sweep=.0, set_as_ref=True) wing_param.build_airfoils_from_ref()
import string OC=OperatingCondition('cond1') #OC.set_Mach(0.8) #OC.set_Mach(0.6) #OC.set_AoA(3.5) AoA_list = [float(xx) for xx in range(0, 10)] #Mach_list = [float(xx)/10. for xx in range(3, 9)] Mach_list = [0.3]#,0.6,0.8] OC.set_altitude(3000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',34.1) wing_param.set_value('sweep',0.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',6.1) wing_param.set_value('break_chord',4.6) wing_param.set_value('tip_chord',1.5) wing_param.set_value('root_height',1.28) wing_param.set_value('break_height',0.97) wing_param.set_value('tip_height',0.33) wing_param.build_linear_airfoil(OC, AoA0=0., Cm0=-0.1, set_as_ref=True) wing_param.build_airfoils_from_ref() wing_param.update() print 'AR=',wing_param.get_AR()
# # Imports from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMSolver import DLLMSolver from MDOTools.OC.operating_condition import OperatingCondition OC = OperatingCondition('cond1') OC.set_Mach(0.3) OC.set_AoA(4.) OC.set_altitude(1000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) wing_param.build_wing() wing_param.set_value('span', 2.392) #34.1 wing_param.set_value('sweep', 26.7) wing_param.set_value('break_percent', 33.) #33. wing_param.set_value('root_chord', 0.806) #6.1 wing_param.set_value('break_chord', 0.689) wing_param.set_value('tip_chord', 0.451) #1.5 wing_param.set_value('root_height', 0.0782) wing_param.set_value('break_height', 0.0668) wing_param.set_value('tip_height', 0.0438) wing_param.convert_to_design_variable('span', (10., 50.)) wing_param.convert_to_design_variable('sweep', (0., 40.)) wing_param.convert_to_design_variable('break_percent', (20., 40.)) wing_param.convert_to_design_variable('root_chord', (5., 7.)) wing_param.convert_to_design_variable('break_chord', (3., 5.))
def test_Wing_param_linear_airfoil(self): OC = self.__init_OC() wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) wing_param.build_wing() wing_param.set_value('span', 34.1) wing_param.set_value('sweep', 32.) wing_param.set_value('break_percent', 33.) wing_param.set_value('root_chord', 6.1) wing_param.set_value('break_chord', 4.6) wing_param.set_value('tip_chord', 1.5) wing_param.set_value('root_height', 1.28) wing_param.set_value('break_height', 0.97) wing_param.set_value('tip_height', 0.33) wing_param.convert_to_design_variable('span', (10., 50.)) wing_param.convert_to_design_variable('sweep', (0., 40.)) wing_param.convert_to_design_variable('break_percent', (20., 40.)) wing_param.convert_to_design_variable('root_chord', (5., 7.)) wing_param.convert_to_design_variable('break_chord', (3., 5.)) wing_param.convert_to_design_variable('tip_chord', (1., 2.)) wing_param.convert_to_design_variable('root_height', (1., 1.5)) wing_param.convert_to_design_variable('break_height', (0.8, 1.2)) wing_param.convert_to_design_variable('tip_height', (0.2, 0.5)) try: wing_param.build_linear_airfoil(OC, AoA0=-2., Cm0=-0.1, set_as_ref=True) wing_param.build_airfoils_from_ref() ok = True except: ok = False assert (ok)
# # http://github.com/TBD # from DLLM.DLLMGeom.wing_param import Wing_param from MDOTools.OC.operating_condition import OperatingCondition import numpy import string OC=OperatingCondition('cond1',atmospheric_model='simple') OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',2.392) #wing_param.set_value('sweep',34.) wing_param.set_value('sweep',26.7) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',0.806) wing_param.set_value('break_chord',0.689) wing_param.set_value('tip_chord',0.451) #wing_param.set_value('root_height',1.28) wing_param.set_value('root_height',0.0782) #wing_param.set_value('break_height',0.97) wing_param.set_value('break_height',0.0668) #wing_param.set_value('tip_height',0.33) wing_param.set_value('tip_height',0.0438) #wing_param.convert_to_design_variable('span',10.,50.)
def test_Wing_param_instantiation(self): """ test class instantiation """ wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) assert (wing_param is not None)
from MDOTools.ValidGrad.FDValidGrad import FDValidGrad from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMSolver import DLLMSolver from MDOTools.OC.operating_condition import OperatingCondition import numpy OC = OperatingCondition("cond1") OC.set_Mach(0.8) OC.set_AoA(3.5) OC.set_altitude(10000.0) OC.set_T0_deg(15.0) OC.set_P0(101325.0) OC.set_humidity(0.0) OC.compute_atmosphere() wing_param = Wing_param("test_param", geom_type="Broken", n_sect=20) wing_param.build_wing() wing_param.set_value("span", 34.1) wing_param.set_value("sweep", 34.0) wing_param.set_value("break_percent", 33.0) wing_param.set_value("root_chord", 6.1) wing_param.set_value("break_chord", 4.6) wing_param.set_value("tip_chord", 1.5) wing_param.set_value("root_height", 1.28) wing_param.set_value("break_height", 0.97) wing_param.set_value("tip_height", 0.33) wing_param.convert_to_design_variable("span", (0.0, 50.0)) wing_param.convert_to_design_variable("sweep", (0.0, 40.0)) wing_param.convert_to_design_variable("break_percent", (20.0, 40.0)) wing_param.convert_to_design_variable("root_chord", (5.0, 7.0)) wing_param.convert_to_design_variable("break_chord", (3.0, 5.0))
def test_Wing_param_set_value(self): """ test set value for Wing_param """ wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) wing_param.build_wing() try: wing_param.set_value('span', 34.1) wing_param.set_value('sweep', 32.) wing_param.set_value('break_percent', 33.) wing_param.set_value('root_chord', 6.1) wing_param.set_value('break_chord', 4.6) wing_param.set_value('tip_chord', 1.5) wing_param.set_value('root_height', 1.28) wing_param.set_value('break_height', 0.97) wing_param.set_value('tip_height', 0.33) ok = True except: ok = False assert (ok)
from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMTargetCl import DLLMTargetCl from MDOTools.OC.operating_condition import OperatingCondition import numpy import sys OC=OperatingCondition('cond1') OC.set_Mach(0.3) OC.set_AoA(0.) OC.set_altitude(3000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',3.) wing_param.set_value('sweep',30.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',1.0) wing_param.set_value('break_chord',1.0) wing_param.set_value('tip_chord',1.0) wing_param.set_value('root_height',0.15) wing_param.set_value('break_height',0.15) wing_param.set_value('tip_height',0.15) wing_param.build_linear_airfoil(OC, AoA0=0., Cm0=0.0, set_as_ref=True) wing_param.build_airfoils_from_ref() wing_param.update() print wing_param
# # Imports from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMSolver import DLLMSolver from MDOTools.OC.operating_condition import OperatingCondition OC=OperatingCondition('cond1') OC.set_Mach(0.4) OC.set_AoA(3.5) OC.set_altitude(5000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',34.1) #34.1 wing_param.set_value('sweep',34.) wing_param.set_value('break_percent',23.) #33. wing_param.set_value('root_chord',5.4) #6.1 wing_param.set_value('break_chord',4.6) wing_param.set_value('tip_chord',1.2) #1.5 wing_param.set_value('root_height',.98) wing_param.set_value('break_height',0.70) wing_param.set_value('tip_height',0.18) wing_param.convert_to_design_variable('span',(10.,50.)) wing_param.convert_to_design_variable('sweep',(0.,40.)) wing_param.convert_to_design_variable('break_percent',(20.,40.)) wing_param.convert_to_design_variable('root_chord',(5.,7.)) wing_param.convert_to_design_variable('break_chord',(3.,5.))
import string OC = OperatingCondition('cond1', atmospheric_model='simple') #OC.set_Mach(0.8) #OC.set_Mach(0.6) #OC.set_AoA(3.5) AoA_list = [float(xx) for xx in range(0, 10)] #Mach_list = [float(xx)/10. for xx in range(3, 9)] Mach_list = [0.3, 0.6, 0.8] OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) wing_param.build_wing() wing_param.set_value('span', 2.392) #wing_param.set_value('sweep',34.) wing_param.set_value('sweep', 26.7) wing_param.set_value('break_percent', 33.) wing_param.set_value('root_chord', 0.806) wing_param.set_value('break_chord', 0.689) wing_param.set_value('tip_chord', 0.451) #wing_param.set_value('root_height',1.28) wing_param.set_value('root_height', 0.0782) #wing_param.set_value('break_height',0.97) wing_param.set_value('break_height', 0.0668) #wing_param.set_value('tip_height',0.33) wing_param.set_value('tip_height', 0.0438) #wing_param.convert_to_design_variable('span',10.,50.)
from MDOTools.ValidGrad.FDValidGrad import FDValidGrad from DLLM.DLLMGeom.wing_param import Wing_param from DLLM.DLLMKernel.DLLMSolver import DLLMSolver from MDOTools.OC.operating_condition import OperatingCondition import numpy OC = OperatingCondition('cond1') OC.set_Mach(0.8) OC.set_AoA(3.5) OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) wing_param.build_wing() wing_param.set_value('span', 34.1) wing_param.set_value('sweep', 34.) wing_param.set_value('break_percent', 33.) wing_param.set_value('root_chord', 6.1) wing_param.set_value('break_chord', 4.6) wing_param.set_value('tip_chord', 1.5) wing_param.set_value('root_height', 1.28) wing_param.set_value('break_height', 0.97) wing_param.set_value('tip_height', 0.33) wing_param.convert_to_design_variable('span', (0., 50.)) wing_param.convert_to_design_variable('sweep', (0., 40.)) wing_param.convert_to_design_variable('break_percent', (20., 40.)) wing_param.convert_to_design_variable('root_chord', (5., 7.)) wing_param.convert_to_design_variable('break_chord', (3., 5.))
OC=OperatingCondition('cond1') #OC.set_Mach(0.8) #OC.set_Mach(0.6) #OC.set_AoA(3.5) AoA_list = [float(xx) for xx in range(0, 10)] AoA_list = [9.] #Mach_list = [float(xx)/10. for xx in range(3, 9)] Mach_list = [0.2]#,0.6,0.8] OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) wing_param=Wing_param('test_param',geom_type='Rectangular',n_sect=50) wing_param.build_wing() wing_param.set_value('span',40.) #wing_param.set_value('sweep',34.) wing_param.set_value('sweep',0.) wing_param.set_value('root_chord',1.0) wing_param.set_value('root_height',0.1) wing_param.set_value('tip_height',0.1) wing_param.build_linear_airfoil(OC, AoA0=0., Cm0=-0.1, Ka=0.75, set_as_ref=True) #wing_param.build_meta_airfoil(OC, '../ONERA_D.xml', relative_thickness=.09, camber=0, Sref=1., Lref=1., sweep=.0, set_as_ref=True) wing_param.build_airfoils_from_ref() wing_param.update() print wing_param
from DLLM.DLLMKernel.DLLMTargetCl import DLLMTargetCl from MDOTools.OC.operating_condition import OperatingCondition from MDOTools.ValidGrad.FDValidGrad import FDValidGrad import numpy import sys OC=OperatingCondition('cond1') OC.set_Mach(0.3) OC.set_AoA(0.) OC.set_altitude(3000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param=Wing_param('test_param',geom_type='Broken',n_sect=20) wing_param.build_wing() wing_param.set_value('span',40.) wing_param.set_value('sweep',0.) wing_param.set_value('break_percent',33.) wing_param.set_value('root_chord',1.0) wing_param.set_value('break_chord',1.0) wing_param.set_value('tip_chord',1.0) wing_param.set_value('root_height',0.15) wing_param.set_value('break_height',0.15) wing_param.set_value('tip_height',0.15) wing_param.build_linear_airfoil(OC, AoA0=0., Cm0=0.0, set_as_ref=True) wing_param.build_airfoils_from_ref() wing_param.update() print wing_param
def __init_wing_param(self): OC = OperatingCondition('cond1') OC.set_Mach(0.8) OC.set_AoA(3.5) OC.set_altitude(10000.) OC.set_T0_deg(15.) OC.set_P0(101325.) OC.set_humidity(0.) OC.compute_atmosphere() wing_param = Wing_param('test_param', geom_type='Broken', n_sect=20) wing_param.build_wing() wing_param.set_value('span', 34.1) wing_param.set_value('sweep', 34.) wing_param.set_value('break_percent', 33.) wing_param.set_value('root_chord', 6.1) wing_param.set_value('break_chord', 4.6) wing_param.set_value('tip_chord', 1.5) wing_param.set_value('root_height', 1.28) wing_param.set_value('break_height', 0.97) wing_param.set_value('tip_height', 0.33) wing_param.convert_to_design_variable('span', (10., 50.)) wing_param.convert_to_design_variable('sweep', (0., 40.)) wing_param.convert_to_design_variable('break_percent', (20., 40.)) wing_param.convert_to_design_variable('root_chord', (5., 7.)) wing_param.convert_to_design_variable('break_chord', (3., 5.)) wing_param.convert_to_design_variable('tip_chord', (1., 2.)) wing_param.convert_to_design_variable('root_height', (1., 1.5)) wing_param.convert_to_design_variable('break_height', (0.8, 1.2)) wing_param.convert_to_design_variable('tip_height', (0.2, 0.5)) wing_param.build_meta_airfoil(OC, '../examples/MetaModelFixed.xml', relative_thickness=.12, camber=0., Sref=1., Lref=1., sweep=.0, set_as_ref=True) wing_param.build_airfoils_from_ref() wing_param.update() return OC, wing_param