/[ascend]/trunk/models/johnpye/fprops/water.c
ViewVC logotype

Diff of /trunk/models/johnpye/fprops/water.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1995 by jpye, Wed Feb 4 03:52:36 2009 UTC revision 1996 by jpye, Thu Feb 5 09:42:42 2009 UTC
# Line 53  http://www.iapws.org/relguide/IAPWS95.pd Line 53  http://www.iapws.org/relguide/IAPWS95.pd
53  */  */
54  const HelmholtzData helmholtz_data_water = {  const HelmholtzData helmholtz_data_water = {
55      /* R */ WATER_R /* J/kg/K */      /* R */ WATER_R /* J/kg/K */
56      , /* M */ 0.00000000000000 /* kg/kmol  -- need to look up value cited by IAPWS */      , /* M */ 18.015242 /* kg/kmol -- G S Kell, J Phys Chem Ref Data (6) 1109 (1977) */
57      , /* rho_star */322. /* kg/m³ */      , /* rho_star */322. /* kg/m³ */
58      , /* T_star */ WATER_TSTAR /* K */      , /* T_star */ WATER_TSTAR /* K */
59        , 0.344 /* acentric factor, source: Reid, Prausnitz & Polling */
60      , &ideal_data_water      , &ideal_data_water
61      , 51 /* np */      , 51 /* np */
62      , (const HelmholtzPowTerm[]){      , (const HelmholtzPowTerm[]){
# Line 183  double phi0(const double delta, const do Line 184  double phi0(const double delta, const do
184  typedef struct{double T, rho, p, cv, w, s;} TestDataIAPWS95;  typedef struct{double T, rho, p, cv, w, s;} TestDataIAPWS95;
185  const TestDataIAPWS95 td[]; const unsigned ntd;  const TestDataIAPWS95 td[]; const unsigned ntd;
186    
187    typedef struct{double T, p, rho_f, rho_g, h_f, h_g, s_f, s_g;} TestDataSat;
188    const TestDataSat tds[]; const unsigned ntds;
189    
190  int main(void){  int main(void){
191      double rho, T;      double rho, T;
192      const HelmholtzData *d;      const HelmholtzData *d;
# Line 199  int main(void){ Line 203  int main(void){
203          if(fabs(relerrpc)>maxerr)maxerr=fabs(relerrpc);\          if(fabs(relerrpc)>maxerr)maxerr=fabs(relerrpc);\
204          if(fabs(err)>fabs(TOL)){\          if(fabs(err)>fabs(TOL)){\
205              fprintf(stderr,"ERROR in line %d: value of '%s(%f,%f,%s)' = %0.8f,"\              fprintf(stderr,"ERROR in line %d: value of '%s(%f,%f,%s)' = %0.8f,"\
206                  " should be %f, error is %.10e (%.2f%%)!\n"\                  " should be %f, error is %.10e (%.7f%%)!\n"\
207                  , __LINE__, #FN,PARAM1,PARAM2,#PARAM3, cval, VAL,cval-(VAL)\                  , __LINE__, #FN,PARAM1,PARAM2,#PARAM3, cval, VAL,cval-(VAL)\
208                  ,relerrpc\                  ,relerrpc\
209              );\              );\
# Line 211  int main(void){ Line 215  int main(void){
215          }\          }\
216      }      }
217    
   
218  #if 0  #if 0
219      /* these tests pass, but don't prove much */      /* these tests pass, but don't prove much */
220      fprintf(stderr,"COMPARISON OF phi0 VALUES WITH THOSE FROM FREESTEAM\n");      fprintf(stderr,"COMPARISON OF phi0 VALUES WITH THOSE FROM FREESTEAM\n");
# Line 259  int main(void){ Line 262  int main(void){
262      ASSERT_TOL(helm_resid_tautau, tau, delta, d, -0.223440737E1, 1e-8);      ASSERT_TOL(helm_resid_tautau, tau, delta, d, -0.223440737E1, 1e-8);
263      ASSERT_TOL(helm_resid_deltau, tau, delta, d, -0.112176915e1, 1e-8);      ASSERT_TOL(helm_resid_deltau, tau, delta, d, -0.112176915e1, 1e-8);
264    
265    #if 0
266      fprintf(stderr,"\nADDITIONAL LOW-LEVEL TESTS NEAR CRITICAL POINT\n");      fprintf(stderr,"\nADDITIONAL LOW-LEVEL TESTS NEAR CRITICAL POINT\n");
267            
268      T = 647.; /* K */      T = 647.; /* K */
# Line 274  int main(void){ Line 278  int main(void){
278      ASSERT_TOL(helmholtz_p, T, rho, d, 2.203847557e7, 7e-4);      ASSERT_TOL(helmholtz_p, T, rho, d, 2.203847557e7, 7e-4);
279      ASSERT_TOL(helmholtz_cp, T, rho, d, 3.531798573e6, 1e-8);      ASSERT_TOL(helmholtz_cp, T, rho, d, 3.531798573e6, 1e-8);
280      ASSERT_TOL(helmholtz_w, T, rho, d, 2.52140783e2, 1e-8);      ASSERT_TOL(helmholtz_w, T, rho, d, 2.52140783e2, 1e-8);
281    #endif
282    
283      fprintf(stderr,"\nIAPWS95 TABLE 7 (SINGLE-PHASE) TESTS\n");      fprintf(stderr,"\nIAPWS95 TABLE 7 (SINGLE-PHASE) TESTS\n");
284      for(i=0; i<ntd; ++i){      for(i=0; i<ntd; ++i){
# Line 290  int main(void){ Line 295  int main(void){
295          ASSERT_TOL(helmholtz_w, T, rho, d, w, w*2e-5);          ASSERT_TOL(helmholtz_w, T, rho, d, w, w*2e-5);
296      }      }
297    
298    #ifdef NOT_YET_FDA_APPROVED
299        fprintf(stderr,"\nIAPWS95 TABLE 8 (SATURATION) TESTS\n");
300        for(i=0; i<ntds; ++i){
301            double T = tds[i].T;
302            double p = tds[i].p * 1e6; /* Pa */
303            double rho_f = tds[i].rho_f;
304            double rho_g = tds[i].rho_g;
305            double h_f = tds[i].h_f * 1e3;
306            double h_g = tds[i].h_g * 1e3;
307            double s_f = tds[i].s_f * 1e3;
308            double s_g = tds[i].s_g * 1e3;
309            fprintf(stderr,"T = %f, p = %f, rho_f = %f, rho_g = %f\n",T,p,rho_f, rho_g);
310            double rho_f_eval, rho_g_eval, p_eval;
311    
312            int res;
313            res = helmholtz_sat_t(T, &p, &rho_f, &rho_g, d);
314        }
315    #endif
316    
317      fprintf(stderr,"Tests completed OK (maximum error = %0.8f%%)\n",maxerr);      fprintf(stderr,"Tests completed OK (maximum error = %0.8f%%)\n",maxerr);
318      exit(0);      exit(0);
# Line 313  const TestDataIAPWS95 td[] = { Line 336  const TestDataIAPWS95 td[] = {
336    
337  const unsigned ntd = sizeof(td)/sizeof(TestDataIAPWS95);  const unsigned ntd = sizeof(td)/sizeof(TestDataIAPWS95);
338    
339    const TestDataSat tds[] = {
340        /* T, p (MPa), rho_f, rho_g, h_f (kJ/kg), h_g (kJ/kg), s_f (kJ/kgK), s_g (kJ/kgK) */
341        {450, 0.932203564, 0.890341250e3, 0.481200360e1, 0.749161585e3, 0.277441078e4, 0.210865845e1, 0.660921221e1}
342        ,{275, 0.698451167e-3, 0.999887406e3, 0.550664919e-2, 0.775972202e1, 0.250428995e4, 0.283094670e-1, 0.910660121e1}
343        ,{625, 0.169082693e2, 0.567090385e3, 0.118290280e3, 0.168626976e4, 0.255071625e4, 0.380194683e1, 0.518506121e1}
344    };
345    
346    const unsigned ntds = sizeof(tds)/sizeof(TestDataSat);
347    
348  #endif  #endif
349    

Legend:
Removed from v.1995  
changed lines
  Added in v.1996

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