<commit_before>#!/usr/bin/env python

'''
Using the CCSD method as the active space solver to compute an approximate
CASCI energy.

A wrapper is required to adapt the CCSD solver to CASCI fcisolver interface.
Inside the wrapper function, the CCSD code is the same as the example
40-ccsd_with_given_hamiltonian.py
'''

import numpy
from pyscf import gto, scf, cc, ao2mo, mcscf

class AsFCISolver(object):
    def __init__(self):
        self.mycc = None

    def kernel(self, h1, h2, norb, nelec, ci0=None, ecore=0, **kwargs):
        fakemol = gto.M(verbose=0)
        nelec = numpy.sum(nelec)
        fakemol.nelectron = nelec
        fake_hf = scf.RHF(fakemol)
        fake_hf._eri = ao2mo.restore(8, h2, norb)
        fake_hf.get_hcore = lambda *args: h1
        fake_hf.get_ovlp = lambda *args: numpy.eye(norb)
        fake_hf.kernel()
        self.mycc = cc.CCSD(fake_hf)
        self.eris = self.mycc.ao2mo()
        e_corr, t1, t2 = self.mycc.kernel(eris=self.eris)
        l1, l2 = self.mycc.solve_lambda(t1, t2, eris=self.eris)
        e = fake_hf.e_tot + e_corr
        return e, [t1,t2,l1,l2]

    def make_rdm1(self, fake_ci, norb, nelec):
        mo = self.mycc.mo_coeff<commit_msg>Fix error in example<commit_after>#!/usr/bin/env python

'''
Using the CCSD method as the active space solver to compute an approximate
CASCI energy.

A wrapper is required to adapt the CCSD solver to CASCI fcisolver interface.
Inside the wrapper function, the CCSD code is the same as the example
40-ccsd_with_given_hamiltonian.py
'''

import numpy
from pyscf import gto, scf, cc, ao2mo, mcscf

class AsFCISolver(object):
    def __init__(self):
        self.mycc = None

    def kernel(self, h1, h2, norb, nelec, ci0=None, ecore=0, **kwargs):
        fakemol = gto.M(verbose=0)
        nelec = numpy.sum(nelec)
        fakemol.nelectron = nelec
        fake_hf = scf.RHF(fakemol)
        fake_hf._eri = ao2mo.restore(8, h2, norb)
        fake_hf.get_hcore = lambda *args: h1
        fake_hf.get_ovlp = lambda *args: numpy.eye(norb)
        fake_hf.kernel()
        self.mycc = cc.CCSD(fake_hf)
        self.eris = self.mycc.ao2mo()
        e_corr, t1, t2 = self.mycc.kernel(eris=self.eris)
        l1, l2 = self.mycc.solve_lambda(t1, t2, eris=self.eris)
        e = fake_hf.e_tot + e_corr
        return e+ecore, [t1,t2,l1,l2]

    def make_rdm1(self, fake_ci, norb, nelec):
        mo = self.mycc.mo_coeff
{'fraction_non_alphanumeric': 0.1077819392426134, 'fraction_numerical': 0.019975031210986267, 'mean_word_length': 2.8525641025641026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4806258', 'n_tokens_mistral': 969, 'n_tokens_neox': 938, 'n_words': 234}