Boys orbital localization

I have written a simple code in psi4numpy to localize orbitals utilizing the Boys algorithm to start with:

psi4.set_memory(‘2 GB’)
psi4.core.set_output_file(‘output.dat’, False)
numpy_memory = 2

mol = psi4.geometry("""
O
H 1 1.1
H 1 1.1 2 104
symmetry c1
“”")

psi4.set_options({‘basis’: ‘aug-cc-pvdz’,
‘scf_type’: ‘pk’,
‘mp2_type’: ‘conv’,
‘e_convergence’: 1e-8,
‘d_convergence’: 1e-8})

scf_e, wfn = psi4.energy(‘SCF’, return_wfn=True)
zero_bas = psi4.core.BasisSet.zero_ao_basis_set()
C = wfn.Ca()

loc = psi4.core.BoysLocalizer.build(“loc”, zero_bas, C)

However, I am getting the following error massage:

Traceback (most recent call last):
File “/apps/anaconda/bin/psi4”, line 248, in
exec(content)
File “”, line 37, in

RuntimeError:
Fatal Error: Localizer: Unrecognized localization algorithm
Error occurred in file: /scratch/psilocaluser/conda-builds/psi4_1495009270718/work/psi4/src/psi4/libmints/local.cc on line: 74

The most recent 5 function calls were:
psi::PsiException::PsiException(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, char const*, int)
psi::Localizer::build(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::shared_ptrpsi::BasisSet, std::shared_ptrpsi::Matrix, psi::Options&)
psi::Localizer::build(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::shared_ptrpsi::BasisSet, std::shared_ptrpsi::Matrix)
std::shared_ptrpsi::Localizer pybind11::detail::argument_loader<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::shared_ptrpsi::BasisSet, std::shared_ptrpsi::Matrix >::call_impl<std::shared_ptrpsi::Localizer, std::shared_ptrpsi::Localizer (&)(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::shared_ptrpsi::BasisSet, std::shared_ptrpsi::Matrix), 0ul, 1ul, 2ul>(std::shared_ptrpsi::Localizer (&)(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, std::shared_ptrpsi::BasisSet, std::shared_ptrpsi::Matrix), pybind11::detail::index_sequence<0ul>)

Has anyone experienced the same issue before?

I get the same error when running your code as given.

Poking around in libmints/local.cc, I think your error can be avoided by using:

loc = psi4.core.Localizer.build(‘BOYS’, wfn.basisset(), C)
loc.localize()
loc.L.print_out()

However it looks like the localization procedure does not converge, so add:

‘LOCAL_MAXITER’:1000

to your set_options dictionary.

Summary: use the code below

import psi4
psi4.set_memory(‘2 GB’)
psi4.core.set_output_file(‘output.dat’, False)
numpy_memory = 2

mol = psi4.geometry("""
O
H 1 1.1
H 1 1.1 2 104
symmetry c1
“”")

psi4.set_options({‘basis’: ‘aug-cc-pvdz’,
‘scf_type’: ‘pk’,
‘mp2_type’: ‘conv’,
‘e_convergence’: 1e-10,
‘d_convergence’: 1e-10,
‘LOCAL_MAXITER’:10000})

scf_e, wfn = psi4.energy(‘SCF’, return_wfn=True)
zero_bas = psi4.core.BasisSet.zero_ao_basis_set()
C = wfn.Ca()

loc = psi4.core.Localizer.build(‘BOYS’, wfn.basisset(), C)
loc.localize()
print(“Boys Localization Convergedness: {}”.format(loc.converged))
loc.L.print_out()

Thank you so much! I really appreciate your help!

Hmm, yea thats not been worked python side well yet. As mentioned only two algorithms are implemented PIPEK_MEZEY and BOYS. The exception could be much more explicit, feel free to make a PR to edit:

Hi there,

after obtaining the new localized loc.L coeffs, is there I way to output the occupied LMO as a cube file, something similar to

cubeprop(wfn)

It looks as if one would have to turn the coeffs object into a new wavefunction object or copied them into the old one?

Thanks in advance!