Cantera  2.0
FtnTransport.h
Go to the documentation of this file.
1 /**
2  * @file FtnTransport.h
3  *
4  * Customizable Fortran transport manager. This manager calls
5  * external Fortran functions to evaluate the transport
6  * properties. This is designed to be used to build custom transport
7  * managers in Fortran.
8  */
9 
10 // Copyright 2003 California Institute of Technology
11 
12 
13 #ifndef CT_FTNTRANSPORT_H
14 #define CT_FTNTRANSPORT_H
15 
17 
18 
19 /**
20  * Change these definitions to change the names of the Fortran
21  * procedures. If you want to define more than one custom Fortran
22  * transport manager, copy this file, rename the class, and change
23  * these definitions.
24  *
25  * The Fortran procedure names must follow the conventions of the Fortran
26  * compiler. On most unix systems, this means the names must be lowercase,
27  * and must include a trailing underscore.
28  *
29  */
30 #define __VISC__ visc_
31 #define __BULKVISC__ bvisc_
32 #define __TCON__ tcon_
33 #define __TDIFF__ tdiff_
34 #define __MULTIDIFF__ multidiff_
35 #define __MIXDIFF__ mixdiff_
36 #define __SIGMA__ sigma_
37 #define __GETMOBILITIES__ getmobilities_
38 
39 
40 extern "C" {
41 
42  doublereal __VISC__(doublereal* t, doublereal* p, doublereal* x);
43  doublereal __BULKVISC__(doublereal* t, doublereal* p, doublereal* x);
44  doublereal __TCON__(doublereal* t, doublereal* p, doublereal* x);
45 
46  void __TDIFF__(doublereal* t, doublereal* p, doublereal* x, doublereal* dt);
47  void __MULTIDIFF__(doublereal* t, doublereal* p, doublereal* x,
48  integer* ld, doublereal* d);
49  void __MIXDIFF__(doublereal* t, doublereal* p, doublereal* x, doublereal* d);
50  void __BINDIFF__(doublereal* t, doublereal* p, doublereal* x, integer* ld, doublereal* d);
51  doublereal __SIGMA__(doublereal* t, doublereal* p, doublereal* x);
52 
53  doublereal __GETMOBILITIES__(doublereal* t, doublereal* p,
54  doublereal* x, doublereal* mobil);
55 
56 }
57 
58 namespace Cantera
59 {
60 
61 /**
62  * A class that calls external Fortran functions to evaluate
63  * transport properties.
64  */
65 class FtnTransport : public Transport
66 {
67 
68 public:
69 
70  FtnTransport(int model, thermo_t* thermo) : Transport(thermo) {
71  m_model = model;
72  m_x.resize(m_thermo->nSpecies(), 0.0);
73  updateTPX();
74  }
75 
76  virtual int model() {
77  return cFtnTransport + m_model;
78  }
79 
80  virtual doublereal viscosity() {
81  updateTPX();
82  return __VISC__(&m_temp, &m_pres, m_x.begin());
83  }
84 
85  virtual doublereal bulkViscosity() {
86  updateTPX();
87  return __BULKVISC__(&m_temp, &m_pres, m_x.begin());
88  }
89 
90  virtual doublereal thermalConductivity() {
91  updateTPX();
92  return __TCON__(&m_temp, &m_pres, m_x.begin());
93  }
94 
95  virtual doublereal electricalConductivity() {
96  updateTPX();
97  return __SIGMA__(&m_temp, &m_pres, m_x.begin());
98  }
99 
100  virtual void getMobilities(doublereal* mobil) {
101  updateTPX();
102  __GETMOBILITIES__(&m_temp, &m_pres, m_x.begin(), mobil);
103  }
104 
105 
106  virtual void getThermalDiffCoeffs(doublereal* dt) {
107  updateTPX();
108  __TDIFF__(&m_temp, &m_pres, m_x.begin(), dt);
109  }
110 
111  virtual void getBinaryDiffCoeffs(int ld, doublereal* d) {
112  updateTPX();
113  integer ldd = ld;
114  __BINDIFF__(&m_temp, &m_pres, m_x.begin(), &ldd, d);
115  }
116 
117  virtual void getMultiDiffCoeffs(int ld, doublereal* d) {
118  updateTPX();
119  integer ldd = ld;
120  __MULTIDIFF__(&m_temp, &m_pres, m_x.begin(), &ldd, d);
121  }
122 
123  virtual void getMixDiffCoeffs(doublereal* d) {
124  updateTPX();
125  __MIXDIFF__(&m_temp, &m_pres, m_x.begin(), d);
126  }
127 
128 
129 private:
130 
131  void updateTPX() {
132  m_temp = m_thermo->temperature();
133  m_pres = m_thermo->pressure();
134  m_thermo->getMoleFractions(m_x.begin());
135  }
136  doublereal m_temp;
137  doublereal m_pres;
138  vector_fp m_x;
139  int m_model;
140 
141 };
142 
143 }
144 #endif
145 
146 
147 
148 
149 
150