Solenoid force to stroke equation
This might help: -

Force = \$(N\cdot I)^2\cdot 4\pi 10^{-7}\cdot \dfrac{A}{2g^2}\$


F = Force
I = Current
N = Number of turns
g = Length of the gap between the solenoid and the magnetizable metal
A = Area


If current, area and turns are constant, Force is inversely proportional to the gap squared (\$\ell^2\$). Formulas taken from this question.