Open Babel  3.0
kinetics.h
Go to the documentation of this file.
1 /**********************************************************************
2 Copyright (C) 2005 by Chris Morley
3 
4 This file is part of the Open Babel project.
5 For more information, see <http://openbabel.org/>
6 
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 ***********************************************************************/
16 #ifndef OB_KINETICS_H
17 #define OB_KINETICS_H
18 
19 #include <openbabel/generic.h>
20 
21 namespace OpenBabel
22 {
23 
24 const unsigned RateData = 55555;
25 const unsigned ThermoData = 55556;
26 
29 
36 class OBRateData : public OBGenericData
37 {
38 protected:
39  double Rates[3];
40  double LoRates[3];
41  double TroeParams[4];
42  std::map<std::string,double> Efficiencies;
43 public:
44  virtual OBGenericData* Clone(OBBase* parent) const{return new OBRateData(*this);}
45  enum rate_type {A, n, E};
48  OBRateData():OBGenericData("Rate data", RateData)
49  {
50  Rates[0]=Rates[1]=Rates[2]=0;
51  LoRates[0]=LoRates[1]=LoRates[2]=0;
52  TroeParams[0]=TroeParams[1]=TroeParams[2]=TroeParams[3]=0;
53  ReactionType = ARRHENIUS;
54  }
55 
56  double GetRate(rate_type n) const
57  {
58  return Rates[n];
59  }
60 
61  void SetRate(rate_type n, const double val)
62  {
63  if(n<3)
64  Rates[n] = val;
65  }
66 
67  double GetLoRate(rate_type n) const
68  {
69  return LoRates[n];
70  }
71 
72  void SetLoRate(rate_type n, const double val)
73  {
74  if(n<3)
75  LoRates[n] = val;
76  }
77 
78  double GetTroeParam(int n) const
79  {
80  return TroeParams[n];
81  }
82 
83  void SetTroeParams(int n, const double val)
84  {
85  if(n<4)
86  TroeParams[n] = val;
87  }
88 
89  void SetEfficiency(std::string id, double Eff)
90  {
91  Efficiencies[id] = Eff;
92  }
93 
94  double GetEfficiency(std::string id)
95  {
96  return Efficiencies[id]; //will be 0 if not found
97  }
98 
99  bool GetNextEff(std::string& id, double& Eff)
100  {
101  //Supply id empty to begin, then id is the*last* id
102  std::map<std::string, double>::iterator itr;
103  if(id.empty())
104  itr = Efficiencies.begin();
105  else
106  {
107  itr = Efficiencies.find(id);
108  if(itr!=Efficiencies.end())
109  ++itr;
110  }
111  if(itr==Efficiencies.end())
112  return false;
113  id = itr->first;
114  Eff = itr->second;
115  return true;
116  }
117 };
118 
119 //******************************************************************************
122 
135 {
136 protected:
137  double Coeffs[14];
138  double LoT, MidT, HiT;
139  char phase;
140 public:
141  OBNasaThermoData(): LoT(300),MidT(1000),HiT(3000),phase('G')
142  { _type = ThermoData; _attr = "Nasa thermo data";}
143 
144  virtual OBGenericData* Clone(OBBase* parent) const{return new OBNasaThermoData(*this);}
145 
146  double GetCoeff(unsigned n) const
147  {
148  return Coeffs[n];
149  }
150 
151  void SetCoeff(unsigned n, const double val)
152  {
153  if(n<14)
154  Coeffs[n] = val;
155  }
156  double GetLoT() const {return LoT;}
157  double GetMidT() const {return MidT;}
158  double GetHiT() const {return HiT;}
159  void SetLoT(double val){LoT=val;}
160  void SetMidT(double val){MidT=val;}
161  void SetHiT(double val){HiT=val;}
162 
163  char GetPhase() const {return phase;}
164  void SetPhase(char ph){phase=ph;}
165 };
166 
167 } //namespace OpenBabel
168 
169 #endif //OB_KINETICS_H
170 
const unsigned ThermoData
Definition: kinetics.h:25
double TroeParams[4]
Definition: kinetics.h:41
double GetRate(rate_type n) const
Definition: kinetics.h:56
Holds rate constant data for OBReaction.
Definition: kinetics.h:36
OBRateData()
Definition: kinetics.h:48
Definition: kinetics.h:46
Base class for generic data.
Definition: base.h:188
void SetTroeParams(int n, const double val)
Definition: kinetics.h:83
double GetTroeParam(int n) const
Definition: kinetics.h:78
char GetPhase() const
Definition: kinetics.h:163
reaction_type
Definition: kinetics.h:46
double GetMidT() const
Definition: kinetics.h:157
Definition: kinetics.h:46
double Rates[3]
Definition: kinetics.h:39
unsigned int _type
attribute type – declared for each subclass
Definition: base.h:192
rate_type
Definition: kinetics.h:45
char phase
Definition: kinetics.h:139
Definition: kinetics.h:45
void SetLoT(double val)
Definition: kinetics.h:159
double MidT
Definition: kinetics.h:138
double GetCoeff(unsigned n) const
Definition: kinetics.h:146
const unsigned RateData
Definition: kinetics.h:24
Thermodynamic data in old style NASA polynomial form for OBMol.
Definition: kinetics.h:134
reaction_type ReactionType
Definition: kinetics.h:47
double GetHiT() const
Definition: kinetics.h:158
Definition: kinetics.h:45
void SetRate(rate_type n, const double val)
Definition: kinetics.h:61
double GetEfficiency(std::string id)
Definition: kinetics.h:94
void SetLoRate(rate_type n, const double val)
Definition: kinetics.h:72
Definition: kinetics.h:46
void SetHiT(double val)
Definition: kinetics.h:161
Definition: kinetics.h:46
OBNasaThermoData()
Definition: kinetics.h:141
Definition: kinetics.h:46
double GetLoT() const
Definition: kinetics.h:156
Definition: kinetics.h:45
bool GetNextEff(std::string &id, double &Eff)
Definition: kinetics.h:99
double GetLoRate(rate_type n) const
Definition: kinetics.h:67
virtual OBGenericData * Clone(OBBase *parent) const
Definition: kinetics.h:144
std::map< std::string, double > Efficiencies
Definition: kinetics.h:42
virtual OBGenericData * Clone(OBBase *parent) const
Definition: kinetics.h:44
void SetMidT(double val)
Definition: kinetics.h:160
Handle generic data classes. Custom data for atoms, bonds, etc.
void SetEfficiency(std::string id, double Eff)
Definition: kinetics.h:89
Base Class.
Definition: base.h:239
std::string _attr
attribute tag (e.g., "UnitCell", "Comment" or "Author")
Definition: base.h:191
void SetPhase(char ph)
Definition: kinetics.h:164
double LoRates[3]
Definition: kinetics.h:40
void SetCoeff(unsigned n, const double val)
Definition: kinetics.h:151
Global namespace for all Open Babel code.
Definition: alias.h:22