Open yulunwang opened 2 years ago
Hi @yulunwang! This is a great feature request.
Perhaps we could add something like the following:
obs = [qml.PauliX(0), qml.PauliZ(1), qml.PauliX(0) @ qml.PauliX(1)]
H = lambda t: qml.Hamiltonian([2 * t, 3 * t, 0.5 * t - 5], obs)
@qml.qnode(dev)
def circuit(t):
qml.TimeEvolution(H)
return qml.expval(qml.PauliZ(0))
where H
is a function that takes a single parameter (t
) and returns the Hamiltonian at that time value.
We could then support some approximate decomposition in order to support this on hardware, perhaps via discretization?
Hi @yulunwang, perhaps this is a bit late now, but there is an even more performant option, based on so-called commutator-free quasi-Magnus operators. Check this repo for an example of how to use Pennylane to simulate time-dependent Hamiltonians https://github.com/XanaduAI/CFQMagnus/blob/main/CFQMagnus/pennylane_simulation.py
Feature details
Hi all,
I am trying to use Pennylane to solve time evolution problems, where the Hamiltonian is time-dependent. With the
ApproxTimeEvolution(H, t, n)
method, I am able to prepare the circuit by inputing the Hamiltonian H and time t (and order of Trotter n). But the Hamiltonian is only allowed to be defined with fixed coeffs and Pauli terms.For example:
H = qml.Hamiltonian( [1, 1, 0.5], [qml.PauliX(0), qml.PauliZ(1), qml.PauliX(0) @ qml.PauliX(1)] )
I hope the
qml.Hamiltonian
can allow time-dependent coeffs so that I don't need to define a new H in every time-step, which is time consuming.For example:
H = qml.Hamiltonian( [2*t, 3*t, 0.5*t-5], [qml.PauliX(0), qml.PauliZ(1), qml.PauliX(0) @ qml.PauliX(1)] )
And then this can be used in
ApproxTimeEvolution()
methodThanks
Implementation
No response
How important would you say this feature is?
2: Somewhat important. Needed this quarter.
Additional information
No response