constant_pwc_operator

Graph.constant_pwc_operator(duration, operator, *, name=None)

Create a constant piecewise-constant operator over a specified duration.

Parameters

  • duration (float) – The duration τ\tau
  • operator (np.ndarray or Tensor) – The operator AA
  • name (str or None , optional) – The name of the node.

Returns

The constant operator tAt\mapsto A (for 0tτ0\leq t\leq\tau

Return type

Pwc

SEE ALSO

Graph.constant_stf_operator : Corresponding operation for Stfs.

Graph.hermitian_part : Hermitian part of an operator.

Graph.pwc_operator : Create Pwc operators.

Notes

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

Examples

Create a Hamiltonian from a batched constant operator.

>>> sigma_x = np.array([[0.0, 1.0], [1.0, 0.0]])
>>> sigma_z = np.array([[1.0, 0.0], [0.0, -1.0]])
>>> batched_operators = np.asarray([sigma_x, sigma_z])
>>> graph.constant_pwc_operator(duration=0.1, operator=batched_operators,  name="op")
<Pwc: name="op", operation_name="constant_pwc_operator", value_shape=(2, 2), batch_shape=(2,)>
>>> result = bo.execute_graph(graph=graph, output_node_names="op")
>>> result["output"]["op"]
{
    'durations': array([0.1]),
    'values': array([
        [[[ 0.,  1.], [ 1.,  0.]]],
        [[[ 1.,  0.], [ 0., -1.]]]
    ]),
    'time_dimension': 1
}

See more examples in the How to represent quantum systems using graphs user guide.

Was this useful?