How to simulate a compression spring
How would you model a piston-like compression spring, which would look essentially like a cylinder attached something at either end, but whose length changes by a configurable amount, asserting a force in proportion to Hooke's law?