Skip to content

Extend generate_xyz_hamiltonian to allow for arbitrary coefficients.  #34

@BryceFuller

Description

@BryceFuller

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions