1
$\begingroup$

I am wondering how to create a square pulse in Qiskit. I am working off this Qiskit documentation but still cannot figure out how to create a square pulse.

$\endgroup$
0
$\begingroup$

From qiskit documentation on pulses, here is a code that implement a constant (square) pulse. I also included the other examples given in the previous link.

Note that the API used here is brand new and still in beta, so it might change in the near future.

from math import pi

import matplotlib.pyplot as plt
from qiskit import pulse
from qiskit.test.mock import FakeCasablanca

backend = FakeCasablanca()

pulse_duration = 64
pulse_amplitude = 1.0

with pulse.build(backend) as schedule:
    d0 = pulse.drive_channel(0)
    # The constant you are looking for
    pulse.play(pulse.library.Constant(pulse_duration, pulse_amplitude), d0)
    # Other pulses
    pulse.delay(20, d0)
    pulse.shift_phase(pi / 2, d0)
    pulse.set_phase(pi, d0)
    pulse.shift_frequency(1e7, d0)
    pulse.set_frequency(5e9, d0)

    with pulse.build() as temp_sched:
        pulse.play(pulse.library.Gaussian(20, 1.0, 3.0), d0)
        pulse.play(pulse.library.Gaussian(20, -1.0, 3.0), d0)

    pulse.call(temp_sched)
    # Measurement
    a0 = pulse.acquire_channel(0)
    pulse.acquire(30, a0, pulse.MemorySlot(0))

schedule.draw()
plt.show()

The code above gives the following image plot of the pulse schedule obtained

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.