Implemented Phase output again

Added PhaseSI function which will return phase for given input - exposed to DLL
PropsSI can also return phase as double if "Phase" is the input

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-10-14 11:21:07 +02:00
parent c200e9e057
commit 199ced3f86
7 changed files with 90 additions and 29 deletions

View File

@@ -262,6 +262,8 @@ double AbstractState::keyed_output(int key)
return viscosity();
case iconductivity:
return conductivity();
case iPhase:
return phase();
default:
throw ValueError(format("This input [%d: \"%s\"] is not valid for keyed_output",key,get_parameter_information(key,"short").c_str()));
}

View File

@@ -31,7 +31,7 @@
#include "Backends/Incompressible/IncompressibleLibrary.h"
#include "Backends/Helmholtz/HelmholtzEOSBackend.h"
#include "Backends/Helmholtz/MixtureParameters.h"
#include "DataStructures.h"
namespace CoolProp
{
@@ -946,5 +946,42 @@ std::string get_fluid_param_string(std::string FluidName, std::string ParamName)
return(std::string("CoolProp error: Indeterminate error"));
}
}
std::string phase_lookup_string(phases Phase)
{
switch (Phase)
{
case iphase_liquid: ///< Liquid
return "liquid";
case iphase_supercritical: ///< Supercritical (p > pc, T > Tc)
return "supercritical";
case iphase_supercritical_gas: ///< Supercritical gas (p < pc, T > Tc)
return "supercritical_gas";
case iphase_supercritical_liquid: ///< Supercritical liquid (p > pc, T < Tc)
return "supercritical_liquid";
case iphase_gas: ///< Subcritical gas
return "gas";
case iphase_twophase: ///< Twophase
return "twophase";
case iphase_unknown: ///< Unknown phase
return "unknown";
case iphase_not_imposed:
return "not_imposed";
}
}
std::string PhaseSI(const std::string &Name1, double Prop1, const std::string &Name2, double Prop2, const std::string &FluidName)
{
double Phase_double = PropsSI("Phase",Name1,Prop1,Name2,Prop2,FluidName);
if (!ValidNumber(Phase_double)){ return "";}
std::size_t Phase_int = static_cast<std::size_t>(round(Phase_double));
return phase_lookup_string(static_cast<phases>(Phase_int));
}
std::string PhaseSI(const std::string &Name1, double Prop1, const std::string &Name2, double Prop2, const std::string &FluidName, const std::vector<double> &z)
{
double Phase_double = PropsSI("Phase",Name1,Prop1,Name2,Prop2,FluidName,z);
if (!ValidNumber(Phase_double)){ return "";}
std::size_t Phase_int = static_cast<std::size_t>(round(Phase_double));
return phase_lookup_string(static_cast<phases>(Phase_int));
}
} /* namespace CoolProp */

View File

@@ -130,6 +130,14 @@ EXPORT_CODE double CONVENTION PropsSI(const char *Output, const char *Name1, dou
std::string _Output = Output, _Name1 = Name1, _Name2 = Name2, _FluidName = FluidName;
return CoolProp::PropsSI(_Output, _Name1, Prop1, _Name2, Prop2, _FluidName);
}
EXPORT_CODE long CONVENTION PhaseSI(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char * FluidName, char *phase)
{
std::string _Name1 = Name1, _Name2 = Name2, _FluidName = FluidName;
std::string ph = CoolProp::PhaseSI(_Name1, Prop1, _Name2, Prop2, _FluidName);
if (ph.size() > strlen(phase)){
strcpy(phase, ph.c_str());
}
}
EXPORT_CODE double CONVENTION PropsSIZ(const char *Output, const char *Name1, double Prop1, const char *Name2, double Prop2, const char * FluidName, const double *z, int n)
{
std::string _Output = Output, _Name1 = Name1, _Name2 = Name2, _FluidName = FluidName;

View File

@@ -85,6 +85,8 @@ parameter_info parameter_info_list[] = {
parameter_info(idalpha0_dtau_constdelta, "dalpha0_dtau_constdelta","O","-","Derivative of ideal Helmholtz energy with tau",false),
parameter_info(idalpha0_ddelta_consttau, "dalpha0_ddelta_consttau","O","-","Derivative of ideal Helmholtz energy with delta",false),
parameter_info(iPhase, "Phase","O","-","Phase index from \ref phases",false),
};
class ParameterInformation