From 58e38a761f33d32af06ab546407deb93c4fd82cc Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 13 Dec 2023 14:34:32 +0000 Subject: [PATCH] constants: Standardise use of kmol instead of mol This prevents spurious factors of 1000 from being introduced in thermodynamic models. It also generalises the system further with respect to alternative unit sets. --- applications/solvers/chemFoam/pEqn.H | 2 +- etc/controlDict | 8 ++++++-- .../materials/air/physicalProperties | 2 +- .../materials/aluminium/physicalProperties | 2 +- .../materials/copper/physicalProperties | 2 +- .../materials/water/physicalProperties | 2 +- .../fundamental/fundamentalConstants.C | 8 ++------ .../physicoChemicalConstants.C | 19 ++----------------- .../physicoChemicalConstants.H | 7 ++----- .../specie/specie/specie.C | 1 - .../constant/fluid/physicalProperties | 2 +- .../materials/air/physicalProperties | 2 +- .../materials/aluminium/physicalProperties | 2 +- .../materials/copper/physicalProperties | 2 +- .../materials/water/physicalProperties | 2 +- 15 files changed, 22 insertions(+), 41 deletions(-) diff --git a/applications/solvers/chemFoam/pEqn.H b/applications/solvers/chemFoam/pEqn.H index 7d62559817..d7b97bbc9b 100644 --- a/applications/solvers/chemFoam/pEqn.H +++ b/applications/solvers/chemFoam/pEqn.H @@ -8,7 +8,7 @@ invW += Y[i][0]/W[i]; } - Rspecific[0] = 1000.0*constant::physicoChemical::R.value()*invW; + Rspecific[0] = constant::physicoChemical::RR.value()*invW; p[0] = rho0*Rspecific[0]*thermo.T()[0]; rho[0] = rho0; diff --git a/etc/controlDict b/etc/controlDict index 3df63c8e96..bc66ae9e1e 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -120,6 +120,7 @@ DimensionedConstants physicoChemical { mu [1 0 0 0 0 0 0] 1.66054e-27; + NA [0 0 0 0 -1 0 0] 6.02214e+26; k [1 2 -2 -1 0 0 0] 1.38065e-23; } @@ -156,6 +157,7 @@ DimensionedConstants physicoChemical { mu [1 0 0 0 0 0 0] 3.66083e-27; + NA [0 0 0 0 -1 0 0] 6.02214e+26; k [1 2 -2 -1 0 0 0] 1.82012e-22; } @@ -182,7 +184,7 @@ DimensionSets m [0 1 0 0 0 0 0] 1; s [0 0 1 0 0 0 0] 1; K [0 0 0 1 0 0 0] 1; - mol [0 0 0 0 1 0 0] 1; + kmol [0 0 0 0 1 0 0] 1; A [0 0 0 0 0 1 0] 1; Cd [0 0 0 0 0 0 1] 1; @@ -204,11 +206,13 @@ DimensionSets // UniformDimensionedField. Not supported in DimensionedField or // GeometricField. g [kg] 1e-3; + um [m] 1e-6; mm [m] 1e-3; cm [m] 1e-2; km [m] 1e3; us [s] 1e-6; ms [s] 1e-3; + mol [kmol] 1e-3; } USCSCoeffs @@ -218,7 +222,7 @@ DimensionSets ft [0 1 0 0 0 0 0] 1; s [0 0 1 0 0 0 0] 1; R [0 0 0 1 0 0 0] 1; - mol [0 0 0 0 1 0 0] 1; + kmol [0 0 0 0 1 0 0] 1; A [0 0 0 0 0 1 0] 1; Cd [0 0 0 0 0 0 1] 1; } diff --git a/etc/templates/singleFluidCHT/templates/materials/air/physicalProperties b/etc/templates/singleFluidCHT/templates/materials/air/physicalProperties index c0a4b9941d..8a08a60b41 100644 --- a/etc/templates/singleFluidCHT/templates/materials/air/physicalProperties +++ b/etc/templates/singleFluidCHT/templates/materials/air/physicalProperties @@ -29,7 +29,7 @@ mixture specie { nMoles 1; - molWeight 28.9; // [g/mol] + molWeight 28.9; // [kg/kmol] } thermodynamics { diff --git a/etc/templates/singleFluidCHT/templates/materials/aluminium/physicalProperties b/etc/templates/singleFluidCHT/templates/materials/aluminium/physicalProperties index ff4cca4cbd..b576f51dfa 100644 --- a/etc/templates/singleFluidCHT/templates/materials/aluminium/physicalProperties +++ b/etc/templates/singleFluidCHT/templates/materials/aluminium/physicalProperties @@ -29,7 +29,7 @@ mixture specie { nMoles 1; - molWeight 27; // [g/mol] + molWeight 27; // [kg/kmol] } transport diff --git a/etc/templates/singleFluidCHT/templates/materials/copper/physicalProperties b/etc/templates/singleFluidCHT/templates/materials/copper/physicalProperties index 36612f88c1..a105cfa4c9 100644 --- a/etc/templates/singleFluidCHT/templates/materials/copper/physicalProperties +++ b/etc/templates/singleFluidCHT/templates/materials/copper/physicalProperties @@ -29,7 +29,7 @@ mixture specie { nMoles 1; - molWeight 63.5; // [g/mol] + molWeight 63.5; // [kg/kmol] } transport diff --git a/etc/templates/singleFluidCHT/templates/materials/water/physicalProperties b/etc/templates/singleFluidCHT/templates/materials/water/physicalProperties index 02a13dcb6f..0ecf5fb1bf 100644 --- a/etc/templates/singleFluidCHT/templates/materials/water/physicalProperties +++ b/etc/templates/singleFluidCHT/templates/materials/water/physicalProperties @@ -29,7 +29,7 @@ mixture specie { nMoles 1; - molWeight 18.0; // [g/mol] + molWeight 18.0; // [kg/kmol] } equationOfState { diff --git a/src/OpenFOAM/global/constants/fundamental/fundamentalConstants.C b/src/OpenFOAM/global/constants/fundamental/fundamentalConstants.C index f041ce0664..e5992cd631 100644 --- a/src/OpenFOAM/global/constants/fundamental/fundamentalConstants.C +++ b/src/OpenFOAM/global/constants/fundamental/fundamentalConstants.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -108,11 +108,7 @@ const Foam::dimensionedScalar physicoChemical::NA ( physicoChemical::group, "NA", - dimensionedScalar - ( - dimensionSet(0, 0, 0, 0, -1), // dimless/dimMoles, - 6.0221417930e+23 - ) + dimensionSet(0, 0, 0, 0, -1) ) ); diff --git a/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.C b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.C index c30b2c6a88..ce270271da 100644 --- a/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.C +++ b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,28 +41,13 @@ const char* const physicoChemical::group = "physicoChemical"; // Note: cannot use dimless etc. as they may not have been constructed yet -const Foam::dimensionedScalar physicoChemical::R -( - dimensionedConstant - ( - physicoChemical::group, - "R", - physicoChemical::NA*physicoChemical::k - ) -); - - -// Note: the 1e3 converts from /mol to /kmol for consistency with the -// SI choice of kg rather than g for mass. -// This is not appropriate for USCS and will be changed to an entry in -// the DimensionedConstants dictionary in etc/controlDict const Foam::dimensionedScalar physicoChemical::RR ( dimensionedConstant ( physicoChemical::group, "RR", - 1000*physicoChemical::R + physicoChemical::NA*physicoChemical::k ) ); diff --git a/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H index 80af589da0..885f45f518 100644 --- a/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H +++ b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -48,13 +48,10 @@ namespace physicoChemical //- Group name for physico-chemical constants extern const char* const group; - //- Universal gas constant: default SI units: [J/mol/K] - extern const dimensionedScalar R; - //- Universal gas constant: default SI units: [J/kmol/K] extern const dimensionedScalar RR; - //- Faraday constant: default SI units: [C/mol] + //- Faraday constant: default SI units: [C/kmol] extern const dimensionedScalar F; //- Stefan-Boltzmann constant: default SI units: [W/m^2/K^4] diff --git a/src/thermophysicalModels/specie/specie/specie.C b/src/thermophysicalModels/specie/specie/specie.C index 00277b32de..569f288f40 100644 --- a/src/thermophysicalModels/specie/specie/specie.C +++ b/src/thermophysicalModels/specie/specie/specie.C @@ -24,7 +24,6 @@ License \*---------------------------------------------------------------------------*/ #include "specie.H" -#include "constants.H" /* * * * * * * * * * * * * * * public constants * * * * * * * * * * * * * * */ diff --git a/tutorials/multiRegion/CHT/coolingCylinder2D/constant/fluid/physicalProperties b/tutorials/multiRegion/CHT/coolingCylinder2D/constant/fluid/physicalProperties index 7c13d5c3eb..7a0aea7091 100644 --- a/tutorials/multiRegion/CHT/coolingCylinder2D/constant/fluid/physicalProperties +++ b/tutorials/multiRegion/CHT/coolingCylinder2D/constant/fluid/physicalProperties @@ -29,7 +29,7 @@ mixture specie { nMoles 1; - molWeight 18; // [g/mol] + molWeight 18; // [kg/kmol] } equationOfState { diff --git a/tutorials/multiRegion/CHT/coolingSphere/templates/materials/air/physicalProperties b/tutorials/multiRegion/CHT/coolingSphere/templates/materials/air/physicalProperties index c0a4b9941d..8a08a60b41 100644 --- a/tutorials/multiRegion/CHT/coolingSphere/templates/materials/air/physicalProperties +++ b/tutorials/multiRegion/CHT/coolingSphere/templates/materials/air/physicalProperties @@ -29,7 +29,7 @@ mixture specie { nMoles 1; - molWeight 28.9; // [g/mol] + molWeight 28.9; // [kg/kmol] } thermodynamics { diff --git a/tutorials/multiRegion/CHT/coolingSphere/templates/materials/aluminium/physicalProperties b/tutorials/multiRegion/CHT/coolingSphere/templates/materials/aluminium/physicalProperties index ff4cca4cbd..b576f51dfa 100644 --- a/tutorials/multiRegion/CHT/coolingSphere/templates/materials/aluminium/physicalProperties +++ b/tutorials/multiRegion/CHT/coolingSphere/templates/materials/aluminium/physicalProperties @@ -29,7 +29,7 @@ mixture specie { nMoles 1; - molWeight 27; // [g/mol] + molWeight 27; // [kg/kmol] } transport diff --git a/tutorials/multiRegion/CHT/coolingSphere/templates/materials/copper/physicalProperties b/tutorials/multiRegion/CHT/coolingSphere/templates/materials/copper/physicalProperties index 36612f88c1..a105cfa4c9 100644 --- a/tutorials/multiRegion/CHT/coolingSphere/templates/materials/copper/physicalProperties +++ b/tutorials/multiRegion/CHT/coolingSphere/templates/materials/copper/physicalProperties @@ -29,7 +29,7 @@ mixture specie { nMoles 1; - molWeight 63.5; // [g/mol] + molWeight 63.5; // [kg/kmol] } transport diff --git a/tutorials/multiRegion/CHT/coolingSphere/templates/materials/water/physicalProperties b/tutorials/multiRegion/CHT/coolingSphere/templates/materials/water/physicalProperties index 02a13dcb6f..0ecf5fb1bf 100644 --- a/tutorials/multiRegion/CHT/coolingSphere/templates/materials/water/physicalProperties +++ b/tutorials/multiRegion/CHT/coolingSphere/templates/materials/water/physicalProperties @@ -29,7 +29,7 @@ mixture specie { nMoles 1; - molWeight 18.0; // [g/mol] + molWeight 18.0; // [kg/kmol] } equationOfState {