1Creating A Powertrain In Chrono (demo_CH_powertrain.cpp) {#tutorial_demo_powertrain}
2==========================
3
4Tutorial covers basic approaches to build
5systems that embed powertrains made with 1-degree-of-freedom
6items (rotating shafts):
7
8- connect 1D shafts with transmission ratios
9- connect 1D shafts with 1D clutches, brakes, etc.
10- connect a 1D shaft to a 3D body.
11- No GUI: only text output.
12
13
14
15\dontinclude demo_CH_powertrain.cpp
16
17## Example 1: create a simple powertrain with ChShaft objects
18
19This models a very basic powertrain with two shafts `A` and `B`,
20connected by a reducer `[ t ]` with transmission ratio `t`. The shafts are
21free to rotate. Shaft A has an applied torque `Ta`, so A and B will
22constantly accelerate. Each shaft must have some inertia and each one is
23marked as `||` in the following scheme:
24~~~{.c}
25        A           B
26   Ta  ||---[ t ]---||
27
28~~~
29First, create a ChShaft, a 1-degree-of-freedom '1D' mechanical object that
30can only rotate. It has one inertia value
31and maybe one applied torque. The ChShaft objects do not have
32any meaning in 3D, they are just 'building blocks'.
33
34\skip my_shaftA
35\until my_system.Add(my_shaftA);
36
37Next, create another shaft. Note that this falls back on the use of shared pointers for ChShaft
38objects. Also note that the elements must be added to the ChSystem object that manages this simulation.
39
40\skip my_shaftB
41\until my_system.Add(my_shaftB);
42
43Finally, create a ChShaftsGear that represents a simplified model
44of a reducer with transmission ratio `t` between two ChShaft objects.
45
46 <div class="ce-info">
47Note that a full blown 3D powertrain could be created using a collection of rigid bodies
48of ChBody type that would be connected via ChLinkLockRevolute and ChLinkGear 3D constraints. However,
49 this would introduce additional complexity to the model which is not always warranted. The 1D items
50 of ChShaft type keep the model much simpler.
51 </div>
52
53
54\skip my_shaft_gearAB
55\until my_system.Add(my_shaft_gearAB);
56
57
58## Example 2: a clutch between two shafts
59
60This models a very basic powertrain with two shafts A and B
61connected by a clutch `[ c ]`. Each shaft (see flywheels `||` in schematic below)
62starts with a nonzero speed and is free to rotate independently
63until the clutch is activated. At that point, they will decelerate
64until they have the same speed.
65~~~{.c}
66       A           B
67  Ta  ||---[ c ]---||
68
69~~~
70
71First, create a ChShaft that starts with nonzero angular velocity:
72
73\skip auto my_shaftA = std::make_shared<ChShaft>();
74\until my_system.Add(my_shaftA);
75
76Next, create another ChShaft with opposite initial angular velocity:
77
78\skip my_shaftB
79\until my_system.Add(my_shaftB);
80
81Now, create a ChShaftsClutch that represents a simplified model
82of a clutch between two ChShaft objects (something that limits
83the max transmitted torque, up to slippage).
84
85\skip my_shaft_clutchAB
86\until my_system.Add(my_shaft_clutchAB);
87
88Below, the simulation is started with the clutch disengaged:
89
90\skipline SetModulation
91
92## Example 3: an epicycloidal reducer
93
94An epicycloidal reducer is modeled below using the ChShaftsPlanetary
95constraint.
96
97The ChShaftsPlanetary sets up a kinematic constraint between three
98shafts. One of them will be _fixed_ and represents the truss
99of the reducer - in epicycloidaal reducer, this is the role of the
100large gear with inner teeth. The two remaining shafts are the
101input and output shafts. In other cases, such as the differential
102planetary gear of cars, all three shafts are free. A brake is applied on the output shaft - it is
103enough that one of these last two shafts is fixed.
104
105In the following schematic, the brake is `[ b ]`, the planetary (the
106reducer) is `[ p ]`, the shafts are `A,B,C,D`, the applied torque is `Ta`, inertias
107of free shafts are shown as flywheels `||` , and fixed shafts are marked with `*` .
108~~~{.c}
109
110       A           B            D
111  Ta  ||---[ p ]---||---[ b ]---*
112           [   ]---*
113                   C
114
115~~~
116
117First, create shaft A with an applied torque:
118
119\skip auto my_shaftA = std::make_shared<ChShaft>();
120\until my_system.Add(my_shaftA);
121
122Next, create shaft B:
123
124\skip my_shaftB
125\until my_system.Add(my_shaftB);
126
127Create shaft C, which will be fixed (used as truss of epicycloidal reducer):
128
129\skip my_shaftC
130\until my_system.Add(my_shaftC);
131
132Create a ChShaftsPlanetary that represents a simplified model
133of a planetary gear between _three_ ChShaft objects (e.g., a car differential).
134An epicycloidal reducer is a special type of planetary gear.
135
136\skip my_shaft_planetaryBAC
137\until my_shaftC);
138
139The ratios of the planetary can be set using a simplified formula for the
140so called _Willis_ case. Imagine we hold fixed the carrier (shaft B in epic. reducers),
141and leave the truss C free (the outer gear with inner teeth in our reducer); which is
142the transmission ratio \f$ t_0 \f$ that we get. It is simply \f$ t_0=-Z_a/Z_c \f$, with \f$ Z_i \f$ = num of teeth of gears.
143Use the following to set all the three ratios:
144
145\skip t0
146\until my_system.Add(my_shaft_planetaryBAC);
147
148Now, let's make a shaft D that is fixed and thus used for the right side
149of a clutch (so the clutch will act as a brake).
150
151\skip my_shaftD
152\until my_system.Add(my_shaftD);
153
154Next, make the brake. It is, in fact, a clutch between shafts B and D, where
155D is fixed as a truss so that the clutch will operate as a brake.
156
157\skip my_shaft_clutchBD
158\until my_system.Add(my_shaft_clutchBD);
159
160
161## Example 4: constraint between a ChBody and a ChShaft
162
163Suppose we want to create a 3D model, for instance a slider-crank,
164built with multiple ChBody objects. Moreover, we want to create a
165powertrain, for instance a motor, a clutch, etc., for the rotation of
166the crank. Connecting _1D items_ of ChShaft class with the
167_3D items_ of ChBody class calls for the use of a ChShaftsBody constraint,
168shown as `[ bs ]` in the schematic in which the 3D body is shown as `<>`.
169This example also considers a 'torsional spring damper' `C`, shown as `[ t ]`,
170that connects shafts `A` and `C` (C is shown as `*` because fixed).
171~~~{.c}
172
173        B             A           C
174  Ta   <>---[ bs ]---||---[ t ]---*
175
176
177~~~
178
179First, create 'A', a 1D shaft:
180
181\skip auto my_shaftA = std::make_shared<ChShaft>();
182\until my_system.Add(my_shaftA);
183
184Next, create 'C', a 1D shaft, fixed:
185
186\skip my_shaftC
187\until my_system.Add(my_shaftC);
188
189Create 'B', a 3D rigid body:
190
191\skip my_bodyB
192\until my_system.Add(my_bodyB);
193
194Define the torsional spring-damper between shafts A and C:
195
196\skip my_shaft_torsionAC
197\until my_system.Add(my_shaft_torsionAC);
198
199Define the shaft 'A' connected to the rotation of the 3D body 'B'.
200Finally, specify the direction (in body coordinates) along which the
201shaft will affect the body:
202
203\skip my_shaftbody_connection
204\until my_system.Add(my_shaftbody_connection);
205
206
207## Example 5: torque converter and thermal engine
208
209This example highlights the use of a torque converter.
210The torque converter is represented by a ChShaftsTorqueConverter
211object that connects three 1D items of ChShaft class:
212- the input shaft A, i.e., the impeller connected to the engine
213- the output shaft B, i.e., the turbine connected to the gears and wheels
214- the stator C, which does not rotate and transmits reaction to the truss
215In the following schematic, the torque converter is represented as `[ tc ]`,
216the thermal engine is marked with `[ e ]`, and the breaking torque is `Tb`
217(C shown as `*` since fixed).
218
219First, create 'A', a 1D shaft:
220
221\skip auto my_shaftA = std::make_shared<ChShaft>();
222\until my_system.Add(my_shaftA);
223
224Next, create 'B', a 1D shaft:
225
226\skip my_shaftB
227\until my_system.Add(my_shaftB);
228
229Create 'C', a 1D shaft, fixed:
230
231\skip my_shaftC
232\until my_system.Add(my_shaftC);
233
234Create 'D', a 1D shaft, fixed:
235
236\skip my_shaftD
237\until my_system.Add(my_shaftD);
238
239Define the torque converter and connect the shafts:
240A (input), B (output), C(truss stator)
241
242\skip my_torqueconverter
243\until my_torqueconverter->SetCurveTorqueRatio(mT);
244
245Define the thermal engine acting on shaft A, the input to
246the torque converter. Note that the thermal engine also
247requires shaft D, which is used to transmit the
248reaction torque back to a truss (the motor block).
249
250**Option A**: use a ChShaftsMotor in MOT_MODE_TORQUE mode.
251It works, but most often this is more useful when in MOT_MODE_SPEED.
252
253\skip auto my_motor = std::make_shared<ChShaftsMotor>();
254\until my_system.Add(my_motor);
255
256**Option B**: use a ChShaftsTorque - it simply applies a torque
257to my_shaftA (say, the crankshaft), and the negative torque
258to my_shaftD (say, the motor block).
259It is a quick approach. Note that
260the torque should be changed at each timestep if a torque curve is to be emulated.
261
262\skip auto my_motor = std::make_shared<ChShaftsTorque>();
263\until my_system.Add(my_motor);
264
265**Option C**: a more versatile approach where one can
266define a torque curve and a throttle value via the
267ChShaftsThermalEngine.
268
269\skip auto my_motor = std::make_shared<ChShaftsThermalEngine>();
270\until my_motor->SetTorqueCurve(mTw);
271
272
273## The complete listing:
274
275\include demo_CH_powertrain.cpp
276