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

Extend generate_xyz_hamiltonian to allow for arbitrary coefficients. #34

Open
BryceFuller opened this issue Sep 15, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@BryceFuller
Copy link

BryceFuller commented Sep 15, 2024

What should we add?

Right now generate_xyz_hamiltonian allows one to specify the coupling coefficients across all edges for each interaction type in the Hamiltonian, but for some applications one might want to, for example, use a set of randomly sampled coefficients for the XX terms.

This could be supported by accepting a dictionary mapping edges in the coupling map to coefficients.

For example:

np.random.seed(42)
xx_coeff_dict = {edge: np.random.randn() for edge in coupling_map}

# Get a qubit operator describing the Heisenberg XYZ model
hamiltonian = generate_xyz_hamiltonian(
    coupling=coupling_map,
    coupling_constants=(xx_coeff_dict, np.pi / 4, np.pi / 2),
    ext_magnetic_field=(np.pi / 3, np.pi / 6, np.pi / 9),
)

A few sanity checks on the input are that if a dict is passed in for one of the coeffs:

  • All edges in the coupling graph must be present in the dictionary
  • Each edge should appear only once, i.e if (0,1) and (1,0) appear and have different coeffs, throw an error
@BryceFuller BryceFuller added the enhancement New feature or request label Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant