Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions pulser-core/pulser/sequence/_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Special containers to store the schedule of operations in the Sequence."""

from __future__ import annotations

import warnings
Expand Down Expand Up @@ -190,19 +191,26 @@ def get_samples(
# The phase of detuned delays is not considered
continue

ph_jump_t = self.channel_obj.phase_jump_time
for last_pulse_ind in range(ind - 1, -1, -1): # From ind-1 to 0
last_pulse_slot = channel_slots[last_pulse_ind]
# Skips over detuned delay pulses
last_pulse = cast(Pulse, last_pulse_slot.type)
if not (
ignore_detuned_delay_phase
and self.is_detuned_delay(
cast(Pulse, last_pulse_slot.type)
)
and self.is_detuned_delay(last_pulse)
):
# Accounts for when pulse is added with 'no-delay'
last_pulse_tf_with_fall_time = (
last_pulse_slot.tf
+ last_pulse.fall_time(
self.channel_obj,
in_eom_mode=self.in_eom_mode(
time_slot=last_pulse_slot
),
)
)
# 'min()' accounts for when pulse is added with 'no-delay'
# i.e. there is no phase_jump_time in between a phase jump
t_start = max(s.ti - ph_jump_t, last_pulse_slot.tf)
t_start = min(s.ti, last_pulse_tf_with_fall_time)
break
else:
t_start = 0
Expand Down
10 changes: 8 additions & 2 deletions tests/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -3083,6 +3083,9 @@ def test_modify_eom_setpoint(
seq.enable_eom_mode("ryd", amp, det_on)
assert seq.is_in_eom_mode("ryd")
seq.add_eom_pulse("ryd", dt, 0.0)
end_of_first_pulse = seq.build(params=[1, 0]).get_duration(
include_fall_time=True
)
seq.delay(dt, "ryd")

new_amp, new_det_on = amp + amp_diff, det_on + det_diff
Expand Down Expand Up @@ -3137,8 +3140,11 @@ def test_modify_eom_setpoint(
assert final_phase == 0.0
else:
assert final_phase != 0.0
np.testing.assert_array_equal(ch_samples.phase[: 2 * dt], 0.0)
np.testing.assert_array_equal(ch_samples.phase[-2 * dt :], final_phase)
np.testing.assert_array_equal(ch_samples.phase[:end_of_first_pulse], 0.0)
start_of_second_pulse = -2 * dt
np.testing.assert_array_equal(
ch_samples.phase[start_of_second_pulse:], final_phase
)


def test_max_duration(reg, mod_device):
Expand Down
7 changes: 4 additions & 3 deletions tests/test_sequence_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,11 @@ def test_phase_sampling(mod_device, custom_phase_jump_time):
seq.add(Pulse.ConstantPulse(dt, 1, 0, phase=1), "ch0")
# With 'no-delay', the jump should in between the two pulses
seq.add(Pulse.ConstantPulse(dt, 1, 0, phase=2), "ch0", protocol="no-delay")
pulse2_end_with_fall = seq.get_duration(include_fall_time=True)
# With the standard protocol, there shoud be a delay added and then
# phase jump time is accounted for
seq.add(Pulse.ConstantPulse(dt, 1, 0, phase=3), "ch0")
pulse3_start = seq.get_duration() - dt
pulse3_end_with_fall = seq.get_duration(include_fall_time=True)
# Detuned delay (its phase should be ignored)
seq.add(
Pulse.ConstantPulse(1000, 0, 1, phase=0), "ch0", protocol="no-delay"
Expand All @@ -532,11 +533,11 @@ def test_phase_sampling(mod_device, custom_phase_jump_time):
assert ph_jump_time > 0
expected_phase = np.zeros(full_duration)
expected_phase[:dt] = 1.0
transition2_3 = pulse3_start - ph_jump_time
transition2_3 = pulse2_end_with_fall
assert transition2_3 >= 2 * dt # = End of pulse2
expected_phase[dt:transition2_3] = 2.0
# The detuned delay is ignored
transition3_4 = full_duration - dt - ph_jump_time
transition3_4 = pulse3_end_with_fall
expected_phase[transition2_3:transition3_4] = 3.0
expected_phase[transition3_4:] = 4.0

Expand Down
Loading