# time_evolution_operators_pwc

Source: https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/time_evolution_operators_pwc

```python
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.

### Parameters
* **hamiltonian** ([*Pwc*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Pwc.md#boulderopal.graph.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.
### Returns
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
[Tensor](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)

### SEE ALSO
[`Graph.state_evolution_pwc`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/state_evolution_pwc.md#boulderopal.graph.Graph.state_evolution_pwc)
: Evolve a quantum state.

[`Graph.time_evolution_operators_stf`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/time_evolution_operators_stf.md#boulderopal.graph.Graph.time_evolution_operators_stf)
: Corresponding operation for Stf Hamiltonians.

## Notes

For more information on Pwc nodes see the [Working with time-dependent functions in
Boulder Opal](https://docs.q-ctrl.com/boulder-opal/topics/working-with-time-dependent-functions-in-boulder-opal) topic.

## Examples

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

```pycon
>>> 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](https://docs.q-ctrl.com/boulder-opal/user-guides/how-to-simulate-quantum-dynamics-for-noiseless-systems-using-graphs) user guide.
