1 #ifndef _SIMULATION_CLASSES_H
2 #define _SIMULATION_CLASSES_H
4 #include "mbsim/dynamic_system_solver.h"
5 #include "mbsim/object.h"
6 #include "mbsim/link.h"
7 #include "mbsim/mbsim_event.h"
8 #include "modelling_classes.h"
12 namespace MBSimControl {
16 namespace MBSimElectronics {
22 std::vector<Branch*> branch;
25 void calcqSize() { qSize = 1;}
26 void calcuSize(
int j) { uSize[j] = (j==0) ? 1 : 0;}
27 void updateStateDependentVariables(
double t) {};
28 void updateJacobians(
double t,
int j=0) {};
29 void updateInverseKineticsJacobians(
double t) {};
30 void init(InitStage stage);
31 Object* getObjectDependingOn()
const {
return precessor;}
32 void setPrecessor(Object* obj) {precessor = obj;}
33 void addBranch(
Branch* branch_) {branch.push_back(branch_);}
34 int getNumberOfBranches() {
return branch.size();}
35 Branch* getBranch(
int i) {
return branch[i];}
36 #ifdef HAVE_OPENMBVCPPINTERFACE
37 boost::shared_ptr<OpenMBV::Group> getOpenMBVGrp() {
return boost::shared_ptr<OpenMBV::Group>(); }
45 std::vector<Mesh*> mesh;
46 std::vector<double> vz;
47 Terminal *startTerminal, *endTerminal;
48 std::vector<Branch*> connectedBranch;
52 Branch(
const std::string &name) : Object(name), Q(1), I(1), flag(0), precessor(0) {}
53 void calcuSize(
int j) { uSize[j] = (j==0) ? 0 : 1;}
54 void updateStateDependentVariables(
double t);
55 void updateJacobians(
double t,
int j=0) {};
56 void updateInverseKineticsJacobians(
double t) {};
57 const fmatvec::Mat& getJacobian(
int j)
const {
return J[j];}
63 void setvz(
double vz_,
Mesh* mesh);
64 void connect(
Mesh *mesh_) {mesh.push_back(mesh_);mesh_->addBranch(
this);vz.push_back(0);}
65 void clearMeshList() {mesh.clear();}
66 int getNumberOfConnectedMeshes()
const {
return mesh.size();}
67 Mesh* getMesh(
int i) {
return mesh[i];}
68 void init(InitStage stage);
69 void setStartTerminal(
Terminal* p) {startTerminal = p; p->addConnectedBranch(
this);}
70 void setEndTerminal(
Terminal* p) {endTerminal = p; p->addConnectedBranch(
this);}
71 Terminal* getStartTerminal() {
return startTerminal;}
72 Terminal* getEndTerminal() {
return endTerminal;}
73 void addConnectedBranch(
Branch* branch);
74 void buildTreeBranches(
Branch* callingBranch, std::vector<Branch*> &treeBranch,
unsigned int nmax);
75 void buildMeshes(
Terminal* callingTerminal,
Branch* callingBranch,
Mesh* currentMesh,
bool &foundMesh);
77 void setFlag(
int f) { flag = f; }
78 int getFlag()
const {
return flag; }
79 Object* getObjectDependingOn()
const {
return precessor;}
80 void setPrecessor(Object* obj) {precessor = obj;}
81 void updateh0Fromh1(
double t);
82 void updateW0FromW1(
double t);
83 void updateV0FromV1(
double t);
84 #ifdef HAVE_OPENMBVCPPINTERFACE
85 boost::shared_ptr<OpenMBV::Group> getOpenMBVGrp() {
return boost::shared_ptr<OpenMBV::Group>(); }
94 virtual Element* getParent() {
return parent;}
95 virtual const Element* getParent()
const {
return parent;}
96 virtual void setParent(Element* parent_) {parent = parent_;}
98 void calcgSize(
int j);
99 void calcgdSize(
int j);
100 void calclaSize(
int j);
101 void updateg(
double t);
102 void updategd(
double t);
103 void updateW(
double t,
int j=0);
104 void plot(
double t,
double dt = 1);
105 virtual std::string getName()
const {
return Link::getName();}
106 virtual void setName(std::string name) {Link::setName(name);}
107 bool isActive()
const {
return true;}
108 bool gActiveChanged() {
return true;}
109 virtual bool isSingleValued()
const {
return true; }
110 void init(InitStage stage);
113 virtual double computeVoltage() {
return 0;}
116 virtual void updater(
double t) { THROW_MBSIMERROR(
"(ElectronicLink::updater): Not implemented!"); }
120 virtual void updateWRef(
const fmatvec::Mat& ref,
int j);
121 virtual void updateVRef(
const fmatvec::Mat& ref,
int j);
122 virtual void updatedhdqRef(
const fmatvec::Mat& ref,
int i=0) {}
124 virtual void updatedhdtRef(
const fmatvec::Vec& ref,
int i=0) {}
133 void updateh(
double t,
int j=0);
134 void setResistance(
double R_) { R = R_;}
135 double computeVoltage();
143 void updateh(
double t,
int j=0);
144 void setCapacity(
double C_) { C = C_;}
153 void updateh(
double t,
int j=0);
162 Diode(
const std::string &name);
163 void setSetValued(
bool flag) {sv = flag;}
164 void updateh(
double t,
int j=0);
165 bool isSetValued()
const {
return sv;}
166 virtual bool isSingleValued()
const {
return not sv;}
167 void checkImpactsForTermination(
double dt);
168 void solveImpactsGaussSeidel(
double dt);
178 Switch(
const std::string &name);
179 void setSetValued(
bool flag) {sv = flag;}
180 bool isSetValued()
const {
return sv;}
181 virtual bool isSingleValued()
const {
return not sv;}
182 void updateh(
double t,
int j=0);
183 void updateW(
double t,
int j=0);
184 void checkImpactsForTermination(
double dt);
185 void solveImpactsGaussSeidel(
double dt);
194 void init(InitStage stage);
195 virtual Element* getParent() {
return parent;}
196 virtual const Element* getParent()
const {
return parent;}
197 virtual void setParent(Element* parent_) {parent = parent_;}
198 void plot(
double t,
double dt = 1);
199 void updateStateDependentVariables(
double t) {};
200 void updateJacobians(
double t,
int j=0) {};
201 void updateInverseKineticsJacobians(
double t) {};
202 virtual std::string getName()
const {
return Object::getName();}
203 virtual void setName(std::string name) {Object::setName(name);}
204 Object* getObjectDependingOn()
const {
return branch;}
205 #ifdef HAVE_OPENMBVCPPINTERFACE
206 boost::shared_ptr<OpenMBV::Group> getOpenMBVGrp() {
return boost::shared_ptr<OpenMBV::Group>(); }
215 void updateM(
double t,
int j=0);
216 void setInductance(
double L_) { L = L_;}
217 void updateStateDependentVariables(
double t);
Definition: simulation_classes.h:138
Definition: simulation_classes.h:89
Definition: simulation_classes.h:210
Definition: simulation_classes.h:158
Definition: simulation_classes.h:128
Definition: simulation_classes.h:190
Definition: simulation_classes.h:19
Definition: simulation_classes.h:41
Definition: modelling_classes.h:42
Definition: simulation_classes.h:171
Definition: modelling_classes.h:19
Definition: simulation_classes.h:147