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