CoolProp  4.2.5
An open-source fluid property and humid air property database
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TTSE.h
Go to the documentation of this file.
1 #ifndef TTSE_H
2 #define TTSE_H
3 
4 #include "FluidClass.h"
5 
6 class Fluid;
7 
9 
11 {
12 public:
15  BiCubicCellClass(){valid_hp = false; valid_Trho = false;};
16 };
17 
19 {
20 public:
21  std::vector< std::vector<BiCubicCellClass> > cells;
22 };
23 
25 {
26 protected:
27  unsigned int N;
29  double dh,dp;
30  double pratio,logpratio;
31 public:
40 
43  void set_size(unsigned int N);
44 
46 
47  // Variables with h, p
48  std::vector<double> T,dTdp,d2Tdp2;
49  std::vector<double> rho,drhodp,d2rhodp2,logrho;
50  std::vector<double> s,dsdp,d2sdp2;
51  std::vector<double> h,dhdp,d2hdp2;
52  std::vector<double> p,logp;
53 
58  double build(double pmin, double pmax, TTSETwoPhaseTableClass *other = NULL);
59 
63  double evaluate(long iParam, double p);
64 
68  double evaluate_T(double T);
69 
73  double evaluate_sat_derivative(long iParam, double p);
74 
78  double evaluate_randomly(long iParam, unsigned int N);
79 
88  double check_randomly(long iParam, unsigned int N, std::vector<double> *p, std::vector<double> *EOSv, std::vector<double> *TTSE);
89 };
90 
92 {
93 protected:
94  unsigned int Nh, Np,NT,Nrho;
99  int mode;
100 public:
104 
105  std::string root_path;
106  std::vector<double> TL,SL,DL,TV,SV,DV;
107 
111 
112  // Storage vectors for bicubic to keep from having to remake them every time (SLOW!)
113  std::vector<double> alpha_bicubic, z_bicubic;
114 
116 
117  // Variables with h, p as inputs
118  std::vector<std::vector<double> > T,dTdh,dTdp,d2Tdh2,d2Tdp2,d2Tdhdp;
119  std::vector<std::vector<double> > rho,drhodh,drhodp,d2rhodh2,d2rhodp2,d2rhodhdp;
120  std::vector<std::vector<double> > s,dsdh,dsdp,d2sdh2,d2sdp2,d2sdhdp;
121  std::vector<double> h, p;
122 
123  // Variables with T, rho as inputs
124  std::vector<std::vector<double> > s_Trho, dsdT_Trho, dsdrho_Trho, d2sdT2_Trho, d2sdrho2_Trho, d2sdTdrho_Trho;
125  std::vector<std::vector<double> > p_Trho, dpdT_Trho, dpdrho_Trho, d2pdT2_Trho, d2pdrho2_Trho, d2pdTdrho_Trho;
126  std::vector<std::vector<double> > h_Trho, dhdT_Trho, dhdrho_Trho, d2hdT2_Trho, d2hdrho2_Trho, d2hdTdrho_Trho;
128  std::vector<std::vector<double> > k_Trho, dkdT_Trho, dkdrho_Trho, d2kdT2_Trho, d2kdrho2_Trho, d2kdTdrho_Trho;
129  std::vector<double> T_Trho, rho_Trho;
130 
133  std::vector<int> IL, IV;
134 
135  int set_mode(int mode);
136  int get_mode();
137  bool read_all_from_file(std::string root_path);
138  void write_all_to_file(std::string root_path = std::string());
139  void matrix_to_file(std::string fName, std::vector< std::vector<double> > *A);
140  void vector_to_file(std::string fName, std::vector<double> *A);
141  void vector_from_file(std::string fName, int N, std::vector<double> *A);
142  void matrix_from_file(std::string fName, std::vector< std::vector<double> > *A);
143 
145  void set_size_ph(unsigned int Np = 100, unsigned int Nh = 100);
147  void set_size_Trho(unsigned int NT = 100, unsigned int Nrho = 100);
148 
150 
151  void update_cell_validity();
152 
160  double build_ph(double hmin, double hmax, double pmin, double pmax, TTSETwoPhaseTableClass *SatL = NULL, TTSETwoPhaseTableClass *SatV = NULL);
161 
169  double build_Trho(double Tmin, double Tmax, double rhomin, double rhomax, TTSETwoPhaseTableClass *SatL, TTSETwoPhaseTableClass *SatV);
170 
176  double evaluate(long iParam, double p, double logp, double h);
177 
179  double evaluate_one_other_input(long iInput1, double Param1, long iOther, double Other);
180 
182  bool within_range(long iInput1, double Input1, long iInput2, double Input2);
183 protected:
184  bool within_range_one_other_input(long iInput1, double Input1, long iOther, double Other, int buf);
185 public:
190  double evaluate_Trho(long iOutput, double T, double rho, double logrho);
191 
197  double interpolate_bicubic_Trho(long iParam, double T, double rho, double logrho);
198 
202  double evaluate_randomly(long iParam, unsigned int N);
203 
209  double interpolate_bicubic_ph(long iParam, double p, double logp, double h);
210 
211  void bicubic_cell_coordinates_Trho(double Tval, double rho, double logrhoval, int *i, int *j);
212  void bicubic_cell_coordinates_ph(double hval, double p, double logpval, int *i, int *j);
213  std::vector<double> * bicubic_cell_coeffs_Trho(long iParam, int i, int j);
214  std::vector<double> * bicubic_cell_coeffs_ph(long iParam, int i, int j);
215  double bicubic_evaluate_first_derivative_ph(long iOF, long iWRT, long iCONSTANT, double p, double logp, double h);
216  double bicubic_evaluate_one_other_input(long iInput1, double Input1, long iOther, double Other);
217 
227  double check_randomly(long iParam, unsigned int N, std::vector<double> *h, std::vector<double> *p, std::vector<double> *EOSv, std::vector<double> *TTSE);
228 
230  void write_dotdrawing_tofile(char fName[]);
231 
237  void nearest_neighbor_ph(int i, int j, double *T0, double *rho0);
238 
242  void nearest_good_neighbor(int *i, int *j);
243 
247  void nearest_good_neighbor_Trho(int *i, int *j);
248 
252  void nearest_good_neighbor_ph_interpolate(int *i, int *j);
253 
257  void nearest_good_neighbor_Trho_interpolate(int *i, int *j);
258 
266  double evaluate_first_derivative(long iOF, long iWRT, long iCONSTANT, double p, double logp, double h);
267 
268 };
269 
270 double matrix_vector_product(std::vector<double> *x, std::vector<double> *y, double yy);
271 
272 #endif
std::vector< std::vector< double > > d2Tdhdp
Definition: TTSE.h:118
std::vector< double > dTdp
Definition: TTSE.h:48
std::vector< std::vector< double > > s
Definition: TTSE.h:120
std::string root_path
Definition: TTSE.h:105
std::vector< double > d2hdp2
Definition: TTSE.h:51
void nearest_neighbor_ph(int i, int j, double *T0, double *rho0)
Definition: TTSE.cpp:425
std::vector< double > p
Definition: TTSE.h:121
std::vector< std::vector< double > > d2sdh2
Definition: TTSE.h:120
std::vector< double > * bicubic_cell_coeffs_Trho(long iParam, int i, int j)
Definition: TTSE.cpp:1660
double matrix_vector_product(std::vector< double > *x, std::vector< double > *y, double yy)
void nearest_good_neighbor_Trho_interpolate(int *i, int *j)
Definition: TTSE.cpp:306
std::vector< double > alpha_rho_hp
Definition: TTSE.h:13
std::vector< double > rho
Definition: TTSE.h:49
double interpolate_bicubic_ph(long iParam, double p, double logp, double h)
Definition: TTSE.cpp:1825
double logpratio
Definition: TTSE.h:30
std::vector< double > alpha_T_hp
Definition: TTSE.h:13
void nearest_good_neighbor_Trho(int *i, int *j)
Definition: TTSE.cpp:396
bool valid_hp
Definition: TTSE.h:14
double evaluate(long iParam, double p, double logp, double h)
Definition: TTSE.cpp:1487
std::vector< std::vector< double > > d2sdTdrho_Trho
Definition: TTSE.h:124
double build(double pmin, double pmax, TTSETwoPhaseTableClass *other=NULL)
Definition: TTSE.cpp:2590
std::vector< std::vector< double > > h_Trho
Definition: TTSE.h:126
std::vector< double > dhdp
Definition: TTSE.h:51
std::vector< int > IL
Definition: TTSE.h:133
double check_randomly(long iParam, unsigned int N, std::vector< double > *p, std::vector< double > *EOSv, std::vector< double > *TTSE)
Definition: TTSE.cpp:2906
std::vector< std::vector< double > > dhdrho_Trho
Definition: TTSE.h:126
void nearest_good_neighbor_ph_interpolate(int *i, int *j)
Definition: TTSE.cpp:351
std::vector< double > dsdp
Definition: TTSE.h:50
std::vector< std::vector< double > > rho
Definition: TTSE.h:119
std::vector< std::vector< double > > T
Definition: TTSE.h:118
std::vector< double > alpha_s_Trho
Definition: TTSE.h:13
std::vector< double > d2Tdp2
Definition: TTSE.h:48
std::vector< double > DL
Definition: TTSE.h:106
std::vector< int > IV
Definition: TTSE.h:133
std::vector< double > alpha_s_hp
Definition: TTSE.h:13
std::vector< std::vector< double > > p_Trho
Definition: TTSE.h:125
std::vector< double > alpha_h_Trho
Definition: TTSE.h:13
BiCubicCellsContainerClass bicubic_cells
Definition: TTSE.h:115
TTSE_MODES
Definition: TTSE.h:8
double bicubic_evaluate_one_other_input(long iInput1, double Input1, long iOther, double Other)
Definition: TTSE.cpp:1933
std::vector< std::vector< double > > k_Trho
Definition: TTSE.h:128
void set_size_Trho(unsigned int NT=100, unsigned int Nrho=100)
Set the sizes of the matrices with Trho as inputs.
Definition: TTSE.cpp:214
std::vector< double > TV
Definition: TTSE.h:106
std::vector< std::vector< double > > dkdrho_Trho
Definition: TTSE.h:128
~TTSETwoPhaseTableClass()
Destructor.
Definition: TTSE.h:39
std::vector< std::vector< double > > dpdT_Trho
Definition: TTSE.h:125
TTSETwoPhaseTableClass * SatL
Definition: TTSE.h:103
std::vector< double > alpha_k_Trho
Definition: TTSE.h:13
double interpolate_bicubic_Trho(long iParam, double T, double rho, double logrho)
Definition: TTSE.cpp:1898
std::vector< std::vector< double > > dTdp
Definition: TTSE.h:118
unsigned int Np
Definition: TTSE.h:94
unsigned int N
Definition: TTSE.h:27
std::vector< std::vector< double > > dmudrho_Trho
Definition: TTSE.h:127
std::vector< double > alpha_p_Trho
Definition: TTSE.h:13
void bicubic_cell_coordinates_Trho(double Tval, double rho, double logrhoval, int *i, int *j)
Definition: TTSE.cpp:1526
std::vector< double > SV
Definition: TTSE.h:106
std::vector< std::vector< double > > mu_Trho
Definition: TTSE.h:127
double evaluate_first_derivative(long iOF, long iWRT, long iCONSTANT, double p, double logp, double h)
Definition: TTSE.cpp:2491
Fluid is the abstract base class that is employed by all the other fluids.
Definition: FluidClass.h:147
void bicubic_cell_coordinates_ph(double hval, double p, double logpval, int *i, int *j)
Definition: TTSE.cpp:1548
std::vector< std::vector< double > > dkdT_Trho
Definition: TTSE.h:128
std::vector< std::vector< double > > d2rhodp2
Definition: TTSE.h:119
std::vector< std::vector< double > > d2sdT2_Trho
Definition: TTSE.h:124
std::vector< std::vector< double > > dmudT_Trho
Definition: TTSE.h:127
std::vector< double > s
Definition: TTSE.h:50
bool within_range(long iInput1, double Input1, long iInput2, double Input2)
See if the inputs are within range.
Definition: TTSE.cpp:2113
std::vector< std::vector< BiCubicCellClass > > cells
Definition: TTSE.h:21
std::vector< std::vector< double > > dsdrho_Trho
Definition: TTSE.h:124
bool valid_Trho
Definition: TTSE.h:14
std::vector< std::vector< double > > dhdT_Trho
Definition: TTSE.h:126
std::vector< std::vector< double > > dsdp
Definition: TTSE.h:120
double check_randomly(long iParam, unsigned int N, std::vector< double > *h, std::vector< double > *p, std::vector< double > *EOSv, std::vector< double > *TTSE)
Definition: TTSE.cpp:1420
double build_ph(double hmin, double hmax, double pmin, double pmax, TTSETwoPhaseTableClass *SatL=NULL, TTSETwoPhaseTableClass *SatV=NULL)
Definition: TTSE.cpp:834
std::vector< double > x(ncmax, 0)
std::vector< std::vector< double > > drhodh
Definition: TTSE.h:119
std::vector< double > h
Definition: TTSE.h:121
TTSETwoPhaseTableClass()
Default Instantiator.
Definition: TTSE.h:33
int set_mode(int mode)
Definition: TTSE.cpp:160
void write_dotdrawing_tofile(char fName[])
Write a representation of the ph surface to file with O in each "good" spot and "X" in each "bad" one...
Definition: TTSE.cpp:1398
std::vector< std::vector< double > > s_Trho
Definition: TTSE.h:124
std::vector< std::vector< double > > d2sdrho2_Trho
Definition: TTSE.h:124
std::vector< double > alpha_bicubic
Definition: TTSE.h:113
std::vector< std::vector< double > > d2Tdh2
Definition: TTSE.h:118
std::vector< double > logrho
Definition: TTSE.h:49
std::vector< std::vector< double > > d2kdrho2_Trho
Definition: TTSE.h:128
std::vector< double > DV
Definition: TTSE.h:106
bool within_range_one_other_input(long iInput1, double Input1, long iOther, double Other, int buf)
Definition: TTSE.cpp:2157
void update_saturation_boundary_indices()
Definition: TTSE.cpp:1342
void set_size(unsigned int N)
Definition: TTSE.cpp:2564
std::vector< std::vector< double > > d2pdrho2_Trho
Definition: TTSE.h:125
std::vector< double > rho_Trho
Definition: TTSE.h:129
double evaluate(long iParam, double p)
Definition: TTSE.cpp:2699
unsigned int Nrho
Definition: TTSE.h:94
std::vector< std::vector< double > > drhodp
Definition: TTSE.h:119
std::vector< std::vector< double > > d2mudTdrho_Trho
Definition: TTSE.h:127
double evaluate_T(double T)
Definition: TTSE.cpp:2786
void vector_from_file(std::string fName, int N, std::vector< double > *A)
Definition: TTSE.cpp:509
std::vector< double > d2rhodp2
Definition: TTSE.h:49
std::vector< double > h
Definition: TTSE.h:51
TTSETwoPhaseTableClass * SatV
Definition: TTSE.h:103
void write_all_to_file(std::string root_path=std::string())
Definition: TTSE.cpp:745
std::vector< double > p
Definition: TTSE.h:52
std::vector< std::vector< double > > d2rhodhdp
Definition: TTSE.h:119
std::vector< double > SL
Definition: TTSE.h:106
double evaluate_randomly(long iParam, unsigned int N)
Definition: TTSE.cpp:1468
std::vector< std::vector< double > > d2mudT2_Trho
Definition: TTSE.h:127
std::vector< std::vector< double > > d2hdrho2_Trho
Definition: TTSE.h:126
double evaluate_randomly(long iParam, unsigned int N)
Definition: TTSE.cpp:2890
std::vector< std::vector< double > > d2mudrho2_Trho
Definition: TTSE.h:127
double build_Trho(double Tmin, double Tmax, double rhomin, double rhomax, TTSETwoPhaseTableClass *SatL, TTSETwoPhaseTableClass *SatV)
Definition: TTSE.cpp:1051
std::vector< std::vector< double > > d2Tdp2
Definition: TTSE.h:118
bool read_all_from_file(std::string root_path)
Definition: TTSE.cpp:588
double bicubic_evaluate_first_derivative_ph(long iOF, long iWRT, long iCONSTANT, double p, double logp, double h)
Definition: TTSE.cpp:1853
void set_size_ph(unsigned int Np=100, unsigned int Nh=100)
Set the sizes of the matrices with h,p as inputs.
Definition: TTSE.cpp:169
std::vector< double > d2sdp2
Definition: TTSE.h:50
std::vector< std::vector< double > > dsdT_Trho
Definition: TTSE.h:124
std::vector< double > T
Definition: TTSE.h:48
std::vector< double > z_bicubic
Definition: TTSE.h:113
std::vector< double > drhodp
Definition: TTSE.h:49
std::vector< std::vector< double > > d2sdhdp
Definition: TTSE.h:120
Fluid * pFluid
Definition: TTSE.h:28
std::vector< double > * bicubic_cell_coeffs_ph(long iParam, int i, int j)
Definition: TTSE.cpp:1570
std::vector< double > logp
Definition: TTSE.h:52
std::vector< double > TL
Definition: TTSE.h:106
double evaluate_sat_derivative(long iParam, double p)
Definition: TTSE.cpp:2847
bool enable_writing_tables_to_files
Definition: TTSE.h:109
void matrix_to_file(std::string fName, std::vector< std::vector< double > > *A)
Definition: TTSE.cpp:468
std::vector< std::vector< double > > d2kdTdrho_Trho
Definition: TTSE.h:128
std::vector< std::vector< double > > d2pdTdrho_Trho
Definition: TTSE.h:125
std::vector< std::vector< double > > d2pdT2_Trho
Definition: TTSE.h:125
std::vector< std::vector< double > > d2hdT2_Trho
Definition: TTSE.h:126
std::vector< double > alpha_mu_Trho
Definition: TTSE.h:13
void vector_to_file(std::string fName, std::vector< double > *A)
Definition: TTSE.cpp:499
unsigned int Nh
Definition: TTSE.h:94
std::vector< std::vector< double > > dTdh
Definition: TTSE.h:118
void nearest_good_neighbor(int *i, int *j)
Definition: TTSE.cpp:257
BiCubicCellClass()
Definition: TTSE.h:15
std::vector< std::vector< double > > dsdh
Definition: TTSE.h:120
std::vector< std::vector< double > > d2hdTdrho_Trho
Definition: TTSE.h:126
std::vector< std::vector< double > > dpdrho_Trho
Definition: TTSE.h:125
std::vector< std::vector< double > > d2kdT2_Trho
Definition: TTSE.h:128
double evaluate_one_other_input(long iInput1, double Param1, long iOther, double Other)
Evaluate the TTSE using P,S or P,T.
Definition: TTSE.cpp:2188
double evaluate_Trho(long iOutput, double T, double rho, double logrho)
Definition: TTSE.cpp:2448
std::vector< double > T_Trho
Definition: TTSE.h:129
std::vector< std::vector< double > > d2sdp2
Definition: TTSE.h:120
std::vector< std::vector< double > > d2rhodh2
Definition: TTSE.h:119
void matrix_from_file(std::string fName, std::vector< std::vector< double > > *A)
Definition: TTSE.cpp:482
unsigned int NT
Definition: TTSE.h:94