Modelling the Sun’s magnetic field