Program listing for file control/src/Controller/CommonSMC.hpp

Program listing for file control/src/Controller/CommonSMC.hpp#

  1#ifndef CommonSMC_H
  2#define CommonSMC_H
  3
  4#include "Actuator.hpp"
  5#include "SiconosAlgebraTypeDef.hpp"
  6#include "SiconosFwd.hpp"
  7
  8#include <relay_cst.h>
  9
 10class CommonSMC : public Actuator
 11{
 12private:
 13  ACCEPT_SERIALIZATION(CommonSMC);
 14
 15protected:
 16
 17  CommonSMC() {};
 18
 19
 20  unsigned int _indx;
 21
 22
 23  std::string _plugineName;
 24
 25
 26  std::string _pluginhName;
 27
 28
 29  std::string _pluginJachxName;
 30
 31
 32  std::string _pluginJachlambdaName;
 33
 34
 35  std::string _pluginJacglambdaName;
 36
 37
 38  SP::SimpleMatrix _Csurface;
 39
 40
 41  SP::SimpleMatrix _D;
 42
 43
 44  double _alpha;
 45
 46
 47  SP::FirstOrderR _relationSMC;
 48
 49
 50  SP::Interaction _interactionSMC;
 51
 52
 53  SP::SiconosVector _lambda;
 54
 55
 56  int _numericsSolverId;
 57
 58
 59  double _precision;
 60
 61
 62  SP::NonSmoothDynamicalSystem _nsdsSMC;
 63
 64
 65  SP::FirstOrderNonLinearDS _DS_SMC;
 66
 67
 68  SP::TimeDiscretisation _td;
 69
 70
 71  SP::TimeStepping _simulationSMC;
 72
 73
 74  SP::OneStepIntegrator _integratorSMC;
 75
 76
 77  double _thetaSMC;
 78
 79
 80  SP::LinearOSNS _OSNSPB_SMC;
 81
 82
 83  SP::EventsManager _eventsManager;
 84
 85
 86  SP::NonSmoothLaw _nsLawSMC;
 87
 88
 89  SP::SimpleMatrix _invCB;
 90
 91
 92  SP::SiconosVector _ueq;
 93
 94
 95  SP::SiconosVector _us;
 96
 97
 98  bool _noUeq;
 99
100
101  bool _computeResidus;
102
103
104  void computeUeq();
105
106public:
107
108
109  CommonSMC(unsigned int type, SP::ControlSensor sensor): Actuator(type, sensor),
110    _indx(0), _alpha(1.0), _numericsSolverId(SICONOS_RELAY_AVI_CAOFERRIS), _precision(1e-8),
111    _thetaSMC(0.5), _noUeq(false), _computeResidus(true) {}
112
113
114  CommonSMC(unsigned int type, SP::ControlSensor sensor, SP::SimpleMatrix B, SP::SimpleMatrix D = std::shared_ptr<SimpleMatrix>()):
115    Actuator(type, sensor, B), _indx(0), _D(D), _alpha(1.0), _numericsSolverId(SICONOS_RELAY_AVI_CAOFERRIS),
116    _precision(1e-8), _thetaSMC(0.5), _noUeq(false), _computeResidus(true) {}
117
118
119
120  virtual void actuate() = 0;
121
122
123  virtual void initialize(const NonSmoothDynamicalSystem& nsds, const Simulation& s);
124
125
126  void sete(const std::string& plugin);
127  void seth(const std::string& plugin);
128  void setJachx(const std::string& plugin);
129  void setJachlambda(const std::string& plugin);
130  void setg(const std::string& plugin);
131  void setJacgx(const std::string& plugin);
132  void setJacglambda(const std::string& plugin);
133
134
135  void setCsurface(SP::SimpleMatrix Csurface);
136
137
138  void setSaturationMatrix(SP::SimpleMatrix newSat);
139
140
141  inline void setAlpha(double alpha) { _alpha = alpha; };
142
143
144  inline SP::SiconosVector lambda() const
145  {
146    return _lambda;
147  };
148
149
150  inline void setSolver(const int numericsSolverId)
151  {
152    _numericsSolverId = numericsSolverId;
153  };
154
155
156  inline void setPrecision(double newPrecision)
157  {
158    _precision = newPrecision;
159  };
160
161
162  inline const LinearOSNS& relay()
163  {
164    return * _OSNSPB_SMC;
165  };
166
167
168  inline SiconosVector& ueq()
169  {
170    return *_ueq;
171  };
172
173
174
175  inline SiconosVector& us()
176  {
177    return *_us;
178  };
179
180
181
182  inline void setTheta(double newTheta)
183  {
184    _thetaSMC = newTheta;
185  };
186
187
188  inline void noUeq(bool b)
189  {
190    _noUeq = b;
191  };
192
193
194  inline void setComputeResidus(bool b)
195  {
196    _computeResidus = b;
197  };
198
199
200  virtual void setTimeDiscretisation(const TimeDiscretisation& td);
201
202
203  void setDS(SP::FirstOrderNonLinearDS ds)
204  {
205    _DS_SMC = ds;
206  };
207
208
209  virtual SP::NonSmoothDynamicalSystem getInternalNSDS() const { return _nsdsSMC; };
210
211
212  OneStepIntegrator& getInternalOSI() const { return *_integratorSMC; };
213
214};
215#endif