#include <iostream>
#include "gas.hpp"
#include <utility>
#include <string>
#include <math.h>

using namespace std;

const double Mincurrent = 0.05;
const double T0 = 273.15;
const double DG0 = -242.55;
const double DG1 = 4.4909E-2;
const double DG2 = 4.8612E-6;
const double DH0 = -238.43;
const double DH1 = 1.2725E-2;
const double DH2 = 3.1588E-6;
const double NaN = numeric_limits<float>::quiet_NaN();

gcomp comp;
double wtemp = T0;
double temp = 850 + T0;
double Tleak = temp;
double P = 1.0;

int main()
{
  comp.H2 = 2.0;
  comp.O2_anode = 0.0;
  comp.N2_anode = 0.0;
  comp.CO2 = 0.0;
  comp.CO = 0.0;
  comp.H2O = 1E-100;
  comp.CH4 = 0.0;
  comp.N2_cathode = 0.0;
  comp.O2_cathode = 0.0;
  comp.Air = 10.0;
  gas initial(Tleak,P,comp);
  gas start(initial);
  if (start != initial)
    {
      throw std::domain_error("Operator overloading of != failed!");
    }
  printf("Emf for initial: %f V\n",initial.emf());
  printf("Emf for start: %f V\n",start.emf());
  start += initial;
  printf("Emf for start+initial: %f V\n",start.emf());
  start.current(2);
  initial.current(2);
  printf("Applying 2 A to both\n");
  printf("Emf for initial: %f V\n",initial.emf());
  printf("Emf for start: %f V\n",start.emf());
  double startemf = start.emf();
  start += initial;
  printf("Emf for start+initial: %f V\n",start.emf());
  if (start.emf() == startemf || start.emf() == initial.emf())
    {
      throw std::domain_error("Operator overloading of +, = or += failed!");
    }
  if (start == initial)
    {
      throw std::domain_error("Operator overloading of == failed!");
    }
  return 0;
}
