-
Notifications
You must be signed in to change notification settings - Fork 1
/
pump.cpp
103 lines (89 loc) · 2.53 KB
/
pump.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "pump.hpp"
using namespace std;
bool pump::solve() {
// out->chem = in->chem;
out->set ( in->nb , in->chem );
out->m = in->m;
in->set(in->P,in->T);
for ( i = 0 ; i < in->nb ; i++ )
if(in->chem[i]->m>EPS) {
in->chem[i]->find_v();
if(in->chem[i]->state==1) {
W+=in->chem[i]->gamma()*in->T*0.0083144*in->chem[i]->n()/
(in->chem[i]->gamma()-1.0)*(pow(P/in->P, 1.0-1.0/in->chem[i]->gamma())-1.0);
tmp += in->chem[i]->gamma();
n++;
}
if(in->chem[i]->state==0)
W+=in->chem[i]->v*(P-in->P)*101.325;
}
if (fabs(state-1)<EPS) //compressing gases
out->T = in->T*pow(P/in->P, 1.0-1.0/(tmp/n));
else //compressing liquids
out->T=in->T;
out->set(P, out->T);
if(eta>EPS)
W /= eta;
else
success=false;
// out->write(); // WRITE TOTO
return success;
}
void pump::write() {
cout << setprecision(6);
string file_name = RUNTIME + name + ".unit";
cout << "WRITE FILE " << file_name << " :\n\tBEGIN\n";
cout <<"\t>> " << name;
cout << endl << "\t>> stream in: "<<in->name<<" out: "<<out->name;
cout << endl << "\t>> P(in) = "<<in->P<<" P(out) = "<<out->P<<" atm";
cout << endl << "\t>> T(in) = "<<in->T<<" T(out) = "<<out->T<<" K";
cout << endl << "\t>> Shaft work = "<<W;
if (success)
cout <<" kW (converge normally)";
cout << "\n\tEND\n\n";
power();
cost();
}
double pump::get_cost ( void ) {
if ( fabs(state-1) < EPS ) {
if(W<450)
W=450;
else if(W>3000)
W=3000;
tmp=2.2891+1.3604*log10(W)-0.1027*pow(log10(W),2);
tmp=3.2*pow(10.0, tmp);
tmp1=2.4604+1.4191*log10(W)-0.1798*pow(log10(W),2);
tmp1=1.5*pow(10.0, tmp1);
tmp+=tmp1;
}
else {
if(W<1)
W=1;
else if(W>300)
W=300;
tmp=3.3892+0.0536*log10(W)+0.1538*pow(log10(W),2);
tmp=pow(10.0, tmp);
P=(P-1.0)*101.325/100.0;
if (P<EPS)
P=1;
if(P>100)
P=100;
W = -0.3925+0.3957*log10(P)-0.00226*pow(log10(P),2);
W=pow(10.0, W); if(W<1) W=1;
tmp*=(1.89+1.35*W*1.8);
}
tmp = tmp*MS_YEAR/MS_2001;
return tmp;
}
void pump::cost() {
string file_name = RUNTIME + name + ".cost";
cout << "WRITE FILE " << file_name << " :\n\tBEGIN\n";
cout << "\t>>" << get_cost();
cout << "\n\tEND\n\n";
}
void pump::power() {
string file_name = RUNTIME + name + ".power";
cout << "WRITE FILE " << file_name << " :\n\tBEGIN\n";
cout << "\t>>" << W;
cout << "\n\tEND\n\n";
}