def setUp(self) -> None: # define some building blocks self.sin_pt = FunctionPT('sin(omega*t)', 't_duration', channel='X') self.cos_pt = FunctionPT('sin(omega*t)', 't_duration', channel='Y') self.exp_pt = AtomicMultiChannelPT(self.sin_pt, self.cos_pt) self.tpt = TablePT({'X': [(0, 0), (3., 4.), ('t_duration', 2., 'linear')], 'Y': [(0, 1.), ('t_y', 5.), ('t_duration', 0., 'linear')]}) self.complex_pt = RepetitionPT(self.tpt, 5) @ self.exp_pt self.parameters = dict(t_duration=10, omega=3.14*2/10, t_y=3.4)
def test_regression_duration_conversion_functionpt(self): old_value = qupulse._program.waveforms.PULSE_TO_WAVEFORM_ERROR try: qupulse._program.waveforms.PULSE_TO_WAVEFORM_ERROR = 1e-6 for duration_in_samples in [64, 2000, 936320]: p = FunctionPT('1', duration_expression=duration_in_samples / 2.4, channel='a') number_of_samples = p.create_program().duration * 2.4 self.assertEqual(number_of_samples.denominator, 1) finally: qupulse._program.waveforms.PULSE_TO_WAVEFORM_ERROR = old_value
def chirp(name): """ Creates a chirp signal Args: name (str): The user defined name of the pulse template. Returns: FunctionPT: The pulse template with the chirp signal. Parameters of the pulse template are the `duration` (in the same unit as time), `omega_0` (in Hz), `delta_omega` (in Hz), `amplitude` and `phase`. Time is in ns. """ linear_chirp_template = FunctionPT('amplitude*cos(2*pi*(omega_0+(t/(2*duration))*delta_omega) *t*1e-9+phase)', 'duration', channel=name) linear_chirp_template.__doc__='Template for linear chirp\nAlso see https://en.wikipedia.org/wiki/Chirp\n\n'+linear_chirp_template.__doc__ return linear_chirp_template
def get_pulse_template(self) -> PulseTemplate: fpt = FunctionPT('sin(omega*t)', 't_duration', 'X', measurements=[('M', 0, 't_duration')]) tpt = TablePT( { 'Y': [(0, 'a'), ('t_duration', 2)], 'Z': [('t_duration', 1)] }, measurements=[('N', 0, 't_duration/2')]) mpt = MappingPT(fpt, parameter_mapping={'omega': '2*pi/t_duration'}, allow_partial_parameter_mapping=True) ampt = AtomicMultiChannelPT(mpt, tpt) body = ampt @ ampt rpt = RepetitionPT(body, 'N_rep', measurements=[('O', 0, 1)]) forpt = ForLoopPT(rpt, 'a', '6') final = SequencePT(rpt, forpt) return final