CoolProp  6.6.1dev
An open-source fluid property and humid air property database
BicubicBackend.h
Go to the documentation of this file.
1 #ifndef BICUBICBACKEND_H
2 #define BICUBICBACKEND_H
3 
4 #include "TabularBackends.h"
5 #include "Exceptions.h"
6 #include "DataStructures.h"
7 #include "Eigen/Core"
8 
9 namespace CoolProp {
10 
60 typedef std::vector<std::vector<double>> mat;
62 {
63  public:
65  BicubicBackend(shared_ptr<CoolProp::AbstractState> AS) : TabularBackend(AS) {
67  // If a pure fluid or a predefined mixture, don't need to set fractions, go ahead and build
68  if (!this->AS->get_mole_fractions().empty()) {
69  check_tables();
72  dataset->build_coeffs(single_phase_logph, dataset->coeffs_ph);
73  dataset->build_coeffs(single_phase_logpT, dataset->coeffs_pT);
74  is_mixture = (this->AS->get_mole_fractions().size() > 1);
75  }
76  };
77  void set_mole_fractions(const std::vector<CoolPropDbl>& mole_fractions) {
78  this->AS->set_mole_fractions(mole_fractions);
79  is_mixture = true;
80  // Check the tables and build if necessary
81  check_tables();
82  // For mixtures, the construction of the coefficients is delayed until this
83  // function so that the set_mole_fractions function can be called
86  dataset->build_coeffs(single_phase_logph, dataset->coeffs_ph);
87  dataset->build_coeffs(single_phase_logpT, dataset->coeffs_pT);
88  };
89  std::string backend_name(void) {
91  }
92 
106  double evaluate_single_phase_derivative(SinglePhaseGriddedTableData& table, std::vector<std::vector<CellCoeffs>>& coeffs, parameters output,
107  double x, double y, std::size_t i, std::size_t j, std::size_t Nx, std::size_t Ny);
108  double evaluate_single_phase_phmolar_derivative(parameters output, std::size_t i, std::size_t j, std::size_t Nx, std::size_t Ny) {
110  };
111  double evaluate_single_phase_pT_derivative(parameters output, std::size_t i, std::size_t j, std::size_t Nx, std::size_t Ny) {
113  };
114 
126  double evaluate_single_phase(const SinglePhaseGriddedTableData& table, const std::vector<std::vector<CellCoeffs>>& coeffs,
127  const parameters output, const double x, const double y, const std::size_t i, const std::size_t j);
128  double evaluate_single_phase_phmolar(parameters output, std::size_t i, std::size_t j) {
130  };
131  double evaluate_single_phase_pT(parameters output, std::size_t i, std::size_t j) {
133  };
134 
135  virtual void find_native_nearest_good_indices(SinglePhaseGriddedTableData& table, const std::vector<std::vector<CellCoeffs>>& coeffs, double x,
136  double y, std::size_t& i, std::size_t& j);
137 
139  virtual void find_nearest_neighbor(SinglePhaseGriddedTableData& table, const std::vector<std::vector<CellCoeffs>>& coeffs,
140  const parameters variable1, const double value1, const parameters otherkey, const double otherval,
141  std::size_t& i, std::size_t& j);
142 
151  double evaluate_single_phase_transport(SinglePhaseGriddedTableData& table, parameters output, double x, double y, std::size_t i, std::size_t j);
152 
153  double evaluate_single_phase_phmolar_transport(parameters output, std::size_t i, std::size_t j) {
155  };
156  double evaluate_single_phase_pT_transport(parameters output, std::size_t i, std::size_t j) {
158  };
159 
169  void invert_single_phase_x(const SinglePhaseGriddedTableData& table, const std::vector<std::vector<CellCoeffs>>& coeffs, parameters other_key,
170  double other, double y, std::size_t i, std::size_t j);
171  void invert_single_phase_y(const SinglePhaseGriddedTableData& table, const std::vector<std::vector<CellCoeffs>>& coeffs, parameters other_key,
172  double other, double x, std::size_t i, std::size_t j);
173 };
174 
175 } // namespace CoolProp
176 
177 #endif // BICUBICBACKEND_H