# Crap Nullpointer Exceptions

This is the blog of John Dulaney, a hacker of Fedora, SCAdian, player of Music, blacksmith, sailor, and consumer of Bacon.

## On calculating port size and steam lap in the simple steam engine valve.

While the traditional way to design steam engines seems to have been to draw out diagrams representing the relationship between the piston, crank, and valve, I prefer to do the math directly.

First, you need to find the angle of the crank at cutoff

$A_c = \sqrt{1 - (\frac{r_c^2 + p^2 - l_r^2}{2 r_c p})^2}$

With

Ac is the angle of the crank, 0 being top dead center
rc is the radius of the crank, equal to one half piston travel
p is the piston’s position at cutoff
lr is the length of the connecting rod

To find the steam lap:

$\frac{S_L}{2 V_t} = cos(A_c + L)$

L is the angle of lead
Vt is the valve travel
SL is the steam lap

Finally, the maximum port opening is simply:

$P_o = \frac{V_t}{2} - S_L$

Po is the port opening