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, write to the Free Software |
16 |
Foundation, Inc., 59 Temple Place - Suite 330, |
17 |
Boston, MA 02111-1307, USA. |
18 |
*//** @file |
19 |
C++ wrapper for the Integrator interface. Intention is that this will allow |
20 |
us to use the PyGTK 'observer' tab to receive the results of an integration |
21 |
job, which can then be easily exported to a spreadsheet for plotting (or |
22 |
we can implement ASCPLOT style plotting, perhaps). |
23 |
*/ |
24 |
#ifndef ASCXX_INTEGRATOR_H |
25 |
#define ASCXX_INTEGRATOR_H |
26 |
|
27 |
#include <string> |
28 |
#include <map> |
29 |
#include <vector> |
30 |
|
31 |
#include "config.h" |
32 |
extern "C"{ |
33 |
#include <solver/integrator.h> |
34 |
#include <solver/samplelist.h> |
35 |
} |
36 |
|
37 |
const int LSODE = INTEG_LSODE; |
38 |
const int IDA = INTEG_IDA; |
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::map<int,std::string> getEngines(); |
54 |
void setEngine(IntegratorEngine engine); |
55 |
void setEngine(int engine); |
56 |
void setEngine(const std::string &name); |
57 |
std::string getEngineName() const; |
58 |
|
59 |
SolverParameters getParameters() const; |
60 |
void setParameters(const SolverParameters &); |
61 |
|
62 |
void setReporter(IntegratorReporterCxx *reporter); |
63 |
|
64 |
void setMinSubStep(double); |
65 |
void setMaxSubStep(double); |
66 |
void setInitialSubStep(double); |
67 |
void setMaxSubSteps(int); |
68 |
|
69 |
void setLinearTimesteps(UnitsM units, double start, double end, unsigned long num); |
70 |
void setLogTimesteps(UnitsM units, double start, double end, unsigned long num); |
71 |
std::vector<double> getCurrentObservations(); |
72 |
Variable getObservedVariable(const long &i); |
73 |
Variable getIndependentVariable(); |
74 |
|
75 |
int findIndependentVar(); /** find the independent variable (must not presume a certain choice of integration engine) */ |
76 |
int analyse(); /** analysis gives you details about what your variables are etc */ |
77 |
void solve(); |
78 |
|
79 |
double getCurrentTime(); |
80 |
long getCurrentStep(); |
81 |
long getNumSteps(); |
82 |
int getNumVars(); |
83 |
int getNumObservedVars(); |
84 |
|
85 |
protected: |
86 |
IntegratorSystem *getInternalType(); |
87 |
private: |
88 |
Simulation &simulation; |
89 |
SampleList *samplelist; |
90 |
IntegratorSystem *blsys; |
91 |
}; |
92 |
|
93 |
#endif |