30 #ifndef GOBY_UTIL_SEAWATER_SWSTATE_H
31 #define GOBY_UTIL_SEAWATER_SWSTATE_H
35 #include <boost/units/quantity.hpp>
36 #include <boost/units/systems/si.hpp>
38 #include <boost/units/systems/temperature/celsius.hpp>
56 typename TemperatureUnit = boost::units::celsius::temperature,
57 typename PressureUnit = decltype(boost::units::si::deci*
bar)>
58 boost::units::quantity<boost::units::si::mass_density>
60 boost::units::quantity<boost::units::absolute<TemperatureUnit> > temperature,
61 boost::units::quantity<PressureUnit>
pressure)
66 double T = quantity<absolute<celsius::temperature> >(temperature).value();
67 double P0 = quantity<decltype(si::deci * bar)>(
pressure).value();
121 double R3500 = 1028.1063;
122 double R4 = 4.8314E-4;
123 double DR350 = 28.106331;
128 double SR = sqrt(abs(S));
133 double R1 = ((((6.536332E-9 * T - 1.120083E-6) * T + 1.001685E-4) * T - 9.095290E-3) * T +
139 double R2 = (((5.3875E-9 * T - 8.2467E-7) * T + 7.6438E-5) * T - 4.0899E-3) * T + 8.24493E-1;
140 double R3 = (-1.6546E-6 * T + 1.0227E-4) * T - 5.72466E-3;
142 double SIG = (R4 * S + R3 * SR + R2) * S + R1;
144 double V350P = 1.0 / R3500;
145 double SVA = -SIG * V350P / (R3500 + SIG);
158 double E = (9.1697E-10 * T + 2.0816E-8) * T - 9.9348E-7;
159 double BW = (5.2787E-8 * T - 6.12293E-6) * T + 3.47718E-5;
160 double B = BW + E * S;
164 double D = 1.91075E-4;
165 double C = (-1.6078E-6 * T - 1.0981E-5) * T + 2.2838E-3;
166 double AW = ((-5.77905E-7 * T + 1.16092E-4) * T + 1.43713E-3) * T - 0.1194975;
167 double A = (D * SR + C) * S + AW;
171 double B1 = (-5.3009E-4 * T + 1.6483E-2) * T + 7.944E-2;
172 double A1 = ((-6.1670E-5 * T + 1.09987E-2) * T - 0.603459) * T + 54.6746;
173 double KW = (((-5.155288E-5 * T + 1.360477E-2) * T - 2.327105) * T + 148.4206) * T - 1930.06;
174 double K0 = (B1 * SR + A1) * S + KW;
182 double DK = (
B * P + A) * P + K0;
183 double K35 = (5.03217E-5 * P + 3.359406) * P + 21582.27;
184 double GAM = P / K35;
185 double PK = 1.0 - GAM;
186 SVA = SVA * PK + (V350P + SVA) * P * DK / (K35 * (K35 + DK));
199 double DR35P = GAM / V350P;
200 double DVAN = SVA / (V350P * (V350P + SVA));
201 double SIGMA = DR350 + DR35P - DVAN;
203 return SIGMA * si::kilograms_per_cubic_meter;
213 template <
typename TemperatureUnit = boost::units::celsius::temperature,
214 typename PressureUnit = decltype(boost::units::si::deci*
bar)>
215 boost::units::quantity<boost::units::si::mass_density>
217 boost::units::quantity<boost::units::absolute<TemperatureUnit> > temperature,
218 boost::units::quantity<PressureUnit>
pressure)