Numerical simulation of N-vector spin models in a magnetic field