Example #1
0
def run(AoA):
    config_dict={}
    # Operating condition configuration
    config_dict['cond1.OC.Mach']=0.4
    config_dict['cond1.OC.AoA']=AoA
    config_dict['cond1.OC.altitude']=2000.
    
    # Parameterisation configuration
    config_dict['cond1.param.geom_type']='Broken'
    config_dict['cond1.param.n_sect']=20
    config_dict['cond1.param.airfoil.type']='simple'
    config_dict['cond1.param.airfoil.AoA0']=-2.
    config_dict['cond1.param.airfoil.Cm0']=-0.1
    # config_dict['cond1.param.airfoil.type']='meta'
    # config_dict['cond1.param.airfoil.surrogate_model']='../MetaModelCleaning.xml'
    config_dict['cond1.param.desc.span.type']='DesignVariable'
    config_dict['cond1.param.desc.span.value']=34.1
    config_dict['cond1.param.desc.span.bounds']=(10.,50.)
    config_dict['cond1.param.desc.sweep.type']='DesignVariable'
    config_dict['cond1.param.desc.sweep.value']=34.
    config_dict['cond1.param.desc.sweep.bounds']=(0.,40.)
    config_dict['cond1.param.desc.break_percent.type']='Variable'
    config_dict['cond1.param.desc.break_percent.value']=33.
    #config_dict['cond1.param.desc.break_percent.bounds']=(20.,40.)
    config_dict['cond1.param.desc.root_chord.type']='DesignVariable'
    config_dict['cond1.param.desc.root_chord.value']=6.1
    config_dict['cond1.param.desc.root_chord.bounds']=(5.,7.)
    config_dict['cond1.param.desc.break_chord.type']='DesignVariable'
    config_dict['cond1.param.desc.break_chord.value']=4.6
    config_dict['cond1.param.desc.break_chord.bounds']=(3.,5.)
    config_dict['cond1.param.desc.tip_chord.type']='DesignVariable'
    config_dict['cond1.param.desc.tip_chord.value']=1.5
    config_dict['cond1.param.desc.tip_chord.bounds']=(1.,2.)
    config_dict['cond1.param.desc.root_height.type']='DesignVariable'
    config_dict['cond1.param.desc.root_height.value']=1.28
    config_dict['cond1.param.desc.root_height.bounds']=(1.,1.5)
    config_dict['cond1.param.desc.break_height.type']='DesignVariable'
    config_dict['cond1.param.desc.break_height.value']=0.97
    config_dict['cond1.param.desc.break_height.bounds']=(0.8,1.2)
    config_dict['cond1.param.desc.tip_height.type']='DesignVariable'
    config_dict['cond1.param.desc.tip_height.value']=0.33
    config_dict['cond1.param.desc.tip_height.bounds']=(0.2,0.5)
    
    # DLLM configuration
    config_dict['cond1.DLLM.type']='Solver'
    config_dict['cond1.DLLM.method']='inhouse'
    config_dict['cond1.DLLM.relax_factor']=0.99
    config_dict['cond1.DLLM.stop_residual']=1e-9
    config_dict['cond1.DLLM.max_iterations']=100
    config_dict['cond1.DLLM.gamma_file_name']='gamma.dat'
    #config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Pressure','Drag_Friction','Cl', 'Cd', 'Cdp', 'Cdf', 'LoD']
    config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Wave','LoD']
    #config_dict['cond1.DLLM.target_Cl']=0.5
    #config_dict['cond1.DLLM.target_Lift']=769200.
    
    DLLMcond1=DLLMWrapper('cond1')
    DLLMcond1.configure(config_dict)
    F_list = DLLMcond1.analysis()
    
    return F_list
