Skip to content

Commit

Permalink
Add unit test for TFP T_from_p_h
Browse files Browse the repository at this point in the history
  • Loading branch information
GiudGiud committed Dec 26, 2024
1 parent 86f21c8 commit c60b342
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ TEST_F(TabulatedBicubicFluidPropertiesTest, fromPTFileToVE)
REL_TEST(T, Ts, 0.001);
}

// check computation of fluids props from p, h
{
Real T = 450;
Real p = 1.5e6;
Real h = _tab_ve_from_pT->h_from_p_T(p, T);
Real Ts = _tab_ve_from_pT->T_from_p_h(p, h);
REL_TEST(T, Ts, 1e-4);
}

// are the two version of functions equivalent
{
Real e = _tab_ve_from_pT->e_from_p_T(p, T);
Expand Down Expand Up @@ -373,6 +382,30 @@ TEST_F(TabulatedBicubicFluidPropertiesTest, fromPTFileToVE)

// cannot test AD c_from_v_e because co2 props do not
// implement enough

// AD T_from_p_h
{
Real h = _tab_ve_from_pT->h_from_p_T(p, T);
DNDerivativeType dpdx;
DNDerivativeType dhdx;
// set it up so these are the derivatives
// w.r.t. to themselves
Moose::derivInsert(dpdx, 0, 1);
Moose::derivInsert(dpdx, 1, 0);
Moose::derivInsert(dhdx, 0, 0);
Moose::derivInsert(dhdx, 1, 1);

ADReal p_ad(p, dpdx);
ADReal h_ad(h, dhdx);
ADReal T_ad = _tab_ve_from_pT->T_from_p_h(p_ad, h_ad);

Real TT_1 = _tab_ve_from_pT->T_from_p_h(p * (1 + pert), h);
Real TT_2 = _tab_ve_from_pT->T_from_p_h(p, h * (1 + pert));
Real dT_dp = (TT_1 - T) / p / pert;
Real dT_dh = (TT_2 - T) / h / pert;
REL_TEST(T_ad.derivatives()[0], dT_dp, 0.0001);
REL_TEST(T_ad.derivatives()[1], dT_dh, 0.0001);
}
}

// Test tabulated fluid properties read from file including comments
Expand Down

0 comments on commit c60b342

Please sign in to comment.