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

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

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

revision 1869 by jpye, Wed Sep 17 06:37:45 2008 UTC revision 1870 by jpye, Wed Sep 17 06:45:10 2008 UTC
# Line 161  int main(void){ Line 161  int main(void){
161          cp0 = td[i].cp0*1e3;          cp0 = td[i].cp0*1e3;
162          ASSERT_TOL(CP0_TEMP, td[i].T+273.15, td[i].rho, d, cp0, cp0*1e-6);          ASSERT_TOL(CP0_TEMP, td[i].T+273.15, td[i].rho, d, cp0, cp0*1e-6);
163      }      }
164    
165  #undef CP0_TEMP  #undef CP0_TEMP
166    
     /* FIXME entropy correction requires the LINEAR term from above to be incorporated into the model! */  
167    
168      fprintf(stderr,"HELMHOLTZ ENERGY TESTS\n");      fprintf(stderr,"CONSISTENCY TESTS (of test data): u, T, s, a...");
169      for(i=0; i<n;++i){      for(i=0; i<n; ++i){
170            u = td[i].u*1e3;
171            T = td[i].T+273.15;
172            s = td[i].s*1e3;
173          a = td[i].a*1e3;          a = td[i].a*1e3;
174          ASSERT_TOL(helmholtz_a, td[i].T+273.15, td[i].rho, d, a, a*1e-3);          //fprintf(stderr,"u - T s = %f, a = %f\n", u-T*s, a);
175            double resid = (u - T*s) - a;
176            assert(fabs(resid) < fabs(a)*1e-6);
177      }      }
178        fprintf(stderr,"done\n");
179    
180      fprintf(stderr,"PRESSURE TESTS\n");      fprintf(stderr,"CONSISTENCY TESTS (of test data): p, rho, h, u...");
181      for(i=0; i<n;++i){      for(i=0; i<n; ++i){
182          T = td[i].T+273.15;          h = td[i].h*1e3;
183          p = td[i].p*1e6;          p = td[i].p*1e6;
184          rho = td[i].rho;          rho = td[i].rho;
185          ASSERT_TOL(helmholtz_p, T, rho, d, p, p*1e-6);          u = td[i].u*1e3;
186            //fprintf(stderr,"h - p/rho - T s = %f, a = %f\n", h - p/rho-T*s, a);
187            double resid = (u + p/rho) - h;
188            assert(fabs(resid) < fabs(h)*1e-6);
189      }      }
190        fprintf(stderr,"done\n");
191    
192      fprintf(stderr,"INTERNAL ENERGY TESTS\n");      fprintf(stderr,"INTERNAL ENERGY TESTS\n");
193      for(i=0; i<n;++i){      for(i=0; i<n;++i){
# Line 185  int main(void){ Line 195  int main(void){
195          ASSERT_TOL(helmholtz_u, td[i].T+273.15, td[i].rho, d, u, u*1e-3);          ASSERT_TOL(helmholtz_u, td[i].T+273.15, td[i].rho, d, u, u*1e-3);
196      }      }
197    
198        fprintf(stderr,"CONSISTENCY TESTS (of calculated values): u, T, s, a\n");
199        for(i=0; i<n; ++i){
200            T = td[i].T+273.15;
201            rho = td[i].rho;
202            a = helmholtz_a(T,rho,d);
203            s = helmholtz_s(T,rho,d);
204            u = helmholtz_u(T,rho,d);
205            ASSERT_TOL(helmholtz_a, T, rho, d, u-T*s, (u-T*s)*1e-3);
206        }
207        fprintf(stderr,"done\n");
208    
209        fprintf(stderr,"PRESSURE TESTS\n");
210        for(i=0; i<n;++i){
211            T = td[i].T+273.15;
212            p = td[i].p*1e6;
213            rho = td[i].rho;
214            ASSERT_TOL(helmholtz_p, T, rho, d, p, p*1e-6);
215        }
216    
217      fprintf(stderr,"ENTHALPY TESTS\n");      fprintf(stderr,"ENTHALPY TESTS\n");
218      for(i=0; i<n;++i){      for(i=0; i<n;++i){
219          h = td[i].h*1e3;          h = td[i].h*1e3;
220          ASSERT_TOL(helmholtz_h, td[i].T+273.15, td[i].rho, d, h, 1E3);          ASSERT_TOL(helmholtz_h, td[i].T+273.15, td[i].rho, d, h, 1E3);
221      }      }
222    
223        fprintf(stderr,"HELMHOLTZ ENERGY TESTS\n");
224        for(i=0; i<n;++i){
225            T = td[i].T+273.15;
226            rho = td[i].rho;
227            a = td[i].a*1e3;
228            ASSERT_TOL(helmholtz_a, T, rho, d, a, a*1e-3);
229        }
230    
231        /* entropy offset required to attain agreement with REFPROP */
232        double Y =  0;
233        /* FIXME entropy correction requires the LINEAR term from above to be incorporated into the model! */
234    
235      fprintf(stderr,"ENTROPY TESTS\n");      fprintf(stderr,"ENTROPY TESTS\n");
236      for(i=0; i<n;++i){      for(i=0; i<n;++i){
237          s = td[i].s*1e3;          s = td[i].s*1e3 + Y;
238          ASSERT_TOL(helmholtz_s, td[i].T+273.15, td[i].rho, d, s, 1e-3*s);          ASSERT_TOL(helmholtz_s, td[i].T+273.15, td[i].rho, d, s, 1e3*s);
239      }      }
240    
241      fprintf(stderr,"Tests completed OK (maximum error = %0.2f%%)\n",maxerr);      fprintf(stderr,"Tests completed OK (maximum error = %0.2f%%)\n",maxerr);

Legend:
Removed from v.1869  
changed lines
  Added in v.1870

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