Example #2
0
def run(AoA):
    config_dict={}
    # Operating condition configuration
    config_dict['cond1.OC.Mach']=0.4
    config_dict['cond1.OC.AoA']=AoA
    config_dict['cond1.OC.altitude']=2000.
    
    # Parameterisation configuration
    config_dict['cond1.param.geom_type']='Broken'
    config_dict['cond1.param.n_sect']=20
    config_dict['cond1.param.airfoil.type']='meta'
    config_dict['cond1.param.airfoil.surrogate_model']='../MetaModelCleaning.xml'
    config_dict['cond1.param.desc.span.type']='DesignVariable'
    config_dict['cond1.param.desc.span.value']=34.1
    config_dict['cond1.param.desc.span.bounds']=(10.,50.)
    config_dict['cond1.param.desc.sweep.type']='DesignVariable'
    config_dict['cond1.param.desc.sweep.value']=34.
    config_dict['cond1.param.desc.sweep.bounds']=(0.,40.)
    config_dict['cond1.param.desc.break_percent.type']='Variable'
    config_dict['cond1.param.desc.break_percent.value']=33.
    #config_dict['cond1.param.desc.break_percent.bounds']=(20.,40.)
    config_dict['cond1.param.desc.root_chord.type']='DesignVariable'
    config_dict['cond1.param.desc.root_chord.value']=6.1
    config_dict['cond1.param.desc.root_chord.bounds']=(5.,7.)
    config_dict['cond1.param.desc.break_chord.type']='DesignVariable'
    config_dict['cond1.param.desc.break_chord.value']=4.6
    config_dict['cond1.param.desc.break_chord.bounds']=(3.,5.)
    config_dict['cond1.param.desc.tip_chord.type']='DesignVariable'
    config_dict['cond1.param.desc.tip_chord.value']=1.5
    config_dict['cond1.param.desc.tip_chord.bounds']=(1.,2.)
    config_dict['cond1.param.desc.root_height.type']='DesignVariable'
    config_dict['cond1.param.desc.root_height.value']=1.28
    config_dict['cond1.param.desc.root_height.bounds']=(1.,1.5)
    config_dict['cond1.param.desc.break_height.type']='DesignVariable'
    config_dict['cond1.param.desc.break_height.value']=0.97
    config_dict['cond1.param.desc.break_height.bounds']=(0.8,1.2)
    config_dict['cond1.param.desc.tip_height.type']='DesignVariable'
    config_dict['cond1.param.desc.tip_height.value']=0.33
    config_dict['cond1.param.desc.tip_height.bounds']=(0.2,0.5)
    
    # DLLM configuration
    config_dict['cond1.DLLM.type']='Solver'
    config_dict['cond1.DLLM.method']='inhouse'
    config_dict['cond1.DLLM.relax_factor']=0.99
    config_dict['cond1.DLLM.stop_residual']=1e-9
    config_dict['cond1.DLLM.max_iterations']=100
    config_dict['cond1.DLLM.gamma_file_name']='gamma.dat'
    #config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Pressure','Drag_Friction','Cl', 'Cd', 'Cdp', 'Cdf', 'LoD']
    config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Wave','LoD']
    #config_dict['cond1.DLLM.target_Cl']=0.5
    #config_dict['cond1.DLLM.target_Lift']=769200.
    
    DLLMcond1=DLLMWrapper('cond1')
    DLLMcond1.configure(config_dict)
    F_list = DLLMcond1.analysis()
    
    return F_list
Example #3
0
 def test_DLLM_wrapper_TLift(self):
     config_dict = self.__get_base_config_dict()
     config_dict['test.DLLM.type']='TargetLift'
     config_dict['test.DLLM.target_Lift']=769200.
     
     DLLMWrap = DLLMWrapper('test', verbose=0)
     DLLMWrap.configure(config_dict)
     DLLMWrap.set_out_format('numpy')
     DLLMWrap.set_grad_format('numpy')
     
     DLLMWrap.analysis()
     Lift=DLLMWrap.get_F_value('Lift')
     assert((Lift-769200.)<1.e-2)
Example #4
0
 def test_DLLM_wrapper_TCl(self):
     config_dict = self.__get_base_config_dict()
     config_dict['test.DLLM.type']='TargetCl'
     config_dict['test.DLLM.target_Cl']=0.5
     
     DLLMWrap = DLLMWrapper('test', verbose=0)
     DLLMWrap.configure(config_dict)
     DLLMWrap.set_out_format('numpy')
     DLLMWrap.set_grad_format('numpy')
     
     DLLMWrap.analysis()
     Cl=DLLMWrap.get_F_value('Cl')
     assert((Cl-0.5)<1.e-8)
Example #5
0
 def __configure_wrapper_list(self):
     self.__wrapper_list = []
     for i in xrange(self.__nb_cond):
         cond_name = self.__cond_name + str(i + 1)
         self.__wrapper_list.append(
             DLLMWrapper(self.__tag + '.' + cond_name))
         if self.__AoA_id_list is not None:
             AoA_id = self.__AoA_id_list[i]
             self.__wrapper_list[i].set_AoA_id(AoA_id)
         self.__wrapper_list[i].set_out_format('list')
         self.__wrapper_list[i].set_grad_format('list')
         self.__wrapper_list[i].configure(self.__list_config_dict[i])
config_dict['cond1.param.BCfilename']='input_parameters.par'
config_dict['cond1.param.airfoil.type']='simple'
config_dict['cond1.param.airfoil.AoA0']=-2.
config_dict['cond1.param.airfoil.Cm0']=-0.1

# DLLM configuration
config_dict['cond1.DLLM.type']='TargetLift'
config_dict['cond1.DLLM.method']='inhouse'
config_dict['cond1.DLLM.F_list_names']=['Drag']
config_dict['cond1.DLLM.relax_factor']=0.99
config_dict['cond1.DLLM.stop_residual']=1e-9
config_dict['cond1.DLLM.max_iterations']=100
config_dict['cond1.DLLM.gamma_file_name']='gamma.dat'
config_dict['cond1.DLLM.target_Lift']=769200.

DLLMcond1=DLLMWrapper('cond1', verbose=0)
DLLMcond1.configure(config_dict)
DLLMcond1.set_out_format('numpy')
DLLMcond1.set_grad_format('numpy')

x0=DLLMcond1.get_x0()
print 'dv array shape',x0.shape
print 'dv_array=',x0

val_grad=FDValidGrad(2,DLLMcond1.run,DLLMcond1.run_grad,fd_step=1.e-8)
ok,df_fd,df=val_grad.compare(x0,treshold=2.e-6,split_out=True,return_all=True)

for j in xrange(len(df[:,0])):
    fid=open('gradient_file'+str(j)+'.dat','w')
    for i in xrange(len(x0)):
        fid.write(str(i)+' '+str(df_fd[j,i])+' '+str(df[j,i])+'\n')
Example #7
0
# Operating condition configuration
config_dict['cond1.OC.Mach']=0.8
config_dict['cond1.OC.AoA']=3.5
config_dict['cond1.OC.altitude']=10000.

# Parameterisation configuration
config_dict['cond1.param.geom_type']='Broken'
config_dict['cond1.param.n_sect']=20
config_dict['cond1.param.BCfilename']='input_parameters.par'
config_dict['cond1.param.airfoil.type']='simple'
config_dict['cond1.param.airfoil.AoA0']=-2.
config_dict['cond1.param.airfoil.Cm0']=-0.1

# DLLM configuration
config_dict['cond1.DLLM.type']='Solver'
config_dict['cond1.DLLM.method']='inhouse'
config_dict['cond1.DLLM.relax_factor']=0.99
config_dict['cond1.DLLM.stop_residual']=1e-9
config_dict['cond1.DLLM.max_iterations']=100
config_dict['cond1.DLLM.gamma_file_name']='gamma.dat'
#config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Pressure','Drag_Friction','Cl', 'Cd', 'Cdp', 'Cdf', 'LoD']
config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Pressure','Drag_Friction','LoD']
#config_dict['cond1.DLLM.target_Cl']=0.5
#config_dict['cond1.DLLM.target_Lift']=769200.

DLLMcond1=DLLMWrapper('cond1')
DLLMcond1.config_from_file('conf_file.json')
DLLMcond1.analysis_and_grad()


Example #8
0
config_dict['cond1.param.desc.tip_height.value'] = 0.33
config_dict['cond1.param.desc.tip_height.bounds'] = (0.2, 0.5)

# DLLM configuration
config_dict['cond1.DLLM.type'] = 'Solver'
config_dict['cond1.DLLM.method'] = 'inhouse'
config_dict['cond1.DLLM.relax_factor'] = 0.99
config_dict['cond1.DLLM.stop_residual'] = 1e-9
config_dict['cond1.DLLM.max_iterations'] = 100
config_dict['cond1.DLLM.gamma_file_name'] = 'gamma.dat'
#config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Pressure','Drag_Friction','Cl', 'Cd', 'Cdp', 'Cdf', 'LoD']
#config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Pressure','Drag_Friction','LoD']
#config_dict['cond1.DLLM.target_Cl']=0.5
#config_dict['cond1.DLLM.target_Lift']=769200.

