Skip to content

Commit eaeb52a

Browse files
committed
[Test] Switch real gas derivative tests to thermo consistency tests
Removed `getIsothermalCompressibility` and `getThermalExpansionCoeff` from `PengRobinson_Test` and `RedlichKwongMFTP_Test`. Add finite difference tests to `TestConsistency` as `betaT_eq_minus_dmv_dP_const_T_div_mv` and `alphaV_eq_dmv_dT_const_P_div_mv`.
1 parent 8d6b4c2 commit eaeb52a

File tree

3 files changed

+50
-104
lines changed

3 files changed

+50
-104
lines changed

test/thermo/PengRobinson_Test.cpp

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -179,58 +179,6 @@ TEST_F(PengRobinson_Test, CoolPropValidate)
179179
}
180180
}
181181

182-
TEST_F(PengRobinson_Test, getIsothermalCompressibility)
183-
{
184-
const double isothermalCompressibility[10] = {
185-
2.0565735288179827e-06,
186-
2.043354114849639e-06,
187-
2.0336631623657743e-06,
188-
2.0263828696824072e-06,
189-
2.0208047779848385e-06,
190-
2.0164611841648566e-06,
191-
2.0130329255806156e-06,
192-
2.010296131734592e-06,
193-
2.0080900822010764e-06,
194-
2.0062970726140575e-06
195-
};
196-
197-
double p = 5e5;
198-
199-
for(int i=0; i<10; i++)
200-
{
201-
const double temp = 300 + i*25;
202-
set_r(1.0);
203-
test_phase->setState_TP(temp, p);
204-
EXPECT_NEAR(test_phase->isothermalCompressibility(),isothermalCompressibility[i],1.e-12);
205-
}
206-
}
207-
208-
TEST_F(PengRobinson_Test, getThermalExpansionCoeff)
209-
{
210-
const double thermalExpansionCoeff[10] = {
211-
0.0036236953242238055,
212-
0.0032907286131624216,
213-
0.003018150217266326,
214-
0.0027901653673486353,
215-
0.0025961927676142714,
216-
0.0024288429329921953,
217-
0.0022827789874782295,
218-
0.0021540380684750378,
219-
0.0020396082523816846,
220-
0.0019371545393275069
221-
};
222-
223-
double p = 5e5;
224-
225-
for(int i=0; i<10; i++)
226-
{
227-
const double temp = 300 + i*25;
228-
set_r(1.0);
229-
test_phase->setState_TP(temp, p);
230-
EXPECT_NEAR(test_phase->thermalExpansionCoeff(),thermalExpansionCoeff[i],1.e-9);
231-
}
232-
}
233-
234182
TEST(PengRobinson, lookupSpeciesProperties)
235183
{
236184
AnyMap phase_def = AnyMap::fromYamlString(

test/thermo/RedlichKwongMFTP_Test.cpp

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -110,58 +110,6 @@ TEST_F(RedlichKwongMFTP_Test, setTP)
110110
}
111111
}
112112

113-
TEST_F(RedlichKwongMFTP_Test, getIsothermalCompressibility)
114-
{
115-
const double isothermalCompressibility[10] = {
116-
2.050805848598598e-06,
117-
2.039662581125248e-06,
118-
2.0314744830510903e-06,
119-
2.0253016382569196e-06,
120-
2.020549462982612e-06,
121-
2.0168263925524153e-06,
122-
2.013865922214169e-06,
123-
2.0114815945776956e-06,
124-
2.009539860089652e-06,
125-
2.0079431083026355e-06
126-
};
127-
128-
double p = 5e5;
129-
130-
for(int i=0; i<10; i++)
131-
{
132-
const double temp = 300 + i*25;
133-
set_r(1.0);
134-
test_phase->setState_TP(temp, p);
135-
EXPECT_NEAR(test_phase->isothermalCompressibility(),isothermalCompressibility[i],1.e-12);
136-
}
137-
}
138-
139-
TEST_F(RedlichKwongMFTP_Test, getThermalExpansionCoeff)
140-
{
141-
const double thermalExpansionCoeff[10] = {
142-
0.003578413284819209,
143-
0.003257292385643213,
144-
0.0029931405440041577,
145-
0.00277129023136564,
146-
0.0025818659337611253,
147-
0.002417938630670952,
148-
0.0022744816978795736,
149-
0.0021477468339320253,
150-
0.002034873745423023,
151-
0.0019336365732413633
152-
};
153-
154-
double p = 5e5;
155-
156-
for(int i=0; i<10; i++)
157-
{
158-
const double temp = 300 + i*25;
159-
set_r(1.0);
160-
test_phase->setState_TP(temp, p);
161-
EXPECT_NEAR(test_phase->thermalExpansionCoeff(),thermalExpansionCoeff[i],1.e-9);
162-
}
163-
}
164-
165113
TEST_F(RedlichKwongMFTP_Test, critPropLookup)
166114
{
167115
// Check to make sure that RedlichKwongMFTP is able to properly calculate a and b

test/thermo/consistency.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,56 @@ TEST_P(TestConsistency, dSdv_const_T_eq_dPdT_const_V) {
345345
}
346346
}
347347

348+
TEST_P(TestConsistency, betaT_eq_minus_dmv_dP_const_T_div_mv)
349+
{
350+
double betaT1;
351+
try {
352+
betaT1 = phase->isothermalCompressibility();
353+
} catch (NotImplementedError& err) {
354+
GTEST_SKIP() << err.getMethod() << " threw NotImplementedError";
355+
}
356+
357+
double T = phase->temperature();
358+
double P1 = phase->pressure();
359+
double mv1 = phase->molarVolume();
360+
361+
double P2 = P1 * (1 + 1e-7);
362+
phase->setState_TP(T, P2);
363+
double betaT2 = phase->isothermalCompressibility();
364+
double mv2 = phase->molarVolume();
365+
366+
double betaT_mid = 0.5 * (betaT1 + betaT2);
367+
double mv_mid = 0.5 * (mv1 + mv2);
368+
double betaT_fd = -1 / mv_mid * (mv2 - mv1) / (P2 - P1);
369+
370+
EXPECT_NEAR(betaT_fd, betaT_mid, max({rtol_fd * betaT_mid, rtol_fd * betaT_fd, atol}));
371+
}
372+
373+
TEST_P(TestConsistency, alphaV_eq_dmv_dT_const_P_div_mv)
374+
{
375+
double alphaV1;
376+
try {
377+
alphaV1 = phase->thermalExpansionCoeff();
378+
} catch (NotImplementedError& err) {
379+
GTEST_SKIP() << err.getMethod() << " threw NotImplementedError";
380+
}
381+
382+
double P = phase->pressure();
383+
double T1 = phase->temperature();
384+
double mv1 = phase->molarVolume();
385+
386+
double T2 = T1 * (1 + 1e-7);
387+
phase->setState_TP(T2, P);
388+
double alphaV2 = phase->thermalExpansionCoeff();
389+
double mv2 = phase->molarVolume();
390+
391+
double alphaV_mid = 0.5 * (alphaV1 + alphaV2);
392+
double mv_mid = 0.5 * (mv1 + mv2);
393+
double alphaV_fd = 1 / mv_mid * (mv2 - mv1) / (T2 - T1);
394+
395+
EXPECT_NEAR(alphaV_fd, alphaV_mid, max({rtol_fd * alphaV_mid, rtol_fd * alphaV_fd, atol}));
396+
}
397+
348398
// ---------- Tests for consistency of standard state properties ---------------
349399

350400
TEST_P(TestConsistency, hk0_eq_uk0_plus_p_vk0)

0 commit comments

Comments
 (0)