Saturday, May 10, 2008

Tractive Effort

This week is another short, fun snippet of code. We're going to calculate the tractive effort of a steam locomotive. Useless to most people, but I've got a large project where I'll be using it myself.


ASP

  1. function TractiveEffort(cylinderDiameter, stroke, pressure, wheelDiameter)
  2.     TractiveEffort = cylinderDiameter ^ 2 * stroke * pressure * 0.85 / wheelDiameter
  3. end function

PHP

  1. function $tractiveEffort($cylinderDiameter, $stroke, $pressure, $wheelDiameter)
  2. {
  3.     return $cylinderDiameter ^ 2 * $stroke * $pressure * 0.85 / $wheelDiameter;
  4. }

It should be noted that the formula only applies to non-compound steam locomotives. Locomotives with multiple cylinders are more complex.

No comments: