1 #ifndef THERMOLIB_H 2 #define THERMOLIB_H 3 #include "secant.hpp" 4 using namespace std; 5 6 class thermolib 7 { 8 private: 9 bool success; 10 int dim, i, j; 11 double pressure, temperature, molevolume, mole,*molefrac; 12 double *Pc, *Tc, *omega, Z, tmp, Tr, Pr; 13 void construct(); a(int i)14 double a(int i) {return (0.42748*pow(8.8144,2)*pow(Tc[i],2)*pow(1.0+f_omega(i)*(1.0-sqrt(temperature/Tc[i])), 2)/Pc[i]);} 15 double a_mix(); b(int i)16 double b(int i) {return (0.08664*8.3144*Tc[i]/Pc[i]);} 17 double b_mix(); A(int i)18 double A(int i) {return (a(i)*pressure/pow(8.3144, 2)/pow(temperature, 2));} A()19 double A() {return (a_mix()*pressure/pow(8.3144, 2)/pow(temperature, 2));} B(int i)20 double B(int i) {return (b(i)*pressure/8.3144/temperature);} B()21 double B(){return (b_mix()*pressure/8.3144/temperature);} 22 double Zv(), phiV(int), phiL(int); f_omega(int i)23 double f_omega(int i) {return (0.48 + 1.574*omega[i] - 0.176*pow(omega[i], 2));} 24 int task; //0=find P 1=find T 2=find v 3= find K 4=find Zv 25 secant<thermolib> *solver; 26 27 public: 28 double P(); //retruns pressure at T and v, in atm 29 double T(); //returns temperature at P and v, in K 30 double v(); //returns volume flow at P, T, n(), in m3/s K()31 double K() {Z = Zv(); return phiL(0)/phiV(0);} //returns the vapor-liquid equilibirum constant K(int i)32 double K(int i) {return phiL(i)/phiV(i);} compres_coeff()33 double compres_coeff(){return 1.0;}; 34 35 36 // affectation : 37 thermolib & operator = ( const thermolib & t ); 38 thermolib(int d=1)39 thermolib ( int d = 1 ) { dim=d; construct();} 40 send(double pc,double tc,double w)41 void send(double pc, double tc, double w) { Pc[0] = pc*101.325; Tc[0] = tc; omega[0]=w;} 42 void send(double*, double*, double*, double*); set(double p,double t,double v,double n)43 void set(double p, double t, double v, double n) {pressure=p*101.325; temperature=t; molevolume=0.001*n/v; mole=n;} 44 double f(double); get_dim()45 int get_dim() {return dim;} 46 ~thermolib(); 47 void reset(int); 48 }; 49 #endif 50 51