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

Annotation of /trunk/models/johnpye/fprops/test/ideal.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2735 - (hide annotations) (download) (as text)
Tue Dec 10 12:26:54 2013 UTC (6 years, 9 months ago) by jpye
File MIME type: text/x-csrc
File size: 1592 byte(s)
problem with cp0 in ideal gas case.
1 jpye 2732 #include "../ideal.h"
2     #include "../fluids.h"
3     #include "../fprops.h"
4     #include "../refstate.h"
5     #include "../color.h"
6    
7     extern const EosData eos_rpp_methane;
8 jpye 2734 extern const EosData eos_rpp_nitrogen;
9     extern const EosData eos_rpp_oxygen;
10     extern const EosData eos_rpp_carbon_dioxide;
11     extern const EosData eos_rpp_water;
12 jpye 2732
13     #include <assert.h>
14     #include <math.h>
15    
16     #define MSG FPROPS_MSG
17     #define ERRMSG FPROPS_ERRMSG
18    
19     #define TOL_T 1e-3
20     #define TOL_RHO 1e-3
21    
22     int main(void){
23     FpropsError err = FPROPS_NO_ERROR;
24    
25 jpye 2734 MSG("Testing ideal EOS ");
26 jpye 2732
27     ReferenceState ref = {FPROPS_REF_REF0};
28 jpye 2734 enum MyFluids{N2,O2,CO2,H2O,CH4,NFLUIDS};
29     PureFluid *P[NFLUIDS];
30     P[N2] = ideal_prepare(&eos_rpp_nitrogen, &ref);
31     P[O2] = ideal_prepare(&eos_rpp_oxygen, &ref);
32     P[CO2] = ideal_prepare(&eos_rpp_carbon_dioxide, &ref);
33     P[H2O] = ideal_prepare(&eos_rpp_water, &ref);
34     P[CH4] = ideal_prepare(&eos_rpp_methane, &ref);
35 jpye 2732
36 jpye 2734 int i;
37     for(i=0;i<NFLUIDS;++i){
38 jpye 2735 double cp0 = ideal_cp(298.2, 0, P[i]->data, &err);
39 jpye 2734 double h0 = ideal_h(298.2, 0, P[i]->data, &err);
40 jpye 2735 MSG("%-20s: M = %f, R = %f, cp0(298.2) = %f, hbar(298.2) = %f J/kmol",P[i]->name,P[i]->data->M, P[i]->data->R, h0*P[CH4]->data->M);
41 jpye 2734 }
42    
43     MSG("%-20s\t%s\t%s\t%s","comp","h(850 K)","h(1520 K)","Dh (kJ/kmol)");
44     for(i=0;i<NFLUIDS;++i){
45     double h1 = ideal_h(850,1000,P[i]->data,&err);
46     double h2 = ideal_h(1520,1000,P[i]->data,&err);
47     double Dh = h2 - h1;
48     MSG("%-20s\t%f\t%f\t%f",P[i]->name,h1,h2,Dh);
49     }
50    
51    
52 jpye 2732 fprintf(stderr,"\n");
53     color_on(stderr,ASC_FG_BRIGHTGREEN);
54     fprintf(stderr,"SUCCESS (%s)",__FILE__);
55     color_off(stderr);
56     fprintf(stderr,"\n");
57     return 0;
58     }
59    

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