1 |
/* ASCEND modelling environment |
2 |
Copyright (C) 2006 Carnegie Mellon University |
3 |
|
4 |
This program is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
6 |
the Free Software Foundation; either version 2, or (at your option) |
7 |
any later version. |
8 |
|
9 |
This program is distributed in the hope that it will be useful, |
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
GNU General Public License for more details. |
13 |
|
14 |
You should have received a copy of the GNU General Public License |
15 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 |
*//** @file |
17 |
C++ wrapper for the Integrator interface. Intention is that this will allow |
18 |
us to use the PyGTK 'observer' tab to receive the results of an integration |
19 |
job, which can then be easily exported to a spreadsheet for plotting (or |
20 |
we can implement ASCPLOT style plotting, perhaps). |
21 |
*/ |
22 |
#ifndef ASCXX_INTEGRATOR_H |
23 |
#define ASCXX_INTEGRATOR_H |
24 |
|
25 |
#include <string> |
26 |
#include <map> |
27 |
#include <vector> |
28 |
|
29 |
#include "config.h" |
30 |
extern "C"{ |
31 |
#include <ascend/integrator/integrator.h> |
32 |
#include <ascend/integrator/samplelist.h> |
33 |
} |
34 |
|
35 |
const int LSODE = INTEG_LSODE; |
36 |
#ifdef ASC_WITH_IDA |
37 |
const int IDA = INTEG_IDA; |
38 |
#endif |
39 |
|
40 |
#include "simulation.h" |
41 |
#include "units.h" |
42 |
#include "integratorreporter.h" |
43 |
#include "variable.h" |
44 |
|
45 |
class Integrator{ |
46 |
friend class IntegratorReporterCxx; |
47 |
friend class IntegratorReporterConsole; |
48 |
|
49 |
public: |
50 |
Integrator(Simulation &); |
51 |
~Integrator(); |
52 |
|
53 |
static std::vector<std::string> getEngines(); |
54 |
void setEngine(const std::string &name); |
55 |
std::string getName() const; |
56 |
|
57 |
SolverParameters getParameters() const; |
58 |
void setParameters(const SolverParameters &); |
59 |
|
60 |
void setReporter(IntegratorReporterCxx *reporter); |
61 |
|
62 |
void setMinSubStep(double); |
63 |
void setMaxSubStep(double); |
64 |
void setInitialSubStep(double); |
65 |
void setMaxSubSteps(int); |
66 |
|
67 |
void setLinearTimesteps(UnitsM units, double start, double end, unsigned long num); |
68 |
void setLogTimesteps(UnitsM units, double start, double end, unsigned long num); |
69 |
std::vector<double> getCurrentObservations(); |
70 |
Variable getObservedVariable(const long &i); |
71 |
Variable getIndependentVariable(); |
72 |
|
73 |
void findIndependentVar(); /**< find the independent variable (must not presume a certain choice of integration engine) */ |
74 |
void analyse(); |
75 |
void solve(); |
76 |
|
77 |
/** write out a named matrix associated with the integrator, if possible. type can be NULL for the default matrix. */ |
78 |
void writeMatrix(FILE *fp,const char *type) const; |
79 |
void writeDebug(FILE *fp) const; |
80 |
|
81 |
double getCurrentTime(); |
82 |
long getCurrentStep(); |
83 |
long getNumSteps(); |
84 |
int getNumVars(); |
85 |
int getNumObservedVars(); |
86 |
|
87 |
protected: |
88 |
IntegratorSystem *getInternalType(); |
89 |
private: |
90 |
Simulation &simulation; |
91 |
SampleList *samplelist; |
92 |
IntegratorSystem *blsys; |
93 |
}; |
94 |
|
95 |
#endif |