excited state variational method