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

#include <valve.h>

Inheritance diagram for Dynamic_control_valve:
Collaboration diagram for Dynamic_control_valve:

Public Member Functions

 Dynamic_control_valve (unsigned int uL, const DofOwner *pD, HydraulicFluid *hf, const PressureNode *p1, const PressureNode *p2, const PressureNode *p3, const PressureNode *p4, const DriveCaller *pDC, doublereal s0, doublereal s_mx, doublereal W, doublereal Loss_A, doublereal Valve_d, doublereal Valve_rho, doublereal cs, doublereal cv, doublereal ca, flag fOut)
 
 ~Dynamic_control_valve (void)
 
virtual HydraulicElem::Type GetHydraulicType (void) 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 Output (OutputHandler &OH) const
 
virtual void SetValue (DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph=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 unsigned int iGetNumPrivData (void) const
 
virtual unsigned int iGetPrivDataIdx (const char *s) const
 
virtual doublereal dGetPrivData (unsigned int i) const
 
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 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 HydraulicElem
 HydraulicElem (unsigned int uL, const DofOwner *pDO, HydraulicFluid *hf, flag fOut)
 
virtual ~HydraulicElem (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
 
virtual void SetInitialValue (VectorHandler &X)
 
- Public Member Functions inherited from DriveOwner
 DriveOwner (const DriveCaller *pDC=0)
 
 DriveOwner (const DriveOwner &drive)
 
virtual ~DriveOwner (void)
 
void Set (const DriveCaller *pDC)
 
DriveCallerpGetDriveCaller (void) const
 
doublereal dGet (const doublereal &dVar) const
 
doublereal dGet (void) const
 
bool bIsDifferentiable (void) const
 
doublereal dGetP (const doublereal &dVar) const
 
doublereal dGetP (void) const
 

Private Attributes

const PressureNodepNode1
 
const PressureNodepNode2
 
const PressureNodepNode3
 
const PressureNodepNode4
 
doublereal start
 
doublereal c_spost
 
doublereal c_vel
 
doublereal c_acc
 
doublereal Force
 
doublereal Cd
 
doublereal width
 
doublereal loss_area
 
doublereal valve_diameter
 
doublereal valve_density
 
doublereal s_max
 
doublereal A1
 
doublereal A2
 
doublereal A3
 
doublereal A4
 
doublereal Mass
 
doublereal flow1
 
doublereal flow2
 
doublereal flow3
 
doublereal flow4
 
doublereal s
 
doublereal v
 
doublereal sp
 
doublereal vp
 
doublereal c1
 
doublereal c2
 
doublereal c3
 
doublereal cf1
 
doublereal cf2
 
doublereal cf3
 
doublereal deltaP
 

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 HydraulicElem
enum  Type {
  UNKNOWN = -1, MINOR_LOSS = 0, THREEWAYMINORLOSS, CONTROL_VALVE,
  DYNAMIC_CONTROL_VALVE, PRESSURE_FLOW_CONTROL_VALVE, PRESSURE_VALVE, FLOW_VALVE,
  ORIFICE, ACCUMULATOR, TANK, PIPE,
  DYNAMIC_PIPE, HYDRAULIC_ACTUATOR, ACTUATOR, LASTHYDRAULICTYPE
}
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 
- Protected Attributes inherited from ToBeOutput
flag fOutput
 
- Protected Attributes inherited from HydraulicElem
HydraulicFluidHF
 
- Protected Attributes inherited from DriveOwner
DriveCallerpDriveCaller
 

Detailed Description

Definition at line 226 of file valve.h.

Constructor & Destructor Documentation

Dynamic_control_valve::Dynamic_control_valve ( unsigned int  uL,
const DofOwner pD,
HydraulicFluid hf,
const PressureNode p1,
const PressureNode p2,
const PressureNode p3,
const PressureNode p4,
const DriveCaller pDC,
doublereal  s0,
doublereal  s_mx,
doublereal  W,
doublereal  Loss_A,
doublereal  Valve_d,
doublereal  Valve_rho,
doublereal  cs,
doublereal  cv,
doublereal  ca,
flag  fOut 
)

Definition at line 628 of file valve.cc.

References ASSERT, Cd, PressureNode::GetNodeType(), Node::HYDRAULIC, M_PI, pNode1, pNode2, pNode3, pNode4, valve_density, and valve_diameter.

642 : Elem(uL, fOut),
643 HydraulicElem(uL, pDO, hf, fOut), DriveOwner(pDC),
644 pNode1(p1), pNode2(p2), pNode3(p3), pNode4(p4),
645 start(s0), c_spost(cs), c_vel(cv), c_acc(ca),
646 width(W), loss_area(Loss_A),
647 valve_diameter(Valve_d), valve_density(Valve_rho), s_max(s_mx)
648 {
649  ASSERT(pNode1 != NULL);
651  ASSERT(pNode2 != NULL);
653  ASSERT(pNode3 != NULL);
655  ASSERT(pNode4 != NULL);
657  ASSERT(s0 >= 0.);
658  ASSERT(Valve_rho > std::numeric_limits<doublereal>::epsilon());
659  ASSERT(Valve_d > std::numeric_limits<doublereal>::epsilon());
660  ASSERT(W > std::numeric_limits<doublereal>::epsilon());
661  ASSERT(Loss_A >= 0.);
662  ASSERT(s_mx >= 0.);
663 
664  Cd = .611; /* coefficiente di perdita */
665  Mass = 1.175*valve_diameter*valve_diameter*valve_diameter*valve_density*M_PI; // massa della valvola
666 
667  // W = .005; /* larghezza del condotto (m): A=x*W 0.005; */
668  // diameter = .01; /* diametro della valvola (m) */
669  // densityvalve = 7900.; /* densita' del corpo della valvola (acciaio) (kg/m^3) */
670  // Mass = 1.175*diameter*diameter*diameter*densityvalve*M_PI; /* massa della valvola (Kg) */
671  // s_max = 2.; /* corsa massima della valvola (m) */
672 }
#define M_PI
Definition: gradienttest.cc:67
const PressureNode * pNode1
Definition: valve.h:228
doublereal start
Definition: valve.h:232
const PressureNode * pNode4
Definition: valve.h:231
doublereal c_acc
Definition: valve.h:235
doublereal valve_diameter
Definition: valve.h:241
doublereal Cd
Definition: valve.h:238
doublereal c_spost
Definition: valve.h:233
const PressureNode * pNode2
Definition: valve.h:229
HydraulicElem(unsigned int uL, const DofOwner *pDO, HydraulicFluid *hf, flag fOut)
Definition: preselem.cc:54
doublereal valve_density
Definition: valve.h:242
#define ASSERT(expression)
Definition: colamd.c:977
Definition: body.h:45
doublereal s_max
Definition: valve.h:244
doublereal loss_area
Definition: valve.h:240
doublereal width
Definition: valve.h:239
const PressureNode * pNode3
Definition: valve.h:230
virtual Node::Type GetNodeType(void) const
Definition: presnode.h:54
Elem(unsigned int uL, flag fOut)
Definition: elem.cc:41
doublereal c_vel
Definition: valve.h:234
DriveOwner(const DriveCaller *pDC=0)
Definition: drive.cc:627

Here is the call graph for this function:

Dynamic_control_valve::~Dynamic_control_valve ( void  )

Definition at line 675 of file valve.cc.

References NO_OP.

676 {
677  NO_OP;
678 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

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

Implements Elem.

Definition at line 712 of file valve.cc.

References A1, A2, A3, A4, c1, c2, c3, Cd, cf1, cf2, cf3, copysign(), DEBUGCOUT, deltaP, HydraulicFluid::dGetDensity(), ScalarAlgebraicNode::dGetX(), grad::fabs(), HydraulicElem::HF, Node::iGetFirstColIndex(), DofOwnerOwner::iGetFirstIndex(), Node::iGetFirstRowIndex(), pNode1, pNode2, pNode3, pNode4, FullSubMatrixHandler::PutCoef(), FullSubMatrixHandler::PutColIndex(), FullSubMatrixHandler::PutRowIndex(), FullSubMatrixHandler::ResizeReset(), s, VariableSubMatrixHandler::SetFull(), sp, grad::sqrt(), v, valve_diameter, and width.

716 {
717  DEBUGCOUT("Entering Control_valve::AssJac()" << std::endl);
718 
719  FullSubMatrixHandler& WM = WorkMat.SetFull();
720  WM.ResizeReset(6, 6);
721 
722  integer iNode1RowIndex = pNode1->iGetFirstRowIndex()+1;
723  integer iNode2RowIndex = pNode2->iGetFirstRowIndex()+1;
724  integer iNode3RowIndex = pNode3->iGetFirstRowIndex()+1;
725  integer iNode4RowIndex = pNode4->iGetFirstRowIndex()+1;
726  integer iNode1ColIndex = pNode1->iGetFirstColIndex()+1;
727  integer iNode2ColIndex = pNode2->iGetFirstColIndex()+1;
728  integer iNode3ColIndex = pNode3->iGetFirstColIndex()+1;
729  integer iNode4ColIndex = pNode4->iGetFirstColIndex()+1;
730  integer iFirstIndex = iGetFirstIndex();
731 
732  WM.PutRowIndex(1, iNode1RowIndex);
733  WM.PutRowIndex(2, iNode2RowIndex);
734  WM.PutRowIndex(3, iNode3RowIndex);
735  WM.PutRowIndex(4, iNode4RowIndex);
736  WM.PutColIndex(1, iNode1ColIndex);
737  WM.PutColIndex(2, iNode2ColIndex);
738  WM.PutColIndex(3, iNode3ColIndex);
739  WM.PutColIndex(4, iNode4ColIndex);
740 
741  WM.PutRowIndex(5, iFirstIndex+1);
742  WM.PutColIndex(5, iFirstIndex+1);
743  WM.PutRowIndex(6, iFirstIndex+2);
744  WM.PutColIndex(6, iFirstIndex+2);
745 
746  doublereal p1 = pNode1->dGetX();
747  doublereal p2 = pNode2->dGetX();
748  doublereal p3 = pNode3->dGetX();
749  doublereal p4 = pNode4->dGetX();
750  doublereal density = HF->dGetDensity();
751 
752  s = XCurr(iFirstIndex+1); /* spostamento */
753  v = XCurr(iFirstIndex+2); /* velocita' */
754 
755  doublereal jumpPres12 = fabs(p1-p2); /* salto di pressione nodo1 & nodo2 */
756  doublereal jumpPres13 = fabs(p1-p3); /* salto di pressione nodo1 & nodo3 */
757  doublereal jumpPres24 = fabs(p2-p4); /* salto di pressione nodo2 & nodo4 */
758  doublereal jumpPres34 = fabs(p3-p4); /* salto di pressione nodo3 & nodo4 */
759 
760  if (jumpPres12 < 1.e8*std::numeric_limits<doublereal>::epsilon()) {
761  jumpPres12 = 1.e8*std::numeric_limits<doublereal>::epsilon();
762  }
763  if (jumpPres13 < 1.e8*std::numeric_limits<doublereal>::epsilon()) {
764  jumpPres13 = 1.e8*std::numeric_limits<doublereal>::epsilon();
765  }
766  if (jumpPres24 < 1.e8*std::numeric_limits<doublereal>::epsilon()) {
767  jumpPres24 = 1.e8*std::numeric_limits<doublereal>::epsilon();
768  }
769  if (jumpPres34 < 1.e8*std::numeric_limits<doublereal>::epsilon()) {
770  jumpPres34 = 1.e8*std::numeric_limits<doublereal>::epsilon();
771  }
772  doublereal Jac15;
773  doublereal Jac25;
774  doublereal Jac35;
775  doublereal Jac45;
776 
777  doublereal primo = Cd*A1/sqrt(2.*jumpPres12/density);
778  doublereal secondo = Cd*A2/sqrt(2.*jumpPres13/density);
779  doublereal terzo = Cd*A4/sqrt(2.*jumpPres24/density);
780  doublereal quarto = Cd*A3/sqrt(2.*jumpPres34/density);
781 
782  doublereal Jac11 = -primo-secondo;
783  doublereal Jac12 = primo;
784  doublereal Jac13 = secondo;
785  doublereal Jac14 = 0.;
786  doublereal Jac21 = primo;
787  doublereal Jac22 = -primo-terzo;
788  doublereal Jac23 = 0.;
789  doublereal Jac24 = terzo;
790  doublereal Jac31 = secondo;
791  doublereal Jac32 = 0.;
792  doublereal Jac33 = -secondo-quarto;
793  doublereal Jac34 = quarto;
794  doublereal Jac41 = 0.;
795  doublereal Jac42 = terzo;
796  doublereal Jac43 = quarto;
797  doublereal Jac44 = -terzo-quarto;
798 
799  doublereal costante = density*Cd*width*valve_diameter;
800 
801 #if 0
802  doublereal Jac51 = -.2*costante*sp/sqrt(density*deltaP)-.43*width*s;
803  doublereal Jac52 = -Jac51;
804  doublereal Jac53 = Jac51;
805  doublereal Jac54 = -Jac51;
806  doublereal Jac55 = -.4*valve_diameter*Cd*width*sqrt(density*deltaP)-dCoef*.43*width*deltaP-dCoef*c1-c2-dCoef*cf1-cf2;
807  doublereal Jac56 = -Mass-c3-cf3;
808 #endif
809 
810  doublereal Jac51 = -.2*costante*sp/sqrt(density*deltaP)-.43*width*s;
811  doublereal Jac52 = 0.;
812  doublereal Jac53 = 0.;
813  doublereal Jac54 = 0.;
814  doublereal Jac55 = -.4*valve_diameter*Cd*width*sqrt(density*deltaP)-dCoef*.43*width*deltaP-dCoef*c1-c2-dCoef*cf1-cf2;
815  doublereal Jac56 = -Mass-c3-cf3;
816 
817  if (s > 0.) { /* collegamento diretto 1->2 3->4 */
818  Jac15 = dCoef*density*Cd*width*copysign(sqrt(2.*jumpPres12/density), p1-p2);
819  Jac25 = -Jac15;
820  Jac35 = dCoef*density*Cd*width*copysign(sqrt(2.*jumpPres34/density), p3-p4);
821  Jac45 = -Jac35;
822  } else { /* collegamento inverso 1->3 2->4 */
823  Jac15 = -dCoef*density*Cd*width*copysign(sqrt(2.*jumpPres13/density), p1-p3);
824  Jac25 = -dCoef*density*Cd*width*copysign(sqrt(2.*jumpPres24/density), p2-p4);
825  Jac35 = -Jac15;
826  Jac45 = -Jac25;
827  }
828 
829  doublereal Jac65 = -1;
830  doublereal Jac66 = dCoef;
831 
832  WM.PutCoef(1, 1, Jac11);
833  WM.PutCoef(1, 2, Jac12);
834  WM.PutCoef(1, 3, Jac13);
835  WM.PutCoef(1, 4, Jac14);
836  WM.PutCoef(1, 5, Jac15);
837  WM.PutCoef(2, 1, Jac21);
838  WM.PutCoef(2, 2, Jac22);
839  WM.PutCoef(2, 3, Jac23);
840  WM.PutCoef(2, 4, Jac24);
841  WM.PutCoef(2, 5, Jac25);
842  WM.PutCoef(3, 1, Jac31);
843  WM.PutCoef(3, 2, Jac32);
844  WM.PutCoef(3, 3, Jac33);
845  WM.PutCoef(3, 4, Jac34);
846  WM.PutCoef(3, 5, Jac35);
847  WM.PutCoef(4, 1, Jac41);
848  WM.PutCoef(4, 2, Jac42);
849  WM.PutCoef(4, 3, Jac43);
850  WM.PutCoef(4, 4, Jac44);
851  WM.PutCoef(4, 5, Jac45);
852  WM.PutCoef(5, 1, Jac51);
853  WM.PutCoef(5, 2, Jac52);
854  WM.PutCoef(5, 3, Jac53);
855  WM.PutCoef(5, 5, Jac55);
856  WM.PutCoef(5, 6, Jac56);
857  WM.PutCoef(6, 5, Jac65);
858  WM.PutCoef(6, 6, Jac66);
859 
860  return WorkMat;
861 }
doublereal sp
Definition: valve.h:258
doublereal deltaP
Definition: valve.h:266
doublereal A2
Definition: valve.h:247
void PutColIndex(integer iSubCol, integer iCol)
Definition: submat.h:325
const PressureNode * pNode1
Definition: valve.h:228
doublereal cf2
Definition: valve.h:264
FullSubMatrixHandler & SetFull(void)
Definition: submat.h:1168
const PressureNode * pNode4
Definition: valve.h:231
doublereal valve_diameter
Definition: valve.h:241
void PutCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:672
doublereal A1
Definition: valve.h:246
doublereal Cd
Definition: valve.h:238
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
const PressureNode * pNode2
Definition: valve.h:229
virtual doublereal dGetDensity(void) const =0
virtual const doublereal & dGetX(void) const
Definition: node.h:492
doublereal cf3
Definition: valve.h:265
HydraulicFluid * HF
Definition: preselem.h:79
doublereal c2
Definition: valve.h:261
doublereal cf1
Definition: valve.h:263
doublereal copysign(doublereal x, doublereal y)
Definition: gradient.h:97
#define DEBUGCOUT(msg)
Definition: myassert.h:232
virtual integer iGetFirstRowIndex(void) const
Definition: node.cc:82
doublereal s
Definition: valve.h:256
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
Definition: gradient.h:2974
doublereal A4
Definition: valve.h:249
Definition: body.h:45
virtual void ResizeReset(integer, integer)
Definition: submat.cc:182
doublereal c1
Definition: valve.h:260
void PutRowIndex(integer iSubRow, integer iRow)
Definition: submat.h:311
doublereal A3
Definition: valve.h:248
doublereal v
Definition: valve.h:257
doublereal width
Definition: valve.h:239
const PressureNode * pNode3
Definition: valve.h:230
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
doublereal c3
Definition: valve.h:262
virtual integer iGetFirstColIndex(void) const
Definition: node.cc:88

Here is the call graph for this function:

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

Implements Elem.

Definition at line 864 of file valve.cc.

References A1, A2, A3, A4, c1, c2, c3, c_acc, c_spost, c_vel, Cd, cf1, cf2, cf3, copysign(), DEBUGCOUT, deltaP, DriveCaller::dGet(), HydraulicFluid::dGetDensity(), ScalarAlgebraicNode::dGetX(), grad::fabs(), flow1, flow2, flow3, flow4, HydraulicElem::HF, DofOwnerOwner::iGetFirstIndex(), Node::iGetFirstRowIndex(), loss_area, DriveOwner::pGetDriveCaller(), pNode1, pNode2, pNode3, pNode4, SubVectorHandler::PutItem(), VectorHandler::Resize(), s, s_max, sp, grad::sqrt(), v, valve_density, valve_diameter, vp, and width.

868 {
869  DEBUGCOUT("Entering Dynamic_control_valve::AssRes()" << std::endl);
870 
871  WorkVec.Resize(6);
872 
873  integer iNode1RowIndex = pNode1->iGetFirstRowIndex()+1;
874  integer iNode2RowIndex = pNode2->iGetFirstRowIndex()+1;
875  integer iNode3RowIndex = pNode3->iGetFirstRowIndex()+1;
876  integer iNode4RowIndex = pNode4->iGetFirstRowIndex()+1;
877  integer iFirstIndex = iGetFirstIndex();
878 
879  doublereal p1 = pNode1->dGetX();
880  doublereal p2 = pNode2->dGetX();
881  doublereal p3 = pNode3->dGetX();
882  doublereal p4 = pNode4->dGetX();
883  doublereal density = HF->dGetDensity();
884 
885  Force = pGetDriveCaller()->dGet();
886 
887  s = XCurr(iFirstIndex+1); /* spostamento */
888  v = XCurr(iFirstIndex+2); /* velocita' */
889  sp = XPrimeCurr(iFirstIndex+1); /* velocita' */
890  vp = XPrimeCurr(iFirstIndex+2); /* accelerazione */
891 
892  doublereal jumpPres12 = fabs(p1-p2); /* salto di pressione nodo1 & nodo2 */
893  doublereal jumpPres13 = fabs(p1-p3); /* salto di pressione nodo1 & nodo3 */
894  doublereal jumpPres24 = fabs(p2-p4); /* salto di pressione nodo2 & nodo4 */
895  doublereal jumpPres34 = fabs(p3-p4); /* salto di pressione nodo3 & nodo4 */
896 
897  /* qui decido se sono a fondo od ad inizio corsa e di conseguenza calcolo
898  * i giusti coefficienti */
899 
900 
901  doublereal area_max = width*s_max; // Area massima
902  doublereal area_min = area_max*loss_area; // Area minimo
903  doublereal deltaA = s*width;
904 
905  if (s > 0.) {
906  A1 = area_min+deltaA;
907  A2 = area_min;
908  A3 = area_min+deltaA;
909  A4 = area_min;
910  } else { /* ho deltaA negativo */
911  A1 = area_min;
912  A2 = area_min-deltaA;
913  A3 = area_min;
914  A4 = area_min-deltaA;
915  }
916 
917  if (s <= -s_max) {
918  c1 = c_spost;
919 
920  if (sp < 0.) {
921  c2 = c_vel; /* ho v negativa devo smorzare */
922  } else {
923  c2 = 0.;
924  }
925 
926  if (vp < 0.) {
927  c3 = c_acc; /* ho acc negativa devo smorzare */
928  } else {
929  c3 = 0.;
930  }
931 
932  } else {
933  c1 = 0.;
934  c2 = 0.;
935  c3 = 0.;
936  }
937 
938  if (s >= s_max) {
939  cf1 = c_spost;
940 
941  if (sp > 0.) {
942  cf2 = c_vel; /* ho v positiva devo smorzare */
943  } else {
944  cf2 = 0.;
945  }
946 
947  if (vp > 0.) {
948  cf3 = c_acc; /* ho acc positiva devo smorzare */
949  } else {
950  cf3 = 0.;
951  }
952 
953  } else {
954  cf1 = 0.;
955  cf2 = 0.;
956  cf3 = 0.;
957  }
958 
959 
960  doublereal Q12 = density*Cd*A1*copysign(sqrt(2.*jumpPres12/density), p1-p2);
961  doublereal Q13 = density*Cd*A2*copysign(sqrt(2.*jumpPres13/density), p1-p3);
962  doublereal Q24 = density*Cd*A4*copysign(sqrt(2.*jumpPres24/density), p2-p4);
963  doublereal Q34 = density*Cd*A3*copysign(sqrt(2.*jumpPres34/density), p3-p4);
964 
965  doublereal Res_1 = Q12+Q13;
966  doublereal Res_2 = -Q12+Q24;
967  doublereal Res_3 = -Q13+Q34;
968  doublereal Res_4 = -Q34-Q24;
969 
970  deltaP =p1;
971 
972  if (deltaP == 0.) {
973  deltaP = 10.; /* evito di dividere per zero nello jacobiano */
974  }
975 
976  doublereal C = .4*valve_diameter*Cd*width*sqrt(density*deltaP);
977  doublereal K = .43*width*deltaP;
978  doublereal Res_5 = -Force+Mass*vp+C*sp+K*s+c1*(s+s_max)+c2*sp+c3*vp+cf1*(s-s_max)+cf2*sp+cf3*vp;
979  doublereal Res_6 = sp-v;
980 
981  flow1 = -Res_1;
982  flow2 = -Res_2;
983  flow3 = -Res_3;
984  flow4 = -Res_4;
985 
986 #ifdef HYDR_DEVEL
987  DEBUGCOUT("Force: " << Force << std::endl);
988  DEBUGCOUT("X equilibrio: " << Force/K << std::endl);
989  DEBUGCOUT("A1: " << A1 << std::endl);
990  DEBUGCOUT("A2: " << A2 << std::endl);
991  DEBUGCOUT("A3: " << A3 << std::endl);
992  DEBUGCOUT("A4: " << A4 << std::endl);
993  DEBUGCOUT("p1: " << p1 << std::endl);
994  DEBUGCOUT("p2: " << p2 << std::endl);
995  DEBUGCOUT("p3: " << p3 << std::endl);
996  DEBUGCOUT("p4: " << p4 << std::endl);
997  DEBUGCOUT("Cd: " << Cd << std::endl);
998  DEBUGCOUT("s_max : " << s_max << std::endl);
999  DEBUGCOUT("s : " << s << std::endl);
1000  DEBUGCOUT("sp: " << sp << std::endl);
1001  DEBUGCOUT("v : " << v << std::endl);
1002  DEBUGCOUT("vp: " << vp << std::endl);
1003  DEBUGCOUT("Valve_diameter:" << valve_diameter << std::endl);
1004  DEBUGCOUT("massa: " << Mass << std::endl);
1005  DEBUGCOUT("smorzatore: " << C << std::endl);
1006  DEBUGCOUT("molla: " << K << std::endl);
1007  DEBUGCOUT("density: " << density << std::endl);
1008  DEBUGCOUT("Valve_density: " << valve_density << std::endl);
1009  DEBUGCOUT("Area_max: " << area_max << std::endl);
1010  DEBUGCOUT("Width: " << width << std::endl);
1011  DEBUGCOUT("Loss_area: " << loss_area << std::endl);
1012  DEBUGCOUT("c1: " << c1 << std::endl);
1013  DEBUGCOUT("c2: " << c2 << std::endl);
1014  DEBUGCOUT("c3: " << c3 << std::endl);
1015  DEBUGCOUT("cf1: " << cf1 << std::endl);
1016  DEBUGCOUT("cf2: " << cf2 << std::endl);
1017  DEBUGCOUT("cf3: " << cf3 << std::endl);
1018  DEBUGCOUT("Q12: " << Q12 << std::endl);
1019  DEBUGCOUT("Q13: " << Q13 << std::endl);
1020  DEBUGCOUT("Q24: " << Q24 << std::endl);
1021  DEBUGCOUT("Q34: " << Q34 << std::endl);
1022  DEBUGCOUT("PORTATE AI VARI NODI (positive se entranti)"<< std::endl);
1023  DEBUGCOUT("-Res_1 (portata nodo1): " << -Res_1 << std::endl);
1024  DEBUGCOUT("-Res_2 (portata nodo2): " << -Res_2 << std::endl);
1025  DEBUGCOUT("-Res_3 (portata nodo3): " << -Res_3 << std::endl);
1026  DEBUGCOUT("-Res_4 (portata nodo4): " << -Res_4 << std::endl);
1027  DEBUGCOUT("-Res_5 eq.dinamica : " << -Res_5 << std::endl);
1028  DEBUGCOUT("-Res_6 sp-v : " << -Res_6 << std::endl);
1029 #endif
1030 
1031  WorkVec.PutItem(1, iNode1RowIndex, Res_1);
1032  WorkVec.PutItem(2, iNode2RowIndex, Res_2);
1033  WorkVec.PutItem(3, iNode3RowIndex, Res_3);
1034  WorkVec.PutItem(4, iNode4RowIndex, Res_4);
1035  WorkVec.PutItem(5, iFirstIndex+1, Res_5);
1036  WorkVec.PutItem(6, iFirstIndex+2, Res_6);
1037 
1038  return WorkVec;
1039 }
doublereal sp
Definition: valve.h:258
doublereal deltaP
Definition: valve.h:266
doublereal A2
Definition: valve.h:247
const PressureNode * pNode1
Definition: valve.h:228
doublereal cf2
Definition: valve.h:264
doublereal vp
Definition: valve.h:259
doublereal flow2
Definition: valve.h:253
const PressureNode * pNode4
Definition: valve.h:231
doublereal c_acc
Definition: valve.h:235
doublereal valve_diameter
Definition: valve.h:241
Definition: force.h:46
doublereal A1
Definition: valve.h:246
doublereal Cd
Definition: valve.h:238
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
virtual void PutItem(integer iSubRow, integer iRow, const doublereal &dCoef)
Definition: submat.h:1445
doublereal c_spost
Definition: valve.h:233
const PressureNode * pNode2
Definition: valve.h:229
virtual doublereal dGetDensity(void) const =0
virtual const doublereal & dGetX(void) const
Definition: node.h:492
doublereal flow3
Definition: valve.h:254
doublereal cf3
Definition: valve.h:265
HydraulicFluid * HF
Definition: preselem.h:79
doublereal c2
Definition: valve.h:261
doublereal cf1
Definition: valve.h:263
doublereal copysign(doublereal x, doublereal y)
Definition: gradient.h:97
#define DEBUGCOUT(msg)
Definition: myassert.h:232
virtual integer iGetFirstRowIndex(void) const
Definition: node.cc:82
doublereal valve_density
Definition: valve.h:242
doublereal flow1
Definition: valve.h:252
doublereal s
Definition: valve.h:256
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
Definition: gradient.h:2974
doublereal A4
Definition: valve.h:249
DriveCaller * pGetDriveCaller(void) const
Definition: drive.cc:658
Definition: body.h:45
doublereal s_max
Definition: valve.h:244
doublereal loss_area
Definition: valve.h:240
virtual doublereal dGet(const doublereal &dVar) const =0
doublereal c1
Definition: valve.h:260
doublereal A3
Definition: valve.h:248
doublereal v
Definition: valve.h:257
doublereal width
Definition: valve.h:239
const PressureNode * pNode3
Definition: valve.h:230
doublereal flow4
Definition: valve.h:255
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
doublereal c3
Definition: valve.h:262
doublereal c_vel
Definition: valve.h:234
virtual void Resize(integer iNewSize)=0

Here is the call graph for this function:

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

Reimplemented from Elem.

Definition at line 310 of file valve.h.

References pNode1, pNode2, pNode3, and pNode4.

310  {
311  connectedNodes.resize(4);
312  connectedNodes[0] = pNode1;
313  connectedNodes[1] = pNode2;
314  connectedNodes[2] = pNode3;
315  connectedNodes[3] = pNode4;
316  };
const PressureNode * pNode1
Definition: valve.h:228
const PressureNode * pNode4
Definition: valve.h:231
const PressureNode * pNode2
Definition: valve.h:229
const PressureNode * pNode3
Definition: valve.h:230
DofOrder::Order Dynamic_control_valve::GetDofType ( unsigned int  i) const
virtual

Reimplemented from Elem.

Definition at line 697 of file valve.cc.

References ASSERT, and DofOrder::DIFFERENTIAL.

698 {
699  ASSERT(i >= 0 && i <= 1);
700  return DofOrder::DIFFERENTIAL;
701 }
#define ASSERT(expression)
Definition: colamd.c:977
HydraulicElem::Type Dynamic_control_valve::GetHydraulicType ( void  ) const
virtual

Implements HydraulicElem.

Definition at line 681 of file valve.cc.

References HydraulicElem::DYNAMIC_CONTROL_VALVE.

unsigned int Dynamic_control_valve::iGetNumDof ( void  ) const
virtual

Reimplemented from Elem.

Definition at line 692 of file valve.cc.

693 {
694  return 2;
695 }
void Dynamic_control_valve::Output ( OutputHandler OH) const
virtual

Reimplemented from ToBeOutput.

Definition at line 1042 of file valve.cc.

References A1, A2, A3, A4, ToBeOutput::bToBeOutput(), flow1, flow2, flow3, flow4, WithLabel::GetLabel(), OutputHandler::Hydraulic(), s, sp, and vp.

1043 {
1044  if (bToBeOutput()) {
1045  std::ostream& out = OH.Hydraulic();
1046  out << std::setw(8) << GetLabel()
1047  << " " << s << " " << sp << " " << vp
1048  << " " << flow1 << " " << flow2 << " " << flow3 << " " << flow4
1049  << " " << A1 << " " << A2 << " " << A3 << " " << A4 << " " << std::endl;
1050  }
1051 }
doublereal sp
Definition: valve.h:258
doublereal A2
Definition: valve.h:247
virtual bool bToBeOutput(void) const
Definition: output.cc:890
doublereal vp
Definition: valve.h:259
doublereal flow2
Definition: valve.h:253
doublereal A1
Definition: valve.h:246
doublereal flow3
Definition: valve.h:254
doublereal flow1
Definition: valve.h:252
doublereal s
Definition: valve.h:256
doublereal A4
Definition: valve.h:249
doublereal A3
Definition: valve.h:248
doublereal flow4
Definition: valve.h:255
std::ostream & Hydraulic(void) const
Definition: output.h:492
unsigned int GetLabel(void) const
Definition: withlab.cc:62

Here is the call graph for this function:

std::ostream & Dynamic_control_valve::Restart ( std::ostream &  out) const
virtual

Implements Elem.

Definition at line 687 of file valve.cc.

688 {
689  return out << "Dynamic_control_valve not implemented yet!" << std::endl;
690 }
void Dynamic_control_valve::SetValue ( DataManager pDM,
VectorHandler X,
VectorHandler XP,
SimulationEntity::Hints ph = 0 
)
virtual

Reimplemented from SimulationEntity.

Definition at line 1055 of file valve.cc.

References DofOwnerOwner::iGetFirstIndex(), VectorHandler::PutCoef(), and start.

1058 {
1059  integer i = iGetFirstIndex();
1060 
1061  X.PutCoef(i+1, start);
1062  X.PutCoef(i+2, 0.);
1063  XP.PutCoef(i+1, 0.);
1064  XP.PutCoef(i+2, 0.);
1065 }
doublereal start
Definition: valve.h:232
virtual void PutCoef(integer iRow, const doublereal &dCoef)=0
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 Dynamic_control_valve::WorkSpaceDim ( integer piNumRows,
integer piNumCols 
) const
virtual

Implements Elem.

Definition at line 705 of file valve.cc.

706 {
707  *piNumRows = 6;
708  *piNumCols = 6;
709 }

Member Data Documentation

doublereal Dynamic_control_valve::A1
private

Definition at line 246 of file valve.h.

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

doublereal Dynamic_control_valve::A2
private

Definition at line 247 of file valve.h.

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

doublereal Dynamic_control_valve::A3
private

Definition at line 248 of file valve.h.

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

doublereal Dynamic_control_valve::A4
private

Definition at line 249 of file valve.h.

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

doublereal Dynamic_control_valve::c1
private

Definition at line 260 of file valve.h.

Referenced by AssJac(), and AssRes().

doublereal Dynamic_control_valve::c2
private

Definition at line 261 of file valve.h.

Referenced by AssJac(), and AssRes().

doublereal Dynamic_control_valve::c3
private

Definition at line 262 of file valve.h.

Referenced by AssJac(), and AssRes().

doublereal Dynamic_control_valve::c_acc
private

Definition at line 235 of file valve.h.

Referenced by AssRes().

doublereal Dynamic_control_valve::c_spost
private

Definition at line 233 of file valve.h.

Referenced by AssRes().

doublereal Dynamic_control_valve::c_vel
private

Definition at line 234 of file valve.h.

Referenced by AssRes().

doublereal Dynamic_control_valve::Cd
private

Definition at line 238 of file valve.h.

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

doublereal Dynamic_control_valve::cf1
private

Definition at line 263 of file valve.h.

Referenced by AssJac(), and AssRes().

doublereal Dynamic_control_valve::cf2
private

Definition at line 264 of file valve.h.

Referenced by AssJac(), and AssRes().

doublereal Dynamic_control_valve::cf3
private

Definition at line 265 of file valve.h.

Referenced by AssJac(), and AssRes().

doublereal Dynamic_control_valve::deltaP
private

Definition at line 266 of file valve.h.

Referenced by AssJac(), and AssRes().

doublereal Dynamic_control_valve::flow1
private

Definition at line 252 of file valve.h.

Referenced by AssRes(), and Output().

doublereal Dynamic_control_valve::flow2
private

Definition at line 253 of file valve.h.

Referenced by AssRes(), and Output().

doublereal Dynamic_control_valve::flow3
private

Definition at line 254 of file valve.h.

Referenced by AssRes(), and Output().

doublereal Dynamic_control_valve::flow4
private

Definition at line 255 of file valve.h.

Referenced by AssRes(), and Output().

doublereal Dynamic_control_valve::Force
private

Definition at line 236 of file valve.h.

doublereal Dynamic_control_valve::loss_area
private

Definition at line 240 of file valve.h.

Referenced by AssRes().

doublereal Dynamic_control_valve::Mass
private

Definition at line 251 of file valve.h.

const PressureNode* Dynamic_control_valve::pNode1
private

Definition at line 228 of file valve.h.

Referenced by AssJac(), AssRes(), Dynamic_control_valve(), and GetConnectedNodes().

const PressureNode* Dynamic_control_valve::pNode2
private

Definition at line 229 of file valve.h.

Referenced by AssJac(), AssRes(), Dynamic_control_valve(), and GetConnectedNodes().

const PressureNode* Dynamic_control_valve::pNode3
private

Definition at line 230 of file valve.h.

Referenced by AssJac(), AssRes(), Dynamic_control_valve(), and GetConnectedNodes().

const PressureNode* Dynamic_control_valve::pNode4
private

Definition at line 231 of file valve.h.

Referenced by AssJac(), AssRes(), Dynamic_control_valve(), and GetConnectedNodes().

doublereal Dynamic_control_valve::s
private

Definition at line 256 of file valve.h.

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

doublereal Dynamic_control_valve::s_max
private

Definition at line 244 of file valve.h.

Referenced by AssRes().

doublereal Dynamic_control_valve::sp
private

Definition at line 258 of file valve.h.

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

doublereal Dynamic_control_valve::start
private

Definition at line 232 of file valve.h.

Referenced by SetValue().

doublereal Dynamic_control_valve::v
private

Definition at line 257 of file valve.h.

Referenced by AssJac(), and AssRes().

doublereal Dynamic_control_valve::valve_density
private

Definition at line 242 of file valve.h.

Referenced by AssRes(), and Dynamic_control_valve().

doublereal Dynamic_control_valve::valve_diameter
private

Definition at line 241 of file valve.h.

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

doublereal Dynamic_control_valve::vp
private

Definition at line 259 of file valve.h.

Referenced by AssRes(), and Output().

doublereal Dynamic_control_valve::width
private

Definition at line 239 of file valve.h.

Referenced by AssJac(), and AssRes().


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