CoolProp
TTSEBackend.h
1 #ifndef TTSEBACKEND_H
2 #define TTSEBACKEND_H
3 
4 #include "TabularBackends.h"
5 #include "DataStructures.h"
6 
7 namespace CoolProp
8 {
9 
11 {
12  public:
13  std::string backend_name(void) { return get_backend_string(TTSE_BACKEND); }
15  TTSEBackend(shared_ptr<CoolProp::AbstractState> AS) : TabularBackend (AS) {
16  imposed_phase_index = iphase_not_imposed;
17  // If a pure fluid or a predefined mixture, don't need to set fractions, go ahead and build
18  if (!this->AS->get_mole_fractions().empty()){
19  check_tables();
20  SinglePhaseGriddedTableData &single_phase_logph = dataset->single_phase_logph;
21  SinglePhaseGriddedTableData &single_phase_logpT = dataset->single_phase_logpT;
22  dataset->build_coeffs(single_phase_logph, dataset->coeffs_ph);
23  dataset->build_coeffs(single_phase_logpT, dataset->coeffs_pT);
24  is_mixture = (this->AS->get_mole_fractions().size() > 1);
25  }
26  }
27  double evaluate_single_phase(SinglePhaseGriddedTableData &table, parameters output, double x, double y, std::size_t i, std::size_t j);
28  double evaluate_single_phase_transport(SinglePhaseGriddedTableData &table, parameters output, double x, double y, std::size_t i, std::size_t j);
29  double evaluate_single_phase_phmolar(parameters output, std::size_t i, std::size_t j){
30  SinglePhaseGriddedTableData &single_phase_logph = dataset->single_phase_logph;
31  return evaluate_single_phase(single_phase_logph, output, _hmolar, _p, i, j);
32  }
33  double evaluate_single_phase_pT(parameters output, std::size_t i, std::size_t j){
34  SinglePhaseGriddedTableData &single_phase_logpT = dataset->single_phase_logpT;
35  return evaluate_single_phase(single_phase_logpT, output, _T, _p, i, j);
36  }
37  double evaluate_single_phase_phmolar_transport(parameters output, std::size_t i, std::size_t j){
38  SinglePhaseGriddedTableData &single_phase_logph = dataset->single_phase_logph;
39  return evaluate_single_phase_transport(single_phase_logph, output, _hmolar, _p, i, j);
40  }
41  double evaluate_single_phase_pT_transport(parameters output, std::size_t i, std::size_t j){
42  SinglePhaseGriddedTableData &single_phase_logpT = dataset->single_phase_logpT;
43  return evaluate_single_phase_transport(single_phase_logpT, output, _T, _p, i, j);
44  }
45  void invert_single_phase_x(const SinglePhaseGriddedTableData &table, const std::vector<std::vector<CellCoeffs> > &coeffs, parameters output, double x, double y, std::size_t i, std::size_t j);
46  void invert_single_phase_y(const SinglePhaseGriddedTableData &table, const std::vector<std::vector<CellCoeffs> > &coeffs, parameters output, double y, double x, std::size_t i, std::size_t j);
47 
49  virtual void find_native_nearest_good_indices(SinglePhaseGriddedTableData &table, const std::vector<std::vector<CellCoeffs> > &coeffs, double x, double y, std::size_t &i, std::size_t &j){
50  return table.find_native_nearest_good_neighbor(x, y, i, j);
51  };
54  const std::vector<std::vector<CellCoeffs> > &coeffs,
55  const parameters variable1,
56  const double value1,
57  const parameters otherkey,
58  const double otherval,
59  std::size_t &i,
60  std::size_t &j){
61  table.find_nearest_neighbor(variable1, value1, otherkey, otherval, cached_single_phase_i, cached_single_phase_j);
62  };
63 
76  double evaluate_single_phase_derivative(SinglePhaseGriddedTableData &table, parameters output, double x, double y, std::size_t i, std::size_t j, std::size_t Nx, std::size_t Ny);
77  double evaluate_single_phase_phmolar_derivative(parameters output, std::size_t i, std::size_t j, std::size_t Nx, std::size_t Ny){
78  SinglePhaseGriddedTableData &single_phase_logph = dataset->single_phase_logph;
79  return evaluate_single_phase_derivative(single_phase_logph, output, _hmolar, _p, i, j, Nx, Ny);
80  };
81  double evaluate_single_phase_pT_derivative(parameters output, std::size_t i, std::size_t j, std::size_t Nx, std::size_t Ny){
82  SinglePhaseGriddedTableData &single_phase_logpT = dataset->single_phase_logpT;
83  return evaluate_single_phase_derivative(single_phase_logpT, output, _T, _p, i, j, Nx, Ny);
84  };
85 };
86 
87 } // namespace CoolProp
88 
89 #endif // TTSEBACKEND_H
void invert_single_phase_x(const SinglePhaseGriddedTableData &table, const std::vector< std::vector< CellCoeffs > > &coeffs, parameters output, double x, double y, std::size_t i, std::size_t j)
Solve for deltax.
Definition: TTSEBackend.cpp:42
void invert_single_phase_y(const SinglePhaseGriddedTableData &table, const std::vector< std::vector< CellCoeffs > > &coeffs, parameters output, double y, double x, std::size_t i, std::size_t j)
Solve for deltay.
Definition: TTSEBackend.cpp:100
void check_tables()
Definition: TabularBackends.h:1042
double evaluate_single_phase(SinglePhaseGriddedTableData &table, parameters output, double x, double y, std::size_t i, std::size_t j)
Use the single-phase table to evaluate an output.
Definition: TTSEBackend.cpp:162
void find_nearest_neighbor(parameters givenkey, double givenval, parameters otherkey, double otherval, std::size_t &i, std::size_t &j)
Find the nearest neighbor for one (given) variable native, one variable non-native.
Definition: TabularBackends.h:571
TTSEBackend(shared_ptr< CoolProp::AbstractState > AS)
Instantiator; base class loads or makes tables.
Definition: TTSEBackend.h:15
double evaluate_single_phase_derivative(SinglePhaseGriddedTableData &table, parameters output, double x, double y, std::size_t i, std::size_t j, std::size_t Nx, std::size_t Ny)
Evaluate a derivative in terms of the native inputs of the table.
Definition: TTSEBackend.cpp:185
std::string backend_name(void)
Get a string representation of the backend - for instance "HelmholtzEOSMixtureBackend" for the core m...
Definition: TTSEBackend.h:13
double evaluate_single_phase_transport(SinglePhaseGriddedTableData &table, parameters output, double x, double y, std::size_t i, std::size_t j)
Use the single_phase table to evaluate an output for a transport property.
Definition: TTSEBackend.cpp:14
This class holds the data for a single-phase interpolation table that is regularly spaced...
Definition: TabularBackends.h:439
void build_coeffs(SinglePhaseGriddedTableData &table, std::vector< std::vector< CellCoeffs > > &coeffs)
Build the coefficients for bicubic interpolation.
Definition: TabularBackends.cpp:1289
Definition: TTSEBackend.h:10
void find_native_nearest_good_neighbor(double x, double y, std::size_t &i, std::size_t &j)
Find the nearest good neighbor node for inputs that are the same as the grid inputs If the straightfo...
Definition: TabularBackends.h:602
virtual void find_native_nearest_good_indices(SinglePhaseGriddedTableData &table, const std::vector< std::vector< CellCoeffs > > &coeffs, double x, double y, std::size_t &i, std::size_t &j)
Find the best set of i,j for native inputs.
Definition: TTSEBackend.h:49
This class contains the general code for tabular backends (TTSE, bicubic, etc.)
Definition: TabularBackends.h:837
This file contains flash routines in which the state is unknown, and a solver of some kind must be us...
Definition: AbstractState.h:19
parameters
Define some constants that will be used throughout These are constants for the input and output para...
Definition: DataStructures.h:49
virtual void find_nearest_neighbor(SinglePhaseGriddedTableData &table, const std::vector< std::vector< CellCoeffs > > &coeffs, const parameters variable1, const double value1, const parameters otherkey, const double otherval, std::size_t &i, std::size_t &j)
Ask the derived class to find the nearest neighbor (pure virtual)
Definition: TTSEBackend.h:53