9.4. fciqmcscf — Full configuration interaction quantum Monte Carlo (FCIQMC)

An interface to the NECI FCIQMC solver. To use NECI, you need create a config file pyscf/fciqmcscf/settings.py to store the path where NECI was installed.

9.4.1. Program reference

pyscf.fciqmcscf.fciqmc.add_inactive_space_to_rdm(mol, mo_coeff, one_pdm, two_pdm)[source]

If a CASSCF calculation has been done, the final RDMs from neci will not contain the doubly occupied inactive orbitals. This function will add them and return the full density matrices.

pyscf.fciqmcscf.fciqmc.add_spinned_core_rdms(mf, ncore, dm1a_act, dm1b_act, dm2aa_act, dm2ab_act, dm2bb_act, reorder=True)[source]

Add an RHF core to the rdms in the MO basis to the 1 and 2 RDMs

pyscf.fciqmcscf.fciqmc.calc_dipole(mol, mo_coeff, one_pdm)[source]

Calculate and return the dipole moment for a given molecule, set of molecular orbital coefficients and a 1-rdm.

Args:
molan instance of Mole

Specifies the molecule.

mo_coeffndarray

Orbital coefficients. Each column is one orbital.

one_pdmndarray

1-rdm.

Returns:
tot_dipmomlist of float

The total dipole moment of the system in each dimension.

elec_dipmomlist of float

The electronic component of the dipole moment in each dimension.

nuc_dipmomlist of float

The nuclear component of the dipole moment in each dimension.

pyscf.fciqmcscf.fciqmc.calc_energy_from_rdms(mol, mo_coeff, one_rdm, two_rdm)[source]

From the full density matrices, calculate the energy.

Args:
molAn instance of Mole

The molecule to calculate

mo_coeff: ndarray

The MO orbitals in which the RDMs are calculated

one_rdm: ndarray

The 1RDM

two_rdm: ndarray

The 2RDM as RDM_ijkl = < a^+_is a^+_kt a_lt a_js >.

pyscf.fciqmcscf.fciqmc.execute_fciqmc(fciqmcci)[source]

Call the external FCIQMC program.

Args:
fciqmccian instance of FCIQMCCI

Specifies the FCIQMC calculation.

pyscf.fciqmcscf.fciqmc.find_full_casscf_12rdm(fciqmcci, mo_coeff, filename, norbcas, neleccas, directory='.')[source]

Return the 1 and 2 full RDMs after a CASSCF calculation, by adding on the contributions from the inactive spaces. Requires the cas space to be given, as we as a set of mo coefficients in the complete space.

pyscf.fciqmcscf.fciqmc.one_from_two_pdm(two_pdm, nelec)[source]

Return a 1-rdm, given a 2-rdm to contract.

Args:
two_pdmndarray

A (spin-free) 2-particle reduced density matrix.

nelec: int

The number of electrons contributing to the RDMs.

Returns:
one_pdmndarray

The (spin-free) 1-particle reduced density matrix.

pyscf.fciqmcscf.fciqmc.read_energy(fciqmcci)[source]

Read and return the final RDM energy from a NECI output file.

Args:
fciqmccian instance of FCIQMCCI

Specifies the FCIQMC calculation. Used to locate the FCIQMC output file.

Returns:
rdm_energyfloat

The final RDM energy printed to the output file.

pyscf.fciqmcscf.fciqmc.read_neci_1dms(fciqmcci, norb, nelec, filename='OneRDM.1', directory='.')[source]

Read spinned rdms, as they are in the neci output

pyscf.fciqmcscf.fciqmc.read_neci_2dms(fciqmcci, norb, nelec, filename_aa='TwoRDM_aaaa.1', filename_abba='TwoRDM_abba.1', filename_abab='TwoRDM_abab.1', directory='.', reorder=True, dm1a=None, dm1b=None)[source]

Find spinned RDMs (assuming a/b symmetry). Return in pyscf form that you would get from the e.g. direct_spin1.make_rdm12s routine, with Reorder=True.

This means (assuming reorder = True): dm2ab[i,j,k,l] = < i_a* k_b* l_b j_a > dm2aa[i,j,k,l] = < i_a* k_a* l_a j_a >

to get the dm2abba matrix (see spin_op.make_rdm2_abba) from this (assuming rhf), then you need dm2abba = -dm2ab.transpose(2,1,0,3)

if reorder = False:

dm2aa[:,k,k,:] += dm1a dm2bb[:,k,k,:] += dm1b dm2ab unchanged

Note that the spin-free RDMs are just dm2aa + dm2bb + 2*dm2ab if reorder = True

pyscf.fciqmcscf.fciqmc.read_neci_one_pdm(fciqmcci, filename, norb, nelec, directory='.')[source]

Obtain the spin-free 1RDM from neci by reading in the spin free 2RDM. If core orbitals have been indicated as frozen in neci, this core contribution will be explicitly added back in to the RDM. Therefore, the norb parameter should be the total number of orbitals passed to neci (inc. frozen), while nelec is the total number of electrons (inc. frozen), but not inactive if running through CASSCF.

pyscf.fciqmcscf.fciqmc.read_neci_two_pdm(fciqmcci, filename, norb, directory='.')[source]

Read a spin-free 2-rdm output from a NECI calculation, and return it in a form supported by pyscf. Note that the RDMs in neci are written in as RDM_ijkl = < a^+_is a^+_jt a_lt a_ks >. In pyscf, the correlated _after reordering_ is 2RDM_ijkl = < a^+_is a^+_kt a_lt a_js >, where s and t are spin indices to be summed over. Therefore, the middle two indices need to be swapped. If core orbitals have been indicated as frozen in neci, this core contribution will be explicitly added back in to the RDM. Therefore, the norb parameter should be the unfrozen number of orbitals passed to neci, but not inactive if running through CASSCF.

Args:
filenamestr

Name of the file to read the 2-rdm from.

norbint

The number of orbitals inc. frozen in neci, and therefore the number of values each 2-rdm index can take.

directorystr

The directory in which to search for the 2-rdm file.

Returns:
two_pdmndarray

The read-in 2-rdm.

pyscf.fciqmcscf.fciqmc.run_standalone(fciqmcci, scf_obj, orbs=None, restart=None)[source]

Run a standalone NECI calculation for the molecule listed in the FCIQMCCI object. The basis to run this calculation in is given by the orbs array.

Args:
fciqmccian instance of FCIQMCCI

FCIQMC calculation containing parameters of NECI calculation to run.

mo_coeffndarray

Orbital coefficients. Each column is one orbital.

restartbool

Is this a restarted NECI calculation?

Returns:
rdm_energyfloat

Final RDM energy obtained from the NECI output file.

pyscf.fciqmcscf.fciqmc.write_fciqmc_config_file(fciqmcci, neleca, nelecb, restart, tUHF=False)[source]

Write an input file for a NECI calculation.

Args:
fciqmccian instance of FCIQMCCI

Contains all the parameters used to create the input file.

nelecaint

The number of alpha electrons.

nelecbint

The number of beta electrons.

restartbool

Is this a restarted NECI calculation?

pyscf.fciqmcscf.fciqmc.write_integrals_file(h1e, eri, norb, neleca, nelecb, fciqmcci, ecore=0)[source]

Write an integral dump file, based on the integrals provided.

Args:
h1e2D ndarray

Core Hamiltonian.

eri2D ndarray

Two-electron integrals.

norbint

Number of orbitals.

nelecaint

Number of alpha electrons.

nelecbint

Number of beta electrons

fciqmccian instance of FCIQMCCI

FCIQMC calculation, used to access the integral dump file name and some symmetry properties.

pyscf.fciqmcscf.fciqmc.write_uhf_integrals_neci(fciqmcci, scf_obj, nmo, nelec, orbs, orbsym, tol=1e-15)[source]

nmo is number of MO orbitals per spin channel note that ordering is abababa…