FERRETGame engine over Babylon.js
Ferret

Engines

Skill ferret-physics-engines · download all skills · SKILL.md

When to use#

A locomotive or a steam launch, a mill engine with a governor, a car or a motorbike engine that has to start, idle, rev and stall, a generator set on rubber mounts.

The model#

An engine is a torque source on a drivetrain shaft; its torque is the work the gas does over the angle the crank turned. The steam cylinder takes steam from a Boiler through a port that opens and closes by crank angle (the valve gear); a multi-cylinder piston engine is several PistonEngines on one crank, shifted by the firing order. The shaft's housing (A0) takes the reaction torque; applyInertia puts the reciprocating masses' unbalanced force on the mounts.

Steps#

  1. Build the Boiler (physics-combustion) and a Drivetrain with a crank shaft (physics-mechanisms; give it a housing if the block moves).
  2. new SteamEngine({ bore, crank, rod, boiler, inlet, exhaustPort, phases: [0, Math.PI / 2], gear: { cutoff, lead, release, compression } }) or new MultiCylinderEngine({ cylinder, count, order }), then drivetrain.drive(crank, engine.torque).
  3. Register the controls for programs: engineForms(bridge, { engines, boilers }) gives throttle, cutoff, reverse, ignition, fuel, engine-rpm, pressure, level.
  4. Write the governor, the starter and the reverser as programs and bindings.
  5. For the shaking, call engine.applyInertia(omega, theta, mount) every step with the body or vessel as mount.

Check afterwards#

The work per turn is the indicator area for the cut-off; the pressure of the boiler falls as steam is drawn; the four-cylinder torque varies far less than one cylinder's; the primary inertia forces of an inline four cancel.

What usually goes wrong#

  • A one-cylinder steam engine sticks on a dead centre: use two cylinders at 90° (phases).
  • The speed runs away: there is no load, or the governor program does not run (tick the runtime).
  • The engine does not start: the port is shut at that crank angle (a cut-off of 0.5 or less can leave a 90° pair with no open port); use a longer cut-off to start.
  • A used engine object is reused after the crank angle was reset: an engine remembers the angle of its last call; build a fresh one.

Files#