Numerical Simulation of Plasma Dynamics in a Nonuniform Magnetic Field