#include "mix.hpp" #include "bissection.cpp" using namespace std; mix::mix ( int n , stream ** s1 , stream * s2 ) { nb_in=n; in = s1; out= s2; success = true; solver = new bissection(); } bool mix::solve() { //Mass balance out->m=0; out->purge(); for (j=0; jnb;j++) for (i=0;ichem[j]->m>EPS) { out->chem[j]->m+=in[i]->chem[j]->m; out->m+=in[i]->chem[j]->m; } //Find the temperature double max=0.0; double min=1e6; for(i=0;inb;j++) { if(in[i]->chem[j]->T>max && in[i]->chem[j]->m>EPS) max=in[i]->chem[j]->T; if(in[i]->chem[j]->Tchem[j]->m>EPS) min=in[i]->chem[j]->T; } if(fabs(max-min)set(this, min, max); success = solver->run(); } out->set(P,T); // if (success==false) // { // log.open(MESSAGES, ios::app); // log<<" --> Warning <-- Solver of "<m; // if(fabs(min-out->m)>sqrt(EPS)) // { // log.open(MESSAGES, ios::app); // log<<" --> Warning <-- Block "<m)/min<<").\n"; // log.close(); // } // out->write(); // WRITE TOTO return success; } double mix::f(double x) { T=x; double energy=0.0; //in kW for (j=0; jnb;j++) for (i=0;ichem[j]->dH(in[i]->T, T, P)*in[i]->chem[j]->n()/1000; return energy; } void mix::write() { cout << "WRITE FILE " << RUNTIME << name << ".unit" << " :\n\tBEGIN\n"; cout << "\t>> " << name << endl << "\t>> streams in: "; for ( int i = 0 ; i < nb_in ; i++ ) cout << in[i]->name << " "; cout << endl << "\t>> stream out: " << out->name; cout <> P = " << P << " atm, T = " << T; if (success) cout << " K (converged normally)"; cout << "\n\tEND\n\n"; }