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

Contents of /trunk/pygtk/simulation.h

Parent Directory Parent Directory | Revision Log Revision Log


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

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