Giter VIP home page Giter VIP logo

openfermion-psi4's People

Contributors

babbush avatar bastianzim avatar bsenjean avatar dabacon avatar jarrodmcc avatar kevinsung avatar loriab avatar ncrubin avatar tarinihardikar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openfermion-psi4's Issues

Automatically adding the "missing" amplitudes from Psi4.

Hi,

When I tried to recover the CCSD energy based on the CCSD amplitudes extracted from OpenFermion-Psi4, I realized that some were missing: the same-spin amplitudes.

See here for a question I asked on the Psi4 forum: http://forum.psicode.org/t/understanding-mp2-ccsd-amplitudes-for-h4/1866

Also this is not an issue as they can be determined later on, I think it would actually be better to extract those directly from the OpenFermion-Psi4 interface, because I'm pretty sure most user will not know that they are missing. And CCSD amplitudes could be used in some UCC ansatz.

Error in IPython demo file + _psi_template file (?)

Hi!

I noticed that there was a small error with the demo notebook for the plugin, most likely a remnant of the fermilibplugin naming.

I believe from openfermion.utils import MolecularData should be from openfermion.hamiltonians import MolecularData.

Additionally, the default template file has the line:

from openfermion.ops import (one_body_basis_change, two_body_basis_change)

I might be mistaken, but to the best of my knowledge, I couldn't find a one_body_basis_change or two_body_basis_change in ops (or anywhere else for that matter). The closest function I could find was general_basis_change.

Thanks,
Tarini

Sorting of CCSD amplitudes

Hi,

I am currently checking if the CCSD amplitudes extracted from Psi4 are sorted correctly in OpenFermion, and I have the impression that something is wrong (but maybe I'm doing something wrong). Here is an example for H4 (I enclose the whole script below if you want to run it).

I find that in Psi4, the CCSD amplitudes are the following:

    Largest TIjAb Amplitudes:
      1   1   1   1        -0.2129966367
      1   1   0   0        -0.1959962733
      0   1   1   0        -0.1937183230
      1   0   0   1        -0.1937183230
      0   1   0   1        -0.1876273767
      1   0   1   0        -0.1876273767
      0   0   1   1        -0.1861373089
      0   0   0   0        -0.1697814772

Where the indices are:
"I" --> occupied alpha spin-orbital (labelled from 0 to 1)
"j" --> occupied beta spin-orbital (labelled from 0 to 1)
"A" --> virtual alpha spin-orbital (labelled from 0 to 1)
"b" --> virtual beta spin-orbital (labelled from 0 to 1).

So if I'm not mistaken, those spin-orbitals have the following indices in OpenFermion:
I = 0 --> 0
I = 1 --> 2
j = 0 --> 1
j = 1 --> 3
A = 0 --> 4
A = 1 --> 6
b = 0 --> 5
b = 1 --> 7

So the amplitude -0.2129966367 should correspond to `2 3 6^ 7^'.

However, if I look at the (normal ordered) ucc amplitudes generated by OpenFermion, I get the following:

-0.1861373089 [1^ 0^ 5 4] +
-0.1697814772 [1^ 0^ 7 6] +
-0.193718323 [2^ 1^ 6 5] +
0.1876273767 [2^ 1^ 7 4] +
0.1876273767 [3^ 0^ 6 5] +
-0.193718323 [3^ 0^ 7 4] +
-0.2129966367 [3^ 2^ 5 4] +
-0.1959962733 [3^ 2^ 7 6] +
0.1861373089 [5^ 4^ 1 0] +
0.2129966367 [5^ 4^ 3 2] +
0.193718323 [6^ 5^ 2 1] +
-0.1876273767 [6^ 5^ 3 0] +
-0.1876273767 [7^ 4^ 2 1] +
0.193718323 [7^ 4^ 3 0] +
0.1697814772 [7^ 6^ 1 0] +
0.1959962733 [7^ 6^ 3 2]

And so at the end it's like the indices for the virtual orbitals are swapped, i.e. 4 <--> 6 and 5 <--> 7.
I checked in more details and it seems the indices are already swapped (according to me) in molecule.ccsd_double_amplitudes.

I enclose a script to test it below. Am I missing something obvious or not ? Thanks !

import psi4
import openfermion
import openfermionpsi4
import numpy as np
import os

data_dir = os.getcwd()
theta = 60
radius = 1.5 #Angstrom
phi = theta*0.5*np.pi/180. #phi = 1/2*theta. Convert to radians
x = radius*np.cos(phi)
y = radius*np.sin(phi)
basis = "sto-3g"
multiplicity = 1
description = str(theta)
geometry = [('H', (x,y, 0.)), ('H', (x, -y, 0.)), ('H', (-x,y, 0.)), ('H', (-x, -y, 0.))]

# TEST PSI4
psi4.geometry('''
H  {0}  {1}  0.
H  {0} -{1}  0.
H -{0}  {1}  0.
H -{0} -{1}  0.
'''.format(x,y))
psi4.core.set_output_file("ccsd_H4.txt", False)
psi4.set_options({"basis": basis,
                  "mp2_amps_print":True,
                  "num_amps_print":26})
cc_energy, cc_wfn = psi4.energy('ccsd',return_wfn = True)

# TEST OPENFERMION
molecule = openfermion.MolecularData(
    geometry,
    basis,
    multiplicity,
    description=description,
    data_directory=data_dir)

molecule = openfermionpsi4.run_psi4(molecule,
                    run_ccsd=1)

hamiltonian, one_body, two_body = molecule.get_molecular_hamiltonian()

ucc_ccsd = openfermion.utils.uccsd_generator(molecule.ccsd_single_amps,molecule.ccsd_double_amps)
ucc_ccsd_normalordered = openfermion.normal_ordered(ucc_ccsd)

ind1, ind2, ind3, ind4 = np.nonzero(molecule.ccsd_double_amps)
individual_t2_values_ccsd = []
for indice in range(len(ind1)):
 t2_value = abs(molecule.ccsd_double_amps[ind1[indice],ind2[indice],ind3[indice],ind4[indice]])
 individual_t2_values_ccsd.append(t2_value) if abs(t2_value) not in individual_t2_values_ccsd else individual_t2_values_ccsd

with open("ccsd_H4.txt","a") as f:
 f.write("From OpenFermion, t2 amps:\n")
 for indice in range(len(ind1)):
    # double_amplitudes is stored as t[i,j,k,l] * (a_i^\dagger a_j a_k^\dagger a_l - H.C.)
    f.write(str(ind1[indice]) + " " + str(ind2[indice]) + " " + str(ind3[indice]) + " " + str(ind4[indice]) + " " + str(2*molecule.ccsd_double_amps[ind1[indice], ind2[indice], ind3[indice], ind4[indice]]) + "\n")
 f.write("  double uccsd amps:\n" + str(ucc_ccsd) + "\n")
 f.write("  double uccsd amps normal ordered:\n" + str(ucc_ccsd_normalordered) + "\n")

You can check the ccsd_H4.txt file to see the amplitudes and corresponding indices.

Better install instructions

Psi4 needs to be configured with anaconda python. It would be great to have better instructions for this and possibly even provide a docker image. I'll take care of the better instructions when I have a chance.

possible issue with basis rotation

I hope this is not a user error.
Seems like run_psi4 is not generating the same hdf5 files that you have under openfermion/data.
The calculated hf energies are correct but the one_body_integrals are not and they are not diagonal; maybe an issue with basis rotation?

attached is a sample output comparing the loaded one_body_integrals with the run.
load_vs_run.pdf

Psi4 calculation converges, Openfermionpsi4 plugin calculation doesn't

This is a really ridiculous situation, but when I submit a SCF calculation for a very specific molecule (lattice of atoms) with Psi4, the calculation converges. When I submit it through the plugin, it doesn't converge (even though it runs for more iterations) and says maybe there's a seg fault with Psi4. To the best of my knowledge, all my parameters are exactly the same.

Is there anything that is changed when the plugin calls psi4? Or am I just missing something?

Warning: No calculation saved. Psi4 segmentation fault possible.

I am having trouble with the basic usage of openfermionpsi4. The error is

molecule = run_psi4(molecule,
                        run_scf=True,
                        run_fci=False)

returning

Users/pablo/.local/lib/python3.7/site-packages/openfermionpsi4/_run_psi4.py:226: Warning: No calculation saved. Psi4 segmentation fault possible.
  Warning)

To replicate it, I have created a conda environment called openfermion, installed both psi4 and openfermion and run a small code:

  1. conda create -n openfermion python=3.7
  2. conda activate openfermion
  3. conda install -c psi4 psi4 as done here
  4. pip install git+https://github.com/quantumlib/OpenFermion.git@master as done in the tutorial in the section Basics of MolecularData class. Notice here that just pip installing openfermion will result in a Module not found error when attempting from openfermion.chem import geometry_from_pubchem, MolecularData.
  5. pip install openfermionpsi4 although everything is already installed, so you may as well skip this.
  6. Run the main code in a jupyter notebook (installed for instance via anaconda navigator)
from openfermion.chem import geometry_from_pubchem, MolecularData
from openfermionpsi4 import run_psi4

methane_geometry = geometry_from_pubchem('methane')
print(methane_geometry)

basis = 'sto-3g'

molecule = MolecularData(methane_geometry, basis, multiplicity = 1)

molecule = run_psi4(molecule,
                        run_scf=True,
                        run_fci=False)

As indicated previously, this last line will raise an error

Users/pablo/.local/lib/python3.7/site-packages/openfermionpsi4/_run_psi4.py:226: Warning: No calculation saved. Psi4 segmentation fault possible.
  Warning)

Thanks in advance for the help

unable to run example

Hello,
Sorry to open an issue for this but I don't know where else to turn. I am unable to run the example script provided. If I do pip install of openfermion and openfermion-psi4 then I get an import error for openfermion.chem, which I take is related to the last commit in July. If I then clone and python -m pip install -e . both openfermion and openfermion-psi4 it is able to do the imports successfully but then throws an error trying to run Psi4, here is a link to the error ouput: https://pastebin.com/jC2FLhN1
If you could tell me how to fix this or just give me an idea of what the problem is I would be greatly appreciative, thanks.

Python-based CCSD Amplitudes

Psi4 added the ability to pull CCSD amplitudes directly from the Python layer:

Ne = psi4.geometry("""
 0 1
 Ne 0.0 0.0 0.0
 symmetry c1
 """)
psi4.set_options({'basis': 'cc-pvdz', 'freeze_core': 'false'})

_, wfn = psi4.energy('ccsd', return_wfn=True, molecule=Ne)
amps = wfn.get_amplitudes()

TIjAb = amps['tIjAb'].to_array()
TIA = amps['tIA'].to_array()

Full PR here. #39 reminded me of this and may simplify the T2 acquisition procedure greatly.

Data update problem

There appears to be a bug where a molecular data file will fail to update if a later calculation is done on the same molecule with an increased number of calculations. For example, running:

from openfermion.hamiltonians import MolecularData
from openfermionpsi4 import run_psi4

geometry = [["H", [0, 0, 0]],
            ["H", [0, 0, 0.74]]]
basis = "sto-3g"
multiplicity = 1
charge = 0
h2_molecule = MolecularData(geometry, basis, multiplicity, charge)
h2_molecule = run_psi4(h2_molecule,
                       run_mp2=True,
                       run_cisd=True,
                       run_ccsd=True,
                       run_fci=True)

Will produce the correct result. However, if one precedes the Psi4 computation by a less detailed calculation, i.e.

h2_molecule = run_psi4(h2_molecule)
h2_molecule = run_psi4(h2_molecule,
                       run_mp2=True,
                       run_cisd=True,
                       run_ccsd=True,
                       run_fci=True)

The data structure will fail to update with only some of the new data, specifically the energies. That is, things like the RDMs will populate but the cisd_ and fci_energies will remain as None. This appears to be an issued with the plugin rather than MolecularData generally, as this issue doesn't persist with the PySCF plugin. Moreover, running PySCF plugin with updated data, WILL update the incomplete molecule as intended, but this plugin will not.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.