  We examine a simulation of flux emergence and cancellation, which shows a
complex sequence of processes that accumulate free magnetic energy in the solar
corona essential for the eruptive events such as coronal mass ejections (CMEs),
filament eruptions and flares. The flow velocity at the surface and in the
corona shows a consistent shearing pattern along the polarity inversion line
(PIL), which together with the rotation of the magnetic polarities, builds up
the magnetic shear. Tether-cutting reconnection above the PIL then produces
longer sheared magnetic field lines that extend higher into the corona, where a
sigmoidal structure forms. Most significantly, reconnection and upward
energy-flux transfer are found to occur even as magnetic flux is submerging and
appears to cancel at the photosphere. A comparison of the simulated coronal
field with the corresponding coronal potential field graphically shows the
development of nonpotential fields during the emergence of the magnetic flux
and formation of sunspots.
