/[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 2756 - (show annotations) (download) (as text)
Thu Mar 20 06:07:13 2014 UTC (4 years, 7 months ago) by jpye
File MIME type: text/x-csrc
File size: 2206 byte(s)
working on test code for thcond.
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 <math.h>
21
22 #define THCOND_DEBUG
23 #ifdef THCOND_DEBUG
24 # include "color.h"
25 # define MSG FPROPS_MSG
26 # define ERRMSG FPROPS_ERRMSG
27 #else
28 # define MSG(ARGS...) ((void)0)
29 # define ERRMSG(ARGS...) ((void)0)
30 #endif
31
32 void thcond_prepare(PureFluid *P, const ThermalConductivityData *K, FpropsError *err){
33 MSG("Preparing thermal conductivity: currently we are just reusing the FileData pointer; no changes");
34 P->thcond = K;
35
36 }
37
38 double thcond1_k(FluidState state, FpropsError *err){
39 // if we are here, we should be able to assume that state, should be able to remove following test (convert to assert)
40 if(state.fluid->thcond->type != FPROPS_THCOND_1){
41 *err = FPROPS_INVALID_REQUEST;
42 return NAN;
43 }
44
45 const ThermalConductivityData1 *k1 = &(state.fluid->thcond->data.k1);
46
47 // value for the conductivity at the zero-density limit
48 double r;
49 double CS_star;
50 double lam0 = 0.475598 * sqrt(state.T) * (1 + SQ(r)) / CS_star;
51
52 // value for the residual thermal conductivity
53 double lamr = 0;
54 double tau = k1->T_star / state.T;
55 double del = state.rho / k1->rho_star;
56 int i = 0;
57 for(i=0; i < k1->nr; ++i){
58 double lamri = k1->rt[i].N * pow(tau, k1->rt[i].t) * pow(del, k1->rt[i].d);
59 if(0 == k1->rt[i].l){
60 lamr += lamri;
61 }else{
62 lamr += lamri * exp(-pow(del, k1->rt[i].l));
63 }
64 }
65
66 double lamc = 0;
67 if(!(k1->crit)){
68 MSG("No critical enhancement function provided");
69 }else{
70 MSG("Critical enhancement function not yet implemented");
71 }
72
73 return k1->k_star * (lam0 + lamr + lamc);
74 }
75
76
77
78
79
80
81
82
83
84
85
86
87
88

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