An analytical functional for the evaluation of seismic damage in structures