Exemple #1
0
    def test_run_simulation_from_backend(self):
        """Construct from a backend and run a simulation."""
        armonk_backend = FakeArmonk()

        # manually override parameters to insulate from future changes to FakeArmonk
        freq_est = 4.97e9
        drive_est = 6.35e7
        armonk_backend.defaults().qubit_freq_est = [freq_est]
        armonk_backend.configuration().hamiltonian['h_str'] = [
            'wq0*0.5*(I0-Z0)', 'omegad0*X0||D0'
        ]
        armonk_backend.configuration().hamiltonian['vars'] = {
            'wq0': 2 * np.pi * freq_est,
            'omegad0': drive_est
        }
        armonk_backend.configuration().hamiltonian['qub'] = {'0': 2}
        dt = 2.2222222222222221e-10
        armonk_backend.configuration().dt = dt

        armonk_sim = PulseSimulator.from_backend(armonk_backend)
        armonk_sim.set_options(meas_level=2, meas_return='single', shots=1)

        total_samples = 250
        amp = np.pi / (drive_est * dt * total_samples)

        sched = self._1Q_schedule(total_samples, amp)
        # run and verify that a pi pulse had been done
        result = armonk_sim.run(sched).result()
        final_vec = result.get_statevector()
        probabilities = np.abs(final_vec)**2
        self.assertTrue(probabilities[0] < 1e-5)
        self.assertTrue(probabilities[1] > 1 - 1e-5)
# Mock Armonk backend
from qiskit.test.mock.backends.armonk.fake_armonk import FakeArmonk


# In[191]:


armonk_backend = FakeArmonk()


# In[192]:


freq_est = 4.97e9
drive_est = 6.35e7
armonk_backend.defaults().qubit_freq_est = [freq_est]
armonk_backend.configuration().hamiltonian['h_str']= ['wq0*0.5*(I0-Z0)', 'omegad0*X0||D0']
armonk_backend.configuration().hamiltonian['vars'] = {'wq0': 2 * np.pi * freq_est, 'omegad0': drive_est}
armonk_backend.configuration().hamiltonian['qub'] = {'0': 2}
armonk_backend.configuration().dt = 2.2222222222222221e-10


# In[200]:


dim_oscillators = 3

# single oscillator drift parameters
oscillator_freqs = [5.0e9, 5.1e9, 5.2e9]
anharm_freqs = [-0.33e9, -0.33e9, -0.33e9]