1 |
|
2 |
#include "../fluids.h" |
3 |
#include "../fprops.h" |
4 |
#include "../solve_ph.h" |
5 |
#include "../refstate.h" |
6 |
|
7 |
#include <assert.h> |
8 |
#include <math.h> |
9 |
|
10 |
#include "../color.h" |
11 |
|
12 |
#define MSG(FMT, ...) \ |
13 |
color_on(stderr,ASC_FG_BRIGHTRED);\ |
14 |
fprintf(stderr,"%s:%d: ",__FILE__,__LINE__);\ |
15 |
color_on(stderr,ASC_FG_BRIGHTBLUE);\ |
16 |
fprintf(stderr,"%s: ",__func__);\ |
17 |
color_off(stderr);\ |
18 |
fprintf(stderr,FMT "\n",##__VA_ARGS__) |
19 |
|
20 |
#define ERRMSG(STR,...) \ |
21 |
color_on(stderr,ASC_FG_BRIGHTRED);\ |
22 |
fprintf(stderr,"ERROR:");\ |
23 |
color_off(stderr);\ |
24 |
fprintf(stderr," %s:%d:" STR "\n", __func__, __LINE__ ,##__VA_ARGS__) |
25 |
|
26 |
#define TOL_T 1e-8 |
27 |
#define TOL_RHO 1e-3 |
28 |
|
29 |
|
30 |
int main(void){ |
31 |
const PureFluid *P; |
32 |
FpropsError err; |
33 |
FluidState S; |
34 |
double T0, rho0, p, h, T, rho; |
35 |
|
36 |
#define TEST_PH(T1,RHO1) \ |
37 |
err = FPROPS_NO_ERROR;\ |
38 |
/*MSG("TEST_PH(T1=%f, RHO1=%f)",T1,RHO1);*/ \ |
39 |
T0 = T1; \ |
40 |
rho0 = RHO1; \ |
41 |
/*MSG("setting T,rho");*/\ |
42 |
S = fprops_set_Trho(T0,rho0,P,&err); \ |
43 |
assert(!err); \ |
44 |
/*MSG("calc p");*/\ |
45 |
p = fprops_p(S,&err); \ |
46 |
assert(!err); \ |
47 |
/*MSG("calc h");*/\ |
48 |
h = fprops_h(S,&err); \ |
49 |
assert(!err); \ |
50 |
/*MSG("solving ph");*/\ |
51 |
fprops_solve_ph(p,h,&T,&rho,0,P,&err); \ |
52 |
assert(!err); \ |
53 |
MSG("T err: %f",(T-T0));\ |
54 |
MSG("rho err: %f",(rho-rho0));\ |
55 |
assert(fabs(T - T0) < TOL_T); \ |
56 |
assert(fabs(rho - rho0) < TOL_RHO); |
57 |
|
58 |
P = fprops_fluid("water","helmholtz",NULL); |
59 |
assert(P); |
60 |
err = FPROPS_NO_ERROR; |
61 |
|
62 |
TEST_PH(314.4054538268115, 999.7897902747587); |
63 |
|
64 |
TEST_PH(4.278618181818e+02, 3.591421624513e-03); |
65 |
TEST_PH(3.453541818182e+02, 6.899880592960e-03); |
66 |
TEST_PH(7.166385454545e+02, 6.899880592960e-03); |
67 |
TEST_PH(7.372654545455e+02, 4.092431601778e-03); |
68 |
|
69 |
TEST_PH(304.10372142680086, 999.7863801065582); |
70 |
TEST_PH(283.4886584572104, 999.7900620473787); |
71 |
TEST_PH(293.8028752316878, 999.7858245521049); |
72 |
|
73 |
P = fprops_fluid("water","pengrob","IAPWS"); |
74 |
ReferenceState R = {FPROPS_REF_TPF}; |
75 |
fprops_set_reference_state(P,&R); |
76 |
MSG("Testing '%s' (type '%d', source '%s')", P->name, P->type, P->source); |
77 |
assert(P); |
78 |
err = FPROPS_NO_ERROR; |
79 |
|
80 |
TEST_PH(2.731600000000e+02, 8.618514819566e+02); |
81 |
MSG("p = %f",p); |
82 |
MSG("h = %f",h); |
83 |
|
84 |
fprintf(stderr,"\n"); |
85 |
color_on(stderr,ASC_FG_BRIGHTGREEN); |
86 |
fprintf(stderr,"SUCCESS (%s)",__FILE__); |
87 |
color_off(stderr); |
88 |
fprintf(stderr,"\n"); |
89 |
return 0; |
90 |
} |
91 |
|