示例#1
0
    def do_pulse_sequence(self, psi0, **kwargs):
        '''
		Run a detuning pulse sequence
		'''
        opts = qu.Options(nsteps=100000)

        self.device.build_hamiltonian(detuning=0)
        initial_hamiltonian = self.device.Hamiltonian
        conversion_factor = self.device.alpha * const.eV / const.h  # Convert voltage pulse to frequency units
        detuning_hamiltonian = conversion_factor * qu.Qobj(
            np.array([[1 / 2, 0, 0, 0, 0], [0, 1 / 2, 0, 0, 0],
                      [0, 0, 1 / 2, 0, 0], [0, 0, 0, 1 / 2, 0],
                      [0, 0, 0, 0, -1 / 2]]))
        qutip_time_dependence = qu.Cubic_Spline(
            self.lePulse.time_vec[0], self.lePulse.time_vec[-1],
            self.lePulse.simulation_waveform)
        full_H = [
            initial_hamiltonian, [detuning_hamiltonian, qutip_time_dependence]
        ]
        output = qu.mesolve(full_H,
                            psi0,
                            tlist=self.lePulse.time_vec,
                            c_ops=[],
                            e_ops=[],
                            options=opts,
                            progress_bar=True)
        self.simulation_result = output
示例#2
0
def _n_correlation(times, n_expectation):
    """
    Numerical integration of the correlation function given an array of
    expectation values.
    """
    interp = qutip.Cubic_Spline(times[0], times[-1], n_expectation)
    n = interp(np.concatenate([times, times[1:] + times[-1]]))
    return np.array([[n[t] * n[t+tau] for tau in range(times.shape[0])]
                     for t in range(times.shape[0])])
示例#3
0
def _2_tuple_splines(dimension, kappa, times):
    a = qutip.destroy(dimension)
    spectrum = "{kappa} * (w >= 0)".format(kappa=kappa)
    spline = qutip.Cubic_Spline(times[0], times[-1], np.ones_like(times))
    return ([np.sqrt(kappa) * a,
             np.sqrt(kappa) * a,
             np.sqrt(kappa) * a],
            [np.sqrt(kappa) * a], [[a + a.dag(), spectrum],
                                   [(a, a.dag()), (spectrum, spline, spline)]])
示例#4
0
def test_equivalence_to_scipy(noise):
    x = np.linspace(0, 2 * np.pi, 200)
    y = np.sin(x) + noise(x.shape[0])
    test = qutip.Cubic_Spline(x[0], x[-1], y)
    expected = scipy.interpolate.CubicSpline(x, y, bc_type="natural")
    # We use the bc_type="natural", i.e. zero second-derivatives at the
    # boundaries because that matches qutip.
    np.testing.assert_allclose(test(x), expected(x), atol=1e-10)
    centres = 0.5 * (x[:-1] + x[1:])
    # Test some points not in the original.
    for point in centres:
        assert np.abs(test(point) - expected(point)) < 1e-10, "Scalar argument"
示例#5
0
def test_time_dependent_spline_in_c_ops():
    N = 10
    a = qutip.destroy(N)
    H = a.dag() * a
    psi0 = qutip.basis(N, 9)
    times = np.linspace(0, 10, 100)
    kappa = 0.2
    exact = 9 * np.exp(-2 * kappa * (1 - np.exp(-times)))
    a_ops = [[a + a.dag(), _string_w_interpolating_t(kappa, times)]]
    collapse_points = np.sqrt(kappa) * np.exp(-0.5 * times)
    c_ops = [[a, qutip.Cubic_Spline(times[0], times[-1], collapse_points)]]
    brme = qutip.brmesolve(H,
                           psi0,
                           times,
                           a_ops,
                           e_ops=[a.dag() * a],
                           c_ops=c_ops)
    assert np.mean(np.abs(brme.expect[0] - exact) / exact) < 1e-5
示例#6
0
    def do_pulse_sequence(self, lePulse, psi0, **kwargs):
        '''
		Run a detuning pulse sequence
		NOTE - some weird compiler errors have been observed using the Qutip Cubic_Spline functionality - don't blame me,
		this runs fine on my computer!
		Inputs:
			lePulse - pulse object as defined by PulseSequence class
			psi0 - initial state before pulse happens
			nsteps (optional) - max number of steps the solver can take. Sometimes needs to be increased for long sims
		'''
        nsteps = kwargs.get('nsteps', 500000)
        opts = qu.Options(nsteps)

        self.build_hamiltonian(detuning=0)
        initial_hamiltonian = self.Hamiltonian
        conversion_factor = self.alpha * const.eV / const.h  # Convert voltage pulse to frequency units
        detuning_hamiltonian = 2 * np.pi * conversion_factor * qu.Qobj(
            np.array([[1 / 2, 0, 0, 0, 0], [0, 1 / 2, 0, 0, 0],
                      [0, 0, 1 / 2, 0, 0], [0, 0, 0, 1 / 2, 0],
                      [0, 0, 0, 0, -1 / 2]]))
        # Cubic_Spline interpolation is how Qutip handles arbitrary time dependence as input. Look it up in their docs
        # if you want to know more.
        qutip_time_dependence = qu.Cubic_Spline(lePulse.time_vec[0],
                                                lePulse.time_vec[-1],
                                                lePulse.simulation_waveform)
        full_H = [
            initial_hamiltonian, [detuning_hamiltonian, qutip_time_dependence]
        ]
        output = qu.mesolve(full_H,
                            psi0,
                            tlist=lePulse.time_vec,
                            c_ops=[],
                            e_ops=[],
                            options=opts,
                            progress_bar=True)
        return output
示例#7
0
# Modified pulses
tau12_tilde_STA = lambda t: (derivative(eta, t, dx=dx_derivative) * np.cos(
    chi(t)) + derivative(chi, t, dx=dx_derivative) / (np.tan(eta(t)) + 1e-16) *
                             np.sin(chi(t))) / np.sqrt(2) * hbar
tau23_tilde_STA = lambda t: (derivative(chi, t, dx=dx_derivative) * np.cos(
    chi(t)) / (np.tan(eta(t)) + 1e-16) - derivative(eta, t, dx=dx_derivative) *
                             np.sin(chi(t))) / np.sqrt(2) * hbar

phase = np.pi / 2

prop = 1

pulse1 = tau12_tilde_STA
pulse2 = tau23_tilde_STA

tau12_interpolated = qt.Cubic_Spline(time[0], time[-1], pulse1(time))
tau23_interpolated = qt.Cubic_Spline(time[0], time[-1], pulse2(time))

psi0 = qt.basis(6, 0)

if __name__ == '__main__':
    results_list = []
    pbar = tqdm(total=n_total,
                desc='Processing',
                file=sys.stdout,
                ncols=90,
                bar_format='{l_bar}{bar}{r_bar}')

    start = timer.perf_counter()
    for i in range(0, np.int(np.ceil(n_total / chunksize))):
        initial = i * chunksize
示例#8
0
 def spline(self, times):
     return self, qutip.Cubic_Spline(times[0], times[-1], self(times))
示例#9
0
def _string_w_interpolating_t(kappa, times):
    spline = qutip.Cubic_Spline(times[0], times[-1], np.exp(-times))
    return ("{kappa} * (w >= 0)".format(kappa=kappa), spline)