DLLMcond1 = DLLMWrapper('cond1')
DLLMcond1.configure(config_dict)
DLLMcond1.set_out_format('numpy')
DLLMcond1.set_grad_format('numpy')

x0 = DLLMcond1.get_x0()
print 'dv array shape', x0.shape
print 'dv_array=', x0

val_grad = FDValidGrad(2, DLLMcond1.run, DLLMcond1.run_grad, fd_step=1.e-8)
ok, df_fd, df = val_grad.compare(x0,
                                 treshold=1.e-6,
                                 split_out=True,
                                 return_all=True)

for j in xrange(len(df[:, 0])):
Example #9
0
config_dict['cond1.param.desc.tip_chord.type']='DesignVariable'
config_dict['cond1.param.desc.tip_chord.value']=1.5
config_dict['cond1.param.desc.tip_chord.bounds']=(1.,2.)
config_dict['cond1.param.desc.root_height.type']='DesignVariable'
config_dict['cond1.param.desc.root_height.value']=1.28
config_dict['cond1.param.desc.root_height.bounds']=(1.,1.5)
config_dict['cond1.param.desc.break_height.type']='DesignVariable'
config_dict['cond1.param.desc.break_height.value']=0.97
config_dict['cond1.param.desc.break_height.bounds']=(0.8,1.2)
config_dict['cond1.param.desc.tip_height.type']='DesignVariable'
config_dict['cond1.param.desc.tip_height.value']=0.33
config_dict['cond1.param.desc.tip_height.bounds']=(0.2,0.5)

# DLLM configuration
config_dict['cond1.DLLM.type']='Solver'
config_dict['cond1.DLLM.method']='inhouse'
config_dict['cond1.DLLM.relax_factor']=0.99
config_dict['cond1.DLLM.stop_residual']=1e-9
config_dict['cond1.DLLM.max_iterations']=100
config_dict['cond1.DLLM.gamma_file_name']='gamma.dat'
#config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Pressure','Drag_Friction','Cl', 'Cd', 'Cdp', 'Cdf', 'LoD']
config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Pressure','Drag_Friction','LoD']
#config_dict['cond1.DLLM.target_Cl']=0.5
#config_dict['cond1.DLLM.target_Lift']=769200.

DLLMcond1=DLLMWrapper('cond1')
DLLMcond1.configure(config_dict)
DLLMcond1.analysis_and_grad()


Example #10
0
config_dict['cond1.param.desc.tip_chord.type'] = 'DesignVariable'
config_dict['cond1.param.desc.tip_chord.value'] = 1.5
config_dict['cond1.param.desc.tip_chord.bounds'] = (1., 2.)
config_dict['cond1.param.desc.root_height.type'] = 'DesignVariable'
config_dict['cond1.param.desc.root_height.value'] = 1.28
config_dict['cond1.param.desc.root_height.bounds'] = (1., 1.5)
config_dict['cond1.param.desc.break_height.type'] = 'DesignVariable'
config_dict['cond1.param.desc.break_height.value'] = 0.97
config_dict['cond1.param.desc.break_height.bounds'] = (0.8, 1.2)
config_dict['cond1.param.desc.tip_height.type'] = 'DesignVariable'
config_dict['cond1.param.desc.tip_height.value'] = 0.33
config_dict['cond1.param.desc.tip_height.bounds'] = (0.2, 0.5)

# DLLM configuration
config_dict['cond1.DLLM.type'] = 'Solver'
config_dict['cond1.DLLM.method'] = 'inhouse'
config_dict['cond1.DLLM.relax_factor'] = 0.99
config_dict['cond1.DLLM.stop_residual'] = 1e-9
config_dict['cond1.DLLM.max_iterations'] = 100
config_dict['cond1.DLLM.gamma_file_name'] = 'gamma.dat'
#config_dict['cond1.DLLM.F_list_names']=['Lift','Drag','Drag_Pressure','Drag_Friction','Cl', 'Cd', 'Cdp', 'Cdf', 'LoD']
config_dict['cond1.DLLM.F_list_names'] = [
    'Lift', 'Drag', 'Drag_Pressure', 'Drag_Friction', 'LoD'
]
#config_dict['cond1.DLLM.target_Cl']=0.5
#config_dict['cond1.DLLM.target_Lift']=769200.

