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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2759 - (show annotations) (download) (as text)
Fri Mar 21 11:25:55 2014 UTC (3 years, 8 months ago) by jpye
File MIME type: text/x-csrc
File size: 3448 byte(s)
thcond test for nitrogen.
1 /* ASCEND modelling environment
2 Copyright (C) 2014 John Pye
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19 #include "thcond.h"
20 #include "visc.h"
21 #include <math.h>
22
23 #define THCOND_DEBUG
24 #ifdef THCOND_DEBUG
25 # include "color.h"
26 # define MSG FPROPS_MSG
27 # define ERRMSG FPROPS_ERRMSG
28 #else
29 # define MSG(ARGS...) ((void)0)
30 # define ERRMSG(ARGS...) ((void)0)
31 #endif
32
33 void thcond_prepare(PureFluid *P, const ThermalConductivityData *K, FpropsError *err){
34 MSG("Preparing thermal conductivity: currently we are just reusing the FileData pointer; no changes");
35 P->thcond = K;
36
37 }
38
39 static double thcond1_cs(const ThermalConductivityData1 *K, double Tstar){
40 double res = 0;
41 int i;
42 for(i=0; i < K->nc; ++i){
43 MSG("b[%d] = %e, i = %d",i,K->ct[i].b, K->ct[i].i);
44 res += K->ct[i].b * pow(Tstar, K->ct[i].i);
45 }
46 return exp(res);
47 }
48
49 double thcond1_k(FluidState state, FpropsError *err){
50 // if we are here, we should be able to assume that state, should be able to remove following test (convert to assert)
51 if(state.fluid->thcond->type != FPROPS_THCOND_1){
52 *err = FPROPS_INVALID_REQUEST;
53 return NAN;
54 }
55
56 const ThermalConductivityData1 *k1 = &(state.fluid->thcond->data.k1);
57
58 // value for the conductivity at the zero-density limit
59 double lam0 = 0;
60
61 if(0==strcmp(state.fluid->name,"carbondioxide")){
62 MSG("lam0 for carbondioxide");
63 /* TODO NAUGHTY! this is code specifically for CO2... */
64 int i;
65 double sum1 = 0;
66 double c[] = {2.387869e-2, 4.350794, -10.33404, 7.981590, -1.940558};
67 for(i=1; i<=5; ++i){
68 sum1 += c[i] * pow(state.T/100, 2-i);
69 }
70 double cint_over_k = 1.0 + exp(-183.5/state.T)*sum1;
71 MSG("cint/k = %f",cint_over_k);
72 double r = sqrt(0.4*cint_over_k);
73 MSG("r = %f",r);
74 double CS_star = thcond1_cs(k1, k1->T_star/state.T);
75 lam0 = 0.475598 * sqrt(state.T) * (1 + SQ(r)) / CS_star;
76 /* END of code specifically for CO2 */
77 }else if(0==strcmp(state.fluid->name,"nitrogen")){
78 MSG("lam0 for nitrogen");
79 double N1 = 1.511;
80 double N2 = 2.117, t2 = -1.;
81 double N3 = -3.332, t3 = -0.7;
82 double tau = k1->T_star / state.T;
83 lam0 = N1 * (visc1_mu0(state,err)/1e-6) + N2 * pow(tau,t2) + N3 * pow(tau,t3);
84 }else{
85 ERRMSG("lam0 not implemented");
86 *err = FPROPS_NOT_IMPLEMENTED;
87 return 0;
88 }
89 MSG("lam0 = %e",lam0);
90
91 // value for the residual thermal conductivity
92 double lamr = 0;
93 double tau = k1->T_star / state.T;
94 double del = state.rho / k1->rho_star;
95 int i;
96 for(i=0; i < k1->nr; ++i){
97 double lamri = k1->rt[i].N * pow(tau, k1->rt[i].t) * pow(del, k1->rt[i].d);
98 if(0 == k1->rt[i].l){
99 lamr += lamri;
100 }else{
101 lamr += lamri * exp(-pow(del, k1->rt[i].l));
102 }
103 }
104 MSG("lamr = %e",lamr);
105
106 double lamc = 0;
107 if(!(k1->crit)){
108 MSG("No critical enhancement function provided");
109 }else{
110 MSG("Critical enhancement function not yet implemented");
111 }
112 MSG("lamc = %e",lamc);
113
114 return k1->k_star * (lam0 + lamr + lamc);
115 }
116
117
118
119
120
121
122
123
124
125

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