Skip to content

Commit 0a2fe67

Browse files
committed
adds 2Pi, changes to Real, and updates tendency terms test
1 parent 0ee6238 commit 0a2fe67

File tree

2 files changed

+52
-49
lines changed

2 files changed

+52
-49
lines changed

components/omega/src/ocn/GlobalConstants.h

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,63 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14+
#include "DataTypes.h"
15+
1416
namespace OMEGA {
1517

1618
// Earth constants
17-
constexpr double Gravity = 9.80616; // Acceleration due to gravity ~ m/s^2
18-
constexpr double Pi = 3.14159265358979323846; // Pi
19-
constexpr double CDay = 86400.0; // Seconds in a calendar day ~ sec
20-
constexpr double SDay = 86164.0; // Seconds in a sidereal day ~ sec
21-
constexpr double Omega =
22-
2.0 * Pi / SDay; // Angular velocity of the Earth ~ rad/sec
23-
constexpr double REarth = 6.37122e6; // Mean radius of the Earth ~ m
19+
constexpr Real Gravity = 9.80616; // Acceleration due to gravity ~ m/s^2
20+
constexpr Real Pi = 3.14159265358979323846; // Pi
21+
constexpr Real TwoPi = 2.0 * Pi; // 2*Pi
22+
constexpr Real CDay = 86400.0; // Seconds in a calendar day ~ sec
23+
constexpr Real SDay = 86164.0; // Seconds in a sidereal day ~ sec
24+
constexpr Real Omega =
25+
2.0 * Pi / SDay; // Angular velocity of the Earth ~ rad/sec
26+
constexpr Real REarth = 6.37122e6; // Mean radius of the Earth ~ m
2427

2528
/// Physical constants
26-
constexpr double TkTrip = 273.16; // Triple point of fresh water ~ K
27-
constexpr double TkFrz = 273.15; // Freezing point of fresh water ~ K
28-
constexpr double TkFrzSw = TkFrz - 1.8; // Freezing point of seawater ~ K
29-
constexpr double RhoAir = 1.2; // Density of air ~ kg/m^3
30-
constexpr double RhoFw = 1.000e3; // Density of fresh water ~ kg/m^3
31-
constexpr double RhoSw = 1.026e3; // Density of seawater ~ kg/m^3
32-
constexpr double RhoIce = 0.917e3; // Density of ice ~ kg/m^3
33-
constexpr double CpAir = 1005.0; // Specific heat capacity of air ~ J/(kg*K)
34-
constexpr double CpFw =
29+
constexpr Real TkTrip = 273.16; // Triple point of fresh water ~ K
30+
constexpr Real TkFrz = 273.15; // Freezing point of fresh water ~ K
31+
constexpr Real TkFrzSw = TkFrz - 1.8; // Freezing point of seawater ~ K
32+
constexpr Real RhoAir = 1.2; // Density of air ~ kg/m^3
33+
constexpr Real RhoFw = 1.000e3; // Density of fresh water ~ kg/m^3
34+
constexpr Real RhoSw = 1.026e3; // Density of seawater ~ kg/m^3
35+
constexpr Real RhoIce = 0.917e3; // Density of ice ~ kg/m^3
36+
constexpr Real CpAir = 1.005e3; // Specific heat capacity of air ~ J/(kg*K)
37+
constexpr Real CpFw =
3538
4.188e3; // Specific heat capacity of fresh water ~ J/(kg*K)
36-
constexpr double CpSw =
37-
3.996e3; // Specific heat capacity of seawater ~ J/(kg*K)
38-
constexpr double CpIce = 2.108e3; // Specific heat capacity of ice ~ J/(kg*K)
39-
constexpr double LatIce = 3.337e5; // Latent heat of fusion ~ J/kg
40-
constexpr double LatVap = 2.501e6; // Latent heat of vaporization ~ J/kg
41-
constexpr double LatSub = LatIce + LatVap; // Latent heat of sublimation ~ J/kg
42-
constexpr double CondIce = 2.1; // Universal gas constant ~ J/(mol*K)
43-
constexpr double OcnRefSal = 34.7; // Reference ocean salinity ~ psu
44-
constexpr double IceRefSal = 4.0; // Reference ice salinity ~ psu
45-
constexpr double Sound = 1.5e2; // Speed of sound ~ m/s
46-
constexpr double VonKar = 0.4; // Von Karman constant ~ dimensionless
47-
constexpr double Emiss = 1.0; // Emissivity ~ dimensionless
48-
constexpr double AtmRefP = 101325.0; // Reference atmospheric pressure ~ Pa
39+
constexpr Real CpSw = 3.996e3; // Specific heat capacity of seawater ~ J/(kg*K)
40+
constexpr Real CpIce = 2.108e3; // Specific heat capacity of ice ~ J/(kg*K)
41+
constexpr Real LatIce = 3.337e5; // Latent heat of fusion ~ J/kg
42+
constexpr Real LatVap = 2.501e6; // Latent heat of vaporization ~ J/kg
43+
constexpr Real LatSub = LatIce + LatVap; // Latent heat of sublimation ~ J/kg
44+
constexpr Real CondIce = 2.1; // Universal gas constant ~ J/(mol*K)
45+
constexpr Real OcnRefSal = 34.7; // Reference ocean salinity ~ psu
46+
constexpr Real IceRefSal = 4.0; // Reference ice salinity ~ psu
47+
constexpr Real Sound = 1.5e2; // Speed of sound ~ m/s
48+
constexpr Real VonKar = 0.4; // Von Karman constant ~ dimensionless
49+
constexpr Real Emiss = 1.0; // Emissivity ~ dimensionless
50+
constexpr Real AtmRefP = 101325.0; // Reference atmospheric pressure ~ Pa
4951

5052
// Conversion factors
51-
constexpr double Sec2Day = 1.0 / 86400.0; // Seconds to days
52-
constexpr double Day2Sec = 86400.0; // Days to seconds
53-
constexpr double Salt2PPt = 1000.0; // Salinity (kg/kg) to parts per thousand
54-
constexpr double PPt2Salt = 1.0e-3; // Parts per thousand to salinity (kg/kg)
55-
constexpr double Mass2Sv = 1.0e-12; // Mass flux (kg/s) to Sverdrup
56-
constexpr double Heat2Pw = 4.186e-15; // Heat flux (W) to Petawatt
57-
constexpr double Salt2SvPpt = 1.0e-9; // Salt flux (kg/s) to Sv*ppt
58-
constexpr double Salt2MmDay = 3.1536e+5; // Salt flux to water flux (mm/day)
59-
constexpr double Db2Pa = 1.0e4; // Decibar to Pascal
60-
constexpr double Pa2Db = 1.0e-4; // Pascal to Decibar
61-
constexpr double Cm2M = 1.0e-2; // Centimeters to meters
62-
constexpr double M2Cm = 1.0e2; // Meters to centimeters
63-
constexpr double HFluxFac =
64-
1.0 / (RhoSw * CpSw); // Heat flux (W/m^2) to temp flux (C*m/s)
65-
constexpr double FwFluxFac = 1.e-6; // Fw flux (kg/m^2/s) to salt((msu/psu)*m/s)
66-
constexpr double SaltFac =
67-
-OcnRefSal * FwFluxFac; // Fw flux (kg/m^2/s) to salt flux (msu*m/s)
68-
constexpr double SFluxFac = 1.0; // Salt flux (kg/m^2/s) to salt flux (msu*m/s)
53+
constexpr Real Sec2Day = 1.0 / 86400.0; // Seconds to days
54+
constexpr Real Day2Sec = 86400.0; // Days to seconds
55+
constexpr Real Salt2PPt = 1000.0; // Salinity (kg/kg) to parts per thousand
56+
constexpr Real PPt2Salt = 1.0e-3; // Parts per thousand to salinity (kg/kg)
57+
constexpr Real Mass2Sv = 1.0e-12; // Mass flux (kg/s) to Sverdrup
58+
constexpr Real Heat2Pw = 4.186e-15; // Heat flux (W) to Petawatt
59+
constexpr Real Salt2SvPpt = 1.0e-9; // Salt flux (kg/s) to Sv*ppt
60+
constexpr Real Salt2MmDay = 3.1536e+5; // Salt flux to water flux (mm/day)
61+
constexpr Real Db2Pa = 1.0e4; // Decibar to Pascal
62+
constexpr Real Pa2Db = 1.0e-4; // Pascal to Decibar
63+
constexpr Real Cm2M = 1.0e-2; // Centimeters to meters
64+
constexpr Real M2Cm = 1.0e2; // Meters to centimeters
65+
constexpr Real HFluxFac =
66+
1.0 / (RhoSw * CpSw); // Heat flux (W/m^2) to temp flux (C*m/s)
67+
constexpr Real FwFluxFac = 1.e-6; // Fw flux (kg/m^2/s) to salt((msu/psu)*m/s)
68+
constexpr Real SaltFac =
69+
-OcnRefSal * FwFluxFac; // Fw flux (kg/m^2/s) to salt flux (msu*m/s)
70+
constexpr Real SFluxFac = 1.0; // Salt flux (kg/m^2/s) to salt flux (msu*m/s)
6971

7072
} // namespace OMEGA
7173
#endif

components/omega/test/ocn/TendencyTermsTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "Decomp.h"
2020
#include "Dimension.h"
2121
#include "Error.h"
22+
#include "GlobalConstants.h"
2223
#include "Halo.h"
2324
#include "HorzMesh.h"
2425
#include "IO.h"
@@ -524,8 +525,8 @@ int testSSHGrad(int NVertLayers, Real RTol) {
524525

525526
Err += setVectorEdge(
526527
KOKKOS_LAMBDA(Real(&VecField)[2], Real X, Real Y) {
527-
VecField[0] = -9.80665_Real * Setup.gradX(X, Y);
528-
VecField[1] = -9.80665_Real * Setup.gradY(X, Y);
528+
VecField[0] = -Gravity * Setup.gradX(X, Y);
529+
VecField[1] = -Gravity * Setup.gradY(X, Y);
529530
},
530531
ExactSSHGrad, EdgeComponent::Normal, Geom, Mesh, ExchangeHalos::No);
531532

0 commit comments

Comments
 (0)