sol = cal_obj.run_optimisation(cal_obj.cost, bounds) print("") sys_mod.get_parameter_summary( print_addition="learnt parameters for model from healthy data") sys_mod.plot_model_vs_measured(measurements_d0, plot_title_addition="healthy") # # Get measured data for unhealthy condition (same operating conditions and noise a healthy) z_real_d1 = sys_real_d1.simulate(c, noise=noise, plot=True) plt.title("Measured data at damaged condition") plt.ylabel("Acceleration of mass 1") plt.savefig("..\\reports\\damaged_measured_1DOF_for_2DOF_all_param2.png") plt.show() # Infer the degree of damage x from the damaged data measurements_d1 = {"c": c, "z": z_real_d1} inf_obj = sys_model.DamageInference( sys_mod, measurements_d1) # sys_mod is updated with most likely # parameters since we ran the callibration above bounds = ((0, 100), ) x_pred = inf_obj.run_optimisation(inf_obj.cost, bounds) print("") print("Actual damaged health state: ", sys_real_d1.g.x) print("Inferred damaged health state: ", x_pred["x"]) # Compare the measured damaged state with model fit sys_mod.plot_model_vs_measured(measurements_d1)
# define real physics-based model at damage state g_real_d1 = g_maps.Chen2011(theta_real, x_real_d1) # define system sys_real_d1 = sys_model.System(g_real_d1, h_real) # Notice that transfer function is independent of damage # # Get measured data for unhealthy condition (same operating conditions and noise a healthy) z_real_d1 = sys_real_d1.simulate(c, noise=noise, plot=False) # # Infer the degree of damage x from the damaged data measurements_d1 = {"c":c, "z":z_real_d1} sys_mod = cal_obj.sys # Use the calibrated healthy object cal_obj_for_damaged = sys_model.DamageInference(sys_mod, measurements_d1) # sys_mod is updated with most likely # parameters since we ran the callibration above bounds =((0.1, 0.5),) #x_pred = cal_obj_for_damaged.run_optimisation(cal_obj_for_damaged.cost, bounds, startpoint=np.array([0.15e8])) x_pred = cal_obj_for_damaged.run_optimisation(bounds, startpoint=np.array([0.15])) print("Actual health state: ", sys_real_d1.g.x) print("Predicted health state: ", x_pred["x"]) print("") with open("mod_damage_inferred_20201101" + str(np.round(damage,2)) + ".pkl", "wb") as fname: pickle.dump(cal_obj_for_damaged, fname) print((time.time() - t_start)/60," min runtime") # #Compare the measured damaged state with model fit # try:
x_mod = np.array([1]) h_mod = h_maps.BasicConceptValidationH(phi_mod) g_mod = g_maps.BasicConceptValidationG(theta_mod, x_mod) sys_mod = sys_model.System(g_mod, h_mod) # Define the operating conditions under which the data is gathered c = [np.array([i]) for i in range(10)] # Get the measured data under healthy conditions noise = {"sd": 0.1} z_real_d0 = sys_real_d0.simulate(c, noise=noise, plot=True) # Solve for the most likely model parameters given the healthy measurements (fit sys_mod to data) measurements_d0 = {"c": c, "z": z_real_d0} cal_obj = sys_model.Calibration(sys_mod, measurements_d0) start_point = np.ones(2) * 2 cal_obj.run_optimisation(start_point) # Get measured data for unhealthy condition (same operating conditions and noise a healthy) z_real_d1 = sys_real_d1.simulate(c, noise=noise) # Infer the damage from the damaged data measurements_d1 = {"c": c, "z": z_real_d1} cal_obj = sys_model.DamageInference( sys_mod, measurements_d1 ) # sys_mod would now be updated with most likely parameters start_point = np.ones(1) x_pred = cal_obj.run_optimisation(start_point) print(x_pred)