//TITLE: Chemical Reactor Design in C++//
//Introduction and Description: Please read my separate file.//


#include "Project.h"

void main()
{

  //Declaration Section.//

  real k, a, b, c, d, eps;
  real x, time;
  real Fax, Vtotal, CA0, Nax;
  real raout;
  real type;

  //Introduction to the Program to user.//

  cout<<endl;
  cout<<endl;

  cout<<"This Program calculates the volume of reactor necessary
to carry out the given chemical reaction. The general chemical
reaction equation used in the program is given as:
a A + b B -> c C + d D where a, b, c and d are stoichiometric
coefficients while A, B, C and D are chemical species involved                 
in the reactions. A and B are reactants while C and D are the
products."<<endl;

  cout<<endl;
  cout<<endl;



  //Getting the Input Variables.//

cout<<"Please enter the chemical stoichiometric coefficients:
a, b, c and d, separated by a space."<<endl;
  
cin>> a >> b >> c >> d;                                                        
cout<<endl;


cout<<"This program could currently handle three types of rate
equations: the zero order with respect to all the species, first
order with respect to A (limiting reactant) and zero order to
the other species, and second order with respect to A and zero
order to the other species.

Please enter 1 for the first type, 2 for the second and 3 for
the third type: "<<endl;                                                       

cin>> type;
cout<<endl;


cout<< "Please enter the rate constant:
Units are :
1. (moles per (cubic meters * hour)) for type 1
2. (1/hour) for type 2
3. (cubic meters / (moles * hour)) for type 3 " <<endl;                        


 cin >> k;

 cout<<endl;



 cout << "The program will calculate the volume required for the
reactor to achieve a desired conversion. Please enter the desired
conversion (between 0 to 0.99): " << endl;

 cin >> x;

 cout<<endl;

 cout<<"The following two inputs are for PFR and CSTR which are
information of the flows coming into the reactor."<<endl;
                                                                               


 cout << "Please enter the input stream volumetric flowrates to
the reactors (in cubic meters/hour): " << endl;

 cin >> Vtotal;

 cout<<endl;


cout << "Please enter the concentration of A in the input
stream (in moles/cubic meters):" <<endl;

 cin >> CA0;

 cout<<endl;


 //Calculating the increase of number of moles during the reaction//          

  eps = (d+c-a-b)/a;

  //Calculating the molar flowrates of A in moles / hour//

  Fax = CA0 * Vtotal;

  cout<<"The following two are for batch reactors. Batch Reactor does not
involve any flows, the reactants are filled to the reactor at time=0
and they are left there until the desired conversion is reached.
Therefore, the volume needed would depend on the time in which the
reactants are allowed to stay in the reactor. Please read the
information on batch reactor in my introduction section."<<endl;

  cout<<endl;
  cout<<"Please enter the time in which you are willing to wait for
the reaction to be carried out in the batch reactor: (in hours) "<<endl;

  cin>>time;                                                                     
  cout<<"Please enter the actual number of moles of the limiting
reactant being filled at time=0: "<<endl;

  cin>>Nax;


  //Calling the Classes and Calculating the Volumes.//
  //Printing out the Volumes of the Reactor.//

  cout<<"*************************************************"<<endl;

  cout<<"For the Continuous Stirred Tank Reactor: "<<endl;

  CSTR CT(Fax, type, k, x, eps, CA0);

  ExtFunc2 (CT);

  cout<<"*************************************************"<<endl;             

  cout<<"*************************************************"<<endl;

  cout<<"For the Plug Flow Reactor: "<<endl;

  PFR PF(Fax, type, k, x, eps, CA0);

  ExtFunc2 (PF);

  cout<<"*************************************************"<<endl;

  cout<<"*************************************************"<<endl;

  cout<<"For the Batch Reactor, based on the waiting period of "<<endl
      << time << " hours and available limiting reactant of "<<endl
      << Nax << " moles in the reactor: "<<endl;

  BATCH BT(Nax, type, k, x, eps, CA0, time);                                   


  ExtFunc2 (BT);

  cout<<"*************************************************"<<endl;

  cout<<"Since the mechanism of batch reactor is different from CSTR or"<<endl
      <<" PFR, we can only compare the volumes of PFR and CSTR, and not "<<endl
      <<"Batch." <<endl;

  cout<<endl;
  cout<<endl;

}                                        
