-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsplit.cpp
53 lines (49 loc) · 1.26 KB
/
split.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
#include "split.hpp"
using namespace std;
split::split(int n, stream* s1, stream** s2)
{
nb_out=n;
in = s1;
out= s2;
success = true;
}
bool split::solve()
{
tmp=0;
for (i=0;i<nb_out; i++) tmp+=frac[i];
if(fabs(1-tmp)<=EPS)
{
success = true;
for (i=0; i<nb_out;i++)
{
out[i]->m=0;
for (j=0;j<in->nb;j++)
{
out[i]->chem[j]->m = frac[i]*in->chem[j]->m;
out[i]->m += out[i]->chem[j]->m;
}
out[i]->set(in->P, in->T);
// out[i]->write(); // TOTO
}
}
tmp=0; for(i=0;i<nb_out;i++) tmp+=out[i]->m;
if(fabs(tmp-in->m)>EPS)
{
// logf.open(MESSAGES, ios::app);
// logf<<" --> Warning <-- Block "<<name<<" is not in mass balance ("<<fabs(tmp-in->m)/tmp<<").\n";
// logf.close();
success = false;
}
else success = true;
return success;
}
void split::write()
{
cout << "WRITE FILE " << RUNTIME << name << ".unit" << " :\n\tBEGIN\n";
cout <<"\t>> "<<name;
cout << endl<<"\t>> stream in: "<<in->name;;
cout<<endl<<"\t>> streams out: "<<setprecision(3);
for ( i = 0 ; i < nb_out ; i++ )
cout << out[i]->name<<" ("<<frac[i]<<") ";
cout << "\n\tEND\n\n";
}