Loading...
Searching...
No Matches
Units.hpp
//===========================================================================
//
// File: Units.hpp
//
// Created: Thu Jul 2 09:19:08 2009
//
// Author(s): Halvor M Nilsen <hnil@sintef.no>
//
// $Date$
//
// $Revision$
//
//===========================================================================
/*
Copyright 2009, 2010, 2011, 2012 SINTEF ICT, Applied Mathematics.
Copyright 2009, 2010, 2011, 2012 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_UNITS_HEADER
#define OPM_UNITS_HEADER
namespace Opm {
namespace prefix
{
constexpr const double micro = 1.0e-6;
constexpr const double milli = 1.0e-3;
constexpr const double centi = 1.0e-2;
constexpr const double deci = 1.0e-1;
constexpr const double kilo = 1.0e3;
constexpr const double mega = 1.0e6;
constexpr const double giga = 1.0e9;
} // namespace prefix
namespace unit
{
constexpr double square(double v) { return v * v; }
constexpr double cubic (double v) { return v * v * v; }
// --------------------------------------------------------------
// Basic (fundamental) units and conversions
// --------------------------------------------------------------
constexpr const double meter = 1;
constexpr const double inch = 2.54 * prefix::centi*meter;
constexpr const double feet = 12 * inch;
constexpr const double second = 1;
constexpr const double minute = 60 * second;
constexpr const double hour = 60 * minute;
constexpr const double day = 24 * hour;
constexpr const double year = 365 * day;
constexpr const double ecl_year = 365.25 * day;
constexpr const double gallon = 231 * cubic(inch);
constexpr const double stb = 42 * gallon;
constexpr const double liter = 1 * cubic(prefix::deci*meter);
constexpr const double kilogram = 1;
constexpr const double gram = 1.0e-3 * kilogram;
// http://en.wikipedia.org/wiki/Pound_(mass)#Avoirdupois_pound
constexpr const double pound = 0.45359237 * kilogram;
constexpr const double joule = 1;
constexpr const double btu = 1054.3503*joule; // "british thermal units"
// --------------------------------------------------------------
// Standardised constants
// --------------------------------------------------------------
constexpr const double gravity = 9.80665 * meter/square(second);
constexpr const double mol = 1;
// --------------------------------------------------------------
// Derived units and conversions
// --------------------------------------------------------------
constexpr const double Newton = kilogram*meter / square(second); // == 1
constexpr const double dyne = 1e-5*Newton;
constexpr const double lbf = pound * gravity; // Pound-force
constexpr const double Pascal = Newton / square(meter); // == 1
constexpr const double barsa = 100000 * Pascal;
constexpr const double atm = 101325 * Pascal;
constexpr const double psia = lbf / square(inch);
constexpr const double degCelsius = 1.0; // scaling factor °C -> K
constexpr const double degCelsiusOffset = 273.15; // offset for the °C -> K conversion
constexpr const double degFahrenheit = 5.0/9.0; // factor to convert a difference in °F to a difference in K
constexpr const double degFahrenheitOffset = 459.67*degFahrenheit; // °F -> K offset (i.e. how many K is 0 °F?)
constexpr const double Pas = Pascal * second; // == 1
constexpr const double Poise = prefix::deci*Pas;
constexpr const double ppm = 1. / prefix::mega;
namespace perm_details {
constexpr const double p_grad = atm / (prefix::centi*meter);
constexpr const double area = square(prefix::centi*meter);
constexpr const double flux = cubic (prefix::centi*meter) / second;
constexpr const double velocity = flux / area;
constexpr const double visc = prefix::centi*Poise;
constexpr const double darcy = (velocity * visc) / p_grad;
// == 1e-7 [m^2] / 101325
// == 9.869232667160130e-13 [m^2]
}
constexpr const double darcy = perm_details::darcy;
namespace convert {
constexpr double from(const double q, const double unit)
{
return q * unit;
}
constexpr double to(const double q, const double unit)
{
return q / unit;
}
} // namespace convert
}
namespace Metric {
using namespace prefix;
using namespace unit;
constexpr const double Pressure = barsa;
constexpr const double Temperature = degCelsius;
constexpr const double TemperatureOffset = degCelsiusOffset;
constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical
constexpr const double Length = meter;
constexpr const double Time = day;
constexpr const double RunTime = second;
constexpr const double Mass = kilogram;
constexpr const double Permeability = milli*darcy;
constexpr const double Transmissibility = centi*Poise*cubic(meter)/(day*barsa);
constexpr const double LiquidSurfaceVolume = cubic(meter);
constexpr const double GasSurfaceVolume = cubic(meter);
constexpr const double ReservoirVolume = cubic(meter);
constexpr const double Area = square(meter);
constexpr const double GeomVolume = cubic(meter);
constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume;
constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume;
constexpr const double Density = kilogram/cubic(meter);
constexpr const double PolymerDensity = kilogram/cubic(meter);
constexpr const double FoamDensity = kilogram/cubic(meter);
constexpr const double FoamSurfactantConcentration = kilogram/cubic(meter);
constexpr const double Salinity = kilogram/cubic(meter);
constexpr const double Viscosity = centi*Poise;
constexpr const double Timestep = day;
constexpr const double SurfaceTension = dyne/(centi*meter);
constexpr const double Energy = kilo*joule;
constexpr const double Moles = kilo*mol;
constexpr const double PPM = ppm;
constexpr const double Ymodule = giga*Pascal;
}
namespace Field {
using namespace prefix;
using namespace unit;
constexpr const double Pressure = psia;
constexpr const double Temperature = degFahrenheit;
constexpr const double TemperatureOffset = degFahrenheitOffset;
constexpr const double AbsoluteTemperature = degFahrenheit; // actually [°R], but the these two are identical
constexpr const double Length = feet;
constexpr const double Time = day;
constexpr const double RunTime = second;
constexpr const double Mass = pound;
constexpr const double Permeability = milli*darcy;
constexpr const double Transmissibility = centi*Poise*stb/(day*psia);
constexpr const double LiquidSurfaceVolume = stb;
constexpr const double GasSurfaceVolume = 1000*cubic(feet);
constexpr const double ReservoirVolume = stb;
constexpr const double Area = square(feet);
constexpr const double GeomVolume = cubic(feet);
constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume;
constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume;
constexpr const double Density = pound/cubic(feet);
constexpr const double PolymerDensity = pound/stb;
constexpr const double FoamDensity = pound/GasSurfaceVolume;
constexpr const double FoamSurfactantConcentration = pound/stb;
constexpr const double Salinity = pound/stb;
constexpr const double Viscosity = centi*Poise;
constexpr const double Timestep = day;
constexpr const double SurfaceTension = dyne/(centi*meter);
constexpr const double Energy = btu;
constexpr const double Moles = kilo*pound*mol;
constexpr const double PPM = ppm;
constexpr const double Ymodule = giga*Pascal;
}
namespace Lab {
using namespace prefix;
using namespace unit;
constexpr const double Pressure = atm;
constexpr const double Temperature = degCelsius;
constexpr const double TemperatureOffset = degCelsiusOffset;
constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical
constexpr const double Length = centi*meter;
constexpr const double Time = hour;
constexpr const double RunTime = second;
constexpr const double Mass = gram;
constexpr const double Permeability = milli*darcy;
constexpr const double Transmissibility = centi*Poise*cubic(centi*meter)/(hour*atm);
constexpr const double LiquidSurfaceVolume = cubic(centi*meter);
constexpr const double GasSurfaceVolume = cubic(centi*meter);
constexpr const double ReservoirVolume = cubic(centi*meter);
constexpr const double Area = square(centi*meter);
constexpr const double GeomVolume = cubic(centi*meter);
constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume;
constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume;
constexpr const double Density = gram/cubic(centi*meter);
constexpr const double PolymerDensity = gram/cubic(centi*meter);
constexpr const double FoamDensity = gram/cubic(centi*meter);
constexpr const double FoamSurfactantConcentration = gram/cubic(centi*meter);
constexpr const double Salinity = gram/cubic(centi*meter);
constexpr const double Viscosity = centi*Poise;
constexpr const double Timestep = hour;
constexpr const double SurfaceTension = dyne/(centi*meter);
constexpr const double Energy = joule;
constexpr const double Moles = mol;
constexpr const double PPM = ppm;
constexpr const double Ymodule = giga*Pascal;
}
namespace PVT_M {
using namespace prefix;
using namespace unit;
constexpr const double Pressure = atm;
constexpr const double Temperature = degCelsius;
constexpr const double TemperatureOffset = degCelsiusOffset;
constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical
constexpr const double Length = meter;
constexpr const double Time = day;
constexpr const double RunTime = second;
constexpr const double Mass = kilogram;
constexpr const double Permeability = milli*darcy;
constexpr const double Transmissibility = centi*Poise*cubic(meter)/(day*atm);
constexpr const double LiquidSurfaceVolume = cubic(meter);
constexpr const double GasSurfaceVolume = cubic(meter);
constexpr const double ReservoirVolume = cubic(meter);
constexpr const double Area = square(meter);
constexpr const double GeomVolume = cubic(meter);
constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume;
constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume;
constexpr const double Density = kilogram/cubic(meter);
constexpr const double PolymerDensity = kilogram/cubic(meter);
constexpr const double FoamDensity = kilogram/cubic(meter);
constexpr const double FoamSurfactantConcentration = kilogram/cubic(meter);
constexpr const double Salinity = kilogram/cubic(meter);
constexpr const double Viscosity = centi*Poise;
constexpr const double Timestep = day;
constexpr const double SurfaceTension = dyne/(centi*meter);
constexpr const double Energy = kilo*joule;
constexpr const double Moles = kilo*mol;
constexpr const double PPM = ppm;
constexpr const double Ymodule = giga*Pascal;
}
}
#endif // OPM_UNITS_HEADER
Opm::prefix::deci
constexpr const double deci
Non-standard unit prefix [d].
Definition Units.hpp:63
Opm::prefix::giga
constexpr const double giga
Unit prefix [G].
Definition Units.hpp:66
Opm::prefix::micro
constexpr const double micro
Unit prefix [ ].
Definition Units.hpp:60
Opm::prefix::kilo
constexpr const double kilo
Unit prefix [k].
Definition Units.hpp:64
Opm::prefix::milli
constexpr const double milli
Unit prefix [m].
Definition Units.hpp:61
Opm::prefix::mega
constexpr const double mega
Unit prefix [M].
Definition Units.hpp:65
Opm::prefix::centi
constexpr const double centi
Non-standard unit prefix [c].
Definition Units.hpp:62
Opm::unit::convert::to
constexpr double to(const double q, const double unit)
Convert from internal units of measurements to equivalent external units of measurements.
Definition Units.hpp:250
Opm::unit::convert::from
constexpr double from(const double q, const double unit)
Convert from external units of measurements to equivalent internal units of measurements.
Definition Units.hpp:227
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30