Hi,

in my group we were looking at the psi4 code that calculates the quadrupole and traceless quadrupole moment (quadrupole.cc, tracelessquadrupole.cc and oeprop.cc) in order to understand the exact equations that are used for the quadrupole calculation.

Looking at quadrupole.cc, the nuclear contribution to the quadrupole is calculated according to Q_ij = sum_l (q_l * (r_il * r_jl)).
And looking at oeprop.cc (line 1513 to 1528), the traceless quadrupole (Q_ii’) seems to be the primitive quadrupole (Q_ii) besides the diagonal elements that are calculated with Q_ii’ = Q_ii - 1/3 * trace.

``````  // Print multipole components
double dfac = pc_dipmom_au2debye * pc_bohr2angstroms;
if (print_output) {
outfile->Printf("  %sQuadrupole Moment: [D A]\n", (transition ? "Transition " : ""));
outfile->Printf("    XX: %10.4lf     YY: %10.4lf     ZZ: %10.4lf\n", qe[0] * dfac, qe[3] * dfac, qe[5] * dfac);
outfile->Printf("    XY: %10.4lf     XZ: %10.4lf     YZ: %10.4lf\n", qe[1] * dfac, qe[2] * dfac, qe[4] * dfac);
outfile->Printf("\n");
}

double dtrace = (1.0 / 3.0) * (qe[0] + qe[3] + qe[5]);
if (print_output) {
outfile->Printf("  Traceless %sQuadrupole Moment: [D A]\n", (transition ? "Transition " : ""));
outfile->Printf("    XX: %10.4lf     YY: %10.4lf     ZZ: %10.4lf\n", (qe[0] - dtrace) * dfac,
(qe[3] - dtrace) * dfac, (qe[5] - dtrace) * dfac);
outfile->Printf("    XY: %10.4lf     XZ: %10.4lf     YZ: %10.4lf\n", qe[1] * dfac, qe[2] * dfac, qe[4] * dfac);
outfile->Printf("\n");
``````

Looking at the file tracelessquadrupole.cc (line 163 to 168) there is an additional factor of (3.0/2.0), i.e.

``````                           double mrr = (1.0 / 3.0) * (mxx + myy + mzz);

buffer_[ao12] += (3.0 / 2.0) * (mxx - mrr);
buffer_[ao12 + xydisp] += (3.0 / 2.0) * mxy;
buffer_[ao12 + xzdisp] += (3.0 / 2.0) * mxz;
buffer_[ao12 + yydisp] += (3.0 / 2.0) * (myy - mrr);
buffer_[ao12 + yzdisp] += (3.0 / 2.0) * myz;
buffer_[ao12 + zzdisp] += (3.0 / 2.0) * (mzz - mrr);
``````

Is the code in tracelessquadrupole.cc used at all for the calculation of the traceless quadrupole moment? Or is instead only the quadrupole.cc code used, and the traceless quadrupole is calculated in the oeprop.cc?

If the tracelessquadrupole.cc code is used, I was also wondering about the calculation of the nuclear contribution to the quadrupole that is not written explicitly in the tracelessquadrupole.cc file. Is this called from the quadrupole.cc code?

With kind regards,
• The `traceless_quadrupole.cc` code will fire if you’re computing a property with coupled cluster theory. Quick `grep` tells me that no other code uses this. Since you’re probably not using this, I’m going to ignore your second question for now.
• The `oeprop.cc` code should fire in any other cases. I know for a fact that’s what fires for a HF or DFT computation. If you’re using some other module, tell me which, and I can confirm which one they’re using.
As for why both of these exist, that’s some Psi history that is before my time. My guess is that `traceless_quadrupole.cc` was written with the CC code in mind, the `oeprop.cc` code was written as a more general package, and the CC code was never ported over to use the newer code because of the effort involved. That’s a running theme in the CC code.