/[ascend]/trunk/pygtk/simulation.h
ViewVC logotype

Contents of /trunk/pygtk/simulation.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1133 - (show annotations) (download) (as text)
Sun Jan 14 11:51:48 2007 UTC (13 years, 4 months ago) by johnpye
File MIME type: text/x-chdr
File size: 3126 byte(s)
Removed the 'REX' and 'IEX' array aliases (added the solver parameter comments directly in the slv_param_* calls).
Renamed Simulation::[gs]etSolverParameters to Simulation::[gs]etParameters.
Added [gs]etParameter (singular) methods to SWIG wrapper.
Fixed missing NULL in IDA.
Fixed bug with BDF/AM wrong way round in LSODE.
Removed some debug output from slv.c
1 #ifndef ASCXX_SIMULATION_H
2 #define ASCXX_SIMULATION_H
3
4 #include <string>
5 #include <vector>
6 #include <map>
7
8 #include "symchar.h"
9 #include "type.h"
10 #include "instance.h"
11 #include "variable.h"
12 #include "relation.h"
13
14 #include "config.h"
15 extern "C"{
16 #include <compiler/createinst.h>
17 #include <solver/slv_types.h>
18 }
19
20 class Solver;
21 class SolverParameters;
22 class SolverStatus;
23 class IncidenceMatrix;
24 class SolverReporter;
25 class Matrix;
26
27 /**
28 A class to contain singularity information as returned by the DOF
29 function slvDOF_structsing.
30 */
31 class SingularityInfo{
32 public:
33 bool isSingular() const;
34 std::vector<Relation> rels; /**< relations involved in the singularity */
35 std::vector<Variable> vars; /**< variables involved in the singularity */
36 std::vector<Variable> freeablevars; /**< vars that should be freed */
37 };
38
39 enum StructuralStatus{
40 ASCXX_DOF_UNDERSPECIFIED=1,
41 ASCXX_DOF_SQUARE=2, /* = everything's ok */
42 ASCXX_DOF_OVERSPECIFIED=4,
43 ASCXX_DOF_STRUCT_SINGULAR=3
44 };
45
46 /**
47 @TODO This class is for *Simulation* instances.
48
49 Handle instantiating, running initialisation functions, solving
50 and outputing results of solutions.
51
52 In ASCEND C-code, a simulation is a special type of Instance. It
53 has a 'simulation root' instance which often needs to be used for
54 solving, inspecting, etc, rather than the simulation instance itself.
55
56 The Simulation can be exported to an Integrator (for time-stepping)
57 or a Solver (for steady-state solutions).
58
59 At present the architecture is a bit muddy wrt to way that Solvers and
60 Integrators 'act on' the Simulation. We need to work on improving the
61 delimitation of solver and integrator, and keeping better track of the
62 state of the Simulation (has it been 'built', etc).
63 */
64 class Simulation : public Instanc{
65 friend class IncidenceMatrix;
66 friend class SolverStatus;
67 friend class Integrator;
68
69 private:
70 Instanc simroot;
71 slv_system_structure *sys;
72 bool is_built;
73 SingularityInfo *sing; /// will be used to store this iff singularity found
74 int activeblock;
75
76 protected:
77 slv_system_structure *getSystem();
78 Simulation();
79
80 public:
81 explicit Simulation(Instance *i, const SymChar &name);
82 Simulation(const Simulation &);
83 ~Simulation();
84
85 Instanc &getModel();
86
87 void runDefaultMethod();
88 void run(const Method &method);
89 void run(const Method &method, Instanc &model);
90 enum StructuralStatus checkDoF() const;
91 void checkInstance();
92 void build();
93 void solve(Solver s, SolverReporter &reporter);
94 std::vector<Variable> getFixableVariables();
95 std::vector<Variable> getVariablesNearBounds(const double &epsilon=1e-4);
96 std::vector<Variable> getFixedVariables();
97 Matrix getMatrix();
98
99 void write();
100
101 void setSolver(Solver &s);
102 const Solver getSolver() const;
103
104 SolverParameters getParameters() const;
105 void setParameters(SolverParameters &);
106
107 IncidenceMatrix getIncidenceMatrix();
108
109 const std::string getInstanceName(const Instanc &) const;
110
111 void processVarStatus();
112 const int getNumVars();
113
114 const int getActiveBlock() const;
115
116 std::vector<Variable> getFreeableVariables();
117 bool checkStructuralSingularity();
118 const SingularityInfo &getSingularityInfo() const;
119 };
120
121
122 #endif

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22