/[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 1906 by jpye, Sat Sep 27 08:56:29 2008 UTC revision 1907 by jpye, Sat Sep 27 09:45:06 2008 UTC
# Line 137  int helm_check_s(const HelmholtzData *d, Line 137  int helm_check_s(const HelmholtzData *d,
137      fprintf(stderr,"sse - n se^2 = %.3e\n",sse - n*se*se);      fprintf(stderr,"sse - n se^2 = %.3e\n",sse - n*se*se);
138  }  }
139    
140  int helm_check_p_T(const HelmholtzData *d, unsigned ntd, const TestData *td){  int helm_check_dpdT_rho(const HelmholtzData *d, unsigned ntd, const TestData *td){
141      unsigned i;      unsigned i;
142      double T,rho,p,T1,p1,dpdT,dpdT_est,err,se = 0,sse = 0;      double T,rho,p,T1,p1,dpdT,dpdT_est,err,se = 0,sse = 0;
143      unsigned n = ntd;      unsigned n = ntd;
# Line 163  int helm_check_p_T(const HelmholtzData * Line 163  int helm_check_p_T(const HelmholtzData *
163      }      }
164      fprintf(stderr,"average error = %.10e\n",se/n);      fprintf(stderr,"average error = %.10e\n",se/n);
165      fprintf(stderr,"sse - n se^2 = %.3e\n",sse - n*se*se);      fprintf(stderr,"sse - n se^2 = %.3e\n",sse - n*se*se);
166    }      
167    
168    int helm_check_dpdrho_T(const HelmholtzData *d, unsigned ntd, const TestData *td){
169        unsigned i;
170        double T,rho,p,rho1,p1,dpdrho,dpdrho_est,err,se = 0,sse = 0;
171        unsigned n = ntd;
172        double tol = 1e-1;
173    
174        double drho = 0.0001 /* finite difference in temperature, in K */;
175    
176        fprintf(stderr,"(dP/dT)_rho RESULTS\n\n");
177        fprintf(stderr,"%-18s\t%-18s\t%-18s\t%-18s\t%-18s\t%12s\t%12s\n","T","rho","p","dp/drho","dp/drho est","err","%err");
178        for(i=0; i<n;++i){
179            T = td[i].T + 273.15;
180            rho = td[i].rho;
181            p = helmholtz_p(T,rho,d);
182            dpdrho = helmholtz_dpdrho_T(T,rho,d);
183            assert(!isinf(dpdrho));
184            rho1 = rho + drho;
185            p1 = helmholtz_p(T, rho1, d);
186            dpdrho_est = (p1 - p)/drho;
187            err = (dpdrho_est - dpdrho);
188            se += err;
189            sse += err*err;
190            fprintf(stderr,"%.12e\t%.12e\t%.12e\t%.12e\t%.12e\t%12.4e\t%12.2f\n",T,rho,p,dpdrho,dpdrho_est,err,err/dpdrho*100);
191        }
192        fprintf(stderr,"average error = %.10e\n",se/n);
193        fprintf(stderr,"sse - n se^2 = %.3e\n",sse - n*se*se);
194  }        }      
195    

Legend:
Removed from v.1906  
changed lines
  Added in v.1907

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