Multiple calls of psi4.properties at cc level

Hello Developers,

I would like to ask how should I use evaluators of properties at CC level multiple times in a separate and independent tasks. I work with psi4-1.2.1 version and I wrote a simple input script after a basic option specification:

ghosts = {1:[2], 2:[1]} 
for n in range(h2o.nfragments()): # just two calls
    id_m = [n+1]
    id_g = ghosts[n+1]
    mol = h2o.extract_subsets(id_m, id_g)
    c_w, c_e = prop('cc2', return_wfn=True, molecule=mol, properties=['DIPOLE', 'NO_OCCUPATIONS'], dertype=0)
    clean()

The error I got reads:

Fatal Error: Attempting to initilize new DPD instance before the old one was freed.
Error occurred in file: /home/globulion/pkg/psi4-1.2.1/psi4/src/psi4/libdpd/init.cc on line: 71

The most recent 5 function calls were:

psi::PsiException::PsiException(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char const*, int)
psi::IntegralTransform::initialize()
psi::IntegralTransform::IntegralTransform(std::shared_ptr<psi::Wavefunction>, std::vector<std::shared_ptr<psi::MOSpace>, std::allocator<std::shared_ptr<psi::MOSpace> > >, psi::IntegralTransform::TransformationType, psi::IntegralTransform::OutputType, psi::IntegralTransform::MOOrdering, psi::IntegralTransform::FrozenOrbitals, bool)

As I understood, it is due to not closed DPD instance (despite using clean() function) and when IntegralTransform object is initialized in the second pass of Python loop, it tries to initialize the instance with DPD ID still active (is it right?). I tried to resolve this by a brute force manner and I added the following line in libtrans/integraltransform.cc (highlighted in bold):

// Set up the DPD library
// TODO implement caching of files
int numSpaces = spacesUsed_.size();
int numIndexArrays = numSpaces * (numSpaces - 1) + 5 * numSpaces;
cacheFiles_ = init_int_array(PSIO_MAXUNIT);
cacheList_ = init_int_matrix(numIndexArrays, numIndexArrays);
int currentActiveDPD = psi::dpd_default;
**if (!dpd_list[myDPDNum_] == 0) dpd_close(myDPDNum_);**
dpd_init(myDPDNum_, nirreps_, memory_, 0, cacheFiles_, cacheList_, nullptr, numSpaces, spaceArray_);

Is there any better way of deaing with this issue? Is my fix wrong and will it cause problems when using Psi4?

Thank you very much for your help and feedback!

Warm regards,
Bartek

Hi everyone,

I’m having the same problem. I’m trying to compute the CCSD polarizability using finite field.
Any updates on this issue?

Best regards,
Huziel.

Please follow best practices for questions here.

At the least, I need to know what input file you’re trying to use (please simplify it as much as possible - shrink the system and the basis set as much as feasible) and what Psi4 version you’re using.