def test_values_compare(self): uq_systemsize = 6 mu_orig = np.array( [mean_Ma, mean_TSFC, mean_W0, mean_E, mean_G, mean_mrho]) rv_dict = { 'Mach_number': mean_Ma, 'CT': mean_TSFC, 'W0': mean_W0, 'E': mean_E, # surface RV 'G': mean_G, # surface RV 'mrho': mean_mrho, # surface RV } 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.OASScanEagleWrapper(uq_systemsize, input_dict, include_dict_rv=True) fuel_burn_val = QoI.eval_QoI(mu_orig, np.zeros(uq_systemsize)) ks_val = QoI.p['oas_scaneagle.AS_point_0.wing_perf.failure'] print() print('fuel burn val = ', fuel_burn_val[0]) print('ks_val = ', ks_val[0])
def test_deterministic_model(self): # Check if the quantity of interest is being computed as expected uq_systemsize = 6 mu_orig = np.array( [mean_Ma, mean_TSFC, mean_W0, mean_E, mean_G, mean_mrho]) std_dev = np.diag([0.005, 0.00607 / 3600, 0.2, 5.e9, 1.e9, 50]) jdist = cp.MvNormal(mu_orig, std_dev) rv_dict = { 'Mach_number': mean_Ma, 'CT': mean_TSFC, 'W0': mean_W0, 'E': mean_E, # surface RV 'G': mean_G, # surface RV 'mrho': mean_mrho, # surface RV } 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.OASScanEagleWrapper(uq_systemsize, input_dict, include_dict_rv=True) # Check the value at the starting point fval = QoI.eval_QoI(mu_orig, np.zeros(uq_systemsize)) true_val = 5.229858093218218 err = abs(fval - true_val) self.assertTrue(err < 1.e-6) # Check if plugging back value also yields the expected results QoI.p['oas_scaneagle.wing.twist_cp'] = np.array([2.60830137, 10., 5.]) QoI.p['oas_scaneagle.wing.thickness_cp'] = np.array( [0.001, 0.001, 0.001]) QoI.p['oas_scaneagle.wing.sweep'] = [18.89098985] QoI.p['oas_scaneagle.alpha'] = [2.19244059] fval = QoI.eval_QoI(mu_orig, np.zeros(uq_systemsize)) true_val = 4.735819672292367 err = abs(fval - true_val) self.assertTrue(err < 1.e-6)
def test_variable_update(self): uq_systemsize = 6 mu_orig = np.array( [mean_Ma, mean_TSFC, mean_W0, mean_E, mean_G, mean_mrho]) std_dev = np.diag([0.005, 0.00607 / 3600, 0.2, 5.e9, 1.e9, 50]) jdist = cp.MvNormal(mu_orig, std_dev) rv_dict = { 'Mach_number': mean_Ma, 'CT': mean_TSFC, 'W0': mean_W0, 'E': mean_E, # surface RV 'G': mean_G, # surface RV 'mrho': mean_mrho, # surface RV } 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.OASScanEagleWrapper(uq_systemsize, input_dict, include_dict_rv=True) mu_pert = mu_orig + 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['E']) self.assertEqual(mu_pert[4], QoI.p['G']) self.assertEqual(mu_pert[5], QoI.p['mrho'])
def test_dfuelburn_drv(self): uq_systemsize = 6 mu_orig = np.array( [mean_Ma, mean_TSFC, mean_W0, mean_E, mean_G, mean_mrho]) std_dev = np.diag([0.005, 0.00607 / 3600, 0.2, 5.e9, 1.e9, 50]) jdist = cp.MvNormal(mu_orig, std_dev) rv_dict = { 'Mach_number': mean_Ma, 'CT': mean_TSFC, 'W0': mean_W0, 'E': mean_E, # surface RV 'G': mean_G, # surface RV 'mrho': mean_mrho, # surface RV } 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.OASScanEagleWrapper(uq_systemsize, input_dict, include_dict_rv=True) dJdrv = QoI.eval_QoIGradient(mu_orig, np.zeros(uq_systemsize)) true_val = np.array([ -83.76493292024509, 74045.31234313066, 0.44175879007053753, -7.34403789212763e-13, -2.527193348815028e-13, 0.8838194148741767 ]) err = abs(dJdrv - true_val) / true_val self.assertTrue((err < 1.e-6).all())
def __init__(self, uq_systemsize, all_rv=False): # Total number of nodes to use in the spanwise (num_y) and # chordwise (num_x) directions. Vary these to change the level of fidelity. num_y = 21 num_x = 3 mesh_dict = { 'num_y': num_y, 'num_x': num_x, 'wing_type': 'rect', 'symmetry': True, 'span_cos_spacing': 0.5, 'span': 3.11, 'root_chord': 0.3, } rv_dict = { 'Mach_number': mean_Ma, 'CT': mean_TSFC, 'W0': mean_W0, 'E': mean_E, # surface RV 'G': mean_G, # surface RV 'mrho': mean_mrho, # surface RV } 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 } self.jdist = cp.MvNormal(mu, std_dev) self.QoI = examples.OASScanEagleWrapper(uq_systemsize, dv_dict, include_dict_rv=all_rv) dfuelburn_dict = { 'dv': { 'dQoI_func': self.QoI.eval_ObjGradient_dv, 'output_dimensions': dv_dict['ndv'], } } dcon_dict = { 'dv': { 'dQoI_func': self.QoI.eval_ConGradient_dv, 'output_dimensions': dv_dict['ndv'] } } dcon_failure_dict = { 'dv': { 'dQoI_func': self.QoI.eval_ConFailureGradient_dv, 'output_dimensions': dv_dict['ndv'], } } self.QoI_dict = { 'fuelburn': { 'QoI_func': self.QoI.eval_QoI, 'output_dimensions': 1, 'deriv_dict': dfuelburn_dict }, # 'constraints' : {'QoI_func' : self.QoI.eval_AllConstraintQoI, # 'output_dimensions' : dv_dict['n_constraints'], # 'deriv_dict' : dcon_dict # }, # 'con_failure' : {'QoI_func' : self.QoI.eval_confailureQoI, # 'output_dimensions' : 1, # 'deriv_dict' : dcon_failure_dict # } }
def __init__(self, uq_systemsize, all_rv=False): # Default values mean_Ma = 0.071 mean_TSFC = 9.80665 * 8.6e-6 mean_W0 = 10.0 mean_E = 85.e9 mean_G = 25.e9 mean_mrho = 1600 # Total number of nodes to use in the spanwise (num_y) and # chordwise (num_x) directions. Vary these to change the level of fidelity. num_y = 21 num_x = 3 mesh_dict = { 'num_y': num_y, 'num_x': num_x, 'wing_type': 'rect', 'symmetry': True, 'span_cos_spacing': 0.5, 'span': 3.11, 'root_chord': 0.3, } rv_dict = { 'Mach_number': mean_Ma, 'CT': mean_TSFC, 'W0': mean_W0, 'E': mean_E, # surface RV 'G': mean_G, # surface RV 'mrho': mean_mrho, # surface RV } 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 = np.array([mean_Ma, mean_TSFC, mean_W0, mean_E, mean_G, mean_mrho]) std_dev = np.diag([0.005, 0.00607 / 3600, 0.2, 5.e9, 1.e9, 50]) self.jdist = cp.MvNormal(mu, std_dev) self.QoI = examples.OASScanEagleWrapper(uq_systemsize, dv_dict, include_dict_rv=all_rv) self.QoI.p['oas_scaneagle.wing.thickness_cp'] = 1.e-3 * np.array([ 5.5, 5.5, 5.5 ]) # This setup is according to the one in the scaneagle paper self.QoI.p['oas_scaneagle.wing.twist_cp'] = 2.5 * np.ones(3) self.QoI.p.final_setup() # self.dominant_space = DimensionReduction(n_arnoldi_sample=uq_systemsize+1, # exact_Hessian=False) # self.dominant_space.getDominantDirections(self.QoI, self.jdist, max_eigenmodes=1) dfuelburn_dict = { 'dv': { 'dQoI_func': self.QoI.eval_ObjGradient_dv, 'output_dimensions': dv_dict['ndv'], } } dcon_dict = { 'dv': { 'dQoI_func': self.QoI.eval_ConGradient_dv, 'output_dimensions': dv_dict['ndv'] } } dcon_failure_dict = { 'dv': { 'dQoI_func': self.QoI.eval_ConFailureGradient_dv, 'output_dimensions': dv_dict['ndv'], } } self.QoI_dict = { 'fuelburn': { 'QoI_func': self.QoI.eval_QoI, 'output_dimensions': 1, 'deriv_dict': dfuelburn_dict }, 'constraints': { 'QoI_func': self.QoI.eval_AllConstraintQoI, 'output_dimensions': dv_dict['n_constraints'], 'deriv_dict': dcon_dict }, 'con_failure': { 'QoI_func': self.QoI.eval_confailureQoI, 'output_dimensions': 1, 'deriv_dict': dcon_failure_dict } }
'mrho': mean_mrho, # surface RV } 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 } QoI = examples.OASScanEagleWrapper(uq_systemsize, dv_dict, include_dict_rv=True) QoI.p['oas_scaneagle.wing.thickness_cp'] = 1.e-3 * np.array([ 5.5, 5.5, 5.5 ]) # This setup is according to the one in the scaneagle paper QoI.p['oas_scaneagle.wing.twist_cp'] = 2.5 * np.ones(3) QoI.p.final_setup() print("twist = ", QoI.p['oas_scaneagle.wing.geometry.twist']) print("thickness =", QoI.p['oas_scaneagle.wing.thickness']) print("sweep = ", QoI.p['oas_scaneagle.wing.sweep']) print("aoa = ", QoI.p['oas_scaneagle.alpha']) print() """ # Dictionary for the collocation object QoI_dict = {'fuelburn' : {'QoI_func' : QoI.eval_QoI,