Manually declare the Hamiltonian matrix

When we create a hamiltonian using the function “hamiltonian = rydberg_h(…)”, we have the possibility to visualize its matrix representation through the command “mat(hamiltonian)”. I would like to know if there is a way to build a hamiltonian declaring its matrix directly, without using the “rydberg_h” function, to then simulate it with “prob = SchrodingerProblem(reg, t , hamiltonian)”.

It would perhaps be something like:

Declaring Hamiltonian

hamiltonian = [0 1; 1 0];

Solving Schrodinger’s equation

prob = SchrodingerProblem(reg, t , hamiltonian)

Thanks for the attention.

Hi @JoaquimMG ,

Unfortunately there isn’t really a way to go about this in Bloqade. Bloqade isn’t designed to be a general purpose simulator which means it wasn’t designed with the ability to load custom matrices.

That being said, we do support a certain set of Hamiltonian term expressions you have some freedom in combining (check out (Maximum Weight Independent Set · Bloqade.jl, Hamiltonians · Bloqade.jl, and Hamiltonians · Bloqade.jl for the full set of supported terms) to create an expression type that then gets lowered into the actual sparse matrices for emulation.

In your case the hamiltonian in your example (a Pauli X matrix) could be simulated like so:

h = SumOfX(1)
reg = zero_state(1)
t_evolution = 1.6
prob = SchrodingerProblem(reg, t_evolution, h)

Hope that helps!

1 Like