コード例 #1
0
 def test_DLLM_valid_TCl(self):
     OC, wing_param = self.__init_wing_param()
     DLLM = DLLMTargetCl('Simple', wing_param, OC)
     DLLM.set_target_Cl(0.5)
     DLLM.run_direct()
     DLLM.run_post()
     F_list = DLLM.get_F_list()
     F_list_names = DLLM.get_F_list_names()
     cl_index = F_list_names.index('Cl')
     Cl = F_list[cl_index]
     assert (abs(Cl - 0.5) < 1.e-10)
コード例 #2
0
def f(x):
    wing_param.update_from_x_list(x)
    DLLM = DLLMTargetCl('Simple',wing_param,OC)
    DLLM.set_target_Cl(0.5)
    DLLM.run_direct()
    DLLM.run_post()
    func=DLLM.get_F_list()
    return func
コード例 #3
0
    def test_DLLM_valid_TCl(self):
        OC,wing_param = self.__init_wing_param()
        DLLM = DLLMTargetCl('Simple',wing_param,OC)
#         F_list=DLLM.get_F_list()
        F_list_names=DLLM.get_F_list_names()
        DLLM.set_target_Cl(0.5)
        DLLM.run_direct()
        DLLM.run_post()
        F_list=DLLM.get_F_list()
        F_list_names=DLLM.get_F_list_names()
        cl_index = F_list_names.index('Cl')
        Cl=F_list[cl_index]
        assert(abs(Cl-0.5)<1.e-10)
コード例 #4
0
 def df1(x):
     wing_param.update_from_x_list(x)
     DLLM = DLLMTargetCl('Simple',wing_param,OC)
     DLLM.set_target_Cl(0.5)
     DLLM.run_direct()
     DLLM.run_post()
     DLLM.run_adjoint()
     func_grad=np.array(DLLM.get_dF_list_dchi())
     N = func_grad.shape[0]
     ndv = func_grad.shape[1]
     out_grad = np.zeros((N,ndv))
     for i in xrange(N):
         out_grad[i,:] = func_grad[i,:]/Ref_list[i]
     return out_grad
コード例 #5
0
ファイル: DLLMWrapper.py プロジェクト: regislebrun/DLLM
 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)
             
コード例 #6
0
 def test_DLLM_valid_grad_TCl(self):
     OC,wing_param = self.__init_wing_param()
     x0=wing_param.get_dv_array()
     
     DLLM = DLLMTargetCl('Simple',wing_param,OC)
     DLLM.set_target_Cl(0.5)
     DLLM.run_direct()
     DLLM.run_post()
     Ref_list=DLLM.get_F_list()
     
     def f1(x):
         wing_param.update_from_x_list(x)
         DLLM = DLLMTargetCl('Simple',wing_param,OC)
         DLLM.set_target_Cl(0.5)
         DLLM.run_direct()
         DLLM.run_post()
         func=DLLM.get_F_list()
         return func/Ref_list
        
     def df1(x):
         wing_param.update_from_x_list(x)
         DLLM = DLLMTargetCl('Simple',wing_param,OC)
         DLLM.set_target_Cl(0.5)
         DLLM.run_direct()
         DLLM.run_post()
         DLLM.run_adjoint()
         func_grad=np.array(DLLM.get_dF_list_dchi())
         N = func_grad.shape[0]
         ndv = func_grad.shape[1]
         out_grad = np.zeros((N,ndv))
         for i in xrange(N):
             out_grad[i,:] = func_grad[i,:]/Ref_list[i]
         return out_grad
        
     val_grad1=FDValidGrad(2,f1,df1,fd_step=1.e-8)
     ok1,df_fd1,df1=val_grad1.compare(x0,treshold=1.e-5,split_out=True,return_all=True)
     assert(ok1)
コード例 #7
0
ファイル: Rect_sweep0.py プロジェクト: FrancoisGallard/DLLM
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

print 'AR=',wing_param.get_AR()

DLLM = DLLMTargetCl('Rectsweep0',wing_param,OC)
DLLM.set_target_Cl(0.5)
DLLM.run_direct()
DLLM.run_post()



コード例 #8
0
def df(x):
    wing_param.update_from_x_list(x)
    DLLM = DLLMTargetCl('Simple',wing_param,OC)
    DLLM.set_target_Cl(0.5)
    DLLM.run_direct()
    DLLM.run_post()
    DLLM.run_adjoint()
    func_grad=numpy.array(DLLM.get_dF_list_dchi())
    return func_grad
コード例 #9
0
# Imports
from MDOTools.OC.operating_condition import OperatingCondition
from DLLM.DLLMGeom.wing_broken import Wing_Broken
from DLLM.DLLMKernel.DLLMTargetCl import DLLMTargetCl

OC=OperatingCondition('cond1', atmospheric_model='ISA')
OC.set_Mach(0.8)
OC.set_AoA(3.0)
OC.set_altitude(10000.)
OC.set_T0_deg(15.)
OC.set_P0(101325.)
OC.set_humidity(0.)
OC.compute_atmosphere()

wing_param=Wing_Broken('broken_wing',n_sect=20)
wing_param.import_BC_from_file('input_parameters.par')
wing_param.build_linear_airfoil(OC, AoA0=0.0, set_as_ref=True)
wing_param.build_airfoils_from_ref()
wing_param.update()
wing_param.plot()

DLLM = DLLMTargetCl('TCl',wing_param,OC)
DLLM.set_target_Cl(0.5)
DLLM.run_direct()
DLLM.run_post()
DLLM.run_adjoint()

print 'Cl = ',DLLM.get_DLLMPost().Cl,' Target = ',0.5
print 'AoA = ',OC.get_AoA()

dF_list_dchi=DLLM.get_dF_list_dchi()
コード例 #10
0
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

print 'AR=',wing_param.get_AR()

DLLM = DLLMTargetCl('RectLowARsweep30',wing_param,OC)
DLLM.set_target_Cl(0.5)
DLLM.run_direct()
DLLM.run_post()



コード例 #11
0
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()

print wing_param

DLLM = DLLMTargetCl('TCl',wing_param,OC)
#DLLM.set_method('scipy')
DLLM.set_target_Cl(0.5)
DLLM.run_direct()
DLLM.run_post()
DLLM.run_adjoint()

dF_list_dchi=DLLM.get_dF_list_dchi()

# for i,name in enumerate(DLLM.get_F_list_names()):
#     print 'gradients for '+name+' = ',dF_list_dchi[i]

コード例 #12
0
ファイル: test_target_Cl.py プロジェクト: regislebrun/DLLM
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()

print wing_param

DLLM = DLLMTargetCl('TCl', wing_param, OC)
#DLLM.set_method('scipy')
DLLM.set_target_Cl(0.5)
DLLM.run_direct()
DLLM.run_post()
DLLM.run_adjoint()

dF_list_dchi = DLLM.get_dF_list_dchi()

# for i,name in enumerate(DLLM.get_F_list_names()):
#     print 'gradients for '+name+' = ',dF_list_dchi[i]
コード例 #13
0
OC.set_humidity(0.)
OC.compute_atmosphere()

wing_param=Wing_Broken('broken_wing',n_sect=20)
wing_param.import_BC_from_file('input_parameters.par')
wing_param.build_linear_airfoil(OC, AoA0=0.0, set_as_ref=True)
wing_param.build_airfoils_from_ref()
wing_param.update()

print wing_param

x0=wing_param.get_dv_array()
print 'dv array shape',x0.shape
print 'dv_array=',x0

DLLM = DLLMTargetCl('Simple',wing_param,OC)
DLLM.set_target_Cl(0.5)
DLLM.run_direct()
DLLM.run_post()
Ref_F = DLLM.get_F_list()

def f(x):
    wing_param.update_from_x_list(x)
    DLLM = DLLMTargetCl('Simple',wing_param,OC)
    DLLM.set_target_Cl(0.5)
    DLLM.run_direct()
    DLLM.run_post()
    func=DLLM.get_F_list()
    return func/Ref_F

def df(x):