mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-02-09 21:35:28 -05:00
Updated codelite and added Tabular backend structure
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
71
src/Backends/Tabular/TabularBackends.cpp
Normal file
71
src/Backends/Tabular/TabularBackends.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
#include "TabularBackends.h"
|
||||
|
||||
namespace CoolProp{
|
||||
|
||||
void GriddedTableBackend::build_tables(tabular_types type)
|
||||
{
|
||||
std::size_t Nx = 200, Ny = 200;
|
||||
long double xmin, xmax, ymin, ymax, x, y;
|
||||
bool logy, logx;
|
||||
|
||||
switch(type){
|
||||
case LOGPH_TABLE:
|
||||
{
|
||||
parameters xkey, ykey;
|
||||
|
||||
// ---------------------------------
|
||||
// Calculate the limits of the table
|
||||
// ---------------------------------
|
||||
|
||||
// Minimum enthalpy is the saturated liquid enthalpy
|
||||
AS->update(QT_INPUTS, 0, AS->Ttriple());
|
||||
xmin = AS->hmolar();
|
||||
ymin = log(AS->p());
|
||||
|
||||
// Check both the enthalpies at the Tmax isotherm to see whether to use low or high pressure
|
||||
AS->update(PT_INPUTS, 1e-10, AS->Tmax());
|
||||
long double xmax1 = AS->hmolar();
|
||||
AS->update(PT_INPUTS, AS->pmax(), AS->Tmax());
|
||||
long double xmax2 = AS->hmolar();
|
||||
xmax = std::max(xmax1, xmax2);
|
||||
|
||||
ymax = log(AS->p());
|
||||
xkey = iHmolar;
|
||||
ykey = iP;
|
||||
logy = true;
|
||||
logx = false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw ValueError(format(""));
|
||||
}
|
||||
}
|
||||
// ------------------------
|
||||
// Actually build the table
|
||||
// ------------------------
|
||||
for (std::size_t i = 0; i < Nx; ++i)
|
||||
{
|
||||
// Calculate the x value
|
||||
x = xmin + (xmax - xmin)/(Nx-1)*i;
|
||||
if (logx){
|
||||
x = log(x);
|
||||
}
|
||||
for (std::size_t j = 0; j < Ny; ++j)
|
||||
{
|
||||
// Calculate the y value
|
||||
y = ymin + (ymax - ymin)/(Ny-1)*j;
|
||||
if (logy){
|
||||
y = log(y);
|
||||
}
|
||||
|
||||
// Update the state
|
||||
|
||||
// Calculate the derivatives
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace CoolProp */
|
||||
36
src/Backends/Tabular/TabularBackends.h
Normal file
36
src/Backends/Tabular/TabularBackends.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef TABULAR_BACKENDS_H
|
||||
#define TABULAR_BACKENDS_H
|
||||
|
||||
#include "AbstractState.h"
|
||||
|
||||
namespace CoolProp{
|
||||
|
||||
class GriddedTableBackend : public AbstractState
|
||||
{
|
||||
protected:
|
||||
enum tabular_types {LOGPH_TABLE};
|
||||
AbstractState *AS;
|
||||
public:
|
||||
bool using_mole_fractions(void){return true;}
|
||||
bool using_mass_fractions(void){return false;}
|
||||
bool using_volu_fractions(void){return false;}
|
||||
|
||||
void update(long input_pair, double Value1, double Value2){};
|
||||
void set_mole_fractions(const std::vector<long double> &mole_fractions){};
|
||||
void set_mass_fractions(const std::vector<long double> &mass_fractions){};
|
||||
|
||||
void build_tables(tabular_types type);
|
||||
void load_tables(void);
|
||||
void bounding_curves(void);
|
||||
};
|
||||
|
||||
class TTSEBackend : public GriddedTableBackend
|
||||
{
|
||||
public:
|
||||
TTSEBackend(AbstractState &AS){
|
||||
this->AS = &AS; build_tables(GriddedTableBackend::LOGPH_TABLE);};
|
||||
};
|
||||
|
||||
} /* namespace CoolProp*/
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user