/[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 2300 by jpye, Fri Aug 20 13:50:05 2010 UTC revision 2301 by jpye, Sat Aug 21 13:28:35 2010 UTC
# Line 137  const HelmholtzData helmholtz_data_water Line 137  const HelmholtzData helmholtz_data_water
137  };  };
138    
139  #ifdef TEST  #ifdef TEST
140  # include "test.h"  # include "../test.h"
141  #include "../sat.h"  # include "../sat.h"
142    
143  /*  /*
144      Test suite. These tests attempt to validate the current code using      Test suite. These tests attempt to validate the current code using
145      a few sample figures output by REFPROP 7.0.      a few sample figures output by REFPROP 7.0.
# Line 172  enum Limits{ Line 173  enum Limits{
173      eGamma2 = 9,      eGamma2 = 9,
174  };  };
175    
176  #include <assert.h>  # include <math.h>
177  #include <stdlib.h>  # include <stdlib.h>
178  #include <stdio.h>  # include <stdio.h>
179  #include <math.h>  # include "../ideal_impl.h"
180  #include "ideal_impl.h"  # include "../helmholtz_impl.h"
 #include "helmholtz_impl.h"  
181    
182  double phi0(const double delta, const double tau){  double phi0(const double delta, const double tau){
183      int i;      int i;
# Line 193  double phi0(const double delta, const do Line 193  double phi0(const double delta, const do
193  typedef struct{double T, rho, p, cv, w, s;} TestDataIAPWS95;  typedef struct{double T, rho, p, cv, w, s;} TestDataIAPWS95;
194  const TestDataIAPWS95 td[]; const unsigned ntd;  const TestDataIAPWS95 td[]; const unsigned ntd;
195    
 typedef struct{double T, p, rho_f, rho_g, h_f, h_g, s_f, s_g;} TestDataSat;  
196  const TestDataSat tds[]; const unsigned ntds;  const TestDataSat tds[]; const unsigned ntds;
197    
198  const TestData td1[]; const unsigned ntd1;  const TestData td1[]; const unsigned ntd1;
# Line 287  int main(void){ Line 286  int main(void){
286          ASSERT_TOL(helmholtz_w, T, rho, d, w, w*2e-5);          ASSERT_TOL(helmholtz_w, T, rho, d, w, w*2e-5);
287      }      }
288    
289      fprintf(stderr,"\nIAPWS95 TABLE 8 (SATURATION) TESTS\n");      fprintf(stderr,"\nIAPWS95 TABLE 8 (SATURATION) TESTS (%d items)\n",ntds);
290      for(i=0; i<ntds; ++i){      for(i=0; i<ntds; ++i){
291          double T = tds[i].T;          double T = tds[i].T;
292          double p = tds[i].p * 1e6; /* Pa */          double p = tds[i].p * 1e6; /* Pa */
293          double rho_f = tds[i].rho_f;          double rho_f = tds[i].rhof;
294          double rho_g = tds[i].rho_g;          double rho_g = tds[i].rhog;
295          double h_f = tds[i].h_f * 1e3;          double h_f = tds[i].hf * 1e3;
296          double h_g = tds[i].h_g * 1e3;          double h_g = tds[i].hg * 1e3;
297          double s_f = tds[i].s_f * 1e3;          double s_f = tds[i].sf * 1e3;
298          double s_g = tds[i].s_g * 1e3;          double s_g = tds[i].sg * 1e3;
299          fprintf(stderr,"T = %f, p = %f bar, rho_f = %f, rho_g = %f\n",T,p/1e5,rho_f, rho_g);          fprintf(stderr,"T = %f, p = %f bar, rho_f = %f, rho_g = %f\n",T,p/1e5,rho_f, rho_g);
300          double rho_f_eval, rho_g_eval, p_eval;          double rho_f_eval, rho_g_eval, p_eval;
301          int res;          int res = fprops_sat_T(T, &p_eval, &rho_f_eval, &rho_g_eval, d);
   
         res = fprops_sat_T(T, &p_eval, &rho_f_eval, &rho_g_eval, d);  
302          ASSERT_TOL_VAL(p_eval, p, 1e-8);          ASSERT_TOL_VAL(p_eval, p, 1e-8);
303          ASSERT_TOL_VAL(rho_f_eval, rho_f, 1e-8);          ASSERT_TOL_VAL(rho_f_eval, rho_f, 1e-8);
304          ASSERT_TOL_VAL(rho_g_eval, rho_g, 1e-8);          ASSERT_TOL_VAL(rho_g_eval, rho_g, 1e-8);
# Line 323  int main(void){ Line 320  int main(void){
320      }      }
321  #endif  #endif
322    
323  #if 1  # if 1
324      helm_run_test_cases(d, ntd1, td1, 'K');      helm_run_test_cases(d, ntd1, td1, 'K');
325  #endif  # endif
326    
327      //helm_check_dpdrho_T(d, ntd1, td1);      //helm_check_dpdrho_T(d, ntd1, td1);
328    
329  #if 1  # if 1
330      //helm_check_d2pdrho2_T(d,ntd1, td1);      //helm_check_d2pdrho2_T(d,ntd1, td1);
331    
332      fprintf(stderr,"Tests completed OK (maximum error = %0.8f%%)\n",maxerr);      fprintf(stderr,"Tests completed OK (maximum error = %0.8f%%)\n",maxerr);
333  #endif  # endif
334    
335      exit(0);      exit(0);
336  }  }

Legend:
Removed from v.2300  
changed lines
  Added in v.2301

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