1 /*
2 This unit takes operating P and T, and indexes of streams. It applies
3 the Rachford-Rice procedure to solve the isothermal flash problem
4 (ref : Seader & Henley).
5 
6 Structure in the .process file:
7 flash {name} {pressure} {temperature} {index of input stream} {index of output liquid and output vapor}
8 
9 How to use:
10    1- Call the constructor : flash1 = new flash(in, out_L, out_V);			//in is the feed, out_L is the liquid output and out_V is the vapor output
11    2- Set P and T: flash1->set(P,T);
12    3- Set the name: flash1->set(name);
13    4a- Perform an isothermal flash : flash1->solve();
14    4b- Perform an adiabatic flash: flash1->adiabatic();
15 */
16 #ifndef FLASH_H
17 #define FLASH_H
18 
19 #include "stream.hpp"
20 #include "bissection.hpp"
21 using namespace std;
22 
23 class flash {
24 private:
25   bool success;
26   bissection<flash> *solver;
27   // ofstream log, results;
28 //   char name[31], filename[41];  //name of the unit
29 
30   string name;
31 
32   int i, task;          //task=0: isothermal flash;   task=1:adiabatic flash
33   stream *F, *Fcopy;		   //pointer to the input stream
34   stream *L, *V;	//pointers to liquid and vapor output streams
35   double f_x, x, *K, *z;			//pressure (given) and temperature (given)
36   double Q, Tin, step, vol;			//required power, in kW
37 
38 public:
flash()39   flash(){P=0.0; T=0.0;}
40   flash(stream*, stream*, stream*);		//defines the connectivities of this unit
~flash()41   ~flash(){delete Fcopy; delete [] K; delete []  z; delete solver;}
42   double P ,T;
43   void set(double, double);
set(const string & n)44   void set( const string & n ) { name = n; }
45   bool solve();								//applies the Rachford-Rice procedure
46   bool adiabatic();						//adiabatic isobaric flash
47   double f(double);						//returns the function to the solver
48   void write();
49   double get_water ( void );
50   double get_cost ( void );
51 
get_power(void) const52   double get_power ( void ) const { return Q; }
53   void cost(), water(), power();
54 };
55 #endif
56