GithubHelp home page GithubHelp logo

Comments (14)

jarrodmcc avatar jarrodmcc commented on July 20, 2024

from openfermion.

msteudtner avatar msteudtner commented on July 20, 2024

Hi @jarrodmcc
We want to relabel the indices.

Maybe to highlight a bit the relevance of this problem:
Let's say we have a molecule with spatial orbitals labeled ( A, B, C, ... ). The multiplicity of the spin will give you a spin-up version of A, let's call it A0, and a spin-down version of A, called A1. Similar for all other orbitals.
Now in OpenFermion, we consider (when we talk about a Fermion basis state) that it is generated by creation operators like in the following example:

a^{+}_0 a^{+}_1 a^{+}_2 a^{+}_3 ... |vac> .

Here the indices (0, 1, 2, 3, ... ) are short for the labels (A0, A1, B0, B1 , ... ).
That's a good choice: in Jordan-Wigner transform, Hubbard-like terms will probably be local i. e. ~ Z2 Z3 .
However: hopping terms from e.g. A0 to C0 will run over some orbitals with opposite spin, so here yield operators ~ X0 Z1 Z2 Z3 X4.
In arXiv:1403.1539 it is argued that one can save gates if we switch the ordering to
(A0, B0, C0, ... A1, B1, C1, ... ). Its true that the same hopping is then ~ X0 Z1 X2.

from openfermion.

babbush avatar babbush commented on July 20, 2024

I am not a big fan of increasing the complexity of FermionOperator for this purpose. So I would vote against any solution that involves letting FermionOperator "know" its order. While it is conceivable that users could make the mistake mentioned in (1) by @conta877 , I don't have a lot of sympathy for such users. If one reorders FermionOperator A but not FermionOperator B and then adds them, that's sort of their fault (from my perspective). One should never need to reorder until immediately before mapping to qubits. In that sense, this problem should not be such a concern.

from openfermion.

kevinsung avatar kevinsung commented on July 20, 2024

I agree with Ryan. Right now our approach is that users can specify the spin-indexing in functions that generate Hamiltonian models; the default is the even-odd scheme, but you can also specify other schemes (right now this is true for the functions in hamiltonians/_special_operators.py but #217 makes this true for Hubbard and mean-field as well). @conta877 @msteudtner is this approach is good enough for your purposes?

from openfermion.

msteudtner avatar msteudtner commented on July 20, 2024

Would it perhaps be more practical to define a function somewhere that takes a FermionOperator and the number of modes as input and outputs the reordered FermionOperator (+ a function to undo this)?

The advantage would be that you wouldnt need to define it into every model, also not for any model in the future. Furthermore it allows me to do this reordering to a custom Hamiltonian. The disadvantage would be though, that it is faster to do this when creating a Hamiltonian rather than going over every index again afterwards.

What do you think ?

from openfermion.

kevinsung avatar kevinsung commented on July 20, 2024

Do you have an example of a situation where you would want to use different spin-indexing schemes for different parts of the computation? If not, then I think it's better to just initialize all of your FermionOperators using the indexing scheme that you intend to use.

I just noticed that the even-odd scheme is hard-coded into the MolecularData data structure, but I think we can change that too.

from openfermion.

msteudtner avatar msteudtner commented on July 20, 2024

Actually, if we could build in a 'half up'-option for the molecules, I would be deeply satisfied.

from openfermion.

babbush avatar babbush commented on July 20, 2024

Sure, this should be fairly straightforward. I think this is a good solution.

from openfermion.

conta877 avatar conta877 commented on July 20, 2024

So we are allowed to embed it into molecularData instead of a separate function? maybe initialize with a half_up = bool toggle?

from openfermion.

msteudtner avatar msteudtner commented on July 20, 2024

from openfermion.

babbush avatar babbush commented on July 20, 2024

Yes I think that is okay. @jarrodmcc or @kevinsung do you have any specific thoughts about that?

from openfermion.

kevinsung avatar kevinsung commented on July 20, 2024

I think a boolean toggle to indicate which spin-indexing scheme to use is fine.

from openfermion.

jarrodmcc avatar jarrodmcc commented on July 20, 2024

from openfermion.

idk3 avatar idk3 commented on July 20, 2024

@msteudtner @conta877 a while back I implemented something that can generically reorder fermionic modes in OpenFermion-ProjectQ. But looking at the discussion you might not need it after all :)

https://github.com/quantumlib/OpenFermion-ProjectQ/blob/master/openfermionprojectq/_ffft.py#L242 has swap_adjacent_fermionic_modes, the other half you'd need is some of the parallel bubble sort routines in OpenFermion-ProjectQ/_parallel_bubble_sort.py. Let me know if you have any questions.

from openfermion.

Related Issues (20)

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.