def test_export(): CAPH = CAPHamiltonian(output=os.path.join(dest_dir, "n2_opencap.out")) CAPH.export("test.out") CAPH2 = CAPHamiltonian(output="test.out") assert np.isclose(CAPH._H0[0][0], CAPH2._H0[0][0]) os.remove("test.out")
h0 = np.zeros((nstates, nstates)) for i in range(0, len(h0)): h0[i][i] = E_0 + state.excitation_energy[i] for i in range(0, nstates): state2state = State2States(state, initial=i) rdm = state.state_dm[i] rdm_alpha, rdm_beta = rdm.to_ao_basis() rdm_alpha = rdm_alpha.to_ndarray() rdm_beta = rdm_beta.to_ndarray() pc.add_tdms(rdm_alpha, rdm_beta, i, i, "psi4") for j, tdm in enumerate(state2state.transition_dm): tdm_alpha, tdm_beta = tdm.to_ao_basis() tdm_alpha = tdm_alpha.to_ndarray() tdm_beta = tdm_beta.to_ndarray() pc.add_tdms(tdm_alpha, tdm_beta, i, i + j + 1, "psi4") pc.add_tdms(tdm_alpha.conj().T, tdm_beta.conj().T, i + j + 1, i, "psi4") pc.compute_projected_cap() W = pc.get_projected_cap() from pyopencap.analysis import CAPHamiltonian as CAPH my_CAPH = CAPH(H0=h0, W=W) my_CAPH.export("n2_adc_opencap.out") end = time.time() print("Time:") print(end - start)
# fill density matrices h0 = np.zeros((nstates, nstates)) for i in range(0, len(e)): h0[i][i] = e[i] # compute CAP pc = pyopencap.CAP(s, cap_dict, nstates) for i in range(0, len(fs.ci)): for j in range(0, len(fs.ci)): dm1 = fs.trans_rdm1(fs.ci[i], fs.ci[j], myhf.mo_coeff.shape[1], mol.nelec) dm1_ao = np.einsum('pi,ij,qj->pq', myhf.mo_coeff, dm1, myhf.mo_coeff.conj()) pc.add_tdm(dm1_ao, i, j, "pyscf") pc.compute_projected_cap() W = pc.get_projected_cap() from pyopencap.analysis import CAPHamiltonian as CAPH my_CAPH = CAPH(H0=h0, W=W) my_CAPH.export("H2_fci_opencap.out") end = time.time() print("Time:") print(end - start) import os os.remove("molden_in.molden")
mytd = tdscf.TDA(mf).run(nstates=nstates) print(mytd.e_tot) H0 = np.zeros((nstates, nstates)) for i in range(0, len(mytd.e_tot)): H0[i][i] = mytd.e_tot[i] for i in range(0, nstates): for j in range(i, nstates): dm1_alpha, dm1_beta = tda_density_matrix(mytd, i, j) pc.add_tdms(dm1_alpha, dm1_beta, i, j, "pyscf") if not i == j: pc.add_tdms(dm1_alpha.conj().T, dm1_beta.conj().T, j, i, "pyscf") pc.compute_projected_cap() W = pc.get_projected_cap() from pyopencap.analysis import CAPHamiltonian as CAPH my_CAPH = CAPH(H0=H0, W=W) my_CAPH.export("n2_tddft_opencap.out") import os os.remove("molden_in.molden") os.remove('n2.chk') end = time.time() print("Time:") print(end - start)