linear_ramp_stf

The Boulder Opal Toolkits are currently in beta phase of development. Breaking changes may be introduced.

linear_ramp_stf(slope, shift=0.0)

Create an Stf representing a linear ramp.

Parameters
  • slope (float or complex or Tensor) – The slope of the ramp, \(a\). It must either be a scalar or contain a single element.

  • shift (float or complex or Tensor, optional) – The value of the ramp at \(t = 0\), \(b\). It must either be a scalar or contain a single element. Defaults to 0.

Returns

The sampleable linear ramp.

Return type

Stf

See also

pulses.linear_ramp()

Function to create a Pulse object representing a linear ramp.

pulses.linear_ramp_pwc()

Corresponding operation with Pwc output.

pulses.tanh_ramp_stf()

Create an Stf representing a hyperbolic tangent ramp.

Notes

The linear ramp is defined as

\[\mathop{\mathrm{Linear}}(t) = a t + b .\]

Examples

Define a linear STF ramp.

>>> linear = graph.pulses.linear_ramp_stf(slope=4.0, shift=-2.0)
>>> linear
<Stf: operation_name="add", value_shape=(), batch_shape=()>
>>> graph.sample_stf(stf=linear, sample_times=np.linspace(0, 1, 5), name="linear_ramp")
<Tensor: name="linear_ramp", operation_name="sample_stf", shape=(5,)>
>>> graph.discretize_stf(linear, duration=1, segment_count=100, name="discretized_linear")
<Pwc: name="discretized_linear", operation_name="discretize_stf", value_shape=(), batch_shape=()>
>>> result = qctrl.functions.calculate_graph(
...     graph=graph, output_node_names=["linear_ramp", "discretized_linear"]
... )
>>> result.output["linear_ramp"]["value"]
array([-2., -1., 0., 1., 2.]

Define a linear STF ramp with an optimizable slope and root.

>>> slope = graph.optimization_variable(
...     count=1, lower_bound=-4, upper_bound=4, name="slope"
... )
>>> root = graph.optimization_variable(
...     count=1, lower_bound=-4, upper_bound=4, name="slope"
... )
>>> shift = - slope * root
>>> graph.pulses.linear_ramp_stf(slope=slope, shift=shift)
<Stf: operation_name="add", value_shape=(), batch_shape=()>