Skip to content

Commit ade7cc3

Browse files
committed
formatting. Add carnahan starling AZbar
1 parent 2b7d0b5 commit ade7cc3

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

singularity-eos/eos/eos_carnahan_starling.hpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,29 @@ using namespace eos_base;
3838
class CarnahanStarling : public EosBase<CarnahanStarling> {
3939
public:
4040
CarnahanStarling() = default;
41-
PORTABLE_INLINE_FUNCTION CarnahanStarling(Real gm1, Real Cv, Real bb, Real qq)
41+
PORTABLE_INLINE_FUNCTION
42+
CarnahanStarling(Real gm1, Real Cv, Real bb, Real qq,
43+
const MeanAtomicProperties &AZbar = MeanAtomicProperties())
4244
: _Cv(Cv), _gm1(gm1), _bb(bb), _qq(qq), _T0(ROOM_TEMPERATURE),
4345
_P0(ATMOSPHERIC_PRESSURE), _qp(0.0),
4446
_rho0(DensityFromPressureTemperature(_P0, _T0)), _vol0(robust::ratio(1.0, _rho0)),
4547
_sie0(Cv * _T0 + qq),
4648
_bmod0(_rho0 * Cv * _T0 *
4749
(PartialRhoZedFromDensity(_rho0) +
4850
ZedFromDensity(_rho0) * ZedFromDensity(_rho0) * gm1)),
49-
_dpde0(_rho0 * ZedFromDensity(_rho0) * gm1) {
51+
_dpde0(_rho0 * ZedFromDensity(_rho0) * gm1), _AZbar(AZbar) {
5052
CheckParams();
5153
}
52-
PORTABLE_INLINE_FUNCTION CarnahanStarling(Real gm1, Real Cv, Real bb, Real qq, Real qp,
53-
Real T0, Real P0)
54+
PORTABLE_INLINE_FUNCTION
55+
CarnahanStarling(Real gm1, Real Cv, Real bb, Real qq, Real qp, Real T0, Real P0,
56+
const MeanAtomicProperties &AZbar = MeanAtomicProperties())
5457
: _Cv(Cv), _gm1(gm1), _bb(bb), _qq(qq), _T0(T0), _P0(P0), _qp(qp),
5558
_rho0(DensityFromPressureTemperature(P0, T0)), _vol0(robust::ratio(1.0, _rho0)),
5659
_sie0(Cv * T0 + qq),
5760
_bmod0(_rho0 * Cv * T0 *
5861
(PartialRhoZedFromDensity(_rho0) +
5962
ZedFromDensity(_rho0) * ZedFromDensity(_rho0) * gm1)),
60-
_dpde0(_rho0 * ZedFromDensity(_rho0) * gm1) {
63+
_dpde0(_rho0 * ZedFromDensity(_rho0) * gm1), _AZbar(AZbar) {
6164
CheckParams();
6265
}
6366
CarnahanStarling GetOnDevice() { return *this; }
@@ -247,12 +250,18 @@ class CarnahanStarling : public EosBase<CarnahanStarling> {
247250
static std::string EosType() { return std::string("CarnahanStarling"); }
248251
static std::string EosPyType() { return EosType(); }
249252

253+
PORTABLE_INLINE_FUNCTION
254+
Real MeanAtomicMass() const { return _AZbar.Abar; }
255+
PORTABLE_INLINE_FUNCTION
256+
Real MeanAtomicNumber() const { return _AZbar.Zbar; }
257+
250258
private:
251259
Real _Cv, _gm1, _bb, _qq;
252260
// optional reference state variables
253261
Real _T0, _P0, _qp;
254262
// reference values
255263
Real _rho0, _vol0, _sie0, _bmod0, _dpde0;
264+
MeanAtomicProperties _AZbar;
256265
// static constexpr const Real _T0 = ROOM_TEMPERATURE;
257266
// static constexpr const Real _P0 = ATMOSPHERIC_PRESSURE;
258267
static constexpr const unsigned long _preferred_input =

test/test_eos_ideal.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ SCENARIO("Ideal gas entropy", "[IdealGas][Entropy][GibbsFreeEnergy]") {
8181
}
8282
}
8383

84-
SCENARIO("Ideal gas mean atomic properties", "[IdealGas][MeanAtomicMass][MeanAtomicNumber]") {
84+
SCENARIO("Ideal gas mean atomic properties",
85+
"[IdealGas][MeanAtomicMass][MeanAtomicNumber]") {
8586
constexpr Real Cv = 5.0;
8687
constexpr Real gm1 = 0.4;
8788
constexpr Real Abar = 4.0; // Helium
@@ -93,21 +94,24 @@ SCENARIO("Ideal gas mean atomic properties", "[IdealGas][MeanAtomicMass][MeanAto
9394
Real Ab_eval = host_eos.MeanAtomicMass();
9495
Real Zb_eval = host_eos.MeanAtomicNumber();
9596
THEN("We get the right answer") {
96-
REQUIRE( isClose(Ab_eval, Abar, 1e-12) );
97-
REQUIRE( isClose(Zb_eval, Zbar, 1e-12) );
97+
REQUIRE(isClose(Ab_eval, Abar, 1e-12));
98+
REQUIRE(isClose(Zb_eval, Zbar, 1e-12));
9899
}
99100
}
100101
WHEN("We evaluate it on device, using a loop") {
101102
constexpr int N = 100;
102103
auto device_eos = host_eos.GetOnDevice();
103104
int nwrong = 0;
104-
portableReduce("Check mean atomic number", 0, N, PORTABLE_LAMBDA(const int i, int &nw) {
105-
double rho = i;
106-
double T = 100.0*i;
107-
double Ab_eval = device_eos.MeanAtomicMassFromDensityTemperature(rho, T);
108-
double Zb_eval = device_eos.MeanAtomicNumberFromDensityTemperature(rho, T);
109-
nw += !(isClose(Ab_eval, Abar, 1e-12)) + !(isClose(Zb_eval, Zbar, 1e-12));
110-
}, nwrong);
105+
portableReduce(
106+
"Check mean atomic number", 0, N,
107+
PORTABLE_LAMBDA(const int i, int &nw) {
108+
double rho = i;
109+
double T = 100.0 * i;
110+
double Ab_eval = device_eos.MeanAtomicMassFromDensityTemperature(rho, T);
111+
double Zb_eval = device_eos.MeanAtomicNumberFromDensityTemperature(rho, T);
112+
nw += !(isClose(Ab_eval, Abar, 1e-12)) + !(isClose(Zb_eval, Zbar, 1e-12));
113+
},
114+
nwrong);
111115
REQUIRE(nwrong == 0);
112116
device_eos.Finalize();
113117
}

0 commit comments

Comments
 (0)