Numerical studies of the hysteresis in locomotion of a passively pitching foil