which leads to the interaction between QM and external fields within the dipole approximation. Here M is the dipole moment matrix and R I the I-th QM nuclear coordinate. The corresponding Fock matrix to be used in the SCF cycles could be obtained by differentiating the total energy given by Eq. (10) with respect to the density matrix (P):