Back to index

wims  3.65+svn20090927
Public Member Functions | Private Attributes
Chemeq Class Reference

#include <chemeq.h>

Collaboration diagram for Chemeq:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Chemeq (Membre *g, Membre *d)
const Membremembredroit () const
const Membremembregauche () const
void addChemeq (const Chemeq *)
void subChemeq (const Chemeq *)
void simplifie (bool tri)
void numerote ()
void triage ()
void coeff1 ()
void multiply (int num, int den)
fraction nbelectron () const
long double enthalpy () const
void normalise ()
void printnorm (std::ostream &o)
void printcount (std::ostream &o) const
void printelec (std::ostream &o) const
void printspecies (std::ostream &o) const
void printweight (std::ostream &o) const
void printNernst (std::ostream &o, std::ostream &w, bool wantedlatex=false)
std::string equilibre ()
bool redox () const
const std::string constante () const
void constante (const std::string s)
bool valdefined () const
double valeur () const
std::string valeur_latex () const
void valeur (double r)

Private Attributes

Membregauche
Membredroit
std::string cste
long double val

Detailed Description

Definition at line 220 of file chemeq.h.


Constructor & Destructor Documentation

Chemeq::Chemeq ( Membre g,
Membre d 
) [inline]

Definition at line 225 of file chemeq.h.

: gauche (g), droit(d), val(MINVAL){};

Member Function Documentation

void Chemeq::addChemeq ( const Chemeq c)

Definition at line 651 of file chemeq.cc.

                                      {
  if (valdefined() && c->valdefined()){
    long double e1=enthalpy(), e2=c->enthalpy();
    fraction n1=nbelectron(), n2=c->nbelectron();
    long double e = e1+e2;
    fraction n=n1+n2;
    if (n.i==0) val=exp(-e/R/T0);
    else val=-e*n.d/n.i/Faraday;
  } else {
    val=MINVAL;
  }
  gauche->addMembre(c->gauche);
  droit->addMembre(c->droit);
  simplifie(true);
}

Here is the call graph for this function:

void Chemeq::coeff1 ( )

