First tests for derivatives of am for VTPR

@JonWel, looks like there is some more debugging to be done here :(
This commit is contained in:
Ian Bell
2016-08-23 20:01:49 -06:00
parent e21a27d5df
commit 779ef0e8c3

View File

@@ -77,3 +77,31 @@ const UNIFAQLibrary::UNIFAQParameterLibrary & CoolProp::VTPRBackend::LoadLibrary
}
return lib;
}
#ifdef ENABLE_CATCH
#include "catch.hpp"
#include "Backends/Cubics/CubicBackend.h"
using namespace CoolProp;
TEST_CASE("VTPR test","[VTPR]")
{
shared_ptr<VTPRBackend> VTPR(new VTPRBackend(strsplit("Ethane&n-Propane&n-Butane",'&')));
std::vector<double> z(3); z[0] = 0.1; z[1] = 0.2; z[2] = 0.7;
VTPR->set_mole_fractions(z);
SECTION("dam_dxi"){
shared_ptr<AbstractCubic> cubic = VTPR->get_cubic();
double tau = 0.001, dz = 1e-6;
std::vector<double> zp = z, zm = z;
zp[0] += dz; zm[0] -= dz;
double dam_dxi_num = (cubic->am_term(tau, zp, 0) - cubic->am_term(tau, zm, 0))/(2*dz);
double dam_dxi_ana = cubic->d_am_term_dxi(tau, z, 0, 0, XN_INDEPENDENT);
double diff = dam_dxi_num-dam_dxi_ana;
CHECK(std::abs(diff)<1e-6);
}
}
#endif