specimen.dk_Manual)) ''' 数据保存 ''' if filesave: for specimen in specimen_data: data = np.array([ specimen.n_Manual, specimen.a_Manual, specimen.dk_Manual, specimen.dadn_Manual, specimen.kc_Manual ]) name = [ "Original_Cycles", "Original_CrackLength/mm", "Original_SIFRange/MPam0.5", "Original_FCGRate/mm per cycle", "Original_ClosureSIF/MPam0.5" ] _ = write_data.SaveData(dataset=data, name=name, filename=specimen.name) ''' 绘图命令 ''' # 评估移动平均对dadN的修正效果 plt.figure(num=1, figsize=(10, 8)) for specimen in specimen_data: plt.scatter(specimen.dk_Manual, specimen.dadn_Manual, label=specimen.name, marker='.') plt.plot(specimen.dk_Manual, specimen.dadn_Manual) #plt.scatter(specimen.dk_MTS, specimen.dadn_MTS, label='$ExperimentDataByMTS$', color='orange', marker='.') plt.plot(specimen.dk_Manual, dadn_paris_Manual, label='$Paris for CA$',
dadn_alpha_e, label='$CrackClosure Alpha Method$', marker='2') plt.plot(dk_alpha_e, dadn_mixed_1, label='Mix Try 1', color='red', linewidth=2) plt.title("FCG Rates - deltaK(Wheeler Model),OLR=" + str(specimen.overload / specimen.maxload)) plt.ylabel("FCG Rates/mm per cycle") plt.xlabel("DeltaSIF/MPa.m0.5") plt.xscale('log') plt.yscale('log') plt.axis([ max(10, min(specimen.dk)), max(20, max(specimen.dk)), min(specimen.dadn) * 0.9, max(specimen.dadn) * 1.1 ]) plt.grid(which='minor', linestyle='--') plt.grid(which='major', linestyle='--') plt.legend() if show: plt.show() if savedata: data = np.array([specimen.dk, specimen.dadn, dk_alpha_e, dadn_mixed_1]) name = [ 'dk_experiment', 'dadn_experiment', 'dk_ModifiedAlpha', 'dadn_ModifiedAlpha' ] _ = write_data.SaveData(dataset=data, name=name, filename=specimen.name + "_modified_wheeler_alpha")
def WheelerFittingBaseParis2(a, dadn, dk, rm, aol, rol, c, m, eta=0, savedata=0): # usage: 由高载为起始点的数据,以Paris公式为基础裂纹扩展速率模型进行Wheeler模型拟合 # NOTE:数据的起始点必须是高载后! # input parameter: # a, dadn, dk, rm:FCG基础数据及对应时刻的塑性区尺寸rm # aol,rol:高载时刻的裂纹长度aol和塑形区尺寸rol # c,m:基础Paris公式参数 # eta:裂纹长度修正,相当于延长裂纹的长度(即等效裂纹概念),作用于Wheeler系数的分母,默认不修正 # return parameter: # m1:Wheeler迟滞指数 left = a + rm + eta right = aol + rol print(aol, rol) if left[-1] < right: dadn_fitting = dadn dk_fitting = dk a_fitting = a rm_fitting = rm print("Wheeler Region Check: Fitting Region:dk_start=" + str(dk_fitting[0]) + ",to the END.") elif left[0] >= right: print( "ERRORFromWheelerFittingBaseParis2:No Wheeler Region, Check Input Parameter!" ) else: for seq, _ in enumerate(left): if left[seq] >= right: dadn_fitting = dadn[0:seq] dk_fitting = dk[0:seq] a_fitting = a[0:seq] rm_fitting = rm[0:seq] print("Wheeler Region Check: Fitting Region:dk_start=" + str(dk_fitting[0]) + ",dk_final=" + str(dk_fitting[-1])) break # 根据Wheeler公式筛选迟滞参数适用区域(确定拟合采用的数据) X = [] Y = [] for seq, _ in enumerate(dadn_fitting): y = np.log(dadn_fitting[seq]) - m * np.log(dk_fitting[seq]) - np.log(c) Y.append(y) x = np.log(rm_fitting[seq]) - np.log(aol + rol - a_fitting[seq] - eta) X.append(x) X = np.array(X).reshape(-1, ) Y = np.array(Y) def residual_m_wheeler(p): m_wheeler = p return Y - m_wheeler * X k = opt.leastsq(residual_m_wheeler, np.array([1])) m1 = k[0] print("Wheeler Model Fitting Result: m1=", m1) # Wheeler模型 m1系数拟合 ''' 绘图显示拟合效果 ''' plt.figure(num=3, figsize=(8, 6)) plt.scatter(X, Y, label='Data') plt.plot(X, m1 * X, label='Fitting') plt.scatter(0, 0) plt.xlabel('log(dadn(OL)) - log(dadn(CA))') plt.ylabel('log(r,i)-log(a_OL + r_OL - a,i)') plt.legend() ''' 绘图数据输出 ''' if savedata: data = np.array([X, Y, m1 * X]) name = ['X', 'Y(experiment data)', 'fitting curve(m1*X)'] _ = write_data.SaveData(dataset=data, name=name) return m1
max(dadn_Manual), 6)) plt.xticks(np.linspace(min(dk_Manual) * 0.9, max(dk_Manual), 6)) plt.title("FCG Rates - Delta SIF_" + sequence) plt.ylabel("FCG Rates/ mm per cycle") plt.xlabel("DeltaK/ MPa.m0.5") plt.xscale('log') plt.yscale('log') plt.legend() plt.grid(which='minor', linestyle='--') plt.grid(which='major', linestyle='--') # 显示图像 if show: plt.show() ''' 文件输出 ''' if datasave: data = np.array([ dk_Manual, dadn_Manual, dk_selected_averaged2, dadn_alpha_e, dk_Manual_averaged1_selected, dadn_paris_dkeff_bac_selected, a_Manual_averaged1, dk_Manual_averaged0_selected, dadn_paris_dkeff_2pi_selected, a_Manual_averaged0, dk_Manual, dadn_paris_Manual ]) name = [ 'dK_exp', 'dadn_exp', 'dk_alpha', 'dadn_alpha', 'dk_bac', 'dadn_bac', 'a_bac', 'dk_2pi', 'dadn_2pi', 'a_2pi', 'dk_CA', 'dadn_CA' ] _ = write_data.SaveData(dataset=data, name=name)
label='Modified Wheeler-Alpha Model', color='red', linewidth=2) plt.title("FCG Rates - deltaK(Modified Wheeler-Alpha Model),Data:" + specimen.name) plt.ylabel("FCG Rates/mm per cycle") plt.xlabel("DeltaSIF/MPa.m0.5") plt.xscale('log') plt.yscale('log') plt.axis([ max(10, min(specimen.dk)), max(20, max(specimen.dk)), min(specimen.dadn) * 0.9, max(specimen.dadn) * 1.1 ]) plt.grid(which='minor', linestyle='--') plt.grid(which='major', linestyle='--') plt.legend() if show: plt.show() if savedata: data = np.array([specimen.dk, specimen.dadn, dk_alpha_e, dadn_mixed_1]) name = [ 'dk_experiment', 'dadn_experiment', 'dk_ModifiedAlpha', 'dadn_ModifiedAlpha' ] _ = write_data.SaveData(dataset=data, name=name, filename=sequence + "_modified_wheeler_alpha")