During the geometry optimization of the ground state of a molecule, we try to optimize the energy gradient with respect to the nuclear positions such that the system remains in its lowest energy state. Nowadays, excited state geometry optimization is available in many codes for example nwchem, gamess etc. My question is when we do an excited state geometry optimization what are we optimizing? How the energy gradient differ in this case compared to the ground state?
There's many reasons why we may want to optimize the geometry of an excited electronic state, for example the upper state in this figure from my 2011 spectroscopy paper:
"My question is when we do an excited state geometry optimization what are we optimizing? How the energy gradient differ in this case compared to the ground state?"
We are again optimizing the electronic energy as a function of nuclear coordinates. In the above diagram, we'd be optimizing $V(r)$ with respect to the internuclear distance $r$. In terms of the actual implementation of the energy gradients, remember that to calculate electronic excited states you have to use excited state methods such as EOM-CCSD instead of vanilla CCSD, for which the implementation is a bit more complicated but not too uncommon nowadays.
In my above example, if spatial symmetry constraints where you specify occupation numbers in spatial orbitals in a point group bigger than $C_1$ are possible in your electronic structure software, then the upper state in that figure can actually be treated as the "ground state" in that particular spatial symmetry, but if you want the $C$-state or $e$-state in the below figure for the CO molecule, then you will have to use an excited state method such as EOM-CCSD: