Lets consider the following code which uses the Mole object:
import pyscf
mol = pyscf.M(
atom = '''
O
H 1 0.9576257
H 1 0.9576257 2 104.51
'''
)
Is there an easy way to print the chemical formula: H2O
?
In the above-linked documentation page, I couldn't find any example that resembles this type of feature, and when I run a PySCF kernel()
the printout doesn't ever say H2O
so perhaps PySCF doesn't "know" that the molecule can be called H2O
.
I searched on Google for "chemical formula from ZMAT" and some variants of that search phrase, without any success. I understand that things can get quite complicated when there's even just a few atoms, but for atoms, diatomics, and millions of polyatomics, it doesn't seem unreasonable to have a utility that can print or at least guess a chemical formula, especially if the utility were to use a database of known molecules to assist it.
Is there a simple way to print the formula from the ZMAT or XYZ file that would work with PySCF?
itertools
. Can you write an answer that usesitertools
? $\endgroup$