def test_sequential_real_time(self):
        config = simul.SimulationConfig(1., 10)
        config.parallel = False
        config.num_runs = 3
        config.time_sampling = True
        config.sampling_interval = 5
        config.realization_sampling = True

        pmd = TestPMD()
        ham = hamil.HamiltonianFunction(pmd)
        ctrls = np.zeros((10, 0))
        pham = hamil.PrecomputedHamiltonian(pmd, ctrls, config,
                                            ham.get_function())
        sim = simul.Simulation(config, pmd, pham)
        report = sim.run()

        self.assertIsInstance(report.channel, ch.QuantumChannel)
        self.assertIsInstance(report.liouvillian_samples, list)
        self.assertIsInstance(report.time_samples, list)
        self.assertEqual(len(report.liouvillian_samples), 3)
        self.assertTrue(
            all([
                type(c) == ch.QuantumChannel
                for c in report.liouvillian_samples
            ]))
        self.assertEqual(len(report.liouvillian_samples), 3)
        self.assertTrue(all([len(row) == 2 for row in report.time_samples]))
        self.assertTrue(
            all([
                all([type(c) == ch.QuantumChannel for c in row])
                for row in report.time_samples
            ]))
 def test_two_qutrit_I(self):
     config=simulation.SimulationConfig(time_length=.1,num_steps=50)
     config.num_runs=1
     pmd = QutritPMD(2)
     ham = hamiltonian.HamiltonianFunction(pmd)
     ctrls = np.zeros((50,0))
     pham =  hamiltonian.PrecomputedHamiltonian(pmd,ctrls,config,
                                                ham.get_function())
     sim = simulation.Simulation(config,pmd,pham)
     report = sim.run()
     self.assertEqual(la.norm(report.channel.liouvillian()-np.eye(81)),0)
Beispiel #3
0
 def test_blatt_pmd_comp_3(self):
     config = simulation.SimulationConfig(time_length=.1, num_steps=50)
     config.num_runs = 1
     pmd = implementations.BlattPMDComp(3)
     pmd.noise_off()
     ham = hamiltonian.HamiltonianFunction(pmd)
     ctrls = np.zeros((50, 0))
     pham = hamiltonian.PrecomputedHamiltonian(pmd, ctrls, config,
                                               ham.get_function())
     sim = simulation.Simulation(config, pmd, pham)
     report = sim.run()
     self.assertEqual(la.norm(report.channel.liouvillian() - np.eye(64)), 0)
Beispiel #4
0
    def test_attribute_pass_thru(self):
        def pmd():pass
        pmd.xtalk = 36

        h = ham.HamiltonianFunction(pmd)

        self.assertEqual(pmd.xtalk, h.xtalk)

        try:
            h.unknown
        except AttributeError:
            return
        self.assertTrue(False, "HamlitonianFunction object failed to throw exception on unknown attribute")
    def test_sequential(self):
        config = simul.SimulationConfig(1., 10)
        config.parallel = False
        config.num_runs = 3
        config.time_sampling = False
        config.realization_sampling = False

        pmd = TestPMD()
        ham = hamil.HamiltonianFunction(pmd)
        ctrls = np.zeros((10, 0))
        pham = hamil.PrecomputedHamiltonian(pmd, ctrls, config,
                                            ham.get_function())
        sim = simul.Simulation(config, pmd, pham)
        report = sim.run()

        self.assertIsInstance(report.channel, ch.QuantumChannel)
        self.assertIs(report.liouvillian_samples, None)
        self.assertIs(report.time_samples, None)