simulation of flexible rods with automatic generation of jacobian and hessian