Definition at line 761 of file chemeq.cc.

                   {
  fraction mult = gauche->operator[](0)->nombre();
  mult.inverse();
  gauche->coeff(mult);
  droit->coeff(mult);
  simplifie();
  if (!redox() && valdefined()){
    val = val*mult.i/mult.d;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string Chemeq::constante ( ) const [inline]

Definition at line 249 of file chemeq.h.

{ return cste;};

Here is the caller graph for this function:

void Chemeq::constante ( const std::string  s) [inline]

Definition at line 250 of file chemeq.h.

{ cste = s;};
long double Chemeq::enthalpy ( ) const

Definition at line 686 of file chemeq.cc.

                                  {
  fraction n=nbelectron();
  if (redox()){
    return -val*n.i/n.d*Faraday;
  } else {
    return -R*T0*log(val);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

std::string Chemeq::equilibre ( )

Definition at line 751 of file chemeq.cc.

                           {
  std::ostringstream s;
  Compteur cpg, cpd;
  gauche->compte(cpg);
  droit->compte(cpd);
  if(cpg==cpd) s << "OK";
  else s << "ERROR " << cpg << " / " << cpd;
  return std::string(s.str());
}

Here is the call graph for this function:

const Membre* Chemeq::membredroit ( ) const [inline]

Definition at line 226 of file chemeq.h.

{return droit;};

Here is the caller graph for this function:

const Membre* Chemeq::membregauche ( ) const [inline]

Definition at line 227 of file chemeq.h.

{return gauche;};

Here is the caller graph for this function:

void Chemeq::multiply ( int  num,
int  den 
)

Definition at line 772 of file chemeq.cc.

                                     {
  fraction mult(num,den);
  gauche->coeff(mult);
  droit->coeff(mult);
  simplifie();
  if (!redox() && valdefined()){
    val = val*mult.i/mult.d;
  }
}

Here is the call graph for this function:

fraction Chemeq::nbelectron ( ) const [inline]

Definition at line 237 of file chemeq.h.

{return gauche->nbelectron()-droit->nbelectron();};

Here is the call graph for this function:

Here is the caller graph for this function:

void Chemeq::normalise ( ) [inline]

Definition at line 240 of file chemeq.h.

{numerote(); triage(); coeff1();};

Here is the call graph for this function:

void Chemeq::numerote ( ) [inline]

Definition at line 231 of file chemeq.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void Chemeq::printcount ( std::ostream &  o) const

Definition at line 727 of file chemeq.cc.

                                            {
  gauche->printcount(o);
  o << "; ";
  droit->printcount(o);
}

Here is the call graph for this function:

void Chemeq::printelec ( std::ostream &  o) const

Definition at line 733 of file chemeq.cc.

                                           {
  gauche->printelec(o);
  o << "; ";
  droit->printelec(o);
}

Here is the call graph for this function:

void Chemeq::printNernst ( std::ostream &  o,
std::ostream &  w,
bool  wantedlatex = false 
)

Definition at line 786 of file chemeq.cc.

                                       {
  Membre * ga, * dr;
  if (!redox()){
    if (gauche->printableNernst()){
      o << "\\frac{";
      droit->printNernst(o);
      o << "}{";
      gauche->printNernst(o);
      o << "}";
    }
    else {
      droit->printNernst(o);
    }
    droit->printNernstWIMS(w,wantedlatex);
    w << "; ";
    gauche->printNernstWIMS(w,wantedlatex);
    if (val > MINVAL) {
      o << "\\,=\\,";
      if (cste!=std::string("")) o << cste << "\\,=\\,";
      o << valeur_latex();
      if(wantedlatex){
       w << "; " << valeur_latex();
      }else{
       w << "; " << val;
      }
    }
    else{
      o << "\\,=\\,K";
      w << "; K";
    }
  }
  else{ /* c'est une réaction redox  */
    o << "E\\,=\\,";
    if(wantedlatex){
      w << "E\\,=\\,";
    }else{
      w << "E=";
    }
    if (val > MINVAL) {
      o << val;
      w << val << ";";
    }
    else{
      o << "E_{0}";
      if(wantedlatex){
       w << "E_{0};";
      }else{
       w << "E0;";
      }
    }
    o << "\\,+\\,\\frac{R\\,T}{";
    o << gauche->nbelectron()+droit->nbelectron() << "\\,F}";
    o << "\\log";
    w << gauche->nbelectron()+droit->nbelectron() << ";";
    if (gauche->redox()){ /* c'est une réduction */
      ga=gauche; dr=droit;
    }
    else{ /* c'est une oxydation */
      ga=droit; dr=gauche;
    }
    if (dr->printableNernst()){
      o << "\\frac{";
      ga->printNernst(o);
      o << "}{";
      dr->printNernst(o);
      o << "}";
    }
    else {
      o << "(";
      ga->printNernst(o);
      o << ")";
    }
    // implanter la sortie pour Wims ici.
    dr->printNernstWIMS(w,wantedlatex);
    w << "; ";
    ga->printNernstWIMS(w,wantedlatex);
  }
}

Here is the call graph for this function:

void Chemeq::printnorm ( std::ostream &  o)

Definition at line 714 of file chemeq.cc.

                                    {
  gauche->printnorm(o);
  o << " -> ";
  droit->printnorm(o);
  if (val>MINVAL){
    o << " (";
    if (cste!=std::string("")) o << cste << " = ";
    o << val;
    if (redox()) o << " V";
    o << ")";
  }
}

Here is the call graph for this function:

void Chemeq::printspecies ( std::ostream &  o) const

Definition at line 739 of file chemeq.cc.

                                              {
  gauche->printspecies(o);
  o << "; ";
  droit->printspecies(o);
}

Here is the call graph for this function:

void Chemeq::printweight ( std::ostream &  o) const

Definition at line 745 of file chemeq.cc.

                                            {
  gauche->printweight(o);
  o << " ";
  droit->printweight(o);
}

Here is the call graph for this function:

bool Chemeq::redox ( ) const

Definition at line 782 of file chemeq.cc.

                       {
  return gauche->redox() || droit->redox();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Chemeq::simplifie ( bool  tri = false)

Definition at line 695 of file chemeq.cc.

                                    {
  Membre communs(*gauche & *droit);
  if (communs.size()>0){
    Membre * g, *d;
    g= new Membre(*gauche - communs);
    d= new Membre(*droit  - communs);
    delete gauche;
    delete droit;
    gauche=g;
    droit =d;
  }
  gauche->eraseNull();
  droit->eraseNull();
  if (tri){
    numerote(); 
    triage();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Chemeq::subChemeq ( const Chemeq c)

Definition at line 667 of file chemeq.cc.

                                      {
  if (valdefined() && c->valdefined()){
    long double e1=enthalpy(), e2=c->enthalpy();
    fraction n1=nbelectron(), n2=c->nbelectron();
    long double e = e1-e2;
    fraction n=n1-n2;
    if (n.i==0) {
    val=exp(-e/R/T0);
    } else{
      val=-e*n.d/n.i/Faraday;
    }
  } else {
    val=MINVAL;
  }
  gauche->addMembre(c->droit);
  droit->addMembre(c->gauche);
  simplifie(true);
}

Here is the call graph for this function:

void Chemeq::triage ( ) [inline]

Definition at line 232 of file chemeq.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool Chemeq::valdefined ( ) const

Definition at line 647 of file chemeq.cc.

                            {
  return val > MINVAL;
}

Here is the caller graph for this function:

double Chemeq::valeur ( ) const [inline]

Definition at line 252 of file chemeq.h.

{return val;};

Here is the caller graph for this function:

void Chemeq::valeur ( double  r) [inline]

Definition at line 254 of file chemeq.h.

{val=r;};
std::string Chemeq::valeur_latex ( ) const

Definition at line 867 of file chemeq.cc.

                                   {
  std::ostringstream so;
  so << val;
  std::string s(so.str());
  std::string::size_type epos=s.find('e',0);
  if (epos!=std::string::npos){
    s.erase(epos,1);
    s.insert(epos,"\\times 10^{");
    s=s+"}";
  }
  return (std::string) s;
}

Here is the caller graph for this function:


Member Data Documentation

std::string Chemeq::cste [private]

Definition at line 222 of file chemeq.h.

Membre * Chemeq::droit [private]

Definition at line 221 of file chemeq.h.

Membre* Chemeq::gauche [private]

Definition at line 221 of file chemeq.h.

long double Chemeq::val [private]

Definition at line 223 of file chemeq.h.


The documentation for this class was generated from the following files: