Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hamiltonian Modeler #96

Merged
merged 11 commits into from
Oct 29, 2024
Merged

Add Hamiltonian Modeler #96

merged 11 commits into from
Oct 29, 2024

Conversation

Jacomichi
Copy link
Collaborator

Change

  • Add Hamiltonian modeler qamomile.core.modeler
  • Currently, only support Hamiltonian consisting only of Pauli operators

Usage

The simple example is

    E = jm.Placeholder("E", ndim=2)
    e = jm.Element("e", belong_to=E)
    Z = qm_m.PauliExpr.z(shape=3)
    expr = jm.sum(e, Z[e[0]] * Z[e[1]])
    
    hamiltonian_expr = qm_m.HamiltonianExpr(expr, name="test")
    
    E = [[0, 1], [1, 2], [2, 0]]
    
    builder = qm_m.HamiltonianBuilder(hamiltonian_expr, {"E": E})
    op = builder.build()

    expected_hamiltonian = qm_o.Hamiltonian()
    for i,j in E:
        expected_hamiltonian += qm_o.Z(i) * qm_o.Z(j)

    assert op == expected_hamiltonian

We can also see your HamiltonianExpr (algebraic expression of Hamiltonian) as LaTex in jupyter-notebook.
Some example is in the notebook.

Concern

@Jacomichi Jacomichi requested a review from yuyamashiro October 21, 2024 07:58
@Jacomichi
Copy link
Collaborator Author

New Change

  • Add tutorial and docstrings
  • add to_latex method in Hamiltonian

@Jacomichi Jacomichi marked this pull request as ready for review October 22, 2024 13:36
@yuyamashiro yuyamashiro merged commit 17cb52a into main Oct 29, 2024
4 checks passed
@yuyamashiro yuyamashiro deleted the feature/modeler branch October 29, 2024 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants