diff --git a/dev/codelite/coolprop.project b/dev/codelite/coolprop.project index 75e0c55a..558f82c4 100644 --- a/dev/codelite/coolprop.project +++ b/dev/codelite/coolprop.project @@ -2,7 +2,7 @@ - + @@ -54,6 +63,10 @@ + + + + @@ -62,7 +75,6 @@ - @@ -76,6 +88,7 @@ + @@ -179,6 +192,8 @@ + + diff --git a/src/Backends/Tabular/TabularBackends.cpp b/src/Backends/Tabular/TabularBackends.cpp new file mode 100644 index 00000000..4cb727cd --- /dev/null +++ b/src/Backends/Tabular/TabularBackends.cpp @@ -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 */ \ No newline at end of file diff --git a/src/Backends/Tabular/TabularBackends.h b/src/Backends/Tabular/TabularBackends.h new file mode 100644 index 00000000..77107fa2 --- /dev/null +++ b/src/Backends/Tabular/TabularBackends.h @@ -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 &mole_fractions){}; + void set_mass_fractions(const std::vector &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