linear_ramp_pwc

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

linear_ramp_pwc(duration, segment_count, end_value, start_value=None, start_time=0.0, end_time=None, *, name=None)

Create a Pwc representing a linear ramp.

Parameters
  • duration (float) – The duration of the signal, \(T\).

  • segment_count (int) – The number of segments in the PWC.

  • end_value (float or complex or Tensor) – The value of the ramp at \(t = t_\mathrm{end}\), \(a_\mathrm{end}\). It must either be a scalar or contain a single element.

  • start_value (float or complex or Tensor, optional) – The value of the ramp at \(t = t_\mathrm{start}\), \(a_\mathrm{start}\). If passed, it must either be a scalar or contain a single element. Defaults to \(-a_\mathrm{end}\).

  • start_time (float, optional) – The time at which the linear ramp starts, \(t_\mathrm{start}\). Defaults to 0.

  • end_time (float, optional) – The time at which the linear ramp ends, \(t_\mathrm{end}\). Defaults to the given duration \(T\).

  • name (str, optional) – The name of the node.

Returns

The sampled linear ramp.

Return type

Pwc

See also

pulses.linear_ramp()

Function to create a Pulse object representing a linear ramp.

pulses.linear_ramp_stf()

Corresponding operation with Stf output.

pulses.tanh_ramp_pwc()

Create a Pwc representing a hyperbolic tangent ramp.

Notes

The linear ramp is defined as

\[\begin{split}\mathop{\mathrm{Linear}}(t) = \begin{cases} a_\mathrm{start} &\mathrm{if} \quad t < t_\mathrm{start}\\ a_\mathrm{start} + (a_\mathrm{end} - a_\mathrm{start}) \frac{t - t_\mathrm{start}}{t_\mathrm{end} - t_\mathrm{start}} &\mathrm{if} \quad t_\mathrm{start} \le t \le t_\mathrm{end} \\ a_\mathrm{end} &\mathrm{if} \quad t > t_\mathrm{end} \end{cases} .\end{split}\]

Examples

Define a linear PWC ramp.

>>> graph.pulses.linear_ramp_pwc(
...     duration=2.0, segment_count=5, end_value=1.5, start_value=0.5, name="linear_ramp"
... )
<Pwc: name="linear_ramp", operation_name="discretize_stf", value_shape=(), batch_shape=()>
>>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["linear_ramp"])
>>> result.output["linear_ramp"]
[
    {'duration': 0.4, 'value': 0.6},
    {'duration': 0.4, 'value': 0.8},
    {'duration': 0.4, 'value': 1.0},
    {'duration': 0.4, 'value': 1.2},
    {'duration': 0.4, 'value': 1.4},
]

Define a linear ramp with start and end times.

>>> graph.pulses.linear_ramp_pwc(
...     duration=4,
...     segment_count=5,
...     end_value=2,
...     start_time=1,
...     end_time=3,
...     name="linear",
... )
<Pwc: name="linear", operation_name="time_concatenate_pwc", value_shape=(), batch_shape=()>
>>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["linear"])
>>> result.output["linear"]
[
    {'value': -2.0, 'duration': 1.0},
    {'value': -1.5, 'duration': 0.5},
    {'value': -0.5, 'duration': 0.5},
    {'value': 0.5, 'duration': 0.5},
    {'value': 1.5, 'duration': 0.5},
    {'value': 2.0, 'duration': 1.0},
]

Define a linear ramp with an optimizable slope around 0.

>>> duration = 4.0
>>> slope = graph.optimization_variable(
...     count=1, lower_bound=-30, upper_bound=30, name="slope"
... )
>>> end_value = slope * duration / 2
>>> graph.pulses.linear_ramp_pwc(
...     duration=duration, segment_count=64, end_value=end_value, name="linear_ramp"
... )
<Pwc: name="linear_ramp", operation_name="discretize_stf", value_shape=(), batch_shape=()>