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

Contents of /trunk/models/johnpye/fprops/test.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1905 - (show annotations) (download) (as text)
Sat Sep 27 04:54:12 2008 UTC (15 years, 8 months ago) by jpye
File MIME type: text/x-chdr
File size: 1500 byte(s)
Calculated (dp/dT)_rho, seems to look OK when testing with hydrogen.
1 #ifndef HELMHOLTZ_TEST_H
2 #define HELMHOLTZ_TEST_H
3
4 #include "helmholtz.h"
5
6 /* Macros and type declarations for running simple test cases */
7
8 typedef struct{double T,p,rho,u,h,s,cv,cp,cp0,a;} TestData;
9
10 /**
11 Run tests for p, u, h, s, a against values from a user-provided TestData array
12 Tolerances are specified in the cdoe, in test.c.
13
14 @return 1 if any failures occurred.
15 */
16 int helm_run_test_cases(const HelmholtzData *d, unsigned ntd, const TestData *td);
17
18 /**
19 Check 'u' values and output discrepancy for plotting.
20 */
21 int helm_check_u(const HelmholtzData *d, unsigned ntd, const TestData *td);
22
23 /**
24 Check dp/dT values (rho constant) by comparison with finite
25 difference estimates (check that helmholtz_p is working first!)
26 */
27 int helm_check_p_T(const HelmholtzData *d, unsigned ntd, const TestData *td);
28
29 /* a simple macro to actually do the testing */
30 #define ASSERT_TOL(FN,PARAM1,PARAM2,PARAM3,VAL,TOL) {\
31 double cval; cval = FN(PARAM1,PARAM2,PARAM3);\
32 double err; err = cval - (double)(VAL);\
33 double relerrpc = (cval-(VAL))/(VAL)*100;\
34 if(fabs(relerrpc)>maxerr)maxerr=fabs(relerrpc);\
35 if(fabs(err)>fabs(TOL)){\
36 fprintf(stderr,"ERROR in line %d: value of '%s(%f,%f,%s)' = %.5e,"\
37 " should be %.5e, error is %.10e (%.2f%%)!\n"\
38 , __LINE__, #FN,PARAM1,PARAM2,#PARAM3, cval, VAL,cval-(VAL)\
39 ,relerrpc\
40 );\
41 exit(1);\
42 }else{\
43 fprintf(stderr," OK, %s(%f,%f,%s) = %8.2e with %.6f%% err.\n"\
44 ,#FN,PARAM1,PARAM2,#PARAM3,VAL,relerrpc\
45 );\
46 }\
47 }
48
49 #endif

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