def test_deterministic_model(self): # Check if the quantity of interest is being computed as expected rv_dict = { 'Mach_number': { 'mean': mean_Ma, 'std_dev': std_dev_Ma }, 'CT': { 'mean': mean_TSFC, 'std_dev': std_dev_TSFC }, 'W0': { 'mean': mean_W0, 'std_dev': std_dev_W0 }, 'R': { 'mean': mean_R, 'std_dev': std_dev_R }, 'load_factor': { 'mean': mean_load_factor, 'std_dev': std_dev_load_factor }, 'E': { 'mean': mean_E, 'std_dev': std_dev_E }, 'G': { 'mean': mean_G, 'std_dev': std_dev_G }, 'mrho': { 'mean': mean_mrho, 'std_dev': std_dev_mrho }, } uq_systemsize = len(rv_dict) mu_orig, std_dev = utils.get_scaneagle_input_rv_statistics(rv_dict) jdist = cp.MvNormal(mu_orig, std_dev) input_dict = { 'n_twist_cp': 3, 'n_thickness_cp': 3, 'n_CM': 3, 'n_thickness_intersects': 10, 'n_constraints': 1 + 10 + 1 + 3 + 3, 'ndv': 3 + 3 + 2, 'mesh_dict': mesh_dict, 'rv_dict': rv_dict } QoI = examples.oas_scaneagle2.OASScanEagleWrapper2( uq_systemsize, input_dict) # Check if plugging back value also yields the expected results QoI.p['oas_scaneagle.wing.thickness_cp'] = np.array( [0.008, 0.008, 0.008]) QoI.p['oas_scaneagle.wing.twist_cp'] = np.array([2.5, 2.5, 5.]) # 2.5*np.ones(3) QoI.p['oas_scaneagle.wing.sweep'] = 20.0 QoI.p['oas_scaneagle.alpha'] = 5.0 # Check the value at the starting point fval = QoI.eval_QoI(mu_orig, np.zeros(uq_systemsize)) true_val = 5.2059024220429615 err = abs(fval - true_val) self.assertTrue(err < 1.e-6)
def test_selective_rv(self): rv_dict = { 'Mach_number': { 'mean': mean_Ma, 'std_dev': std_dev_Ma }, 'CT': { 'mean': mean_TSFC, 'std_dev': std_dev_TSFC }, 'W0': { 'mean': mean_W0, 'std_dev': std_dev_W0 }, 'R': { 'mean': mean_R, 'std_dev': std_dev_R }, 'load_factor': { 'mean': mean_load_factor, 'std_dev': std_dev_load_factor }, # 'E' : {'mean' : mean_E, # 'std_dev' : std_dev_E}, # 'G' : {'mean' : mean_G, # 'std_dev' : std_dev_G}, 'mrho': { 'mean': mean_mrho, 'std_dev': std_dev_mrho }, 'altitude': { 'mean': mean_altitude, 'std_dev': std_dev_altitude }, } input_dict = { 'n_twist_cp': 3, 'n_thickness_cp': 3, 'n_CM': 3, 'n_thickness_intersects': 10, 'n_constraints': 1 + 10 + 1 + 3 + 3, 'ndv': 3 + 3 + 2, 'mesh_dict': mesh_dict, 'rv_dict': rv_dict } uq_systemsize = len(rv_dict) mu, std_dev = utils.get_scaneagle_input_rv_statistics(rv_dict) jdist = cp.MvNormal(mu, std_dev) QoI = examples.oas_scaneagle2.OASScanEagleWrapper2( uq_systemsize, input_dict) mu_pert = mu + np.diagonal(std_dev) QoI.update_rv(mu_pert) QoI.p.final_setup() self.assertEqual(mu_pert[0], QoI.p['Mach_number']) self.assertEqual(mu_pert[1], QoI.p['CT']) self.assertEqual(mu_pert[2], QoI.p['W0']) self.assertEqual(mu_pert[3], QoI.p['R']) self.assertEqual(mu_pert[4], QoI.p['load_factor']) self.assertEqual(mu_pert[5], QoI.p['mrho']) self.assertEqual(mu_pert[6], QoI.p['altitude'])
'altitude' : {'mean' : mean_altitude, 'std_dev' : std_dev_altitude}, } dv_dict = {'n_twist_cp' : 3, 'n_thickness_cp' : 3, 'n_CM' : 3, 'n_thickness_intersects' : 10, 'n_constraints' : 1 + 10 + 1 + 3 + 3, 'ndv' : 3 + 3 + 2, 'mesh_dict' : mesh_dict, 'rv_dict' : rv_dict } mu, std_dev = utils.get_scaneagle_input_rv_statistics(rv_dict) uq_systemsize = len(mu) jdist = cp.MvNormal(mu, std_dev) QoI = examples.oas_scaneagle2.OASScanEagleWrapper2(uq_systemsize, dv_dict) # Set the design variable dict_val = 'sc_init' design_point = optimal_vals_dict.sc_sol_dict[dict_val] QoI.p['oas_scaneagle.wing.thickness_cp'] = design_point['thickness_cp'] QoI.p['oas_scaneagle.wing.twist_cp'] = design_point['twist_cp'] QoI.p['oas_scaneagle.wing.sweep'] = design_point['sweep'] QoI.p['oas_scaneagle.alpha'] = design_point['alpha'] QoI.p.final_setup()
def test_dfuelburn_drv(self): rv_dict = { 'Mach_number': { 'mean': mean_Ma, 'std_dev': std_dev_Ma }, 'CT': { 'mean': mean_TSFC, 'std_dev': std_dev_TSFC }, 'W0': { 'mean': mean_W0, 'std_dev': std_dev_W0 }, 'R': { 'mean': mean_R, 'std_dev': std_dev_R }, 'load_factor': { 'mean': mean_load_factor, 'std_dev': std_dev_load_factor }, 'E': { 'mean': mean_E, 'std_dev': std_dev_E }, 'G': { 'mean': mean_G, 'std_dev': std_dev_G }, 'mrho': { 'mean': mean_mrho, 'std_dev': std_dev_mrho }, } uq_systemsize = len(rv_dict) mu_orig, std_dev = utils.get_scaneagle_input_rv_statistics(rv_dict) jdist = cp.MvNormal(mu_orig, std_dev) input_dict = { 'n_twist_cp': 3, 'n_thickness_cp': 3, 'n_CM': 3, 'n_thickness_intersects': 10, 'n_constraints': 1 + 10 + 1 + 3 + 3, 'ndv': 3 + 3 + 2, 'mesh_dict': mesh_dict, 'rv_dict': rv_dict } QoI = examples.oas_scaneagle2.OASScanEagleWrapper2( uq_systemsize, input_dict) dJdrv = QoI.eval_QoIGradient(mu_orig, np.zeros(uq_systemsize)) true_val = np.array([ -86.161737972785, 20.460428652057, 0.439735298404, 0.003451150117, 6.014451860042, -0.000000000001, -0., 0.879771028302 ]) err = abs(dJdrv - true_val) / true_val self.assertTrue((err < 1.e-6).all())
def get_input_rv_statistics(self, rv_dict): mu, std_dev = utils.get_scaneagle_input_rv_statistics(rv_dict) return mu, std_dev