# Piston motion equations

The reciprocating motion of a non-offset piston connected to a rotating crank through a connecting rod (as would be found in internal combustion engines) can be expressed by equations of motion. This article shows how these equations of motion can be derived using calculus as functions of angle (angle domain) and of time (time domain).

## Crankshaft geometry

The geometry of the system consisting of the piston, rod and crank is represented as shown in the following diagram:

### Definitions

From the geometry shown in the diagram above, the following variables are defined:
    $l$ rod length (distance between piston pin and crank pin)
    $r$ crank radius (distance between crank center and crank pin, i.e. half stroke)
    $A$ crank angle (from cylinder bore centerline at TDC)
    $x$ piston pin position (distance upward from crank center along cylinder bore centerline)
The following variables are also defined:
    $v$ piston pin velocity (upward from crank center along cylinder bore centerline)
    $a$ piston pin acceleration (upward from crank center along cylinder bore centerline)
    $\omega$ crank angular velocity (in the same direction/sense as crank angle $A$)

### Angular velocity

The frequency (Hz) of the crankshaft's rotation is related to the engine's speed (revolutions per minute) as follows:
    $\nu ={\frac {\mathrm {RPM} }{60}}$
So the angular velocity (radians/s) of the crankshaft is:
    $\omega =2\pi \cdot \nu =2\pi \cdot {\frac {\mathrm {RPM} }{60}}$

### Triangle relation

As shown in the diagram, the crank pin, crank center and piston pin form triangle NOP. By the cosine law it is seen that:
    $l^{2}=r^{2}+x^{2}-2\cdot r\cdot x\cdot \cos A$
where $l$ and $r$ are constant and $x$ varies as $A$ changes.

## Equations with respect to angular position (angle domain)

Angle domain equations are expressed as functions of angle.

### Deriving angle domain equations

The angle domain equations of the piston's reciprocating motion are derived from the system's geometry equations as follows.

### Position (geometry)

Position with respect to crank angle (from the triangle relation, completing the square, utilizing the Pythagorean identity, and rearranging):
    ${\begin{array}{lcl}l^{2}=r^{2}+x^{2}-2\cdot r\cdot x\cdot \cos A\\l^{2}-r^{2}=(x-r\cdot \cos A)^{2}-r^{2}\cdot \cos ^{2}A\\l^{2}-r^{2}+r^{2}\cdot \cos ^{2}A=(x-r\cdot \cos A)^{2}\\l^{2}-r^{2}\cdot (1-\cos ^{2}A)=(x-r\cdot \cos A)^{2}\\l^{2}-r^{2}\cdot \sin ^{2}A=(x-r\cdot \cos A)^{2}\\x=r\cdot \cos A+{\sqrt {l^{2}-r^{2}\cdot \sin ^{2}A}}\\\end{array}}$

### Velocity

