Radical Anion Error/Bug in 1.6

I recently upgraded to 1.6 and as a test case, ran an optimization that was successful under 1.3.2 (and seems to be under 1.4.1 – waiting for it to fully finish, but it has already progressed further than under 1.6)

The Input file (for a given radical anion):

memory 102400 mb

molecule mol {
-1 2
C 0.00000000 0.00000000 0.00000000
C 1.21064700 0.71690500 0.00000000
C 1.20587000 2.10633100 0.00000000
C 0.00000000 2.80649500 0.00000000
C -1.20587000 2.10633100 0.00000000
C -1.21064700 0.71690500 0.00000000
H -2.14648500 0.17133400 0.00000000
H -2.14658900 2.64534700 0.00000000
H 0.00000000 3.89046700 0.00000000
H 2.14658900 2.64534700 0.00000000
H 2.14648500 0.17133400 0.00000000
C 0.00000000 -1.42321300 0.00000000
C 0.00000000 -2.63387100 0.00000000
C 0.00000000 -4.05708400 0.00000000
C -1.21064700 -4.77398900 0.00000000
C -1.20587000 -6.16341500 0.00000000
C 0.00000000 -6.86357900 0.00000000
C 1.20587000 -6.16341500 0.00000000
C 1.21064700 -4.77398900 0.00000000
H 2.14648500 -4.22841800 0.00000000
H 2.14658900 -6.70243100 0.00000000
H 0.00000000 -7.94755100 0.00000000
H -2.14658900 -6.70243100 0.00000000
H -2.14648500 -4.22841800 0.00000000

}

set scf_type df
set basis aug-cc-pVTZ
set reference uks
set_num_threads(64)

mol.update_geometry()
mol.symmetrize(1e-3)

e, wfn = optimize('b3lyp-d3bj', return_wfn=True)
oeprop(wfn, "MULLIKEN_CHARGES")
mol.print_out()
print_variables()

Under version 1.6, I get the error (note there is line that says: “This is a bug. Please file a report.”):

  ==> Iterations <==

                           Total Energy        Delta E     RMS |[F,P]|

   @DF-UKS iter SAD:  -538.66710083028875   -5.38667e+02   0.00000e+00 

Traceback (most recent call last):
  File "/data/Apps/anaconda3/envs/psi4env/bin/psi4", line 338, in <module>
    exec(content)
  File "<string>", line 54, in <module>
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/driver.py", line 1211, in optimize
    G, wfn = gradient(lowername, return_wfn=True, molecule=moleculeclone, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/driver.py", line 619, in gradient
    wfn = procedures['gradient'][lowername](lowername, molecule=molecule, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 90, in select_scf_gradient
    return func(name, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 2550, in run_scf_gradient
    ref_wfn = run_scf(name, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 2455, in run_scf
    scf_wfn = scf_helper(name, post_scf=False, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 1670, in scf_helper
    e_scf = scf_wfn.compute_energy()
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/scf_proc/scf_iterator.py", line 86, in scf_compute_energy
    self.iterations()
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/scf_proc/scf_iterator.py", line 429, in scf_iterate
    self.form_C()

RuntimeError: 
Fatal Error: Count 49 alpha electrons, expected 48.
This is a bug. Please file a report.
Error occurred in file: /scratch/psilocaluser/conda-builds/psi4-multiout_1652994828216/work/psi4/src/psi4/libscf_solver/hf.cc on line: 482
The most recent 5 function calls were:




Printing out the relevant lines from the Psithon --> Python processed input file:
    core.set_global_option("BASIS", "aug-cc-pVTZ")
    core.set_global_option("REFERENCE", "uks")
    set_num_threads(64)
    mol.update_geometry()
    mol.symmetrize(1e-3)
--> e, wfn = optimize('b3lyp-d3bj', return_wfn=True)
    oeprop(wfn, "MULLIKEN_CHARGES")
    mol.print_out()
    print_variables()

!----------------------------------------------------------------------------------!
!                                                                                  !
! Fatal Error: Count 49 alpha electrons, expected 48.                              !
! This is a bug. Please file a report.                                             !
! Error occurred in file: /scratch/psilocaluser/conda-                             !
!     builds/psi4-multiout_1652994828216/work/psi4/src/psi4/libscf_solver/hf.cc on !
!     line: 482                                                                    !
! The most recent 5 function calls were:                                           !
!                                                                                  !
!----------------------------------------------------------------------------------!

    Psi4 stopped on: Friday, 03 June 2022 12:13PM
    Psi4 wall time for execution: 0:05:00.69

*** Psi4 encountered an error. Buy a developer more coffee!
*** Resources and help at github.com/psi4/psi4.
Traceback (most recent call last):
  File "/data/Apps/anaconda3/envs/psi4env/bin/psi4", line 338, in <module>
    exec(content)
  File "<string>", line 54, in <module>
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/driver.py", line 1211, in optimize
    G, wfn = gradient(lowername, return_wfn=True, molecule=moleculeclone, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/driver.py", line 619, in gradient
    wfn = procedures['gradient'][lowername](lowername, molecule=molecule, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 90, in select_scf_gradient
    return func(name, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 2550, in run_scf_gradient
    ref_wfn = run_scf(name, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 2455, in run_scf
    scf_wfn = scf_helper(name, post_scf=False, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 1670, in scf_helper
    e_scf = scf_wfn.compute_energy()
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/scf_proc/scf_iterator.py", line 86, in scf_compute_energy
    self.iterations()
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/scf_proc/scf_iterator.py", line 429, in scf_iterate
    self.form_C()

RuntimeError: 
Fatal Error: Count 49 alpha electrons, expected 48.
This is a bug. Please file a report.
Error occurred in file: /scratch/psilocaluser/conda-builds/psi4-multiout_1652994828216/work/psi4/src/psi4/libscf_solver/hf.cc on line: 482
The most recent 5 function calls were:



Printing out the relevant lines from the Psithon --> Python processed input file:
    core.set_global_option("BASIS", "aug-cc-pVTZ")
    core.set_global_option("REFERENCE", "uks")
    set_num_threads(64)
    mol.update_geometry()
    mol.symmetrize(1e-3)
--> e, wfn = optimize('b3lyp-d3bj', return_wfn=True)
    oeprop(wfn, "MULLIKEN_CHARGES")
    mol.print_out()
    print_variables()


!----------------------------------------------------------------------------------!
!                                                                                  !
! Fatal Error: Count 49 alpha electrons, expected 48.                              !
! This is a bug. Please file a report.                                             !
! Error occurred in file: /scratch/psilocaluser/conda-                             !
!     builds/psi4-multiout_1652994828216/work/psi4/src/psi4/libscf_solver/hf.cc on !
!     line: 482                                                                    !
! The most recent 5 function calls were:                                           !
!                                                                                  !
!----------------------------------------------------------------------------------!


ERROR conda.cli.main_run:execute(34): Subprocess for 'conda run ['/data/Apps/anaconda3/envs/psi4env/bin/psi4', '-s', '/archive/WebMO/webmo-54951/887', 'input.inp', 'output.out']' command failed.  (See above for error)
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image              PC                Routine            Line        Source             
libgdma.so         00007F035C2660DC  for__signal_handl     Unknown  Unknown
libpthread-2.17.s  00007F0371279630  Unknown               Unknown  Unknown
python3.8          000056259F6885D3  Unknown               Unknown  Unknown
core.cpython-38-x  00007F03686A45C0  Unknown               Unknown  Unknown
core.cpython-38-x  00007F036872EAEB  Unknown               Unknown  Unknown
core.cpython-38-x  00007F0368A47700  _ZNSt15_Sp_counte     Unknown  Unknown
core.cpython-38-x  00007F03687E9A67  _ZN3psi7Process11     Unknown  Unknown
libc-2.17.so       00007F0370ED5CE9  Unknown               Unknown  Unknown
libc-2.17.so       00007F0370ED5D37  Unknown               Unknown  Unknown
python3.8          000056259F732608  Unknown               Unknown  Unknown
python3.8          000056259F73263B  Unknown               Unknown  Unknown
python3.8          000056259F732680  Unknown               Unknown  Unknown
python3.8          000056259F735604  PyRun_SimpleFileE     Unknown  Unknown
python3.8          000056259F735A29  Py_RunMain            Unknown  Unknown
python3.8          000056259F735C29  Py_BytesMain          Unknown  Unknown
libc-2.17.so       00007F0370EBE555  __libc_start_main     Unknown  Unknown
python3.8          000056259F6D8AD7  Unknown               Unknown  Unknown

My initial attempts to reproduce this are not working.

How many iterations do you need to get this issue?
What happens if you get rid of the -d3bj correction? What if you downgrade from B3LYp to HF? What if you go from an optimization to an energy computation?

Here’s my replies:

How many iterations do you need to get this issue?
→ Appears after the first Iteration:

   ==> Iterations <==

                           Total Energy        Delta E     RMS |[F,P]|

   @DF-UKS iter SAD:  -538.66710083028840   -5.38667e+02   0.00000e+00 

Traceback (most recent call last):
  File "/data/Apps/anaconda3/envs/psi4env/bin/psi4", line 338, in <module>
    exec(content)
  File "<string>", line 54, in <module>
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/driver.py", line 1211, in optimize
    G, wfn = gradient(lowername, return_wfn=True, molecule=moleculeclone, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/driver.py", line 619, in gradient
    wfn = procedures['gradient'][lowername](lowername, molecule=molecule, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 90, in select_scf_gradient
    return func(name, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 2550, in run_scf_gradient
    ref_wfn = run_scf(name, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 2455, in run_scf
    scf_wfn = scf_helper(name, post_scf=False, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 1670, in scf_helper
    e_scf = scf_wfn.compute_energy()
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/scf_proc/scf_iterator.py", line 86, in scf_compute_energy
    self.iterations()
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/scf_proc/scf_iterator.py", line 429, in scf_iterate
    self.form_C()

RuntimeError: 
Fatal Error: Count 49 alpha electrons, expected 48.
This is a bug. Please file a report.
Error occurred in file: /scratch/psilocaluser/conda-builds/psi4-multiout_1652994828216/work/psi4/src/psi4/libscf_solver/hf.cc on line: 482
The most recent 5 function calls were:

Printing out the relevant lines from the Psithon --> Python processed input file:
    core.set_global_option("BASIS", "aug-cc-pVTZ")
    core.set_global_option("REFERENCE", "uks")
    set_num_threads(64)
    mol.update_geometry()
    mol.symmetrize(1e-3)
--> e, wfn = optimize('b3lyp-d3bj', return_wfn=True)
    oeprop(wfn, "MULLIKEN_CHARGES")
    mol.print_out()
    print_variables()

What happens if you get rid of the -d3bj correction?
→ Same issue. Error appears after first iteration.

What if you downgrade from B3LYp to HF?
→ It completes successfully using this input:

memory 102400 mb

molecule mol {
-1 2
C 0.00000000 0.00000000 0.00000000
C 1.21064700 0.71690500 0.00000000
C 1.20587000 2.10633100 0.00000000
C 0.00000000 2.80649500 0.00000000
C -1.20587000 2.10633100 0.00000000
C -1.21064700 0.71690500 0.00000000
H -2.14648500 0.17133400 0.00000000
H -2.14658900 2.64534700 0.00000000
H 0.00000000 3.89046700 0.00000000
H 2.14658900 2.64534700 0.00000000
H 2.14648500 0.17133400 0.00000000
C 0.00000000 -1.42321300 0.00000000
C 0.00000000 -2.63387100 0.00000000
C 0.00000000 -4.05708400 0.00000000
C -1.21064700 -4.77398900 0.00000000
C -1.20587000 -6.16341500 0.00000000
C 0.00000000 -6.86357900 0.00000000
C 1.20587000 -6.16341500 0.00000000
C 1.21064700 -4.77398900 0.00000000
H 2.14648500 -4.22841800 0.00000000
H 2.14658900 -6.70243100 0.00000000
H 0.00000000 -7.94755100 0.00000000
H -2.14658900 -6.70243100 0.00000000
H -2.14648500 -4.22841800 0.00000000

}

set scf_type df
set basis 6-31G(d)
set reference uhf


mol.update_geometry()
mol.symmetrize(1e-3)

e, wfn = optimize('scf', return_wfn=True)
oeprop(wfn, "MULLIKEN_CHARGES")
mol.print_out()
print_variables()

What if you go from an optimization to an energy computation?
→ Still fails after first Iteration:

 ==> Iterations <==

                           Total Energy        Delta E     RMS |[F,P]|

   @DF-UKS iter SAD:  -538.66710083175246   -5.38667e+02   0.00000e+00 

Traceback (most recent call last):
  File "/data/Apps/anaconda3/envs/psi4env/bin/psi4", line 338, in <module>
    exec(content)
  File "<string>", line 53, in <module>
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/driver.py", line 501, in energy
    wfn = procedures['energy'][lowername](lowername, molecule=molecule, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 2455, in run_scf
    scf_wfn = scf_helper(name, post_scf=False, **kwargs)
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/proc.py", line 1670, in scf_helper
    e_scf = scf_wfn.compute_energy()
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/scf_proc/scf_iterator.py", line 86, in scf_compute_energy
    self.iterations()
  File "/data/Apps/anaconda3/envs/psi4env/lib//python3.8/site-packages/psi4/driver/procrouting/scf_proc/scf_iterator.py", line 429, in scf_iterate
    self.form_C()

RuntimeError: 
Fatal Error: Count 49 alpha electrons, expected 48.
This is a bug. Please file a report.
Error occurred in file: /scratch/psilocaluser/conda-builds/psi4-multiout_1652994828216/work/psi4/src/psi4/libscf_solver/hf.cc on line: 482
The most recent 5 function calls were:

Printing out the relevant lines from the Psithon --> Python processed input file:
    core.set_global_option("SCF_TYPE", "df")
    core.set_global_option("BASIS", "aug-cc-pVTZ")
    core.set_global_option("REFERENCE", "uks")
    core.set_global_option("S_TOLERANCE", 1e-9)
    set_num_threads(64)
--> energy('b3lyp-d3bj')
    mol.print_out()
    print_variables()

Once again, under 1.3.2 and 1.4.1 – not an issue.

The key error seems to be →

RuntimeError: 
**Fatal Error: Count 49 alpha electrons, expected 48.**
**This is a bug. Please file a report.**

One thing I noticed is that during pre-iteration in 1.3.2, you get →

 ==> Pre-Iterations <==

   -------------------------------------------------------
    Irrep   Nso     Nmo     Nalpha   Nbeta   Ndocc  Nsocc
   -------------------------------------------------------
     Ag       160     160       0       0       0       0
     B1g      130     130       0       0       0       0
     B2g       63      63       0       0       0       0
     B3g       84      84       0       0       0       0
     Au        63      63       0       0       0       0
     B1u       84      84       0       0       0       0
     B2u      160     160       0       0       0       0
     B3u      130     130       0       0       0       0
   -------------------------------------------------------
    Total     874     874      48      47      47       1
   -------------------------------------------------------

But in 1.6, you get:

  ==> Pre-Iterations <==

  SCF Guess: Superposition of Atomic Densities via on-the-fly atomic UHF (no occupation information).

   -------------------------
    Irrep   Nso     Nmo    
   -------------------------
     Ag       160     160 
     B1g      130     130 
     B2g       63      63 
     B3g       84      84 
     Au        63      63 
     B1u       84      84 
     B2u      160     160 
     B3u      130     130 
   -------------------------
    Total     874     874
   -------------------------

Ultimately, it seems the number of electrons (95 total) is not being counted correctly in 1.6 for this molecule — ???

I can reproduce this now, which is a start. I’ve added an issue to bring this to the attention of other developers.

Normally, I’d take this one myself, but I have too many obligations to take this one as well.

Thanks. I’ll look forward to it. Until this is fixed there isn’t a way to calculate the polarizability tensor for this molecule under 1.6 – correct? . I recall you had noted that the polarizability tensor issue (for radical anion) had been fixed in 1.5 (?).

Correct: if you can’t get an energy, you certainly can’t get a polarizability tenor.

Yes, you should be able to get this polarizability through 1.5. The important code is this commit.

Yes, can confirm optimization and polarizability worked in 1.5 for this radical anion.