# square_pulse_pwc¶

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

square_pulse_pwc(duration, segment_count, amplitude, start_time=0, end_time=None, segmentation='UNIFORM', *, name=None)

Create a Pwc representing a square pulse.

The entire signal lasts from time 0 to the given duration with the square pulse being applied from the start time to the end time.

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

• segment_count (int) – The number of segments in the PWC. Only used if the segmentation type is “UNIFORM” .

• amplitude (float or complex or Tensor) – The amplitude of the square pulse, $$A$$. It must either be a scalar or contain a single element.

• start_time (float, optional) – The start time of the square pulse, $$t_\mathrm{start}$$. Defaults to 0.

• end_time (float, optional) – The end time of the square pulse, $$t_\mathrm{end}$$. Must be greater than the start time. Defaults to the value of the given duration.

• segmentation (SegmentationType) – The type of segmentation for the pulse. With a “MINIMAL” segmentation, the returned Pwc has between one and three segments, depending on the start time, end time, and duration of the signal. Defaults to “UNIFORM”, in which case the segments are uniformly distributed along the signal’s duration.

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

Returns

The square pulse.

Return type

Pwc

signals.cosine_pulse_pwc()

Create a Pwc representing a cosine pulse.

signals.gaussian_pulse_pwc()

Create a Pwc representing a Gaussian pulse.

signals.sech_pulse_pwc()

Create a Pwc representing a hyperbolic secant pulse.

signals.square_pulse()

Function to create a Signal object representing a square pulse.

Notes

The square pulse is defined as

$\mathop{\mathrm{Square}}(t) = A \theta(t-t_\mathrm{start}) \theta(t_\mathrm{end}-t) ,$

where $$\theta(t)$$ is the Heaviside step function.

Examples

Define a square pulse with an optimizable amplitude.

>>> amplitude = graph.optimization_variable(
...     count=1, lower_bound=0, upper_bound=2.*np.pi, name="amplitude"
... )
>>> graph.signals.square_pulse_pwc(
...     duration=4.0, amplitude=amplitude, name="square"
... )
<Pwc: name="square", operation_name="time_concatenate_pwc", value_shape=(), batch_shape=()>


Define a square PWC pulse.

>>> graph.signals.square_pulse_pwc(
...     duration=4.0,
...     segment_count=100,
...     amplitude=2.5,
...     start_time=1.0,
...     end_time=3.0,
...     name="square",
... )
<Pwc: name="square", operation_name="pwc_signal", value_shape=(), batch_shape=()>
>>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["square"])
>>> result.output["square"]
[
{'duration': 0.04, 'value': 0.0},
...
{'duration': 0.04, 'value': 0.0},
{'duration': 0.04, 'value': 2.5},
...
{'duration': 0.04, 'value': 2.5},
{'duration': 0.04, 'value': 0.0}
...
{'duration': 0.04, 'value': 0.0}
]


Define a square PWC pulse with a minimal segmentation.

>>> graph.signals.square_pulse_pwc(
...     duration=4.0,
...     segment_count=None,
...     amplitude=2.5,
...     start_time=1.0,
...     end_time=3.0,
...     segmentation="MINIMAL",
...     name="square",
... )
<Pwc: name="square", operation_name="time_concatenate_pwc", value_shape=(), batch_shape=()>
>>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["square"])
>>> result.output["square"]
[
{'duration': 1.0, 'value': 0.0},
{'duration': 2.0, 'value': 2.5},
{'duration': 1.0, 'value': 0.0}
]