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

Contents of /trunk/pygtk/simulation.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 774 - (show annotations) (download) (as text)
Fri Jul 14 08:01:48 2006 UTC (13 years, 7 months ago) by johnpye
File MIME type: text/x-chdr
File size: 2666 byte(s)
Added the ability to run methods on sub-models within a simulation. Use the right-click context menu.
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 /**
39 @TODO This class is for *Simulation* instances.
40
41 Handle instantiating, running initialisation functions, solving
42 and outputing results of solutions.
43
44 In ASCEND C-code, a simulation is a special type of Instance. It
45 has a 'simulation root' instance which often needs to be used for
46 solving, inspecting, etc, rather than the simulation instance itself.
47 */
48 class Simulation : public Instanc{
49 friend class IncidenceMatrix;
50 friend class SolverStatus;
51 friend class Integrator;
52
53 private:
54 Instanc simroot;
55 slv_system_structure *sys;
56 bool is_built;
57 SingularityInfo *sing; /// will be used to store this iff singularity found
58
59 // options to pass to BinTokenSetOptions
60 /// TODO these should probably be put somewhere else
61 std::string *bin_srcname;
62 std::string *bin_objname;
63 std::string *bin_libname;
64 std::string *bin_cmd;
65 std::string *bin_rm;
66
67 int activeblock;
68
69 protected:
70 slv_system_structure *getSystem();
71
72 public:
73 explicit Simulation(Instance *i, const SymChar &name);
74 Simulation(const Simulation &);
75 ~Simulation();
76
77 Instanc &getModel();
78 void run(const Method &method);
79 void run(const Method &method, Instanc &model);
80 void checkDoF() const;
81 const bool check();
82 void build();
83 void solve(Solver s, SolverReporter &reporter);
84 std::vector<Variable> getFixableVariables();
85 std::vector<Variable> getVariablesNearBounds(const double &epsilon=1e-4);
86
87 void write();
88
89 void setSolver(Solver &s);
90 const Solver getSolver() const;
91
92 SolverParameters getSolverParameters() const;
93 void setSolverParameters(SolverParameters &);
94
95 IncidenceMatrix getIncidenceMatrix();
96
97 const std::string getInstanceName(const Instanc &) const;
98
99 void processVarStatus();
100 const int getNumVars();
101
102 const int getActiveBlock() const;
103
104 void checkConsistency() const;
105 bool checkStructuralSingularity();
106 const SingularityInfo &getSingularityInfo() const;
107 };
108
109
110 #endif

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