Back to index

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

#include <chemeq.h>

Collaboration diagram for Molec:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Molec (AtomeListe *a, int c=0, int n=1, int d=1)
 Molec (const Molec &m)
AtomeListeliste () const
int charge () const
bool eqMol (const Molec *m) const
void nombre (int n, int d=1)
fraction nombre () const
void add (fraction f)
void sub (fraction f)
moltype typage () const
void typage (moltype at)
void numero (int n)
int numero () const
void triage ()
void compte (Compteur &c) const
double weight (void) const
const std::string signature () const
void printNombre (std::ostream &o) const
bool printcount (std::ostream &o, bool first) const
bool printelec (std::ostream &o, bool first) const
bool printspecies (std::ostream &o, bool first) const
void printnorm (std::ostream &o) const
void printweigh (std::ostream &o) const
void coeff (fraction f)
bool printNernst (std::ostream &o, const char *prefix="")
bool printNernstWIMS (std::ostream &o, bool wantedlatex)
bool iswater () const
bool iselectron () const
fraction nbelectron () const
void debug (int decal=0) const

Private Attributes

AtomeListeal
int ch
fraction nb
int no
moltype t

Friends

Membre operator& (Membre &m1, Membre &m2)
Membre operator- (Membre &m1, Membre &m2)

Detailed Description

Definition at line 127 of file chemeq.h.


Constructor & Destructor Documentation

Molec::Molec ( AtomeListe a,
int  c = 0,
int  n = 1,
int  d = 1 
) [inline]

Definition at line 134 of file chemeq.h.

                                                    : 
    al(a), ch(c), nb(n,d), t(aqueous){};
Molec::Molec ( const Molec m) [inline]

Definition at line 136 of file chemeq.h.

                        :
    al(m.al), ch(m.ch), nb(m.nb.i,m.nb.d), t(m.t) {}

Member Function Documentation

void Molec::add ( fraction  f)

Definition at line 419 of file chemeq.cc.

                         {
  nb = nb+f;
}
int Molec::charge ( ) const [inline]

Definition at line 139 of file chemeq.h.

{return ch;};

Here is the caller graph for this function:

void Molec::coeff ( fraction  f)

Definition at line 299 of file chemeq.cc.

                            {
  nb.i *= f.i;
  nb.d *= f.d;
  nb.simplifie();
}

Here is the call graph for this function:

void Molec::compte ( Compteur c) const [inline]

Definition at line 152 of file chemeq.h.

{if (al) al->compte(c,nb);};

Here is the call graph for this function:

void Molec::debug ( int  decal = 0) const [inline]

Definition at line 167 of file chemeq.h.

                                {
    for (int i=0; i < decal; i++) std::cout << " ";
    std::cout << "Molec : ( " << this << " charge = " << ch 
        << " nombre = " << nb << " no = " << no;
    al->debug(decal+2);
    std::cout << ")\n";
  };

Here is the call graph for this function:

bool Molec::eqMol ( const Molec m) const [inline]

Definition at line 140 of file chemeq.h.

                                    {
    return (al->isEqual(*(m->al))) && (ch== m->ch);
  }

Here is the call graph for this function:

bool Molec::iselectron ( ) const

Definition at line 410 of file chemeq.cc.

                           {
  return (signature()==std::string("e^{-}"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool Molec::iswater ( ) const

Definition at line 403 of file chemeq.cc.

                        {
  if (t != aqueous) return 0;
  if (signature()==std::string("H_{2}O") || 
      signature()==std::string("OH_{2}")) return 1;
  else return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

AtomeListe& Molec::liste ( ) const [inline]

Definition at line 138 of file chemeq.h.

{return *al;};

Here is the caller graph for this function:

Definition at line 414 of file chemeq.cc.

                               {
  if (iselectron()) return nb;
  else return fraction(0);
}

Here is the call graph for this function:

void Molec::nombre ( int  n,
int  d = 1 
) [inline]

Definition at line 143 of file chemeq.h.

{nb=fraction(n,d);};

Here is the caller graph for this function:

fraction Molec::nombre ( ) const [inline]

Definition at line 144 of file chemeq.h.

{return nb;};
void Molec::numero ( int  n) [inline]

Definition at line 149 of file chemeq.h.

{no=n;};
int Molec::numero ( ) const [inline]

Definition at line 150 of file chemeq.h.

{return no;};
bool Molec::printcount ( std::ostream &  o,
bool  first 
) const

Definition at line 263 of file chemeq.cc.

                                                      {
  if (!first) o << ", ";
  first=false;
  printnorm(o);
  o << '|';
  al-> printcount(o,nb);
  return first;
}

Here is the call graph for this function:

bool Molec::printelec ( std::ostream &  o,
bool  first 
) const

Definition at line 272 of file chemeq.cc.

                                                     {
  if (!first) o << ", ";
  first=false;
  printnorm(o);
  o << '|';
  o << nb << '*' << ch;
  return first;
}

Here is the call graph for this function:

bool Molec::printNernst ( std::ostream &  o,
const char *  prefix = "" 
)

Definition at line 305 of file chemeq.cc.

                                                          {
  switch(t){
  case sol : return 0;
  case aqueous :
    if (iswater() || iselectron()) return 0;
    o << prefix << "[" << *al;
    if (ch){
      o << "^{";
      if(fabs(1.0*ch)!=1) o << fabs(1.0*ch);
      if(ch>0) o << "+}"; else o << "-}";
    }
    if (t != aqueous) o << "_{" << moltypeStr[t] << "}";
    o  <<"]";
    if (nb!=1) {
      o << "^{"; 
      printNombre(o);
      o << "}";
    }
    return 1;
  case gas :
    o << prefix << "P_{" << *al << "}";
    if (nb!=1) {
      o << "^{"; 
      printNombre(o);
      o << "}";
    }
    return 1;
  }
}

Here is the call graph for this function:

bool Molec::printNernstWIMS ( std::ostream &  o,
bool  wantedlatex 
)

Definition at line 335 of file chemeq.cc.

                                                           {
  if (iswater() || iselectron()) {
    return false;
  }
  switch(t){
  case sol : {
    return false;
  }
  case aqueous :
    if(wantedlatex){
      o <<  "[" << *al;
    }else{
      o << "["; al->printnorm(o);
    }
    if (ch){
      if(wantedlatex){
       o << "^{";
      }else{
       o << "^";
      }
      if(fabs(1.0*ch)!=1) o << fabs(1.0*ch);
      if(wantedlatex){
       if(ch>0) o << "+}"; else o << "-}";
      }else{
       if(ch>0) o << "+"; else o << "-";
      }
    }
    o  <<"]";
    if (nb!=1) {
      if(wantedlatex){
       o << "^{";
       if (nb.d==1){
         o << nb.i ;
       }
       else {
         o << "\\frac{" << nb.i << "}{" << nb.d << "}";
       }
       o << "}";
      }else{
       o << "^" << nb; 
      }
    }
    return true;
  case gas :
    if(wantedlatex){
      o << "P_{" << *al << "}";
    }else{
      o << "P_"; al->printnorm(o);
    }
    if (nb!=1) {
      if(wantedlatex){
       o << "^{";
       if (nb.d==1){
         o << nb.i ;
       }
       else {
         o << "\\frac{" << nb.i << "}{" << nb.d << "}";
       }
       o << "}";
      }else{
       o << "^" << nb; 
      }
    }
    return true;
  }
  return false;
}

Here is the call graph for this function:

void Molec::printNombre ( std::ostream &  o) const

Definition at line 427 of file chemeq.cc.

                                          {
  if (nb.d==1){
    o << nb.i << "\\,";
  }
  else {
    o << "\\frac{" << nb.i << "}{" << nb.d << "}\\,";
  }
}

Here is the caller graph for this function:

void Molec::printnorm ( std::ostream &  o) const

Definition at line 288 of file chemeq.cc.

                                        {
  if (nb!=1) o << nb << " ";
  al-> printnorm(o);
  if (ch) {
    o << "^";
    if(fabs(1.0*ch)!=1) o << fabs(1.0*ch);
    if(ch>0) o << "+"; else o << "-";
  }
  if (!iswater()&&!iselectron()) o << "_" << moltypeStr[t];
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool Molec::printspecies ( std::ostream &  o,
bool  first 
) const

Definition at line 281 of file chemeq.cc.

                                                        {
  if (!first) o << ", ";
  first=false;
  printnorm(o);
  return first;
}

Here is the call graph for this function:

void Molec::printweigh ( std::ostream &  o) const
const std::string Molec::signature ( ) const

Definition at line 251 of file chemeq.cc.

                                     {
  std::ostringstream o;
  o << liste();
  if (charge()){
    o << "^{";
    if(fabs(1.0*charge())!=1) o << fabs(1.0*charge());
    if(charge()>0) o << "+}"; else o << "-}";
  }
  if (t != aqueous) o << moltypeStr[t];
  return std::string (o.str());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Molec::sub ( fraction  f)

Definition at line 423 of file chemeq.cc.

                         {
  nb = nb-f;
}
void Molec::triage ( ) [inline]

Definition at line 151 of file chemeq.h.

moltype Molec::typage ( ) const [inline]

Definition at line 147 of file chemeq.h.

{return t;};

Here is the caller graph for this function:

void Molec::typage ( moltype  at) [inline]

Definition at line 148 of file chemeq.h.

{t=at;};
double Molec::weight ( void  ) const [inline]

Definition at line 153 of file chemeq.h.

{if (al) return al->weight(nb); else return 0.0;};

Here is the call graph for this function:


Friends And Related Function Documentation

Membre operator& ( Membre m1,
Membre m2 
) [friend]

Definition at line 610 of file chemeq.cc.

                                            {
  Membre result;
  //result.printnorm(std::cout);
  fraction min(1);
  for(Membre::iterator i = m1.begin(); i < m1.end(); i++){
    for(Membre::iterator j = m2.begin(); j < m2.end(); j++){
      if ((*i)->eqMol(*j)){
       Molec *m = new Molec(**i);
       if ((*i)->nb > (*j)->nb){
         min=(*j)->nb;
       }else{
         min=(*i)->nb;
       }
       m->nb=min;
       result.push_back(m);
      }
    }
  }
  return result;
}
Membre operator- ( Membre m1,
Membre m2 
) [friend]

Definition at line 631 of file chemeq.cc.

                                            {
  Membre result;
  fraction diff(1);
  for(Membre::iterator i = m1.begin(); i < m1.end(); i++){
    Molec *m = new Molec(**i);
    for(Membre::iterator j = m2.begin(); j < m2.end(); j++){
      if ((*i)->eqMol(*j)){
       diff=(*i)->nb - (*j)->nb;
       m->nb=diff;
      }
    }
    result.push_back(m);
  }
  return result;
}

Member Data Documentation

AtomeListe* Molec::al [private]

Definition at line 128 of file chemeq.h.

int Molec::ch [private]

Definition at line 129 of file chemeq.h.

fraction Molec::nb [private]

Definition at line 130 of file chemeq.h.

int Molec::no [private]

Definition at line 131 of file chemeq.h.

moltype Molec::t [private]

Definition at line 132 of file chemeq.h.


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