1 // =============================================================================
2 // PROJECT CHRONO - http://projectchrono.org
3 //
4 // Copyright (c) 2014 projectchrono.org
5 // All rights reserved.
6 //
7 // Use of this source code is governed by a BSD-style license that can be found
8 // in the LICENSE file at the top level of the distribution and at
9 // http://projectchrono.org/license-chrono.txt.
10 //
11 // =============================================================================
12 // Authors: Alessandro Tasora, Radu Serban, Rainer Gericke
13 // =============================================================================
14 
15 #ifndef CHSHAFTSTORQUECONVERTER_H
16 #define CHSHAFTSTORQUECONVERTER_H
17 
18 #include "chrono/motion_functions/ChFunction.h"
19 #include "chrono/physics/ChShaftsCouple.h"
20 
21 namespace chrono {
22 
23 /// Class for defining a torque converter between two one-degree-of-freedom parts;
24 /// i.e., shafts that can be used to build 1D models of powertrains. Note that is
25 /// not inherited from ChShaftsTorqueBase, because it requires a third part: the stator.
26 /// The torque converter multiplies the input torque if there is slippage between input
27 /// and output, then the multiplicative effect becomes closer to unity when the slippage
28 /// is almost null; so it is similar to a variable-transmission-ratio gearbox, and just
29 /// like any gearbox it requires a truss (the 'stator') that gets some torque.
30 /// When the vehicle is coasting, the stator is always inactive, then the output torque
31 /// cannot be increased.
32 /// Note: it can work only in a given direction.
33 
34 class ChApi ChShaftsTorqueConverter : public ChPhysicsItem {
35   private:
36     ChShaft* shaft1;
37     ChShaft* shaft2;
38     ChShaft* shaft_stator;
39 
40     double torque_in;
41     double torque_out;
42 
43     std::shared_ptr<ChFunction> K;
44     std::shared_ptr<ChFunction> T;
45 
46     bool state_warning_reverseflow;
47     bool state_warning_wrongimpellerdirection;
48 
49   public:
50     ChShaftsTorqueConverter();
51     ChShaftsTorqueConverter(const ChShaftsTorqueConverter& other);
~ChShaftsTorqueConverter()52     ~ChShaftsTorqueConverter() {}
53 
54     /// "Virtual" copy constructor (covariant return type).
Clone()55     virtual ChShaftsTorqueConverter* Clone() const override { return new ChShaftsTorqueConverter(*this); }
56 
57     /// Number of scalar constraints
GetDOC_c()58     virtual int GetDOC_c() override { return 0; }
59 
60     // (override/implement interfaces for global state vectors, see ChPhysicsItem for comments.)
61     virtual void IntLoadResidual_F(const unsigned int off, ChVectorDynamic<>& R, const double c) override;
62 
63     // Override/implement system functions of ChPhysicsItem
64     // (to assemble/manage data for system solver)
65 
66     virtual void VariablesFbLoadForces(double factor) override;
67 
68     /// Use this function after torque converter creation, to initialize it, given
69     /// input and output shafts to join (plus the stator shaft, that should be fixed).
70     /// Each shaft must belong to the same ChSystem.
71     bool Initialize(std::shared_ptr<ChShaft> mshaft1,       ///< input shaft
72                     std::shared_ptr<ChShaft> mshaft2,       ///< output shaft
73                     std::shared_ptr<ChShaft> mshaft_stator  ///< stator shaft (often fixed)
74     );
75 
76     /// Get the input shaft
GetShaftInput()77     ChShaft* GetShaftInput() { return shaft1; }
78     /// Get the output shaft
GetShaftOutput()79     ChShaft* GetShaftOutput() { return shaft2; }
80     /// Get the stator shaft (the truss)
GetShaftStator()81     ChShaft* GetShaftStator() { return shaft_stator; }
82 
83     /// Set the capacity factor curve, function of speed ratio R.
84     /// It is K(R)= input speed / square root of the input torque.
85     /// Units: (rad/s) / sqrt(Nm)
SetCurveCapacityFactor(std::shared_ptr<ChFunction> mf)86     void SetCurveCapacityFactor(std::shared_ptr<ChFunction> mf) { K = mf; }
87     /// Get the capacity factor curve.
GetCurveCapacityFactor()88     std::shared_ptr<ChFunction> GetCurveCapacityFactor() { return K; }
89 
90     /// Set the torque ratio curve, function of speed ratio R.
91     /// It is T(R) = (output torque) / (input torque)
SetCurveTorqueRatio(std::shared_ptr<ChFunction> mf)92     void SetCurveTorqueRatio(std::shared_ptr<ChFunction> mf) { T = mf; }
93     /// Get the torque ratio curve.
GetCurveTorqueRatio()94     std::shared_ptr<ChFunction> GetCurveTorqueRatio() { return T; }
95 
96     /// Get the torque applied to the input shaft
GetTorqueReactionOnInput()97     double GetTorqueReactionOnInput() const { return torque_in; }
98 
99     /// Get the torque applied to the output shaft
GetTorqueReactionOnOutput()100     double GetTorqueReactionOnOutput() const { return torque_out; }
101 
102     /// Get the torque applied to the stator shaft (the truss)
GetTorqueReactionOnStator()103     double GetTorqueReactionOnStator() const { return -torque_out - torque_in; }
104 
105     /// Get the actual peed ratio, as output speed / input speed.
106     /// Assumes output has same direction as input, and slower than input
107     /// otherwise exchanges input and output.
108     /// For speed ratio = 0, complete slippage, for ratio=1 perfect locking.
109     double GetSpeedRatio() const;
110 
111     /// Get the actual slippage, for slippage = 1 complete slippage,
112     /// for slippage = 0 perfect locking.
GetSlippage()113     double GetSlippage() const { return 1.0 - GetSpeedRatio(); }
114 
115     /// State warning, at last update. Tell if the torque converter is working
116     /// in reverse power flow, i.e. the output turbine is running faster than
117     /// input impeller shaft.
StateWarningReverseFlow()118     bool StateWarningReverseFlow() { return state_warning_reverseflow; }
119 
120     /// State warning, at last update. Tell if the torque converter is working
121     /// with the input shaft in the reverse direction (negative speed).
122     /// This is considered an abnormal behavior, and torques are forced to zero.
StateWarningWrongImpellerDirection()123     bool StateWarningWrongImpellerDirection() { return state_warning_wrongimpellerdirection; }
124 
125     /// Update all auxiliary data of the gear transmission at given time
126     virtual void Update(double mytime, bool update_assets = true) override;
127 
128     /// Method to allow serialization of transient data to archives.
129     virtual void ArchiveOUT(ChArchiveOut& marchive) override;
130 
131     /// Method to allow deserialization of transient data from archives.
132     virtual void ArchiveIN(ChArchiveIn& marchive) override;
133 };
134 
135 CH_CLASS_VERSION(ChShaftsTorqueConverter, 0)
136 
137 }  // end namespace chrono
138 
139 #endif
140