The simulation code TSEC (time-dependent spectral equilibrium code) has been developed to model the axisymmetric evolution of a tokamak on the resistive (L/R) time scale of the external coils, conductors, or shell. The electromagnetic interaction between the plasma and the external circuit is taken into account in a self-consistent manner. The Lagrangian TSEC utilizes magnetic flux coordinates with spectral decomposition in the angle variable θ. The plasma is modeled as a finite-size, zero-inertia, finite-pressure fluid, which adjusts its position and shape to remain in free-boundary equilibrium, consistent with the currents in the external circuits. At the heart of TSEC is a fast method of calculating the self-consistent free-boundary plasma equilibrium at each time step, which is based on the minimization of a certain mean-square error.