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 |
#ifdef ASC_WITH_IDA |
39 |
const int IDA = INTEG_IDA; |
40 |
#endif |
41 |
|
42 |
#include "simulation.h" |
43 |
#include "units.h" |
44 |
#include "integratorreporter.h" |
45 |
#include "variable.h" |
46 |
|
47 |
class Integrator{ |
48 |
friend class IntegratorReporterCxx; |
49 |
friend class IntegratorReporterConsole; |
50 |
|
51 |
public: |
52 |
Integrator(Simulation &); |
53 |
~Integrator(); |
54 |
|
55 |
static std::map<int,std::string> getEngines(); |
56 |
void setEngine(IntegratorEngine engine); |
57 |
void setEngine(int engine); |
58 |
void setEngine(const std::string &name); |
59 |
std::string getEngineName() const; |
60 |
|
61 |
SolverParameters getParameters() const; |
62 |
void setParameters(const SolverParameters &); |
63 |
|
64 |
void setReporter(IntegratorReporterCxx *reporter); |
65 |
|
66 |
void setMinSubStep(double); |
67 |
void setMaxSubStep(double); |
68 |
void setInitialSubStep(double); |
69 |
void setMaxSubSteps(int); |
70 |
|
71 |
void setLinearTimesteps(UnitsM units, double start, double end, unsigned long num); |
72 |
void setLogTimesteps(UnitsM units, double start, double end, unsigned long num); |
73 |
std::vector<double> getCurrentObservations(); |
74 |
Variable getObservedVariable(const long &i); |
75 |
Variable getIndependentVariable(); |
76 |
|
77 |
int findIndependentVar(); /** find the independent variable (must not presume a certain choice of integration engine) */ |
78 |
int analyse(); /** analysis gives you details about what your variables are etc */ |
79 |
void solve(); |
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 |