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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2751 - (show annotations) (download) (as text)
Tue Mar 11 10:44:09 2014 UTC (4 years, 6 months ago) by jpye
File MIME type: text/x-csrc
File size: 2247 byte(s)
viscosity test running, but wrong.
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 "visc.h"
20 #include <math.h>
21
22 #define VISC_DEBUG
23 #ifdef VISC_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 ViscosityData *visc_prepare(const EosData *E, const PureFluid *P, FpropsError *err){
33 MSG("Preparing viscosity");
34 return E->visc;
35 }
36
37 /*----------------------FIRST CORRELATION---------------------------*/
38 /*
39 perhaps v1 data should include 0.0266958/SQ(sigma)?
40 */
41
42 double visc1_ci1(ViscCI1Data *ci1, double Tstar){
43 double res = 0;
44 double lnTstar = log(Tstar);
45 int i;
46 for(i=0; i<ci1->nt; ++i){
47 res += ci1->t[i].b * pow(lnTstar, ci1->t[i].i);
48 }
49 return exp(res);
50 }
51
52 double visc1_mu(FluidState state, FpropsError *err){
53 if(state.fluid->visc->type != FPROPS_VISC_1){
54 *err = FPROPS_INVALID_REQUEST;
55 return NAN;
56 }
57
58 double Omega;
59 ViscosityData1 *v1 = &(state.fluid->visc->data.v1);
60 switch(v1->ci.type){
61 case FPROPS_CI_1:
62 Omega = visc1_ci1(&(v1->ci.data.ci1),state.T / v1->eps_over_k);
63 break;
64 default:
65 *err = FPROPS_INVALID_REQUEST;
66 return NAN;
67 }
68 double mu0 = 0.0266958 * sqrt(v1->M * state.T) / SQ(v1->sigma) / Omega;
69 double mur = 0;
70 double tau = state.fluid->data->T_c / state.T;
71 double del = state.rho / state.fluid->data->rho_c;
72 int i;
73 for(i=0; i<v1->nt; ++i){
74 double mu1i = v1->t[i].N * pow(tau, v1->t[i].t) * pow(del, v1->t[i].d);
75 if(0 == v1->t[i].l){
76 mur += mu1i;
77 }else{
78 mur += mu1i * exp(-pow(del, v1->t[i].l));
79 }
80 }
81 /* TODO something about critical point terms? */
82 return mu0 + mur;
83 }
84
85

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