initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / thermophysicalModels / thermophysicalFunctions / APIfunctions / APIdiffCoefFunc / APIdiffCoefFunc.H
blob7f95e450e3e205d506c1d1dd9af1384a8c66c83a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::APIdiffCoefFunc
28 Description
29     API function for vapour mass diffusivity
31     Source:
32     @verbatim
33             API (American Petroleum Institute)
34                     Technical Data Book
35     @endverbatim
37 \*---------------------------------------------------------------------------*/
39 #ifndef APIdiffCoefFunc_H
40 #define APIdiffCoefFunc_H
42 #include "thermophysicalFunction.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 /*---------------------------------------------------------------------------*\
50                       Class APIdiffCoefFunc Declaration
51 \*---------------------------------------------------------------------------*/
53 class APIdiffCoefFunc
55     public thermophysicalFunction
57     // Private data
59         // API vapour mass diffusivity function coefficients
60         scalar a_, b_, wf_, wa_;
62         // Helper variables
63         scalar alpha_, beta_;
66 public:
68     //- Runtime type information
69     TypeName("APIdiffCoefFunc");
72     // Constructors
74         //- Construct from components
75         APIdiffCoefFunc(scalar a, scalar b, scalar wf, scalar wa)
76         :
77             a_(a),
78             b_(b),
79             wf_(wf),
80             wa_(wa),
81             alpha_(sqrt(1/wf_ + 1/wa_)),
82             beta_(sqr((cbrt(a_) + cbrt(b_))))
83         {}
85         //- Construct from Istream
86         APIdiffCoefFunc(Istream& is)
87         :
88             a_(readScalar(is)),
89             b_(readScalar(is)),
90             wf_(readScalar(is)),
91             wa_(readScalar(is)),
92             alpha_(sqrt(1/wf_ + 1/wa_)),
93             beta_(sqr((cbrt(a_) + cbrt(b_))))
94         {}
97     // Member Functions
99         //- API vapour mass diffusivity function using properties from
100         //  construction
101         scalar f(scalar p, scalar T) const
102         {
103             return 3.6059e-3*(pow(1.8*T, 1.75))*alpha_/(p*beta_);
104         }
106         //- Write the function coefficients
107         void writeData(Ostream& os) const
108         {
109             os  << a_ << token::SPACE
110                 << b_ << token::SPACE
111                 << wf_ << token::SPACE
112                 << wa_;
113         }
116     // Ostream Operator
118         friend Ostream& operator<<(Ostream& os, const APIdiffCoefFunc& f)
119         {
120             f.writeData(os);
121             return os;
122         }
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 } // End namespace Foam
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 #endif
134 // ************************************************************************* //