added magnetic field functions.