MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Motor Class Reference

#include <motor.h>

Inheritance diagram for Motor:
Collaboration diagram for Motor:

Classes

struct  PrivData
 

Public Member Functions

 Motor (unsigned int uL, const DofOwner *pD, const StructNode *pN1, const StructNode *pN2, const ElectricNode *pV1, const ElectricNode *pV2, const Mat3x3 &Rn, doublereal dG, doublereal dl, DriveCaller *dR, doublereal i0, integer p, const DriveCaller *pM0, const DriveCaller *pM1, flag fOut)
 
virtual ~Motor (void)
 
virtual Electric::Type GetElectricType (void) const
 
virtual unsigned int iGetNumPrivData (void) const
 
virtual unsigned int iGetPrivDataIdx (const char *s) const
 
virtual doublereal dGetPrivData (unsigned int i) const
 
virtual std::ostream & Restart (std::ostream &out) const
 
virtual unsigned int iGetNumDof (void) const
 
virtual DofOrder::Order GetDofType (unsigned int i) const
 
virtual void WorkSpaceDim (integer *piNumRows, integer *piNumCols) const
 
VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
SubVectorHandlerAssRes (SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void SetInitialValue (VectorHandler &X)
 
virtual void SetValue (DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *h=0)
 
virtual void GetConnectedNodes (std::vector< const Node * > &connectedNodes) const
 
- Public Member Functions inherited from Elem
 Elem (unsigned int uL, flag fOut)
 
virtual ~Elem (void)
 
virtual std::ostream & DescribeDof (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeDof (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual std::ostream & DescribeEq (std::ostream &out, const char *prefix="", bool bInitial=false) const
 
virtual void DescribeEq (std::vector< std::string > &desc, bool bInitial=false, int i=-1) const
 
virtual void AssMats (VariableSubMatrixHandler &WorkMatA, VariableSubMatrixHandler &WorkMatB, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual bool bInverseDynamics (void) const
 
void SetInverseDynamicsFlags (unsigned uIDF)
 
unsigned GetInverseDynamicsFlags (void) const
 
bool bIsErgonomy (void) const
 
bool bIsRightHandSide (void) const
 
virtual VariableSubMatrixHandlerAssJac (VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
 
virtual SubVectorHandlerAssRes (SubVectorHandler &WorkVec, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr, const VectorHandler &XPrimePrimeCurr, InverseDynamics::Order iOrder=InverseDynamics::INVERSE_DYNAMICS)
 
virtual int GetNumConnectedNodes (void) const
 
- Public Member Functions inherited from WithLabel
 WithLabel (unsigned int uL=0, const std::string &sN="")
 
virtual ~WithLabel (void)
 
void PutLabel (unsigned int uL)
 
void PutName (const std::string &sN)
 
unsigned int GetLabel (void) const
 
const std::string & GetName (void) const
 
- Public Member Functions inherited from SimulationEntity
 SimulationEntity (void)
 
virtual ~SimulationEntity (void)
 
virtual bool bIsValidIndex (unsigned int i) const
 
virtual DofOrder::Order GetEqType (unsigned int i) const
 
virtual HintParseHint (DataManager *pDM, const char *s) const
 
virtual void BeforePredict (VectorHandler &, VectorHandler &, VectorHandler &, VectorHandler &) const
 
virtual void AfterPredict (VectorHandler &X, VectorHandler &XP)
 
virtual void Update (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void DerivativesUpdate (const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
 
virtual void Update (const VectorHandler &XCurr, InverseDynamics::Order iOrder)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP)
 
virtual void AfterConvergence (const VectorHandler &X, const VectorHandler &XP, const VectorHandler &XPP)
 
virtual std::ostream & OutputAppend (std::ostream &out) const
 
virtual void ReadInitialState (MBDynParser &HP)
 
- Public Member Functions inherited from ToBeOutput
 ToBeOutput (flag fOut=fDefaultOut)
 
virtual ~ToBeOutput (void)
 
virtual void OutputPrepare (OutputHandler &OH)
 
virtual void Output (OutputHandler &OH) const
 
virtual void Output (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
virtual flag fToBeOutput (void) const
 
virtual bool bToBeOutput (void) const
 
virtual void SetOutputFlag (flag f=flag(1))
 
- Public Member Functions inherited from Electric
 Electric (unsigned int uL, const DofOwner *pDO, flag fOut)
 
virtual ~Electric (void)
 
virtual Elem::Type GetElemType (void) const
 
- Public Member Functions inherited from ElemWithDofs
 ElemWithDofs (unsigned int uL, const DofOwner *pDO, flag fOut)
 
virtual ~ElemWithDofs (void)
 
- Public Member Functions inherited from DofOwnerOwner
 DofOwnerOwner (const DofOwner *pDO)
 
virtual ~DofOwnerOwner ()
 
virtual const DofOwnerpGetDofOwner (void) const
 
virtual integer iGetFirstIndex (void) const
 

Private Member Functions

doublereal dGetOmega () const
 
doublereal dGetVoltage () const
 
doublereal dGetOmega (const Vec3 &n) const
 
Vec3 GetAxisOfRotation () const
 
doublereal dGetPhiMechanical () const
 
doublereal dGetPhiElectric (doublereal Phi_m) const
 

Private Attributes

const StructNodepStrNode1
 
const StructNodepStrNode2
 
const ElectricNodepVoltage1
 
const ElectricNodepVoltage2
 
Mat3x3 Rn
 
doublereal dGain
 
doublereal dL
 
DriveOwner dR
 
integer p
 
DriveOwner M0
 
DriveOwner M1
 
doublereal M
 
doublereal i
 
doublereal iP
 
doublereal Phi_m
 
doublereal Phi_e
 

Static Private Attributes

static const int iNumPrivData = 12
 
static const struct Motor::PrivData rgPrivData [iNumPrivData]
 

Additional Inherited Members

- Public Types inherited from Elem
enum  Type {
  UNKNOWN = -1, AIRPROPERTIES = 0, INDUCEDVELOCITY, AUTOMATICSTRUCTURAL,
  GRAVITY, BODY, JOINT, JOINT_REGULARIZATION,
  BEAM, PLATE, FORCE, INERTIA,
  ELECTRICBULK, ELECTRIC, THERMAL, HYDRAULIC,
  BULK, LOADABLE, DRIVEN, EXTERNAL,
  AEROMODAL, AERODYNAMIC, GENEL, SOCKETSTREAM_OUTPUT,
  RTAI_OUTPUT = SOCKETSTREAM_OUTPUT, LASTELEMTYPE
}
 
- Public Types inherited from SimulationEntity
typedef std::vector< Hint * > Hints
 
- Public Types inherited from ToBeOutput
enum  { OUTPUT = 0x1U, OUTPUT_MASK = 0xFU, OUTPUT_PRIVATE = 0x10U, OUTPUT_PRIVATE_MASK = ~OUTPUT_MASK }
 
- Public Types inherited from Electric
enum  Type {
  UNKNOWN = -1, ACCELEROMETER = 0, DISPLACEMENT, DISCRETECONTROL,
  MOTOR, LASTELECTRICTYPE
}
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 
- Protected Attributes inherited from ToBeOutput
flag fOutput
 

Detailed Description

Definition at line 64 of file motor.h.

Constructor & Destructor Documentation

Motor::Motor ( unsigned int  uL,
const DofOwner pD,
const StructNode pN1,
const StructNode pN2,
const ElectricNode pV1,
const ElectricNode pV2,
const Mat3x3 Rn,
doublereal  dG,
doublereal  dl,
DriveCaller dR,
doublereal  i0,
integer  p,
const DriveCaller pM0,
const DriveCaller pM1,
flag  fOut 
)

Definition at line 84 of file motor.cc.

References dGain, DriveCaller::dGet(), dGetOmega(), dGetPhiElectric(), dGetPhiMechanical(), dGetVoltage(), grad::fabs(), i, iP, Phi_e, and Phi_m.

93 : Elem(uL, fOut),
94 Electric(uL, pD, fOut),
95 pStrNode1(pN1), pStrNode2(pN2), pVoltage1(pV1), pVoltage2(pV2),
96 Rn(Rn), dGain(dG), dL(dL), dR(dR), p(p), M0(pM0), M1(pM1), M(i0 * dG), i(i0)
97 {
98  const doublereal dU = dGetVoltage();
99  const doublereal omega = dGetOmega();
100 
101  iP = (dU - dGain * omega - dR->dGet(fabs(i)) * i) / dL;
102 
105 }
const StructNode * pStrNode1
Definition: motor.h:66
const ElectricNode * pVoltage1
Definition: motor.h:68
DriveOwner M1
Definition: motor.h:76
doublereal M
Definition: motor.h:85
doublereal i
Definition: motor.h:85
Electric(unsigned int uL, const DofOwner *pDO, flag fOut)
Definition: elec.cc:48
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
doublereal iP
Definition: motor.h:85
DriveOwner M0
Definition: motor.h:76
DriveOwner dR
Definition: motor.h:74
doublereal dGetPhiElectric(doublereal Phi_m) const
Definition: motor.cc:338
doublereal dGetVoltage() const
Definition: motor.cc:314
integer p
Definition: motor.h:75
const ElectricNode * pVoltage2
Definition: motor.h:69
doublereal Phi_m
Definition: motor.h:85
virtual doublereal dGet(const doublereal &dVar) const =0
Mat3x3 Rn
Definition: motor.h:71
doublereal Phi_e
Definition: motor.h:85
doublereal dGetOmega() const
Definition: motor.cc:326
doublereal dL
Definition: motor.h:73
doublereal dGetPhiMechanical() const
Definition: motor.cc:330
const StructNode * pStrNode2
Definition: motor.h:67
Elem(unsigned int uL, flag fOut)
Definition: elem.cc:41
double doublereal
Definition: colamd.c:52
doublereal dGain
Definition: motor.h:72

Here is the call graph for this function:

Motor::~Motor ( void  )
virtual

Definition at line 107 of file motor.cc.

References NO_OP.

108 {
109  NO_OP;
110 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

VariableSubMatrixHandler & Motor::AssJac ( VariableSubMatrixHandler WorkMat,
doublereal  dCoef,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr 
)
virtual

Implements Elem.

Definition at line 166 of file motor.cc.

References Vec3::Cross(), grad::Cross(), dGain, DriveOwner::dGet(), DriveOwner::dGetP(), dL, dR, grad::fabs(), Mat3x3::GetCol(), StructNode::GetgPCurr(), StructNode::GetRCurr(), StructNode::GetRRef(), StructNode::GetWCurr(), StructNode::GetWRef(), i, DofOwnerOwner::iGetFirstIndex(), StructDispNode::iGetFirstMomentumIndex(), StructDispNode::iGetFirstPositionIndex(), Node::iGetFirstRowIndex(), M, M0, M1, MatCross, Mat3x3::MulTM(), p, Phi_e, pStrNode1, pStrNode2, FullSubMatrixHandler::Put(), FullSubMatrixHandler::PutCoef(), FullSubMatrixHandler::PutColIndex(), FullSubMatrixHandler::PutRowIndex(), FullSubMatrixHandler::PutT(), pVoltage1, pVoltage2, FullSubMatrixHandler::ResizeReset(), Rn, VariableSubMatrixHandler::SetFull(), Mat3x3::Tens(), and WorkSpaceDim().

170 {
171  FullSubMatrixHandler& WM = WorkMat.SetFull();
172 
173  /* Dimensiona e resetta la matrice di lavoro */
174  integer iNumRows = 0;
175  integer iNumCols = 0;
176  WorkSpaceDim(&iNumRows, &iNumCols);
177  WM.ResizeReset(iNumRows, iNumCols);
178 
179  integer iStrNode1FirstPosIdx = pStrNode1->iGetFirstPositionIndex() + 3;
180  integer iStrNode2FirstPosIdx = pStrNode2->iGetFirstPositionIndex() + 3;
181  integer iStrNode1FirstMomIdx = pStrNode1->iGetFirstMomentumIndex() + 3;
182  integer iStrNode2FirstMomIdx = pStrNode2->iGetFirstMomentumIndex() + 3;
183  integer iElecNode1FirstIndex = pVoltage1->iGetFirstRowIndex() + 1;
184  integer iElecNode2FirstIndex = pVoltage2->iGetFirstRowIndex() + 1;
185  integer iFirstIndex = iGetFirstIndex() + 1;
186 
187  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
188  WM.PutRowIndex(iCnt, iStrNode1FirstMomIdx + iCnt);
189  WM.PutRowIndex(3+iCnt, iStrNode2FirstMomIdx + iCnt);
190 
191  WM.PutColIndex(iCnt, iStrNode1FirstPosIdx + iCnt);
192  WM.PutColIndex(3+iCnt, iStrNode2FirstPosIdx + iCnt);
193  }
194 
195  WM.PutRowIndex(7, iElecNode1FirstIndex);
196  WM.PutRowIndex(8, iElecNode2FirstIndex);
197  WM.PutRowIndex(9, iFirstIndex);
198 
199  WM.PutColIndex(7, iElecNode1FirstIndex);
200  WM.PutColIndex(8, iElecNode2FirstIndex);
201  WM.PutColIndex(9, iFirstIndex);
202 
203  const doublereal i = XCurr(iFirstIndex);
204  const Mat3x3& R1 = pStrNode1->GetRCurr();
205  const Mat3x3& R2 = pStrNode2->GetRCurr();
206  const Mat3x3& R1_0 = pStrNode1->GetRRef();
207  const Mat3x3& R2_0 = pStrNode2->GetRRef();
208  const Vec3& omega1 = pStrNode1->GetWCurr();
209  const Vec3& omega2 = pStrNode2->GetWCurr();
210  const Vec3& omega1_0 = pStrNode1->GetWRef();
211  const Vec3& omega2_0 = pStrNode2->GetWRef();
212  const Vec3& gP1 = pStrNode1->GetgPCurr();
213  const Vec3& gP2 = pStrNode2->GetgPCurr();
214  const Mat3x3 DeltaR = Rn.MulTM(R1.MulTM(R2));
215  const Vec3 dDeltaR21_dg1_T = -R2.GetCol(1).Cross(R1_0 * Rn.GetCol(2));
216  const Vec3 dDeltaR21_dg2_T = R2_0.GetCol(1).Cross(R1 * Rn.GetCol(2));
217  const Vec3 dDeltaR11_dg1_T = -R2.GetCol(1).Cross(R1_0 * Rn.GetCol(1));
218  const Vec3 dDeltaR11_dg2_T = R2_0.GetCol(1).Cross(R1 * Rn.GetCol(1));
219  const doublereal a0 = DeltaR(1, 1) * DeltaR(1, 1) + DeltaR(2, 1) * DeltaR(2, 1);
220  const Vec3 dPhi_dg1_T = (dDeltaR21_dg1_T * DeltaR(1, 1) - dDeltaR11_dg1_T * DeltaR(2, 1)) / a0;
221  const Vec3 dPhi_dg2_T = (dDeltaR21_dg2_T * DeltaR(1, 1) - dDeltaR11_dg2_T * DeltaR(2, 1)) / a0;
222  const doublereal dM0_dPhi = M0.dGetP(Phi_e) * p;
223  const doublereal dM1_dPhi = M1.dGetP(Phi_e) * p;
224  const Vec3 dM0_dg1_T = dPhi_dg1_T * dM0_dPhi;
225  const Vec3 dM0_dg2_T = dPhi_dg2_T * dM0_dPhi;
226  const Vec3 dM1_dg1_T = dPhi_dg1_T * dM1_dPhi;
227  const Vec3 dM1_dg2_T = dPhi_dg2_T * dM1_dPhi;
228  const Vec3 dM_dg1_T = dM0_dg1_T + dM1_dg1_T * i;
229  const Vec3 dM_dg2_T = dM0_dg2_T + dM1_dg2_T * i;
230  const Mat3x3 dC1_dg1 = Mat3x3(MatCross, R1_0 * Rn.GetCol(3) * M) - (R1 * Rn.GetCol(3)).Tens(dM_dg1_T);
231  const Mat3x3 dC1_dg2 = (-(R1 * Rn.GetCol(3))).Tens(dM_dg2_T);
232  const Vec3 dC1_di = -(R1 * Rn.GetCol(3) * (dGain + M1.dGet(Phi_e)));
233  const Vec3 dOmega_dg1_T = (omega1 - omega2).Cross(R1_0 * Rn.GetCol(3)) - (gP1 * 0.5 + omega1_0).Cross(R1 * Rn.GetCol(3));
234  const doublereal di1_di = -1;
235  const doublereal di2_di = 1;
236  const Vec3 dOmega_dgP1_T = -(R1 * Rn.GetCol(3));
237  const Vec3 dOmega_dg2_T = (gP2 * 0.5 + omega2_0).Cross(R1 * Rn.GetCol(3));
238  const Vec3 dOmega_dgP2_T = R1 * Rn.GetCol(3);
239  const Vec3 dfi_dg1_T = dOmega_dg1_T * (-dGain);
240  const Vec3 dfi_dgP1_T = dOmega_dgP1_T * (-dGain);
241  const Vec3 dfi_dg2_T = dOmega_dg2_T * (-dGain);
242  const Vec3 dfi_dgP2_T = dOmega_dgP2_T * (-dGain);
243  const doublereal dfi_du1 = -1;
244  const doublereal dfi_du2 = 1;
245  const doublereal abs_i = fabs(i);
246  const doublereal dfi_di = -dR.dGet(abs_i) - dR.dGetP(abs_i) * i;
247  const doublereal dfi_diP = -dL;
248 
249  WM.Put(1, 1, dC1_dg1 * (-dCoef));
250  WM.Put(1, 4, dC1_dg2 * (-dCoef));
251  WM.Put(4, 1, dC1_dg1 * dCoef);
252  WM.Put(4, 4, dC1_dg2 * dCoef);
253  WM.Put(1, 9, dC1_di * (-dCoef));
254  WM.Put(4, 9, dC1_di * dCoef);
255  WM.PutCoef(7, 9, -dCoef * di1_di);
256  WM.PutCoef(8, 9, -dCoef * di2_di);
257  WM.PutT(9, 1, -dfi_dgP1_T - dfi_dg1_T * dCoef);
258  WM.PutT(9, 4, -dfi_dgP2_T - dfi_dg2_T * dCoef);
259  WM.PutCoef(9, 7, -dCoef * dfi_du1);
260  WM.PutCoef(9, 8, -dCoef * dfi_du2);
261  WM.PutCoef(9, 9, -dfi_diP - dCoef * dfi_di);
262 
263  return WorkMat;
264 }
const StructNode * pStrNode1
Definition: motor.h:66
const ElectricNode * pVoltage1
Definition: motor.h:68
void PutColIndex(integer iSubCol, integer iCol)
Definition: submat.h:325
Vec3 Cross(const Vec3 &v) const
Definition: matvec3.h:218
DriveOwner M1
Definition: motor.h:76
virtual const Mat3x3 & GetRRef(void) const
Definition: strnode.h:1006
doublereal M
Definition: motor.h:85
Definition: matvec3.h:98
const MatCross_Manip MatCross
Definition: matvec3.cc:639
FullSubMatrixHandler & SetFull(void)
Definition: submat.h:1168
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
void PutT(integer iRow, integer iCol, const Vec3 &v)
Definition: submat.cc:239
doublereal i
Definition: motor.h:85
void Put(integer iRow, integer iCol, const Vec3 &v)
Definition: submat.cc:221
void PutCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:672
Vec3 GetCol(unsigned short int i) const
Definition: matvec3.h:903
const Mat3x3 & Tens(const Vec3 &a, const Vec3 &b)
Definition: matvec3.h:799
virtual const Vec3 & GetWRef(void) const
Definition: strnode.h:1024
doublereal dGetP(const doublereal &dVar) const
Definition: drive.cc:683
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
DriveOwner M0
Definition: motor.h:76
DriveOwner dR
Definition: motor.h:74
integer p
Definition: motor.h:75
const ElectricNode * pVoltage2
Definition: motor.h:69
virtual integer iGetFirstRowIndex(void) const
Definition: node.cc:82
virtual integer iGetFirstMomentumIndex(void) const =0
virtual integer iGetFirstPositionIndex(void) const
Definition: strnode.h:452
virtual const Vec3 & GetWCurr(void) const
Definition: strnode.h:1030
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
Definition: motor.cc:159
Mat3x3 MulTM(const Mat3x3 &m) const
Definition: matvec3.cc:500
VectorExpression< VectorCrossExpr< VectorLhsExpr, VectorRhsExpr >, 3 > Cross(const VectorExpression< VectorLhsExpr, 3 > &u, const VectorExpression< VectorRhsExpr, 3 > &v)
Definition: matvec.h:3248
virtual void ResizeReset(integer, integer)
Definition: submat.cc:182
Mat3x3 Rn
Definition: motor.h:71
doublereal Phi_e
Definition: motor.h:85
void PutRowIndex(integer iSubRow, integer iRow)
Definition: submat.h:311
doublereal dL
Definition: motor.h:73
virtual const Vec3 & GetgPCurr(void) const
Definition: strnode.h:994
doublereal dGet(const doublereal &dVar) const
Definition: drive.cc:664
const StructNode * pStrNode2
Definition: motor.h:67
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
doublereal dGain
Definition: motor.h:72

Here is the call graph for this function:

SubVectorHandler & Motor::AssRes ( SubVectorHandler WorkVec,
doublereal  dCoef,
const VectorHandler XCurr,
const VectorHandler XPrimeCurr 
)
virtual

Implements Elem.

Definition at line 267 of file motor.cc.

References dGain, DriveOwner::dGet(), dGetOmega(), dGetPhiElectric(), dGetPhiMechanical(), dGetVoltage(), dL, dR, grad::fabs(), Mat3x3::GetCol(), StructNode::GetRCurr(), i, DofOwnerOwner::iGetFirstIndex(), StructDispNode::iGetFirstMomentumIndex(), Node::iGetFirstRowIndex(), iP, M, M0, M1, Phi_e, Phi_m, pStrNode1, pStrNode2, VectorHandler::Put(), VectorHandler::PutCoef(), SubVectorHandler::PutRowIndex(), pVoltage1, pVoltage2, VectorHandler::ResizeReset(), Rn, and WorkSpaceDim().

271 {
272  /* Dimensiona e resetta la matrice di lavoro */
273  integer iNumRows = 0;
274  integer iNumCols = 0;
275  WorkSpaceDim(&iNumRows, &iNumCols);
276  WorkVec.ResizeReset(iNumRows);
277 
278  integer iStrNode1FirstIndex = pStrNode1->iGetFirstMomentumIndex() + 3;
279  integer iStrNode2FirstIndex = pStrNode2->iGetFirstMomentumIndex() + 3;
280  integer iElecNode1FirstIndex = pVoltage1->iGetFirstRowIndex() + 1;
281  integer iElecNode2FirstIndex = pVoltage2->iGetFirstRowIndex() + 1;
282  integer iFirstIndex = iGetFirstIndex() + 1;
283 
284  for (integer iCnt = 1; iCnt <= 3; iCnt++) {
285  WorkVec.PutRowIndex(iCnt, iStrNode1FirstIndex + iCnt);
286  WorkVec.PutRowIndex(3+iCnt, iStrNode2FirstIndex + iCnt);
287  }
288 
289  WorkVec.PutRowIndex(7, iElecNode1FirstIndex);
290  WorkVec.PutRowIndex(8, iElecNode2FirstIndex);
291  WorkVec.PutRowIndex(9, iFirstIndex);
292 
295  i = XCurr(iFirstIndex);
296  iP = XPrimeCurr(iFirstIndex);
297  M = M0.dGet(Phi_e) + (dGain + M1.dGet(Phi_e)) * i;
298 
299  const Mat3x3& R1 = pStrNode1->GetRCurr();
300  const Vec3 n(R1 * Rn.GetCol(3));
301  const doublereal dU = dGetVoltage();
302  const Vec3 C(n * M);
303  const doublereal Omega = dGetOmega(n);
304 
305  WorkVec.Put(1, -C);
306  WorkVec.Put(4, C);
307  WorkVec.PutCoef(7, -i);
308  WorkVec.PutCoef(8, i);
309  WorkVec.PutCoef(9, dU - dGain * Omega - dL * iP - dR.dGet(fabs(i)) * i);
310 
311  return WorkVec;
312 }
const StructNode * pStrNode1
Definition: motor.h:66
const ElectricNode * pVoltage1
Definition: motor.h:68
DriveOwner M1
Definition: motor.h:76
doublereal M
Definition: motor.h:85
Definition: matvec3.h:98
virtual void ResizeReset(integer)
Definition: vh.cc:55
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
doublereal i
Definition: motor.h:85
Vec3 GetCol(unsigned short int i) const
Definition: matvec3.h:903
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
doublereal iP
Definition: motor.h:85
virtual void PutRowIndex(integer iSubRow, integer iRow)=0
DriveOwner M0
Definition: motor.h:76
DriveOwner dR
Definition: motor.h:74
doublereal dGetPhiElectric(doublereal Phi_m) const
Definition: motor.cc:338
doublereal dGetVoltage() const
Definition: motor.cc:314
const ElectricNode * pVoltage2
Definition: motor.h:69
virtual integer iGetFirstRowIndex(void) const
Definition: node.cc:82
virtual integer iGetFirstMomentumIndex(void) const =0
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
Definition: motor.cc:159
virtual void PutCoef(integer iRow, const doublereal &dCoef)=0
doublereal Phi_m
Definition: motor.h:85
Mat3x3 Rn
Definition: motor.h:71
doublereal Phi_e
Definition: motor.h:85
doublereal dGetOmega() const
Definition: motor.cc:326
virtual void Put(integer iRow, const Vec3 &v)
Definition: vh.cc:93
doublereal dL
Definition: motor.h:73
doublereal dGet(const doublereal &dVar) const
Definition: drive.cc:664
doublereal dGetPhiMechanical() const
Definition: motor.cc:330
const StructNode * pStrNode2
Definition: motor.h:67
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
doublereal dGain
Definition: motor.h:72

Here is the call graph for this function:

doublereal Motor::dGetOmega ( void  ) const
inlineprivate

Definition at line 326 of file motor.cc.

References GetAxisOfRotation().

Referenced by AssRes(), dGetPrivData(), and Motor().

326  {
327  return dGetOmega(GetAxisOfRotation());
328 }
Vec3 GetAxisOfRotation() const
Definition: motor.cc:322
doublereal dGetOmega() const
Definition: motor.cc:326

Here is the call graph for this function:

doublereal Motor::dGetOmega ( const Vec3 n) const
inlineprivate

Definition at line 318 of file motor.cc.

References StructNode::GetWCurr(), pStrNode1, and pStrNode2.

318  {
319  return TmpDir * (pStrNode2->GetWCurr() - pStrNode1->GetWCurr());
320 }
const StructNode * pStrNode1
Definition: motor.h:66
virtual const Vec3 & GetWCurr(void) const
Definition: strnode.h:1030
const StructNode * pStrNode2
Definition: motor.h:67

Here is the call graph for this function:

doublereal Motor::dGetPhiElectric ( doublereal  Phi_m) const
inlineprivate

Definition at line 338 of file motor.cc.

References ASSERT, M_PI, p, and Phi_e.

Referenced by AssRes(), dGetPrivData(), and Motor().

338  {
339  doublereal Phi_e = fmod(p * Phi_m, 2 * M_PI);
340 
341  if (Phi_e < 0.) {
342  Phi_e += 2 * M_PI;
343  }
344 
345  ASSERT(Phi_e >= 0 && Phi_e <= 2 * M_PI);
346 
347  return Phi_e;
348 }
#define M_PI
Definition: gradienttest.cc:67
integer p
Definition: motor.h:75
#define ASSERT(expression)
Definition: colamd.c:977
doublereal Phi_m
Definition: motor.h:85
doublereal Phi_e
Definition: motor.h:85
double doublereal
Definition: colamd.c:52
doublereal Motor::dGetPhiMechanical ( ) const
inlineprivate

Definition at line 330 of file motor.cc.

References grad::atan2(), Mat3x3::GetCol(), StructNode::GetRCurr(), Mat3x3::MulTV(), pStrNode1, pStrNode2, and Rn.

Referenced by AssRes(), dGetPrivData(), and Motor().

330  {
331  const Mat3x3& R1 = pStrNode1->GetRCurr();
332  const Mat3x3& R2 = pStrNode2->GetRCurr();
333  const Vec3 DeltaR_e1 = Rn.MulTV(R1.MulTV(R2.GetCol(1)));
334 
335  return atan2(DeltaR_e1(2), DeltaR_e1(1));
336 }
const StructNode * pStrNode1
Definition: motor.h:66
Definition: matvec3.h:98
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
Vec3 GetCol(unsigned short int i) const
Definition: matvec3.h:903
Vec3 MulTV(const Vec3 &v) const
Definition: matvec3.cc:482
Mat3x3 Rn
Definition: motor.h:71
const StructNode * pStrNode2
Definition: motor.h:67
GradientExpression< BinaryExpr< FuncAtan2, LhsExpr, RhsExpr > > atan2(const GradientExpression< LhsExpr > &u, const GradientExpression< RhsExpr > &v)
Definition: gradient.h:2962

Here is the call graph for this function:

doublereal Motor::dGetPrivData ( unsigned int  i) const
virtual

Reimplemented from SimulationEntity.

Definition at line 397 of file motor.cc.

References DriveOwner::dGet(), dGetOmega(), dGetPhiElectric(), dGetPhiMechanical(), dGetVoltage(), dR, grad::fabs(), i, iP, M, M0, M1, and MBDYN_EXCEPT_ARGS.

398 {
399  switch (iIndex) {
400  case 1:
401  return dGetOmega();
402  case 2:
403  return M;
404  case 3:
405  return dGetOmega() * M;
406  case 4:
407  return dGetVoltage();
408  case 5:
409  return i;
410  case 6:
411  return iP;
412  case 7:
413  return dGetVoltage() * i;
414  case 8:
415  return dGetPhiMechanical();
416  case 9:
418  case 10:
420  case 11:
422  case 12:
423  return dR.dGet(fabs(i));
424  default:
426  }
427 }
DriveOwner M1
Definition: motor.h:76
doublereal M
Definition: motor.h:85
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
doublereal i
Definition: motor.h:85
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
doublereal iP
Definition: motor.h:85
DriveOwner M0
Definition: motor.h:76
DriveOwner dR
Definition: motor.h:74
doublereal dGetPhiElectric(doublereal Phi_m) const
Definition: motor.cc:338
doublereal dGetVoltage() const
Definition: motor.cc:314
doublereal dGetOmega() const
Definition: motor.cc:326
doublereal dGet(const doublereal &dVar) const
Definition: drive.cc:664
doublereal dGetPhiMechanical() const
Definition: motor.cc:330

Here is the call graph for this function:

doublereal Motor::dGetVoltage ( ) const
inlineprivate

Definition at line 314 of file motor.cc.

References ScalarDifferentialNode::dGetX(), pVoltage1, and pVoltage2.

Referenced by AssRes(), dGetPrivData(), and Motor().

314  {
315  return pVoltage2->dGetX() - pVoltage1->dGetX();
316 }
const ElectricNode * pVoltage1
Definition: motor.h:68
const ElectricNode * pVoltage2
Definition: motor.h:69
virtual const doublereal & dGetX(void) const
Definition: node.h:386

Here is the call graph for this function:

Vec3 Motor::GetAxisOfRotation ( ) const
inlineprivate

Definition at line 322 of file motor.cc.

References Mat3x3::GetCol(), StructNode::GetRCurr(), pStrNode1, and Rn.

Referenced by dGetOmega().

322  {
323  return pStrNode1->GetRCurr() * Rn.GetCol(3);
324 }
const StructNode * pStrNode1
Definition: motor.h:66
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
Vec3 GetCol(unsigned short int i) const
Definition: matvec3.h:903
Mat3x3 Rn
Definition: motor.h:71

Here is the call graph for this function:

void Motor::GetConnectedNodes ( std::vector< const Node * > &  connectedNodes) const
virtual

Reimplemented from Elem.

Definition at line 372 of file motor.cc.

References pStrNode1, pStrNode2, pVoltage1, and pVoltage2.

372  {
373  connectedNodes.resize(4);
374  connectedNodes[0] = pStrNode1;
375  connectedNodes[1] = pStrNode2;
376  connectedNodes[2] = pVoltage1;
377  connectedNodes[3] = pVoltage2;
378 };
const StructNode * pStrNode1
Definition: motor.h:66
const ElectricNode * pVoltage1
Definition: motor.h:68
const ElectricNode * pVoltage2
Definition: motor.h:69
const StructNode * pStrNode2
Definition: motor.h:67
DofOrder::Order Motor::GetDofType ( unsigned int  i) const
virtual

Reimplemented from Elem.

Definition at line 153 of file motor.cc.

References DofOrder::DIFFERENTIAL.

154 {
155  return DofOrder::DIFFERENTIAL;
156 }
Electric::Type Motor::GetElectricType ( void  ) const
virtual

Implements Electric.

Definition at line 112 of file motor.cc.

References Electric::MOTOR.

113 {
114  return Electric::MOTOR;
115 }
unsigned int Motor::iGetNumDof ( void  ) const
virtual

Reimplemented from Elem.

Definition at line 147 of file motor.cc.

148 {
149  return 1;
150 }
unsigned int Motor::iGetNumPrivData ( void  ) const
virtual

Reimplemented from SimulationEntity.

Definition at line 381 of file motor.cc.

References iNumPrivData.

382 {
383  return iNumPrivData;
384 }
static const int iNumPrivData
Definition: motor.h:87
unsigned int Motor::iGetPrivDataIdx ( const char *  s) const
virtual

Reimplemented from SimulationEntity.

Definition at line 386 of file motor.cc.

References i, Motor::PrivData::index, iNumPrivData, and rgPrivData.

387 {
388  for (int i = 0; i < iNumPrivData; ++i ) {
389  if (0 == strcmp(rgPrivData[i].name, s)) {
390  return rgPrivData[i].index;
391  }
392  }
393 
394  return 0;
395 }
doublereal i
Definition: motor.h:85
static const int iNumPrivData
Definition: motor.h:87
static const struct Motor::PrivData rgPrivData[iNumPrivData]
Definition: motor.cc:69
std::ostream & Motor::Restart ( std::ostream &  out) const
virtual

Implements Elem.

Definition at line 119 of file motor.cc.

References dGain, dL, dR, WithLabel::GetLabel(), i, M0, M1, p, DriveOwner::pGetDriveCaller(), pStrNode1, pStrNode2, pVoltage1, pVoltage2, DriveCaller::Restart(), and Rn.

120 {
121  out << "electric: " << GetLabel()
122  << ", motor, "
123  << pStrNode1->GetLabel() << ", "
124  << "orientation, " << Rn << ", "
125  << pStrNode2->GetLabel() << ", "
126  << pVoltage1->GetLabel() << ", "
127  << pVoltage2->GetLabel() << ", "
128  << dGain << ", "
129  << dL << ", ";
130 
131  dR.pGetDriveCaller()->Restart(out);
132 
133  out << ", initial current, " << i << ", M0, ";
134 
135  M0.pGetDriveCaller()->Restart(out);
136 
137  out << ", M1, ";
138 
139  M1.pGetDriveCaller()->Restart(out);
140 
141  out << ", terminal pairs, " << p << ";" << std::endl;
142 
143  return out;
144 }
const StructNode * pStrNode1
Definition: motor.h:66
const ElectricNode * pVoltage1
Definition: motor.h:68
DriveOwner M1
Definition: motor.h:76
doublereal i
Definition: motor.h:85
virtual std::ostream & Restart(std::ostream &out) const =0
DriveOwner M0
Definition: motor.h:76
DriveOwner dR
Definition: motor.h:74
integer p
Definition: motor.h:75
const ElectricNode * pVoltage2
Definition: motor.h:69
DriveCaller * pGetDriveCaller(void) const
Definition: drive.cc:658
Mat3x3 Rn
Definition: motor.h:71
doublereal dL
Definition: motor.h:73
const StructNode * pStrNode2
Definition: motor.h:67
unsigned int GetLabel(void) const
Definition: withlab.cc:62
doublereal dGain
Definition: motor.h:72

Here is the call graph for this function:

void Motor::SetInitialValue ( VectorHandler X)
virtual

Initialize state vector used in initial assembly. May set internal states of the element. Do not rely on being always called, because initial assembly could be implicitly or explicitly skipped

Reimplemented from DofOwnerOwner.

Definition at line 351 of file motor.cc.

References i, and DofOwnerOwner::iGetFirstIndex().

352 {
353  const integer iFirstIndex = iGetFirstIndex() + 1;
354 
355  X(iFirstIndex) = i;
356 }
doublereal i
Definition: motor.h:85
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

void Motor::SetValue ( DataManager pDM,
VectorHandler X,
VectorHandler XP,
SimulationEntity::Hints h = 0 
)
virtual

Reimplemented from SimulationEntity.

Definition at line 359 of file motor.cc.

References i, DofOwnerOwner::iGetFirstIndex(), and iP.

362 {
363  const integer iFirstIndex = iGetFirstIndex() + 1;
364 
365  X(iFirstIndex) = i;
366  XP(iFirstIndex) = iP;
367 }
doublereal i
Definition: motor.h:85
doublereal iP
Definition: motor.h:85
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

void Motor::WorkSpaceDim ( integer piNumRows,
integer piNumCols 
) const
virtual

Implements Elem.

Definition at line 159 of file motor.cc.

Referenced by AssJac(), and AssRes().

160 {
161  *piNumRows = 9;
162  *piNumCols = 9;
163 }

Member Data Documentation

doublereal Motor::dGain
private

Definition at line 72 of file motor.h.

Referenced by AssJac(), AssRes(), Motor(), and Restart().

doublereal Motor::dL
private

Definition at line 73 of file motor.h.

Referenced by AssJac(), AssRes(), and Restart().

DriveOwner Motor::dR
private

Definition at line 74 of file motor.h.

Referenced by AssJac(), AssRes(), dGetPrivData(), and Restart().

doublereal Motor::i
private
const int Motor::iNumPrivData = 12
staticprivate

Definition at line 87 of file motor.h.

Referenced by iGetNumPrivData(), and iGetPrivDataIdx().

doublereal Motor::iP
private

Definition at line 85 of file motor.h.

Referenced by AssRes(), dGetPrivData(), Motor(), and SetValue().

doublereal Motor::M
private

Definition at line 85 of file motor.h.

Referenced by AssJac(), AssRes(), and dGetPrivData().

DriveOwner Motor::M0
private

Definition at line 76 of file motor.h.

Referenced by AssJac(), AssRes(), dGetPrivData(), and Restart().

DriveOwner Motor::M1
private

Definition at line 76 of file motor.h.

Referenced by AssJac(), AssRes(), dGetPrivData(), and Restart().

integer Motor::p
private

Definition at line 75 of file motor.h.

Referenced by AssJac(), dGetPhiElectric(), and Restart().

doublereal Motor::Phi_e
private

Definition at line 85 of file motor.h.

Referenced by AssJac(), AssRes(), dGetPhiElectric(), and Motor().

doublereal Motor::Phi_m
private

Definition at line 85 of file motor.h.

Referenced by AssRes(), and Motor().

const StructNode* Motor::pStrNode1
private
const StructNode* Motor::pStrNode2
private

Definition at line 67 of file motor.h.

Referenced by AssJac(), AssRes(), dGetOmega(), dGetPhiMechanical(), GetConnectedNodes(), and Restart().

const ElectricNode* Motor::pVoltage1
private

Definition at line 68 of file motor.h.

Referenced by AssJac(), AssRes(), dGetVoltage(), GetConnectedNodes(), and Restart().

const ElectricNode* Motor::pVoltage2
private

Definition at line 69 of file motor.h.

Referenced by AssJac(), AssRes(), dGetVoltage(), GetConnectedNodes(), and Restart().

const Motor::PrivData Motor::rgPrivData
staticprivate
Initial value:
= {
{1, "omega"},
{2, "M"},
{3, "Pmech"},
{4, "U"},
{5, "i"},
{6, "iP"},
{7, "Pel"},
{8, "Phimech"},
{9, "Phiel"},
{10, "M0"},
{11, "M1"},
{12, "R"}
}

Definition at line 69 of file motor.cc.

Referenced by iGetPrivDataIdx().

Mat3x3 Motor::Rn
private

Definition at line 71 of file motor.h.

Referenced by AssJac(), AssRes(), dGetPhiMechanical(), GetAxisOfRotation(), and Restart().


The documentation for this class was generated from the following files: