Spring Mechanic

I’ve been trying to make a spring like object, it’s supposed to fall from a high place then measure the impact (using raycast)
once the impact occurs the spring will add force to get back into it’s ‘normal form’ exactly, within a short time range (which I want to be able to modify).
not sure if using acceleration is a better approach than force so I tried both ways, non of those seem to work properly as I expected.
this is the only thing I could come up with:

        if (hitground && velocity.y < 0)
        {
            //groundData.distanceImpact is the distance between the ground and spring (how far the spring squeezed)
            float force = groundData.distanceImpact * rigidbody.mass * gravity; //mass = 60 and gravity = 9.81
            rigidbody.AddForce(rigidbody.transform.up * force);
        }

Why not just set the velocity directly.