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

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

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

revision 2659 by jpye, Wed Jan 16 02:04:07 2013 UTC revision 2660 by jpye, Wed Jan 16 05:57:03 2013 UTC
# Line 50  static const IdealData ideal_data_water Line 50  static const IdealData ideal_data_water
50    
51  /**  /**
52  Residual (non-ideal) property data for Water/Steam, from IAPWS-95.  Residual (non-ideal) property data for Water/Steam, from IAPWS-95.
53  http://www.iapws.org/relguide/IAPWS95.pdf  http://www.iapws.org/relguide/IAPWS95-Rev.pdf
54  */  */
55  static HelmholtzData helmholtz_data_water = {  static HelmholtzData helmholtz_data_water = {
56      /* R */ WATER_R /* J/kg/K */      /* R */ WATER_R /* J/kg/K */
# Line 62  static HelmholtzData helmholtz_data_wate Line 62  static HelmholtzData helmholtz_data_wate
62      , /* rho_c */ WATER_RHOC      , /* rho_c */ WATER_RHOC
63      , /* T_t */ 273.16      , /* T_t */ 273.16
64    
65    #if 1
66      , .ref = {      , .ref = {
67          FPROPS_REF_PHI0          FPROPS_REF_PHI0
68          , .data = {.phi0 = {          , .data = {.phi0 = {
69              .m = /* n_2 = */ 6.6832105275932              .m = /* n_2 = */ 6.6832105275932
70              , .c = /* n_1 = */ -8.3204464837497              , .c = /* n_1 = */ -8.3204464837497
71          }}          }}
72      }      }
73    #endif
74    
75      , 0.344 /* acentric factor, source: Reid, Prausnitz & Polling */      , 0.344 /* acentric factor, source: Reid, Prausnitz & Polling */
76      , &ideal_data_water      , &ideal_data_water
# Line 164  EosData eos_water = { Line 166  EosData eos_water = {
166    
167      ./test.py water      ./test.py water
168  */  */
 /*  
     some code from freesteam, http://freesteam.sf.net/ , which has been thoroughly  
     validated already.  
 */  
   
 const double n0[] = {  
     0.0 /* placeholder */,  
     -8.32044648201, 6.6832105268, 3.00632 /* const, linear, ln(tau) coeffs */  
     , 0.012436, 0.97315, 1.27950, 0.96956, 0.24873 /* exponential coeffs */  
 };  
   
 const double gamma0[] = {  
     0.0, 0.0, 0.0, 0.0,  
     1.28728967,  
     3.53734222,  
     7.74073708,  
     9.24437796,  
     27.5075105  
 };  
   
 enum Limits{  
     eGamma1 = 4,  
     eGamma2 = 9,  
 };  
   
169  # include <math.h>  # include <math.h>
170  # include <stdlib.h>  # include <stdlib.h>
171  # include <stdio.h>  # include <stdio.h>
# Line 199  enum Limits{ Line 176  enum Limits{
176  # include "../ideal.h"  # include "../ideal.h"
177  # include "../helmholtz_impl.h"  # include "../helmholtz_impl.h"
178    
 double phi0(const double delta, const double tau){  
     int i;  
     double sum = 0;  
     for (i = eGamma1; i < eGamma2; i++)  
     {  
         sum += n0[i]*log(1-exp(-tau*gamma0[i]));  
     }  
     sum += log(delta) + n0[1] + n0[2]*tau + n0[3]*log(tau);  
     return sum;  
 }  
   
179  typedef struct{double T, rho, p, cv, w, s;} TestDataIAPWS95;  typedef struct{double T, rho, p, cv, w, s;} TestDataIAPWS95;
180  const TestDataIAPWS95 td[]; const unsigned ntd;  const TestDataIAPWS95 td[]; const unsigned ntd;
181    
# Line 224  int main(void){ Line 190  int main(void){
190      double maxerr = 0;      double maxerr = 0;
191      unsigned i;      unsigned i;
192    
   
 #if 0  
     /* these tests pass, but don't prove much */  
     fprintf(stderr,"COMPARISON OF phi0 VALUES WITH THOSE FROM FREESTEAM\n");  
     for(T = 300; T <= 900; T+= 100){  
         for(rho = 900; rho >= 0.9; rho*=0.5){  
             double delta = rho / P->data->rho_star;  
             double tau = P->data->T_star / T;  
             double p0 = phi0(delta,tau);  
   
             ASSERT_TOL(helm_ideal, tau, delta, P->data->ideal, p0, p0*1e-5);  
         }  
     }  
 #endif  
   
193      /* LOW-LEVEL TEST DATA PROVIDED IN IAPWS95 */      /* LOW-LEVEL TEST DATA PROVIDED IN IAPWS95 */
194    
195      fprintf(stderr,"\nIAPWS95 TABLE 6 TESTS\n");      fprintf(stderr,"\nIAPWS95 TABLE 6 TESTS\n");

Legend:
Removed from v.2659  
changed lines
  Added in v.2660

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