specieI.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "specie.H"
00028
00029
00030
00031 namespace Foam
00032 {
00033
00034
00035
00036
00037 inline specie::specie
00038 (
00039 const word& name,
00040 const scalar nMoles,
00041 const scalar molWeight
00042 )
00043 :
00044 name_(name),
00045 nMoles_(nMoles),
00046 molWeight_(molWeight)
00047 {}
00048
00049
00050
00051 inline specie::specie
00052 (
00053 const scalar nMoles,
00054 const scalar molWeight
00055 )
00056 :
00057
00058 nMoles_(nMoles),
00059 molWeight_(molWeight)
00060 {}
00061
00062
00063
00064
00065
00066 inline specie::specie(const specie& st)
00067 :
00068 name_(st.name_),
00069 nMoles_(st.nMoles_),
00070 molWeight_(st.molWeight_)
00071 {}
00072
00073
00074
00075 inline specie::specie(const word& name, const specie& st)
00076 :
00077 name_(name),
00078 nMoles_(st.nMoles_),
00079 molWeight_(st.molWeight_)
00080 {}
00081
00082
00083
00084
00085
00086 inline scalar specie::W() const
00087 {
00088 return molWeight_;
00089 }
00090
00091
00092 inline scalar specie::nMoles() const
00093 {
00094 return nMoles_;
00095 }
00096
00097
00098 inline scalar specie::R() const
00099 {
00100 return RR/molWeight_;
00101 }
00102
00103
00104
00105
00106 inline void specie::operator=(const specie& st)
00107 {
00108
00109 nMoles_ = st.nMoles_;
00110 molWeight_ = st.molWeight_;
00111 }
00112
00113
00114 inline void specie::operator+=(const specie& st)
00115 {
00116 scalar sumNmoles_ = max(nMoles_ + st.nMoles_, SMALL);
00117
00118 molWeight_ =
00119 nMoles_/sumNmoles_*molWeight_
00120 + st.nMoles_/sumNmoles_*st.molWeight_;
00121
00122 nMoles_ = sumNmoles_;
00123 }
00124
00125
00126 inline void specie::operator-=(const specie& st)
00127 {
00128 scalar diffnMoles_ = nMoles_ - st.nMoles_;
00129 if (mag(diffnMoles_) < SMALL)
00130 {
00131 diffnMoles_ = SMALL;
00132 }
00133
00134 molWeight_ =
00135 nMoles_/diffnMoles_*molWeight_
00136 - st.nMoles_/diffnMoles_*st.molWeight_;
00137
00138 nMoles_ = diffnMoles_;
00139 }
00140
00141
00142 inline void specie::operator*=(const scalar s)
00143 {
00144 nMoles_ *= s;
00145 }
00146
00147
00148
00149
00150 inline specie operator+(const specie& st1, const specie& st2)
00151 {
00152 scalar sumNmoles_ = max(st1.nMoles_ + st2.nMoles_, SMALL);
00153
00154 return specie
00155 (
00156 sumNmoles_,
00157 st1.nMoles_/sumNmoles_*st1.molWeight_
00158 + st2.nMoles_/sumNmoles_*st2.molWeight_
00159 );
00160 }
00161
00162
00163 inline specie operator-(const specie& st1, const specie& st2)
00164 {
00165 scalar diffNmoles_ = st1.nMoles_ - st2.nMoles_;
00166 if (mag(diffNmoles_) < SMALL)
00167 {
00168 diffNmoles_ = SMALL;
00169 }
00170
00171 return specie
00172 (
00173 diffNmoles_,
00174 st1.nMoles_/diffNmoles_*st1.molWeight_
00175 - st2.nMoles_/diffNmoles_*st2.molWeight_
00176 );
00177 }
00178
00179
00180 inline specie operator*(const scalar s, const specie& st)
00181 {
00182 return specie
00183 (
00184 s*st.nMoles_,
00185 st.molWeight_
00186 );
00187 }
00188
00189
00190 inline specie operator==(const specie& st1, const specie& st2)
00191 {
00192 return st2 - st1;
00193 }
00194
00195
00196
00197
00198 }
00199
00200
Copyright © 2000-2009 OpenCFD Ltd