Velocity with respect to crank angle (take first derivative, using the chain rule):
    ${\begin{array}{lcl}x'&=&{\frac {dx}{dA}}\\&=&-r\cdot \sin A+{\frac {({\frac {1}{2}})\cdot (-2)\cdot r^{2}\cdot \sin A\cdot \cos A}{\sqrt {l^{2}-r^{2}\cdot \sin ^{2}A}}}\\&=&-r\cdot \sin A-{\frac {r^{2}\cdot \sin A\cdot \cos A}{\sqrt {l^{2}-r^{2}\cdot \sin ^{2}A}}}\\\end{array}}$

### Acceleration

Acceleration with respect to crank angle (take second derivative, using the chain rule and the quotient rule):
    ${\begin{array}{lcl}x''&=&{\frac {d^{2}x}{dA^{2}}}\\&=&-r\cdot \cos A-{\frac {r^{2}\cdot \cos ^{2}A}{\sqrt {l^{2}-r^{2}\cdot \sin ^{2}A}}}-{\frac {-r^{2}\cdot \sin ^{2}A}{\sqrt {l^{2}-r^{2}\cdot \sin ^{2}A}}}-{\frac {r^{2}\cdot \sin A\cdot \cos A\cdot \left(-{\frac {1}{2}}\right)\cdot (-2)\cdot r^{2}\cdot \sin A\cdot \cos A}{\left({\sqrt {l^{2}-r^{2}\cdot \sin ^{2}A}}\right)^{3}}}\\&=&-r\cdot \cos A-{\frac {r^{2}\cdot \left(\cos ^{2}A-\sin ^{2}A\right)}{\sqrt {l^{2}-r^{2}\cdot \sin ^{2}A}}}-{\frac {r^{4}\cdot \sin ^{2}A\cdot \cos ^{2}A}{\left({\sqrt {l^{2}-r^{2}\cdot \sin ^{2}A}}\right)^{3}}}\\\end{array}}$

### Non Simple Harmonic Motion

The angle domain equations above show that the motion of the piston (connected to rod and crank) is not simple harmonic motion, but is modified by the motion of the rod as it swings with the rotation of the crank. This is in contrast to the Scotch Yoke which directly produces simple harmonic motion.

### Example graphs

Example graphs of the angle domain equations are shown below.

## Equations with respect to time (time domain)

Time domain equations are expressed as functions of time.

### Angular velocity derivatives

Angle is related to time by angular velocity $\omega$ as follows:
    $A=\omega t\,$
If angular velocity $\omega$ is constant, then:
    ${\frac {dA}{dt}}=\omega$
and:
    ${\frac {d^{2}A}{dt^{2}}}=0$

### Deriving time domain equations

The time domain equations of the piston's reciprocating motion are derived from the angle domain equations as follows.

### Position

Position with respect to time is simply:
    $x\,$

### Velocity

Velocity with respect to time (using the chain rule):
    ${\begin{array}{lcl}v&=&{\frac {dx}{dt}}\\&=&{\frac {dx}{dA}}\cdot {\frac {dA}{dt}}\\&=&{\frac {dx}{dA}}\cdot \ \omega \\&=&x'\cdot \omega \\\end{array}}$

### Acceleration

Acceleration with respect to time (using the chain rule and product rule, and the angular velocity derivatives):
    ${\begin{array}{lcl}a&=&{\frac {d^{2}x}{dt^{2}}}\\&=&{\frac {d}{dt}}{\frac {dx}{dt}}\\&=&{\frac {d}{dt}}({\frac {dx}{dA}}\cdot {\frac {dA}{dt}})\\&=&{\frac {d}{dt}}({\frac {dx}{dA}})\cdot {\frac {dA}{dt}}+{\frac {dx}{dA}}\cdot {\frac {d}{dt}}({\frac {dA}{dt}})\\&=&{\frac {d}{dA}}({\frac {dx}{dA}})\cdot ({\frac {dA}{dt}})^{2}+{\frac {dx}{dA}}\cdot {\frac {d^{2}A}{dt^{2}}}\\&=&{\frac {d^{2}x}{dA^{2}}}\cdot ({\frac {dA}{dt}})^{2}+{\frac {dx}{dA}}\cdot {\frac {d^{2}A}{dt^{2}}}\\&=&{\frac {d^{2}x}{dA^{2}}}\cdot \omega ^{2}+{\frac {dx}{dA}}\cdot 0\\&=&x''\cdot \omega ^{2}\\\end{array}}$

### Scaling for angular velocity

From the foregoing, you can see that the time domain equations are simply scaled forms of the angle domain equations: $x$ is unscaled, $x'$ is scaled by ω, and $x''$ is scaled by ω².
To convert the angle domain equations to time domain, first replace A with ωt, and then scale for angular velocity as follows: multiply $x'$ by ω, and multiply $x''$ by ω².

## Velocity maxima and minima

By definition, the velocity maxima and minima occur at the acceleration zeros (crossings of the horizontal axis).

### Crank angle not right-angled

The velocity maxima and minima (see the acceleration zero crossings in the graphs below) depend on rod length $l$ and half stroke $r$ and do not occur when the crank angle $A$ is right angled.

### Crank-rod angle not right angled

The velocity maxima and minima do not necessarily occur when the crank makes a right angle with the rod. Counter-examples exist to disprove the statement "velocity maxima and minima only occur when the crank-rod angle is right angled".

#### Example

For rod length 6" and crank radius 2" (as shown in the example graph below), numerically solving the acceleration zero-crossings finds the velocity maxima/minima to be at crank angles of ±73.17530°. Then, using the triangle law of sines, it is found that the rod-vertical angle is 18.60639° and the crank-rod angle is 88.21832°. Clearly, in this example, the angle between the crank and the rod is not a right angle. Summing the angles of the triangle 88.21832° + 18.60639° + 73.17530° gives 180.00000°. A single counter-example is sufficient to disprove the statement "velocity maxima/minima occur when crank makes a right angle with rod".

## Example graphs of piston motion
### Angle Domain Graphs

The graphs below show the angle domain equations for a constant rod length $l$ (6.0") and various values of half stroke $r$ (1.8", 2.0", 2.2"). Note in the graphs that L is rod length $l$ and R is half stroke $r$.

### Animation

Below is an animation of the piston motion equations with the same values of rod length and crank radius as in the graphs above.

#### Units of Convenience

Note that for the automotive/hotrod use-case the most convenient (used by enthusiasts) unit of length for the piston-rod-crank geometry is the inch, with typical dimensions being 6" (inch) rod length and 2" (inch) crank radius. This article uses units of inch (") for position, velocity and acceleration, as shown in the graphs above.