230 (*it)->post_load(JSON, JSON_CAS);
232 fluid_name_map[(*it)->get_name()] = *it;
234 std::string name = (*it)->get_name();
235 std::string ucasename =
upper(name);
237 if (!((*it)->isAlias(ucasename)) && ucasename.compare(name))
239 (*it)->add_alias(ucasename);
260 fluid_name_map.insert(std::pair<std::string,Fluid*>(FluidName,pREFPROPFluid));
277 std::map<std::string,Fluid*>::iterator it;
279 it = fluid_name_map.find(name);
281 if (it != fluid_name_map.end() )
290 if ( (*it)->isAlias(name) )
319 FL+=(*it)->get_name();
323 FL = FL.substr (0,FL.length()-1);
327 #ifndef DISABLE_CATCH
330 TEST_CASE((
char*)
"Check ancillary curves for pure and pseudo-pure fluids",
"[slow],[ancillary]")
334 SECTION((
char*)
"Saturated Liquid Pressure Ancillary")
336 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
338 std::string name = (*it)->get_name();
339 double Tmin = (*it)->limits.Tmin;
340 double Tmax = (*it)->crit.T-1;
342 for (
double T = Tmin; T <= Tmax; T += (Tmax-Tmin)/(N-1))
345 double pL,pV,rhoL,rhoV;
348 double p_ancillary = (*it)->pure() ? (*it)->psat(T): (*it)->psatL(T);
351 CHECK(fabs(p_EOS/p_ancillary -1) <= 2e-2);
355 SECTION((
char*)
"Saturated Vapor Pressure Ancillary")
357 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
359 std::string name = (*it)->get_name();
360 double Tmin = (*it)->limits.Tmin;
361 double Tmax = (*it)->crit.T-1;
363 for (
double T = Tmin; T <= Tmax; T += (Tmax-Tmin)/(N-1))
365 double pL,pV,rhoL,rhoV;
366 (*it)->saturation_T(T,
false,pL,pV,rhoL,rhoV);
368 double p_ancillary = (*it)->pure() ? (*it)->psat(T): (*it)->psatV(T);
373 CHECK(fabs(p_EOS/p_ancillary -1) <= 2e-2);
378 SECTION((
char*)
"Saturated Liquid Density Ancillary")
380 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
382 std::string name = (*it)->get_name();
383 double Tmin = (*it)->limits.Tmin;
384 double Tmax = (*it)->crit.T-1;
386 for (
double T = Tmin; T <= Tmax; T += (Tmax-Tmin)/(N-1))
388 double pL,pV,rhoL,rhoV;
389 (*it)->saturation_T(T,
false,pL,pV,rhoL,rhoV);
390 double rho_EOS = rhoL;
391 double rho_ancillary = (*it)->rhosatL(T);
395 CHECK(fabs(rho_EOS/rho_ancillary -1) <= 2e-2);
400 SECTION((
char*)
"Saturated Vapor Density Ancillary")
402 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
404 std::string name = (*it)->get_name();
405 double Tmin = (*it)->limits.Tmin;
406 double Tmax = (*it)->crit.T-1;
408 for (
double T = Tmin; T <= Tmax; T += (Tmax-Tmin)/(N-1))
410 double pL,pV,rhoL,rhoV;
411 (*it)->saturation_T(T,
false,pL,pV,rhoL,rhoV);
412 double rho_EOS = rhoV;
413 double rho_ancillary = (*it)->rhosatV(T);
417 CHECK(fabs(rho_EOS/rho_ancillary -1) <= 2e-2);
423 TEST_CASE((
char*)
"Fluid parameter checks not requiring saturation",
"[fast]")
427 SECTION((
char*)
"Check Tmin > Ttriple")
429 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
431 REQUIRE((*it)->params.Ttriple <= (*it)->limits.Tmin);
436 SECTION((
char*)
"Check pcrit matches REFPROP")
438 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
441 if (RPName.compare(
"REFPROP-N/A"))
444 double pcrit_CP = (*it)->crit.p.Pa;
445 double pcrit_RP =
PropsSI((
char*)
"pcrit",(
char*)
"T",300,(
char*)
"D",1e-10,(
char*)RPName.c_str());
449 CHECK(fabs(pcrit_RP/pcrit_CP-1) < 0.01);
456 TEST_CASE((
char*)
"Fluid parameter checks requiring saturation",
"[slow]")
460 SECTION((
char*)
"Check ptriple")
462 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
464 std::string name = (*it)->get_name();
465 double pL,pV,rhoL,rhoV;
466 (*it)->saturation_T((*it)->limits.Tmin,
false,pL,pV,rhoL,rhoV);
467 double ptriple_EOS = pV;
471 REQUIRE((*it)->params.ptriple == ptriple_EOS);
474 SECTION((
char*)
"Check accentric factor")
476 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
478 if ((*it)->limits.Tmin < 0.7*(*it)->crit.T)
480 std::string name = (*it)->get_name();
481 double pL,pV,rhoL,rhoV;
482 (*it)->saturation_T((*it)->crit.T*0.7,
false,pL,pV,rhoL,rhoV);
483 double accentric_EOS = -log10(pV/(*it)->crit.p.Pa)-1;
484 double accentric_Fluid = (*it)->params.accentricfactor;
488 INFO(
format(
"accentric factor should be %0.7g",accentric_EOS));
489 REQUIRE(fabs(accentric_Fluid/accentric_EOS-1) < 1e-2);
494 TEST_CASE((
char*)
"Saturation consistency checks", (
char*)
"[slow],[consistency]" )
499 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
501 double Tt = (*it)->limits.Tmin;
502 double Tc = (*it)->crit.T;
504 for (
double T = Tt; T<Tc; T+=(Tc-Tt)/(N-1))
506 double p, psatV, rhoL, rhoV;
507 std::string name = (*it)->get_name();
511 CHECK_NOTHROW((*it)->saturation_T(T,
false, p, psatV, rhoL, rhoV));
518 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
520 if (!(*it)->pure()){
continue;}
521 double Tt = (*it)->limits.Tmin;
522 double Tc = (*it)->crit.T;
523 double pc = (*it)->crit.p.Pa;
525 for (
double T = Tt; T<Tc; T+=(Tc-0.0001-Tt)/(N-1))
527 double psatL, psatV, TsatL, TsatV,rhoL,rhoV;
528 std::string name = (*it)->get_name();
532 CHECK_NOTHROW((*it)->saturation_T(T,
false, psatL, psatV, rhoL, rhoV));
534 CHECK_NOTHROW((*it)->saturation_p(psatL,
false, TsatL, TsatV, rhoL, rhoV));
537 CHECK(fabs(T/TsatL-1) < 1e-3);
543 for (std::vector<Fluid*>::const_iterator it = Fluids.
FluidsList.begin(); it != Fluids.
FluidsList.end(); it++)
545 if (!(*it)->pure()){
continue;}
546 double Tt = (*it)->limits.Tmin;
547 double Tc = (*it)->crit.T;
548 double pc = (*it)->crit.p.Pa;
550 for (
double T = Tt; T<Tc; T+=(Tc-0.0001-Tt)/(N-1))
552 double psatL, psatV, TsatL, TsatV, rhoL, rhoV;
553 std::string name = (*it)->get_name();
557 CHECK_NOTHROW((*it)->saturation_T(T,
false, psatL, psatV, rhoL, rhoV));
560 CHECK_NOTHROW((*it)->saturation_p(psatV,
false, TsatL, TsatV, rhoL, rhoV));
563 CHECK(fabs(T/TsatV-1) < 1e-3);
GenericDocument & Parse(const Ch *str)
Parse JSON text from a read-only string.
void set_critical_spline_constants(Fluid *pFluid)
#define CHECK_NOTHROW(expr)
Fluid is the abstract base class that is employed by all the other fluids.
double PropsSI(std::string Output, std::string Name1, double Prop1, std::string Name2, double Prop2, std::string Ref)
static bool refpropSupported()
std::vector< Fluid * > FluidsList
A list of pointers to the instances of the fluids.
std::string FluidList()
Returns a std::string of a comma-separated list of the CoolProp names of all the fluids that are load...
#define TEST_CASE(name, description)
REQUIRE(fabs(CPWater.p()-RPWater.p())< 1e-4)
Fluid * get_fluid(std::string name)
#define SECTION(name, description)
long get_fluid_index(Fluid *pFluid)
bool add_REFPROP_fluid(std::string FluidName, std::vector< double > xmol)
std::string get_fluid_param_string(std::string FluidName, std::string ParamName)