grimme-lab / xtb

Semiempirical Extended Tight-Binding Program Package
https://xtb-docs.readthedocs.io/
GNU Lesser General Public License v3.0
574 stars 144 forks source link

Printout of spin #575

Closed kjelljorner closed 2 years ago

kjelljorner commented 2 years ago

There's an issue with the printout of the spin in the "Calculation Setup" section. Regardless of the specified value of --uhf, 0.0 is always printed. Also, sometimes the uhf value is silently ignored. It's a bit difficult to follow in the code, but my guess is that the printout is done before wfn%nopen is set.

I ran a test case with the naphthalene cation and GFN2, input and output is attached. I modified the source code to write out the values of set%nalphabeta and chk%wfn%nopen at the end of the run. These are the results:

uhf nalphabeta open printed spin
0 0 1 0.0
1 1 2 0.0
2 2 2 0.0
3 3 3 0.0

However, the energies are unchanged for uhf 0-2, as would maybe (?) be expected. Maybe it would be better for the program to stop for unreasonable combinations of charge and unpaired electrons.

test.zip

awvwgk commented 2 years ago

We don't really have spin in xTB, which is a bit odd for an electronic structure method, but due to Fermi smearing it doesn't really matter, because we will always prefer low-spin states energetically (discussed in the GFN2-xTB publication).

While we have a concept of alpha and beta spin channel in xtb, however this is not really a unique choice. In DFTB+ a restricted (open-shell) calculation will just put half a spin in each alpha and beta channel. Such a choice would completely remove the number of unpaired electrons from the Hamiltonian.

Also, xtb will attempt to fix up wrong multiplicities automatically. Stopping with a big error like Orca does for a quantity which is only minimally relevant seems too much, but we certainly should print a warning.

awvwgk commented 2 years ago

In any case the printed out spin is probably wrong in any case since I moved the calculation of the unpaired electrons and it should be removed. Going forward I'll probably remove the spin completely from the xtb main, except for reading of --uhf and .UHF, this should be the task of the single point calculation to deal with this.

kjelljorner commented 2 years ago

Ok, probably it would be best to clarify this a bit as the current help for --uhf is "specify Nalpha-Nbeta as INT". Maybe this could instead be called the "number of unpaired electrons" or similar. In that case it would still be clear that you could get something akin to the quartet state of the naphthalene radical cation by specifying --uhf 3 (if I have understood it correctly). The "half-electron" approach (from Dewar if I am not mistaken) is indeed very elegant. Does it work also with Fermi smearing? I think I've seen papers along that line but cannot find it at the moment. For the non-DFT case you can derive the energies analytically for the different pure spin states: 10.1016/0009-2614(71)80298-1

awvwgk commented 2 years ago

The "half-electron" approach (from Dewar if I am not mistaken) is indeed very elegant. Does it work also with Fermi smearing?

This is based on my interpretation of getFillingsAndBandEnergies in DFTB+. The actual filling happens elsewhere, would have to search through all the calls again to find it.