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

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

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

revision 1918 by jpye, Fri Oct 3 05:13:08 2008 UTC revision 1919 by jpye, Fri Oct 3 05:52:22 2008 UTC
# Line 220  int helm_check_dhdT_rho(const HelmholtzD Line 220  int helm_check_dhdT_rho(const HelmholtzD
220      }      }
221      fprintf(stderr,"average error = %.10e\n",se/n);      fprintf(stderr,"average error = %.10e\n",se/n);
222      fprintf(stderr,"sse - n se^2 = %.3e\n",sse - n*se*se);      fprintf(stderr,"sse - n se^2 = %.3e\n",sse - n*se*se);
223    }
224    
225    
226    int helm_check_dhdrho_T(const HelmholtzData *d, unsigned ntd, const TestData *td){
227        unsigned i;
228        double T,rho,h,rho1,h1,dhdrho,dhdrho_est,err,se = 0,sse = 0;
229        unsigned n = ntd;
230        double tol = 1e-1;
231    
232        double drho = 1e-6 /* finite difference in temperature, in K */;
233    
234        fprintf(stderr,"(dh/drho)_T RESULTS\n\n");
235        fprintf(stderr,"%-18s\t%-18s\t%-18s\t%-18s\t%-18s\t%12s\t%12s\n","T","rho","h","dh/drho","dh/drho est","err","%err");
236        for(i=0; i<n;++i){
237            T = td[i].T + 273.15;
238            rho = td[i].rho;
239            h = helmholtz_h(T,rho,d);
240            dhdrho = helmholtz_dhdrho_T(T,rho,d);
241            assert(!isinf(dhdrho));
242            rho1 = rho + drho;
243            h1 = helmholtz_h(T, rho1, d);
244            dhdrho_est = (h1 - h)/drho;
245            err = (dhdrho_est - dhdrho);
246            se += err;
247            sse += err*err;
248            fprintf(stderr,"%.12e\t%.12e\t%.12e\t%.12e\t%.12e\t%12.4e\t%12.2e\n",T,rho,h,dhdrho,dhdrho_est,err,err/dhdrho*100   );
249        }
250        fprintf(stderr,"average error = %.10e\n",se/n);
251        fprintf(stderr,"sse - n se^2 = %.3e\n",sse - n*se*se);
252  }    }  
253    
254    

Legend:
Removed from v.1918  
changed lines
  Added in v.1919

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