# Contents of /trunk/models/johnpye/fprops/python/solve_ph_array.py

Revision 2266 - (show annotations) (download) (as text)
Thu Aug 5 13:53:01 2010 UTC (13 years, 10 months ago) by jpye
File MIME type: text/x-python
File size: 1148 byte(s)
```The (p,h) function is converging almost everywhere. The home-made Newton iteration wasn't starting well for supercritical states
when the starting guess had rho = rho_c, so changing slightly away from fixed almost all the problems.
```
 1 from fprops import * 2 from pylab import * 3 4 D = helmholtz_data_water; 5 6 TT = linspace(273.16, 1000, 100); 7 rr = logspace(log10(0.01), log10(900), 100); 8 9 goodT = [] 10 goodv = [] 11 badT = [] 12 badv = [] 13 14 for T in TT: 15 for rho in rr: 16 print "+++ T = %f, rho = %f" % (T,rho) 17 p = helmholtz_p(T,rho,D) 18 h = helmholtz_h(T,rho,D) 19 print " p = %f bar, h = %f kJ/kg" % (p/1e5,h/1e3) 20 if(h > 8000e3): 21 continue 22 23 res, T1, rho1 = fprops_solve_ph(p,h,0,D); 24 if res: 25 print " +++ BAD RESULT T1 = %f, rho1 = %f" % (T1, rho1) 26 if not isnan(T) and not isnan(rho): 27 badT.append(T); badv.append(1./rho) 28 else: 29 if not isnan(T) and not isnan(rho): 30 goodT.append(T); goodv.append(1./rho) 31 print " +++ GOOD RESULT T1 = %f, rho1 = %f" % (T1, rho1) 32 33 figure() 34 print badT 35 semilogx(badv, badT, 'rx') 36 hold(1) 37 semilogx(goodv, goodT, 'g.') 38 39 # plot saturation curves 40 TT = linspace(D.T_t, D.T_c, 100) 41 TT1 = [] 42 vf1 = [] 43 vg1 = [] 44 for T in TT: 45 res, p, rhof, rhog = fprops_sat_T(T,D) 46 if not res: 47 TT1.append(T) 48 vf1.append(1./rhof) 49 vg1.append(1./rhog) 50 51 semilogx(vf1,TT1,"b-") 52 semilogx(vg1,TT1,"b-") 53 xlabel("specific volume") 54 ylabel("temperature") 55 56 show() 57

 john.pye@anu.edu.au ViewVC Help Powered by ViewVC 1.1.22