Graph.time_evolution_operators_pwc(hamiltonian, sample_times, *, name=None)

Calculate the unitary time-evolution operators for a system defined by a piecewise-constant Hamiltonian.


  • hamiltonian (Pwc) – The control Hamiltonian, or batch of control Hamiltonians.
  • sample_times (np.ndarray) – The N times at which you want to sample the unitaries. Must be ordered and contain at least one element, and lie between 0 and the duration of the Hamiltonian.
  • name (str or None , optional) – The name of the node.


Tensor of shape (..., N, D, D), representing the unitary time evolution. The n-th element (along the -3 dimension) represents the unitary (or batch of unitaries) from t = 0 to sample_times[n].

Return type



Graph.state_evolution_pwc : Evolve a quantum state.

Graph.time_evolution_operators_stf : Corresponding operation for Stf Hamiltonians.


For more information on Pwc nodes see the Working with time-dependent functions in Boulder Opal topic.


Simulate the dynamics of a single qubit, where a constant drive rotates the qubit along the x-axis.

>>> initial_state = np.array([1, 0])
>>> sigma_x = np.array([[0, 1], [1, 0]])
>>> duration = np.pi
>>> hamiltonian = graph.constant_pwc_operator(duration=duration, operator=sigma_x / 2)
>>> graph.time_evolution_operators_pwc(
...     hamiltonian=hamiltonian, sample_times=[duration], name="unitaries"
... )
<Tensor: name="unitaries", operation_name="time_evolution_operators_pwc", shape=(1, 2, 2)>
>>> result = bo.execute_graph(graph=graph, output_node_names="unitaries")
>>> result["output"]["unitaries"]["value"].dot(initial_state)
array([[5.0532155e-16+0.j, 0.0000000e+00-1.j]])

See more examples in the How to simulate quantum dynamics for noiseless systems using graphs user guide.

Was this useful?