I am trying to write a python code that checks the dipole moment and the polarisability of a certain molecule in order to determine if it will be Raman-active or IR-active.

Raman-active molecules are those with a change in the polarisability (so net dipole moment is zero) and IR-active are those with a change in the dipole moment (so net dipole moment is different from zero).

I was trying to use PySCF as it has an attribute for the dipole moment. However, I don't exactly understand the output that PySCF provides. Checking the dipole moment for $\ce{H2O}$ and $\ce{CO2}$ give me the same results.

The idea is that I should get a number (net dipole moment) and I would have to check if it is zero or not. Does someone know how I can do it?

This is the code I have tried:

from pyscf import gto, scf

# Define the H2O molecule
mol = gto.M(atom='O 0 0 0; H 0 1 0; H 0 0 1', basis='sto-3g')

# Perform a RHF calculation for the ground state
mf = scf.RHF(mol)

# Extract the dipole moment for the ground state
ground_state_dipole = mf.dip_moment()

# Perform a RHF calculation for the perturbed state
mf = scf.RHF(mol)
mf.charge = -1

# Extract the dipole moment for the perturbed state
perturbed_state_dipole = mf.dip_moment()

# Calculate the change in dipole moment
dipole_diff = perturbed_state_dipole - ground_state_dipole
print("Change in dipole moment of H2O:", dipole_diff)
  • $\begingroup$ Does someone know how to do what? Get a number, check if it is zero? Check for a tolerance or something else? $\endgroup$
    – itprorh66
    Jan 17 at 20:33
  • 1
    $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community
    Jan 18 at 9:38
  • $\begingroup$ @Tyberius based on your last edit, you might be interested in sharing your opinion in this discussion. $\endgroup$ Feb 24 at 16:55
  • $\begingroup$ @Joan please check if my post answers your question. If it does then please click on the tick mark. You get +2 as well :) $\endgroup$ Mar 10 at 13:44

1 Answer 1


The dipole moment that is calculated by mf.dip_moment() is a vector where the three values returned (µx, µy, and µz) which are the x, y and z components of dipole moment.

So the resultant magnitude of the vector is :


So in terms of code, it would be:

dipole_moment = mf.dip_moment()
total = 0
for component in dipole_moment:
    total+= component**2

resultant_dipole_moment = total**0.5

You can then use this resultant_dipole_moment to figure out whether the compound is raman active or IR active


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .