Create a Pwc representing a cosine pulse.
- Parameters
duration (float) – The duration of the signal, \(T\).
segment_count (int) – The number of segments in the PWC.
Must be at least six.
amplitude (float or complex or Tensor) – The amplitude of the pulse, \(A\).
It must either be a scalar or contain a single element.
drag (float or Tensor, optional) – The DRAG parameter, \(\beta\).
If passed, it must either be a scalar or contain a single element.
Defaults to no DRAG correction.
start_time (float, optional) – The time at which the cosine pulse starts, \(t_\mathrm{start}\).
Defaults to 0.
end_time (float, optional) – The time at which the cosine pulse ends, \(t_\mathrm{end}\).
Defaults to the given duration \(T\).
flat_duration (float, optional) – The amount of time to remain constant after the peak of the cosine,
\(t_\mathrm{flat}\).
If passed, it must be positive and less than the difference between end_time and
start_time.
Defaults to None, in which case no constant part is added to the cosine pulse.
segmentation (SegmentationType) – The type of segmentation for the signal.
With a “MINIMAL” segmentation, most of the segments are placed in the
non-constant parts 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 sampled cosine pulse.
If no flat duration is passed then the pulse is evenly sampled between \(0\) and
\(T\). If one is passed, the flat part of the pulse is described by one or two segments
(depending on the value of segment_count), and the rest of the pulse is sampled with the
remaining segments.
- Return type
Pwc
Notes
The cosine pulse is defined as
\[\begin{split}\mathop{\mathrm{Cos}}(t) =
\begin{cases}
0
&\mathrm{if} \quad t < t_\mathrm{start} \\
\frac{A}{2} \left[1+\cos \left(\omega \{t-\tau_-\} \right)
+ i\omega\beta \sin \left(\omega \{t-\tau_-\}\right)\right]
&\mathrm{if} \quad t_\mathrm{start} \le t < \tau_- \\
A
&\mathrm{if} \quad \tau_- \le t \le \tau_+ \\
\frac{A}{2} \left[1+\cos \left(\omega\{t-\tau_+\}\right)
+ i\omega \beta\sin \left(\omega \{t-\tau_+\}\right)\right]
&\mathrm{if} \quad \tau_+ < t \le t_\mathrm{end} \\
0
&\mathrm{if} \quad t > t_\mathrm{end} \\
\end{cases},\end{split}\]
where \(\omega=2\pi /(t_\mathrm{end}-t_\mathrm{start} - t_\mathrm{flat})\),
\(\tau_\mp\) are the start/end times of the flat segment,
with \(\tau_\mp=(t_\mathrm{start}+t_\mathrm{end} \mp t_\mathrm{flat})/2\).
If the flat duration is zero (the default setting), this reduces to
\[\mathop{\mathrm{Cos}}(t) =
\frac{A}{2} \left[1+\cos \left(\omega \{t-\tau\} \right)
+ i\omega\beta \sin \left(\omega \{t-\tau\}\right)\right]
\theta(t-t_\mathrm{start}) \theta(t_\mathrm{end}-t),\]
where now \(\omega=2\pi /(t_\mathrm{end}-t_\mathrm{start})\),
\(\tau=(t_\mathrm{start}+t_\mathrm{end})/2\)
and \(\theta(t)\) is the
Heaviside step function.
Examples
Define a cosine PWC pulse.
>>> graph.signals.cosine_pulse_pwc(
... duration=3.0, segment_count=100, amplitude=1.0, name="cos_pulse"
... )
<Pwc: name="cos_pulse", operation_name="time_concatenate_pwc", value_shape=(), batch_shape=()>
>>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["cos_pulse"])
>>> result.output["cos_pulse"]
[
{'duration': 0.03, 'value': 0.00024},
{'duration': 0.03, 'value': 0.00221},
...
{'duration': 0.03, 'value': 0.00221},
{'duration': 0.03, 'value': 0.00024}
]
Define a flat-top cosine PWC pulse with a DRAG correction.
>>> graph.signals.cosine_pulse_pwc(
... duration=3.0,
... segment_count=100,
... amplitude=1.0,
... drag=0.1,
... start_time=1.0,
... end_time=2.0,
... flat_duration=0.3,
... name="cos_flat",
... )
<Pwc: name="cos_flat", operation_name="time_concatenate_pwc", value_shape=(), batch_shape=()>
>>> result = qctrl.functions.calculate_graph(graph=graph, output_node_names=["cos_flat"])
>>> result.output["cos_flat"]
[
{'duration': 1.0, 'value': 0j},
{'duration': 0.0072, 'value': (0.0002-0.0146j)}
...
{'duration': 0.0072, 'value': (0.0002+0.0146j)},
{'duration': 1.0, 'value': 0j}
]
Define a cosine pulse with optimizable parameters.
>>> amplitude = graph.optimization_variable(
... count=1, lower_bound=0, upper_bound=2.*np.pi, name="amplitude"
... )
>>> drag = graph.optimization_variable(
... count=1, lower_bound=0, upper_bound=1., name="drag"
... )
>>> graph.signals.cosine_pulse_pwc(
... duration=3.0,
... segment_count=100,
... amplitude=amplitude,
... drag=drag,
... name="cos_pulse",
... )
<Pwc: name="cos_pulse", operation_name="time_concatenate_pwc", value_shape=(), batch_shape=()>