Equation for calculating spring costant I'd like to design some of my own springs in order to obtain some very specific forces for a project. There are plenty of guides on how to make an arbitrary spring, but none I've read explain how to make one in such a way as to obtain a specific spring constant.
Given specifications, like the material (music wire), the material's gauge, number of turns in the spring, diameter of the spring, and space between turns, is there a formula for estimating the spring constant which I can then use with Hooke's law for estimating the force produced by the spring under load?
Googling for formulas or calculators of spring dimensions just gets me a bunch of manufacturer websites selling springs.
 A: A simple model for a coil spring would be that, when the spring is subjected to a force, the entire coil is subjected to a torsion $\tau$. This torque causes the coil the twist by an angle, which can be approximated with,
$$
\theta = \frac{l\, \tau}{I\, G},
$$
where $\theta$ is the angle of twist in radians, $l$ the length of the coil (not to be confused with the length of the spring), $I$ the second moment of inertia of the cross-section of the coil and $G$ the shear modulus of the material the coil is made of.
Assuming that the coil is circular rod, then $I$ would be equal to,
$$
I = \frac{\pi}{2} r^4 = \frac{\pi}{32} d^4,
$$
where $r$ and $d$ are the radius and diameter of the rod respectively.

However the spring constant of such a spring does not relate $\tau$ and $\theta$, but the elongation and (linear) force. The entire spring has free length $L$ and consists of $N$ turns with mean diameter $D$. The coil angle, $\alpha$, is defined as the the angle the coil makes with the plane normal to the length axis of the spring. Also see the Figure below.

If you unroll the spring onto a flat plain, the rod will be the diagonal of a rectangle with height $L$ and width $\pi\, N\, D$. Combining this with the fact that $\alpha$ is the angle between the diagonal and horizontal of this rectangle and therefore will be equal to,
$$
\alpha= \tan^{-1}\left(\frac{L}{\pi\, N\, D}\right).
$$
The relationship between $\theta$ and the elongation, $\Delta L$, can be found by looking at the change in $\alpha$ due to the elongation,
$$
\Delta\alpha = \tan^{-1}\left(\frac{L+\Delta L}{\pi\, N\, D}\right) - \tan^{-1}\left(\frac{L}{\pi\, N\, D}\right) = \frac{\pi\, N\, D}{L^2 + \pi^2 N^2 D^2}\Delta L + O(\Delta L^2).
$$
Namely the change in $\alpha$ is equal to the twist angle of a quarter of a turn of the spring, thus,
$$
\theta = 4\, N\, \Delta\alpha \approx \frac{4\, \pi N^2 D}{L^2 + \pi^2 N^2 D^2} \Delta L.
$$
The relationship between $\tau$ and $F$ can be found by looking at the lever of this torque in the spring,
$$
F = \frac{2 \cos(\alpha)}{D} \tau = \frac{2\, \pi\, N\, \tau}{\sqrt{L^2 + \pi^2 N^2 D^2}}.
$$
By using Pythagorean theorem it can be shown that the length of the coil is equal to,
$$
l = \sqrt{L^2 + \pi^2 N^2 D^2}.
$$
By substituting $F$ and $\Delta L$ from these equations, the spring constant can be approximated by,
$$
k = \frac{F}{\Delta L} \approx \frac{\pi^3 N^3 d^4 D\, G}{4 \left(L^2 + \pi^2 N^2 D^2\right)^2} = \frac{\pi^3 N^3 d^4 D\, G}{4\,l^4}.
$$

To test this we can try to calculate the spring constant of a spring from a ballpoint pen.

One end of the spring has four tightly packed windings, which are measured to have a height of 1.5 mm, thus the diameter of the the rod to be equal to 0.375 mm. The mean diameter of the spring is measured to be about 4 mm. The spring counts 8.5 windings. The length of the spring is measured to be 2 cm. The shear modulus is harder to determine, because I am not certain from which metal it is made of, but because it is attracted to a magnet I will assume it is iron, which has a shear modulus of about 64 GPa. The estimation for the spring constant would then be equal to roughly 173 N/m. Since the spring is relatively small I did not had an accurate way of measuring the elongation of the spring while applying a force. I used my mobile phone, which according to the the online specs weighs 162 g, which causes a compression of roughly 0.7 cm, which would yield a spring constant of roughly 227 N/m. So the predicted spring constant is of by 23.8%, which is quite a large relative error, but at least the same order of magnitude. Sources for this error might be: the fact that the compression was quite large, so the linear approximation in $\Delta L$ might not hold; the measured dimensions of the spring might not be totally accurate, especially the values for $d$ and $l$, which are raised to the fourth power could contribute a lot if the of my a little.
