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

Contents of /trunk/models/johnpye/fprops/fluids.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2664 - (show annotations) (download) (as text)
Fri Jan 18 06:02:15 2013 UTC (10 years, 8 months ago) by jpye
File MIME type: text/x-csrc
File size: 2020 byte(s)
Trying to debug fprops_triple_point for Toluene with pengrob correlation. Something strange is happening with fratio.
1 #include "fluids.h"
2 #include "fluids/fluids_list.h"
3 #include "fprops.h"
4
5 #include <string.h>
6 #include <stdio.h>
7
8 //#define FLUIDS_DEBUG
9 #ifdef FLUIDS_DEBUG
10 # include "color.h"
11 # define MSG(FMT, ...) \
12 color_on(stderr,ASC_FG_BRIGHTRED);\
13 fprintf(stderr,"%s:%d: ",__FILE__,__LINE__);\
14 color_on(stderr,ASC_FG_BRIGHTBLUE);\
15 fprintf(stderr,"%s: ",__func__);\
16 color_off(stderr);\
17 fprintf(stderr,FMT "\n",##__VA_ARGS__)
18 #else
19 # define MSG(ARGS...) ((void)0)
20 #endif
21
22 /* declare the external EosData objects */
23 #define X
24 #define F(NAME) extern const EosData eos_##NAME;
25 FLUIDS(F,X)
26 #undef F
27 #define F(NAME) extern const EosData eos_rpp_##NAME;
28 RPPFLUIDS(F,X)
29 #undef F
30 #undef X
31
32 /* create a list of all the fluids from fluids/fluids_list.h */
33 #define X ,
34 #define F(NAME) &eos_##NAME
35 const EosData *fluids[] ={ FLUIDS(F,X)
36 #undef F
37 #define F(NAME) &eos_rpp_##NAME
38 , RPPFLUIDS(F,X)
39 };
40 #undef X
41 #undef F
42
43 /* count them */
44 #define X +
45 #define F(NAME) 1
46 static int nfluids = 0 + FLUIDS(F,X) + RPPFLUIDS(F,X);
47 #undef F
48 #undef X
49
50 const PureFluid *fprops_fluid(const char *name, const char *corrtype, const char *source){
51 int i;
52 MSG("Looking for fluid '%s' of type '%s', with source text '%s'",name,corrtype,source);
53 for(i = 0; i < nfluids; ++i){
54 if(0==strcmp(name, fluids[i]->name)){
55 MSG("Got '%s' (type %d, source '%s')",name,fluids[i]->type,fluids[i]->source);
56 if(source){
57 if(fluids[i]->source && NULL != strstr(fluids[i]->source, source)){
58 MSG("Source '%s' OK",source);
59 }else{
60 MSG("Source '%s' not matched",source);
61 continue;
62 }
63 }
64 if(fprops_corr_avail(fluids[i],corrtype)){
65 MSG("Match! %d",i);
66 return fprops_prepare(fluids[i],corrtype);
67 }else{
68 MSG("No match");
69 }
70 }
71 }
72 MSG("Returning null");
73 return NULL;
74 }
75
76
77 int fprops_num_fluids(){
78 return nfluids;
79 }
80
81 const PureFluid *fprops_get_fluid(int i){
82 if(i >= 0 && i < nfluids){
83 PureFluid *P = fprops_prepare(fluids[i],NULL);
84 MSG("Fluid '%s' with T_t = %f",P->name,P->data->T_t);
85 return P;
86 }
87 return NULL;
88 }
89
90
91

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