[go: up one dir, main page]

Menu

[r1130]: / trunk / src / System.h  Maximize  Restore  History

Download this file

153 lines (114 with data), 5.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#ifndef GUARD_System_h
#define GUARD_System_h
//-------------------------------------------------------------------------------------------
//
// System.h
//
// Author: Struan Robertson
// Date: 11/Feb/2003
//
// This header file contains the declaration of the System class. This class is the route
// of all molecular and reaction data will contain information about any number of System.
// Reaction System inforamtion will be sorted in a vector of reaction maps. Molecular data
// is stored in the molecule manager.
//
//-------------------------------------------------------------------------------------------
#include <set>
#include "plugin.h"
#include "ReactionManager.h"
#include "calcmethod.h"
#include "CollisionOperator.h"
#include "ConditionsManager.h"
#define MESMER_VERSION "4.0"
namespace mesmer
{
///Search the library of molecules. If PPMolList is valid copy to the main XML file,
// replacing an existing molecule of same name. Return a pointer to the copy (or the librymol).
extern PersistPtr GetFromLibrary(const std::string molName, PersistPtr ppMolList);
//global variable
extern std::string libfile;
class CalcMethod;
class System
{
public:
System(const std::string& libraryfilename) ;
~System() ;
// Initialize the System object.
bool initialize(void) ;
// Read and parse a data input file.
bool parse(PersistPtr ppIOPtr) ;
// Begin calculation.
void executeCalculation() ;
// Begin single calculation.
bool calculate(double& chiSquare, vector<double> &residuals, bool writeReport = false) ;
// Begin single calculation - wrapper function.
bool calculate(double& chiSquare, bool writeReport = false) {
vector<double> residuals ;
return calculate(chiSquare, residuals, writeReport) ;
} ;
// Calculate rate coefficients etc. for a specific condition.
bool calculate(size_t nCond, vector<double> &Quantities, bool writeReport = false) ;
// Begin single calculation.
bool calculate(double &Temperature, double &Concentration, Precision precision,
map<string, double> &phenRates, double &MaxT, const std::string& bathGas);
// Wrapper for single calculation.
bool calculate(size_t nCond, map<string, double> &phenRates) {
//
// Reset microcanonical rate re-calculation flag as parameters, such
// as reaction threshold may have been altered between invocations of
// this method.
//
for (size_t i(0) ; i < m_pReactionManager->size() ; ++i) {
(*m_pReactionManager)[i]->resetCalcFlag();
}
double temp = m_pConditionsManager->PTPointTemp(nCond) ;
double conc = m_pConditionsManager->PTPointConc(nCond);
Precision precision = m_pConditionsManager->PTPointPrecision(nCond) ;
string bathGas(m_pConditionsManager->PTPointBathGas(nCond)) ;
double MaxT(2.0*temp) ;
return calculate(temp, conc, precision, phenRates, MaxT, bathGas);
} ;
// Print system configuration
void configuration(void);
// Deduce the role of each molecule and add it to the XML file
bool assignMolTypes(PersistPtr ppIOPtr) ;
void WriteMetadata(const std::string& infilename);
PersistPtr getPersistPtr() { return m_ppIOPtr; }
PersistPtr getAnalysisPtr() { return m_ppAnalysis; }
MoleculeManager* getMoleculeManager() { return m_pMoleculeManager; } ;
ReactionManager* getReactionManager() { return m_pReactionManager; } ;
ConditionsManager* getConditionsManager(){ return m_pConditionsManager; } ;
// Mesmer control flags.
MesmerFlags m_Flags;
// for each <control> block
std::vector<MesmerFlags> m_FlagsForEachControl;
std::vector<CalcMethod*> m_CalcMethodsForEachControl;
std::vector<ConditionsManager*> m_ConditionsForEachControl;
MesmerEnv& getEnv() { return m_Env; } ;
//Visit each set of Conditions to collect bath gas names
void getAllBathGases(std::set<std::string>& bathGases);
private:
double calcChiSqRateCoefficients(const qdMatrix& mesmerRates, const unsigned calPoint, stringstream &rateCoeffTable, vector<double> &residuals) ;
double calcChiSqYields(const unsigned calPoint, stringstream &rateCoeffTable, vector<double> &residuals);
double calcChiSqEigenvalues(const unsigned calPoint, stringstream &rateCoeffTable, vector<double> &residuals);
//Add extra attributes) containing calculated value and timestamp to <me:experimentalRate> (or similar element)
void AddCalcValToXml(const unsigned calPoint, size_t i, double val) const;
// Location of the molecule manager.
MoleculeManager *m_pMoleculeManager;
// Location of the reaction mananger.
ReactionManager *m_pReactionManager ;
ConditionsManager* m_pConditionsManager;
// Physical variables. Reference to this are passed to all Molecule and Reaction constructors.
MesmerEnv m_Env;
// level in XML file under <mesemer>
PersistPtr m_ppIOPtr;
// current <analysis> element
PersistPtr m_ppAnalysis;
// The method used for the main calculation
CalcMethod* m_CalcMethod;
const char* m_pTitle;
const char* m_pDescription;
CollisionOperator m_collisionOperator ;
} ;
}//namespace
#endif // GUARD_System_h