# Rail3D*

 User Name: Password: Remember me next time.

# Vehicle Dynamics

A note on using scripts for vehicle dynamics and control systems.

## How Rail3D handles dynamics without scripts

Without scripts, most aspects of Rail3D vehicle dynamics and controls are handled by the dynamics.dll. The process is roughly:

1. The train holds up to five “target speed” values. These each store a target speed and a position at which that target speed must be observed. Thus stops and speed restrictions ahead are stored in these target speed values. The first value, TargetSpeed[0] is reserved for signals.
2. If in dos mode, or shunting, the program calculates the clear distance ahead.
3. The program compares the five target speeds, the safe dos/shunt distance and any relevant speed limits, finds the most restrictive of these and calculates the speed the train should be doing at this point. If this is less than the current speed, the brakes are set, if it is more, power is set.
4. There are actually ten control variables. By convention (and in normal Rail3D use)
• Control[0] is the main power control,
• Control[1] is the main brake,
• Control[2] is a secondary brake,
• Control[3] is a steam locomotive cutoff
• Control[5] is used for a combined power/brake control

5. Obviously, if the user is driving the train, the control positions are set by the user, not the computer.
6. At this point the dynamics algorithms are used to calculate the braking or accelerating force resulting from the positions of the controls, and the effect this has on train speed.
7. Twenty parameters are stored to aid calculation (although not all are meaningful at all times)
• Parameter[0] is the train speed (in metres/sec)
• Parameter[1] is the brake pipe pressure (0–100%)
• Parameter[2] is the brake reservoir pressure (0–105%)
• Parameter[3] is the trolley pole angle
• Parameter[4] is the shunting distance
• Parameter[5] is a flag for rack mode
• Parameter[6] is the slip ratio
• Parameter[7] is a measure of how “good” the fire is (steam locos) or engine rpm (diesel locos)
• Parameter[8] is the boiler pressure (in pascal - a large number!)
• Parameter[9] is the back pressure in the cylinders
• Parameter[10] is used internally by the sound subsystem
• Parameter[11] is used internally by the sound subsystem
• Parameter[12] is the target speed as determined by the computer system
• Parameter[13] can be used by a script to drive the sound system
• Parameter[16] to Parameter[19] are reserved for use by scripts : scripts may use these parameters (eg to drive cab gauges)
• Parameter[21] is traction current
• Parameter[23] is locomotive brake
• Parameter[24] is traction power (kW)
• Parameter[25] is tractive force (kN)

8. These parameters may be displayed to the user as cab gauges

## Using scripts to change the default behaviour

Scripts can be used to interact with the default dynamics in a number of ways

• A SetControls() function may be used and this overrides the programs settings. A script can read the target speeds, shunt distance etc and calculate the position of the controls, and the ten controls can be set.
• A script may override the Acceleration force / Brake force calculations to provide alternative calcualtions of the acceleration/deceleration based on the control values.
• The dynamics functions (Acceleration/Brake/Drag) receive two train variables - one to the actual vehicle in question and one to the lead vehicle of the train. This is necessary so that the script has access to parameters for both the specific vehicle (eg boiler pressure, engine rpm) and the controller settings which can only be got from the lead vehicle.

For an example of using these parameters and scripts, see Regenerative Electric

MRG 24/08/2013 17:35:15