qml.qchem.import_state

import_state(solver, tol=1e-15)[source]

Convert an external wavefunction to a state vector.

The sources of wavefunctions that are currently accepted are listed below.

  • The PySCF library (the restricted and unrestricted CISD/CCSD methods are supported). The solver argument is then the associated PySCF CISD/CCSD Solver object.

  • The library Dice implementing the SHCI method. The solver argument is then the tuple(list[str], array[float]) of Slater determinants and their coefficients.

  • The library Block2 implementing the DMRG method. The solver argument is then the tuple(list[int], array[float]) of Slater determinants and their coefficients.

Parameters
  • solver – external wavefunction object

  • tol (float) – the tolerance for discarding Slater determinants based on their coefficients

Raises

ValueError – if external object type is not supported

Returns

normalized state vector of length \(2^M\), where \(M\) is the number of spin orbitals

Return type

array

Example

>>> from pyscf import gto, scf, ci
>>> mol = gto.M(atom=[['H', (0, 0, 0)], ['H', (0,0,0.71)]], basis='sto6g')
>>> myhf = scf.UHF(mol).run()
>>> myci = ci.UCISD(myhf).run()
>>> wf_cisd = qml.qchem.import_state(myci, tol=1e-1)
>>> print(wf_cisd)
[ 0.        +0.j  0.        +0.j  0.        +0.j  0.1066467 +0.j
  0.        +0.j  0.        +0.j  0.        +0.j  0.        +0.j
  0.        +0.j  0.        +0.j  0.        +0.j  0.        +0.j
 -0.99429698+0.j  0.        +0.j  0.        +0.j  0.        +0.j]