88 |
double rho[NFLUIDS]; |
double rho[NFLUIDS]; |
89 |
for(i=N2;i<NFLUIDS;i++){ |
for(i=N2;i<NFLUIDS;i++){ |
90 |
rho[i] = P / Ideals[i]->data->R / T; |
rho[i] = P / Ideals[i]->data->R / T; |
91 |
|
printf("\n\t%s%s is : %.4f kg/m3", "The mass density of ", FluidNames[i], rho[i]); |
92 |
} |
} |
93 |
|
|
94 |
/* mixture properties */ |
/* mixture properties */ |
95 |
double rho_mx = mixture_rho(NFLUIDS, x, rho); |
double rho_mx = mixture_rho(NFLUIDS, x, rho); |
96 |
double p_mx=0.0, /* pressure and enthalpy, calculated from mixture mass densities */ |
double p_mx=0.0, /* pressure and enthalpy, calculated from mixture mass densities */ |
97 |
h_mx=0.0; |
h_mx=0.0; |
98 |
|
|
99 |
|
/* Calculate pressures and enthalpies with the Ideal model (ideal-gas mixture) */ |
100 |
|
double p_i, h_i; /* these will hold individual pressures and enthalpies */ |
101 |
|
printf("\n The ideal-gas case:"); |
102 |
|
for(i=N2;i<NFLUIDS;i++){ |
103 |
|
p_i = ideal_p(T, rho[i], Ideals[i]->data, &err); |
104 |
|
h_i = ideal_h(T, rho[i], Ideals[i]->data, &err); |
105 |
|
printf("\n\t%s %s\n\t\t%s %g Pa;\n\t\t%s %g J/kg.\n", |
106 |
|
"For the substance", FluidNames[i], |
107 |
|
"the pressure is :", p_i, |
108 |
|
"the enthalpy is :", h_i); |
109 |
|
p_mx += x[i] * p_i; |
110 |
|
h_mx += x[i] * h_i; |
111 |
|
} |
112 |
|
printf("\n\t%s\t\t:\t %f kg/m3\n\t%s\t:\t %g Pa\n\t%s\t\t:\t %g J/kg\n", |
113 |
|
"The density of the mixture is", rho_mx, |
114 |
|
"The average pressure of the mixture is", p_mx, |
115 |
|
"The enthalpy of the mixture is", h_mx); |
116 |
|
|
117 |
|
/* Calculate pressures and enthalpies from Helmholtz model */ |
118 |
|
printf("\n The non-ideal-gas case:"); |
119 |
|
p_mx=0.0; /* reset mixture pressure and enthalpy to zero */ |
120 |
|
h_mx=0.0; |
121 |
for(i=N2;i<NFLUIDS;i++){ |
for(i=N2;i<NFLUIDS;i++){ |
|
static double p_i, hi; |
|
122 |
p_i = fprops_p((FluidState){T,rho[i],Helms[i]}, &err); |
p_i = fprops_p((FluidState){T,rho[i],Helms[i]}, &err); |
123 |
h_i = fprops_h((FluidState){T,rho[i],Helms[i]}, &err); |
h_i = fprops_h((FluidState){T,rho[i],Helms[i]}, &err); |
124 |
printf("\n\t%s %s\n\t\t%s %g Pa;\n\t\t%s %g J/kg.\n", |
printf("\n\t%s %s\n\t\t%s %g Pa;\n\t\t%s %g J/kg.\n", |
125 |
"For the substance ", FluidNames[i], |
"For the substance", FluidNames[i], |
126 |
"the pressure is :", p_i, |
"the pressure is :", p_i, |
127 |
"the enthalpy is :", h_i); |
"the enthalpy is :", h_i); |
128 |
p_mx += x[i] * p_i; |
p_mx += x[i] * p_i; |
129 |
h_mx += x[i] * h_i; |
h_mx += x[i] * h_i; |
130 |
} |
} |
131 |
printf("\n\t%s\t:\t %f kg/m3\n\t%s\t:\t %g Pa\n\t%s\t:\t %g J/kg\n", |
printf("\n\t%s\t\t:\t %f kg/m3\n\t%s\t:\t %g Pa\n\t%s\t\t:\t %g J/kg\n", |
132 |
"The density of the mixture is", rho_mx, |
"The density of the mixture is", rho_mx, |
133 |
"The average pressure of the mixture is", p_mx, |
"The average pressure of the mixture is", p_mx, |
134 |
"The enthalpy of the mixture is", h_mx); |
"The enthalpy of the mixture is", h_mx); |
135 |
|
|
136 |
|
/** |
137 |
|
Now I drop the assumption that densities can be calculated from the |
138 |
|
ideal-gas model, and use a root-finding method to find the densities |
139 |
|
that each component must have to be at the pressure P. |
140 |
|
|
141 |
|
That is, since ideal-solution mixing is isobaric (constant pressure), the |
142 |
|
density of each component is found by assuming it is at pressure P before |
143 |
|
mixing, and solving for the density that will satisfy that condition. |
144 |
|
*/ |
145 |
return 0; |
return 0; |
146 |
} |
} |