An Averaging Approach to the Smoluchowski–Kramers Approximation in the Presence of a Varying Magnetic Field