Energy stored in a magnetic field
Consider a circuit consisting of a voltage supply, switch, resistor and a coil of N turns wound on a toroid of length l, all in series.
With the switch open, no current flows inthe coil and therefore there is no flux produced in the core of the coil.
At t=0, the switch is closed and the current builds up with time. It is not instantaneous,because the coil produces a back emf that limits the rate of rise of current
where v = the time dependent back emf created by the coil. The instantaneous power being deliveredby the supply at time t is
vs .i=i2 R+v.i