Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches
salinity.h
Go to the documentation of this file.
1// Copyright 2013-2021:
2// GobySoft, LLC (2013-)
3// Massachusetts Institute of Technology (2007-2014)
4// Community contributors (see AUTHORS file)
5// File authors:
6// Toby Schneider <toby@gobysoft.org>
7//
8//
9// This file is part of the Goby Underwater Autonomy Project Libraries
10// ("The Goby Libraries").
11//
12// The Goby Libraries are free software: you can redistribute them and/or modify
13// them under the terms of the GNU Lesser General Public License as published by
14// the Free Software Foundation, either version 2.1 of the License, or
15// (at your option) any later version.
16//
17// The Goby Libraries are distributed in the hope that they will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU Lesser General Public License for more details.
21//
22// You should have received a copy of the GNU Lesser General Public License
23// along with Goby. If not, see <http://www.gnu.org/licenses/>.
24
25#ifndef GOBY_UTIL_SALINITY_H
26#define GOBY_UTIL_SALINITY_H
27
28#include <cmath>
29
30#include <boost/units/quantity.hpp>
31#include <boost/units/systems/si.hpp>
33#include <boost/units/systems/temperature/celsius.hpp>
34
36#include "units.h"
37
38namespace goby
39{
40namespace util
41{
42namespace seawater
43{
44static const boost::units::quantity<decltype(milli_siemens_per_cm)> conductivity_at_standard{
45 42.914 * milli_siemens_per_cm}; // S = 35, T = 15 deg C, P = 0 dbar
46
54template <typename ConductivityUnit = decltype(milli_siemens_per_cm),
55 typename TemperatureUnit = boost::units::celsius::temperature,
56 typename PressureUnit = decltype(boost::units::si::deci* bar)>
57boost::units::quantity<boost::units::si::dimensionless>
58salinity(boost::units::quantity<ConductivityUnit> conductivity,
59 boost::units::quantity<boost::units::absolute<TemperatureUnit> > temperature,
60 boost::units::quantity<PressureUnit> pressure)
61{
62 using namespace boost::units;
63 double CND = quantity<decltype(milli_siemens_per_cm)>(conductivity) / conductivity_at_standard;
64 double T = quantity<absolute<celsius::temperature> >(temperature).value();
65 double P = quantity<decltype(si::deci * bar)>(pressure).value();
66
67 return quantity<si::dimensionless>(
69}
70
78template <typename TemperatureUnit = boost::units::celsius::temperature,
79 typename DimensionlessUnit = boost::units::si::dimensionless,
80 typename PressureUnit = decltype(boost::units::si::deci* bar)>
81boost::units::quantity<decltype(milli_siemens_per_cm)>
82conductivity(boost::units::quantity<DimensionlessUnit> salinity,
83 boost::units::quantity<boost::units::absolute<TemperatureUnit> > temperature,
84 boost::units::quantity<PressureUnit> pressure)
85{
86 using namespace boost::units;
87 double SAL = salinity;
88 double T = quantity<absolute<celsius::temperature> >(temperature).value();
89 double P = quantity<decltype(si::deci * bar)>(pressure).value();
90
94}
95
103template <typename TemperatureUnit = boost::units::celsius::temperature,
104 typename PressureUnit = decltype(boost::units::si::deci* bar)>
105boost::units::quantity<decltype(milli_siemens_per_cm)>
107 boost::units::quantity<boost::units::absolute<TemperatureUnit> > temperature,
108 boost::units::quantity<PressureUnit> pressure)
109{
110 return conductivity(boost::units::quantity<boost::units::si::dimensionless>(salinity),
111 temperature, pressure);
112}
113
114} // namespace seawater
115} // namespace util
116} // namespace goby
117
118#endif
static double compute(double CND, double T, double P, bool M)
static const boost::units::metric::bar_base_unit::unit_type bar
Definition units.h:36
static const decltype((boost::units::si::milli *boost::units::si::siemen)/(boost::units::si::centi *boost::units::si::meters) milli_siemens_per_cm)
Definition units.h:38
boost::units::quantity< decltype(boost::units::si::deci *bar)> pressure(boost::units::quantity< DepthUnit > depth, boost::units::quantity< LatitudeUnit > latitude)
Calculates pressure from depth and latitude.
Definition pressure.h:55
boost::units::quantity< decltype(milli_siemens_per_cm)> conductivity(boost::units::quantity< DimensionlessUnit > salinity, boost::units::quantity< boost::units::absolute< TemperatureUnit > > temperature, boost::units::quantity< PressureUnit > pressure)
Calculates conductivity from salinity, temperature, and pressure Adapted from "Algorithms for computa...
Definition salinity.h:82
boost::units::quantity< boost::units::si::dimensionless > salinity(boost::units::quantity< ConductivityUnit > conductivity, boost::units::quantity< boost::units::absolute< TemperatureUnit > > temperature, boost::units::quantity< PressureUnit > pressure)
Calculates salinity from conductivity, temperature, and pressure Adapted from "Algorithms for computa...
Definition salinity.h:58
static const boost::units::quantity< decltype(milli_siemens_per_cm)> conductivity_at_standard
Definition salinity.h:44
The global namespace for the Goby project.