DLLMcond1 = DLLMWrapper('cond1')
DLLMcond1.configure(config_dict)
DLLMcond1.analysis_and_grad()
Example #11
0
  def test_DLLM_wrapper_json_valid_grad(self):
      DLLMWrap = DLLMWrapper('test', verbose=0)
      DLLMWrap.config_from_file('conf_file.json')
      DLLMWrap.set_out_format('numpy')
      DLLMWrap.set_grad_format('numpy')
 
      x0=DLLMWrap.get_x0()
       
      DLLMWrap.analysis()
       
      Ref_list=DLLMWrap.get_F_list()
       
      def f(x):
          DLLMWrap.run(x)
          func=DLLMWrap.get_F_list()
          return func/Ref_list
         
      def df(x):
          DLLMWrap.run_grad(x)
          func_grad=np.array(DLLMWrap.get_F_list_grad())
          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_grad=FDValidGrad(2,f,df,fd_step=1.e-8)
      ok,df_fd,df=val_grad.compare(x0,treshold=1.e-5,split_out=True,return_all=True)
      assert(ok)
Example #12
0
 def test_DLLM_wrapper_TLift_valid_grad(self):
     config_dict = self.__get_base_config_dict()
     config_dict['test.DLLM.type']='TargetLift'
     config_dict['test.DLLM.target_Lift']=769200.
     
     DLLMWrap = DLLMWrapper('test', verbose=0)
     DLLMWrap.configure(config_dict)
     DLLMWrap.set_out_format('numpy')
     DLLMWrap.set_grad_format('numpy')
     
     x0=DLLMWrap.get_x0()
      
     DLLMWrap.analysis()
      
     Ref_list=DLLMWrap.get_F_list()
      
     def f(x):
         DLLMWrap.run(x)
         func=DLLMWrap.get_F_list()
         return func/Ref_list
        
     def df(x):
         DLLMWrap.run_grad(x)
         func_grad=np.array(DLLMWrap.get_F_list_grad())
         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_grad=FDValidGrad(2,f,df,fd_step=1.e-8)
     ok,df_fd,df=val_grad.compare(x0,treshold=1.e-5,split_out=True,return_all=True)
     assert(ok)
config_dict['cond1.param.n_sect']=20
config_dict['cond1.param.BCfilename']='input_parameters.par'
config_dict['cond1.param.airfoil.type']='simple'
config_dict['cond1.param.airfoil.AoA0']=-2.
config_dict['cond1.param.airfoil.Cm0']=-0.1

# DLLM configuration
config_dict['cond1.DLLM.type']='TargetCl'
config_dict['cond1.DLLM.method']='inhouse'
config_dict['cond1.DLLM.relax_factor']=0.99
config_dict['cond1.DLLM.stop_residual']=1e-9
config_dict['cond1.DLLM.max_iterations']=100
config_dict['cond1.DLLM.gamma_file_name']='gamma.dat'
config_dict['cond1.DLLM.target_Cl']=0.5

DLLMcond1=DLLMWrapper('cond1', verbose=0)
DLLMcond1.configure(config_dict)
DLLMcond1.set_out_format('numpy')
DLLMcond1.set_grad_format('numpy')

x0=DLLMcond1.get_x0()
print 'dv array shape',x0.shape
print 'dv_array=',x0

val_grad=FDValidGrad(2,DLLMcond1.run,DLLMcond1.run_grad,fd_step=1.e-8)
ok,df_fd,df=val_grad.compare(x0,treshold=1.e-6,split_out=True,return_all=True)

for j in xrange(len(df[:,0])):
    fid=open('gradient_file'+str(j)+'.dat','w')
    for i in xrange(len(x0)):
        fid.write(str(i)+' '+str(df_fd[j,i])+' '+str(df[j,i])+'\n')