Esempio n. 1
0
def test_cpmg_sequence():
    """
    Tests the CPMG sequence.
    """

    duration = 10.0
    offset_count = 4

    sequence = new_cpmg_sequence(
        duration=duration,
        offset_count=offset_count,
    )

    _spacing = duration / offset_count
    _offsets = np.array(
        [
            _spacing * 0.5,
            _spacing * 0.5 + _spacing,
            _spacing * 0.5 + 2 * _spacing,
            _spacing * 0.5 + 3 * _spacing,
        ]
    )
    _rabi_rotations = np.array([np.pi, np.pi, np.pi, np.pi])
    _azimuthal_angles = np.array([np.pi / 2, np.pi / 2, np.pi / 2, np.pi / 2])
    _detuning_rotations = np.array([0, 0, 0, 0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)

    sequence = new_cpmg_sequence(
        duration=duration,
        offset_count=offset_count,
        pre_post_rotation=True,
    )

    _offsets = np.array(
        [
            0,
            _spacing * 0.5,
            _spacing * 0.5 + _spacing,
            _spacing * 0.5 + 2 * _spacing,
            _spacing * 0.5 + 3 * _spacing,
            duration,
        ]
    )
    _rabi_rotations = np.array([np.pi / 2, np.pi, np.pi, np.pi, np.pi, np.pi / 2])
    _azimuthal_angles = np.array([0, np.pi / 2, np.pi / 2, np.pi / 2, np.pi / 2, np.pi])
    _detuning_rotations = np.array([0, 0, 0, 0, 0, 0])

    assert np.allclose(_offsets, sequence.offsets)
    assert np.allclose(_rabi_rotations, sequence.rabi_rotations)
    assert np.allclose(_azimuthal_angles, sequence.azimuthal_angles)
    assert np.allclose(_detuning_rotations, sequence.detuning_rotations)
Esempio n. 2
0
def test_if_cpmg_sequence_with_even_pulses_is_identity():
    """
    Tests if the product of the pulses in a CPMG sequence with pre/post
    pi/2-pulses is an identity, when the number of pulses is even.
    """
    even_cpmg_sequence = new_cpmg_sequence(
        duration=10.0,
        offset_count=8,
        pre_post_rotation=True,
    )

    assert _pulses_produce_identity(even_cpmg_sequence)
Esempio n. 3
0
def test_if_cpmg_sequence_with_odd_pulses_is_identity():
    """
    Tests if the product of the pulses in a CPMG sequence with pre/post
    pi/2-pulses and an extra Z rotation is an identity, when the number of pulses is odd.
    """
    odd_cpmg_sequence = new_cpmg_sequence(
        duration=10.0,
        offset_count=7,
        pre_post_rotation=True,
    )

    assert _pulses_produce_identity(odd_cpmg_sequence)