Comments (7)
Alright, I added the pull request. I tried to minimize the coding as much as possible, i.e. by only adding one dictionary to store the amplitudes that I needed to compute the same-spin amplitudes for restricted/closed-shell calculations.
I realized I needed an additional factor 1/2, I'm not entirely sure where it comes from.
I checked the CCSD energy resulting from these new amplitudes for H4 and LiH, and it worked well (I recover the correct energy up to single precision).
from openfermion-psi4.
I would assume this problem persists with ROHF right? If so then yes we should extract the amplitudes for the users!
from openfermion-psi4.
The problem is solved when using ROHF (which in OpenFermion-Psi4 is used when multiplicity is not equal to 1).
But this should still be fixed when using RHF right ?
from openfermion-psi4.
Hey @bsenjean, sorry getting back to this. I too ran into something similar where I learned the CCSD closed shell amplitudes are S2 and Sz spin adapted (from a very old paper in the 80's which everyone cites). Therefore, as psi4 forum mentions same-spin t2 are defined as T_IJAB = T_IjAb - T_IjBa = T_ijab. Is that what you mean?
from openfermion-psi4.
Yes, typically these amplitudes are required and computed inside Psi4 but they do not print them as they can be determined from the others by the expression T_IJAB = T_IjAb - T_IjBa = T_ijab. So one should also extract them in OpenFermion otherwise you'll see that you don't get the correct CCSD energy.
One of our student made a subroutine to add them to the ccsd operator in OpenFermion, see below (it could certainly be more compacted):
def add_same_spin_amplitudes(
ccsd_op: openfermion.FermionOperator,
n_electrons: int,
n_qubits: int) -> openfermion.FermionOperator:
"""
Add same-spin amplitudes to a normal ordered ccsd operator.
Largest TIJAB Amplitudes:
1 0 1 0 -0.0060909463
Largest Tijab Amplitudes:
1 0 1 0 -0.0060909463
they are equal to T_IJAB = T_ijab = T_IjAb - T_IjBa
(see
http://forum.psicode.org/t/understanding-mp2-ccsd-amplitudes-for-h4/1866/3)
In normal-ordered form: (if not normal order, add the symmetric term with
an appropriate factor 1/2 in the amplitudes)
Args:
ucc_operator (FermionOperator): Coupled-cluster operator.
n_electrons (int): Number of electrons.
n_qubits (int): Number of qubits.
Returns:
ccsd_op(openfermin.FermionOperator): normal ordered ccsd operator.
"""
if not isinstance(ccsd_op, openfermion.FermionOperator):
raise TypeError('CC operator must be FermionOperator.')
ccsd_op = openfermion.normal_ordered(ccsd_op)
for i in range(0, n_electrons, 2):
for j in range(i + 2, n_electrons, 2):
for a in range(n_electrons, n_qubits, 2):
for b in range(a + 2, n_qubits, 2):
# Make sure that T_IjAb is present in ccsd_op
if ((b, 1), (a + 1, 1), (j, 0),
(i + 1, 0)) not in list(ccsd_op.terms.keys()):
# if one is not present then both are not
# (ie if T_IjAb=0 then T_IjBa=0)
if (((b, 1), (a + 1, 1), (j, 0), (i + 1, 0)) or
((b + 1, 1), (a, 1), (j, 0),
(i + 1, 0))) in list(ccsd_op.terms.keys()):
print(
'CCSD operator incomplete, missing: ', ((
b + 1, 1), (a, 1), (j, 0), (i + 1, 0)))
else:
add_op = openfermion.FermionOperator(
'{}^ {}^ {} {}'.format(b, a, j, i), ccsd_op.terms[(
(b, 1), (a + 1, 1), (j, 0), (i + 1, 0))] +
ccsd_op.terms[
((b + 1, 1), (a, 1), (j, 0), (i + 1, 0))])
if list(add_op.terms.keys())[0] not in list(
ccsd_op.terms.keys()):
ccsd_op += add_op
add_op = openfermion.FermionOperator(
'{}^ {}^ {} {}'.format(b + 1, a + 1, j + 1, i + 1),
ccsd_op.terms[(
(b, 1), (a + 1, 1), (j, 0), (i + 1, 0))] +
ccsd_op.terms[
((b + 1, 1), (a, 1), (j, 0), (i + 1, 0))])
if list(add_op.terms.keys())[0] not in list(
ccsd_op.terms.keys()):
ccsd_op += add_op
return ccsd_op
from openfermion-psi4.
Great. Do you or the student want to submit this as a PR? It would be nice to have so others know how to "unspin-adapt" the amplitudes.
from openfermion-psi4.
Sure, I guess a good place would be openfermionpsi4/_psi4_conversion_functions.py
?
I could either modify directly parse_psi4_ccsd_amplitudes
and add the same-spin amplitudes if restricted == True
, or just create another function. In my opinion, it is more a correction than an addition and should be in parse_psi4_ccsd_amplitudes
.
from openfermion-psi4.
Related Issues (13)
- Move to master-based git workflow HOT 1
- Data update problem HOT 3
- Better install instructions HOT 3
- Error in IPython demo file + _psi_template file (?) HOT 4
- ImportError: cannot import name general_basis_change (_psi4_template) HOT 5
- possible issue with basis rotation HOT 5
- Psi4 calculation converges, Openfermionpsi4 plugin calculation doesn't HOT 2
- Cut a new release HOT 2
- Sorting of CCSD amplitudes HOT 1
- Python-based CCSD Amplitudes
- unable to run example HOT 1
- Warning: No calculation saved. Psi4 segmentation fault possible. HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openfermion-psi4.