def test_DLLM_MP_AoA_valid_grad(self): config_dict = self.__get_base_config_dict() config_dict['Case.AoA_id_list']=['AoA1','AoA2','AoA3'] config_dict['Case.param.BCfilename']='input_parameters_AoA.par' MP=DLLMMP('Case') MP.configure(config_dict) MP.set_out_format('numpy') MP.set_grad_format('numpy') x0=MP.get_x0() Ref_list=MP.analysis() def f(x): func=MP.run(x) return func/Ref_list def df(x): func_grad=MP.run_grad(x) 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)
# cond3 Operating condition information config_dict['Case.cond3.OC.Mach']=0.4 config_dict['Case.cond3.OC.AoA']=6. config_dict['Case.cond3.OC.altitude']=1000. # Parameterisation configuration config_dict['Case.param.geom_type']='Broken' config_dict['Case.param.n_sect']=20 config_dict['Case.param.BCfilename']='input_parameters.par' config_dict['Case.param.airfoil.type']='simple' config_dict['Case.param.airfoil.AoA0']=-2. config_dict['Case.param.airfoil.Cm0']=-0.1 # DLLM configuration config_dict['Case.DLLM.type']='Solver' config_dict['Case.DLLM.method']='inhouse' config_dict['Case.DLLM.relax_factor']=0.99 config_dict['Case.DLLM.stop_residual']=1e-9 config_dict['Case.DLLM.max_iterations']=100 config_dict['Case.cond1.DLLM.gamma_file_name']='cond1_gamma.dat' config_dict['Case.cond2.DLLM.gamma_file_name']='cond2_gamma.dat' config_dict['Case.cond3.DLLM.gamma_file_name']='cond3_gamma.dat' list_log=glob('*.log') for log in list_log: os.remove(log) MP=DLLMMP('Case') MP.configure(config_dict) MP.analysis()
config_dict['Case.param.desc.AoA3.value']=0. config_dict['Case.param.desc.AoA3.bounds']=(-20.,+20.) config_dict['Case.DLLM.type']='Solver' config_dict['Case.DLLM.method']='inhouse' config_dict['Case.DLLM.relax_factor']=0.99 config_dict['Case.DLLM.stop_residual']=1e-9 config_dict['Case.DLLM.max_iterations']=100 list_log=glob('*.log') for log in list_log: os.remove(log) MP=DLLMMP('Case') MP.configure(config_dict) MP.analysis() # # Parameterisation configuration # # # 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