Numerical simulation of electrical explosions in megagauss magnetic fields