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

Contents of /trunk/pygtk/simulation.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1046 - (show annotations) (download) (as text)
Fri Jan 5 11:15:16 2007 UTC (13 years, 3 months ago) by johnpye
File MIME type: text/x-chdr
File size: 3059 byte(s)
Several changes to get BinToken compilation active again from PyGTK interface. Still not working but the problems now are in the C layer.
Tidied doc for slvDOF.h
Changed BinTokenSetOptions to saner use of strings -- no more 'taking ownership' of char arrays passed.
Added Compiler.use_binary_compilation option in PyGTK GUI.
Moved all the bintoken stuff out of class Type and into Compiler, where it should be (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
26 /**
27 A class to contain singularity information as returned by the DOF
28 function slvDOF_structsing.
29 */
30 class SingularityInfo{
31 public:
32 bool isSingular() const;
33 std::vector<Relation> rels; /**< relations involved in the singularity */
34 std::vector<Variable> vars; /**< variables involved in the singularity */
35 std::vector<Variable> freeablevars; /**< vars that should be freed */
36 };
37
38 enum StructuralStatus{
39 ASCXX_DOF_UNDERSPECIFIED=1,
40 ASCXX_DOF_SQUARE=2, /* = everything's ok */
41 ASCXX_DOF_OVERSPECIFIED=4,
42 ASCXX_DOF_STRUCT_SINGULAR=3
43 };
44
45 /**
46 @TODO This class is for *Simulation* instances.
47
48 Handle instantiating, running initialisation functions, solving
49 and outputing results of solutions.
50
51 In ASCEND C-code, a simulation is a special type of Instance. It
52 has a 'simulation root' instance which often needs to be used for
53 solving, inspecting, etc, rather than the simulation instance itself.
54
55 The Simulation can be exported to an Integrator (for time-stepping)
56 or a Solver (for steady-state solutions).
57
58 At present the architecture is a bit muddy wrt to way that Solvers and
59 Integrators 'act on' the Simulation. We need to work on improving the
60 delimitation of solver and integrator, and keeping better track of the
61 state of the Simulation (has it been 'built', etc).
62 */
63 class Simulation : public Instanc{
64 friend class IncidenceMatrix;
65 friend class SolverStatus;
66 friend class Integrator;
67
68 private:
69 Instanc simroot;
70 slv_system_structure *sys;
71 bool is_built;
72 SingularityInfo *sing; /// will be used to store this iff singularity found
73 int activeblock;
74
75 protected:
76 slv_system_structure *getSystem();
77 Simulation();
78
79 public:
80 explicit Simulation(Instance *i, const SymChar &name);
81 Simulation(const Simulation &);
82 ~Simulation();
83
84 Instanc &getModel();
85
86 void runDefaultMethod();
87 void run(const Method &method);
88 void run(const Method &method, Instanc &model);
89 enum StructuralStatus checkDoF() const;
90 void checkInstance();
91 void build();
92 void solve(Solver s, SolverReporter &reporter);
93 std::vector<Variable> getFixableVariables();
94 std::vector<Variable> getVariablesNearBounds(const double &epsilon=1e-4);
95
96 void write();
97
98 void setSolver(Solver &s);
99 const Solver getSolver() const;
100
101 SolverParameters getSolverParameters() const;
102 void setSolverParameters(SolverParameters &);
103
104 IncidenceMatrix getIncidenceMatrix();
105
106 const std::string getInstanceName(const Instanc &) const;
107
108 void processVarStatus();
109 const int getNumVars();
110
111 const int getActiveBlock() const;
112
113 std::vector<Variable> getFreeableVariables();
114 bool checkStructuralSingularity();
115 const SingularityInfo &getSingularityInfo() const;
116 };
117
118
119 #endif

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