def fit_phi(): mod = Model(OBJECTIVE_phi) mydata = Data(XXX.copy(), PHI) beta0 = [100 for _ in range(N)] myodr = ODR(mydata, mod, beta0=beta0) myoutput = myodr.run() myoutput.pprint() print myoutput.sum_square YFIT = OBJECTIVE_theta(myoutput.beta,XXX) plt.plot(PHI,YFIT,'o',mfc='none') plt.show() ERR = YFIT-PHI from CoolProp.Plots.Plots import Trho Trho(fluid) plt.plot(np.array(RHO.vec)[np.abs(ERR)<5e-2],np.array(TTT.vec)[np.abs(ERR)<5e-2],'.') MAE = np.mean(np.abs(YFIT/PHI-1))*100 plt.show() return myoutput.beta,MAE
except ValueError: print('TTSE failed: %s %s' % (T, rho)) values.append((T, rho, 0, 0)) pass return values fluid = 'R245fa' values = check_Trho(param='P', fluid=fluid) if len(values) == 0: print('good') T, rho, values_withTTSE, values_noTTSE = zip(*values) CP.disable_TTSE_LUT(fluid) Trho(fluid) plt.plot(rho, T, '.', mfc='none') plt.savefig('Trho_TTSE_Validation.png', dpi=300) plt.gca().set_xscale('log') plt.show() quit() def check_Pother(N=5000, param='T', other='S', fluid='R245fa'): values = [] CP.enable_TTSE_LUT(fluid) try: CP.Props('D', 'P', CP.Props(fluid, 'ptriple') + 1, 'Q', 1, fluid) except: