def ce(m):
    l = 0.0
    dl = 0.001
    k = 0.0
    tt = []
    ll = []
    while k >= 0:
        k = sp.mathieu_a(m, l)
        tt.append(k)
        ll.append(l)
        l = l + dl
    l = 0
    k = 0
    while k >= 0.0:
        k = sp.mathieu_a(m, l)
        tt.append(k)
        ll.append(l)
        l = l - dl
    return (ll, tt)
Exemple #2
0
def transmon_spectrum2(x, EJ, Ec, d, offset, period):
    from scipy.special import mathieu_a, mathieu_b
    from waveforms.quantum.transmon import Transmon

    x = (x - offset) / period
    q = 0.5 * Transmon._flux_to_EJ(x, EJ, d) / Ec

    # if ng == 0:
    #     return Ec * (mathieu_b(2, -q) - mathieu_a(0, -q))
    # if ng == 0.5:
    #     return Ec * (mathieu_b(1, -q) - mathieu_a(0, -q))
    return Ec * (mathieu_b(1, -q) + mathieu_b(2, -q) -
                 2 * mathieu_a(0, -q)) / 2
def transmon_energies_calc(params):
    Ec = params.Ec
    Ej = params.Ej
    q = -Ej / (2 * Ec)
    n_levels = params.t_levels
    n_even = n_levels // 2 + n_levels % 2
    n_odd = n_levels // 2
    even_levels = np.arange(0, 2 * n_even, 2)
    odd_levels = np.arange(2, 2 * (n_odd + 1), 2)
    even_energies = Ec * special.mathieu_a(even_levels, q)
    odd_energies = Ec * special.mathieu_b(odd_levels, q)
    energies = np.hstack([even_energies, odd_energies])
    sorted_energies = np.sort(energies)
    sorted_energies -= sorted_energies[0]
    return sorted_energies
Exemple #4
0
def transmon_eigenvalue(m, my_ng):
    """
    This function calculate the energy eigenvalue of the transmon qubit for a given
    energy level (m) and offset charge (my_ng). The input values are first used to
    calculate the index using the function defined above, and then the calculated
    index is used to calculate the energy eigenvalue using Mathieu's characteristic values.

        Args:
            m (int): The energy level of the qubit (m=0,1,2,3,etc.)
            ng (float): the offset charge of the Josephjunction island (in units of 2e)

        Returns:
            float: the calculated energy eigenvalue.
    """
    index = kidx(m, my_ng)
    return (E_C) * mathieu_a(index, -0.5 * RATIO)
Exemple #5
0
def solve_mathiue_dgl(t0, tmax, N, m, q):
    a = mathieu_a(m, q)
    y0 = mathieu_cem(m, q, 0)
    
    t = np.linspace(t0, tmax, N, endpoint=True)
    res = np.empty(shape=(3,N))
    res[0,0] = t[0]
    res[1,0], res[2,0] = y0
    
    r = ode(dgl_mathieu)
    r.set_integrator('lsoda', atol=1e-10, rtol=1e-10)
    r.set_initial_value(y=y0, t=t0)
    r.set_f_params(a, q)
     
    for i in range(1, N):
        r.integrate(t[i])
        res[0,i] = r.t
        res[1,i], res[2,i] = r.y
    return res
Exemple #6
0
    def evalue_k(self, k: int):
        """
        Return the eigenvalue of the Hamiltonian for level k.

        Arguments:
            k (int): Index of the eigenvalue

        Returns:
            float: eigenvalue of the Hamiltonian
        """
        if self._ng == 0:
            index = k + 1.0 - ((k + 1.0) % 2.0)
        else:
            index = k + 1.0 - ((k + 1.0) % 2.0) + 2.0 * self._ng * (
                (-1.0)**(k - 0.5 * (np.sign(self._ng) - 1.0)))

        self.evals = self._Ec * mathieu_a(index, -0.5 * self._Ej / self._Ec)
        #return self.evals[k]
        return self.evals
Exemple #7
0
    def _mathieu_characteristic_a(self, s):
        """
        Returns characteristic value 'a' of the Mathieu function for biasing
        parameter `s'.

        Notation from https://en.wikipedia.org/wiki/Mathieu_function.

        Parameters
        ----------
        s : float
            Biasing parameter.

        Returns
        -------
        a : float
            Characteristic value 'a' of the Mathieu function.
        """

        return special.mathieu_a(self._mathieu_order,
                                 self._mathieu_characteristic_q(s))
Exemple #8
0
        if (m % 2 == 0):
            h = h + r[i] * np.sin(2 * i * z)
        else:
            h = h + r[i] * np.sin((2 * i + 1) * z)
    return (t, h)


def actfc(m, q, z):
    #z=degrad(z)
    return (sp.mathieu_cem(m, q, z)[0], sp.mathieu_sem(m, q, z)[0])


dq = 0.1
for i in range(1, 5):

    q = 0.0
    while q < 10.0:
        xx = []
        yy = []
        for j in range(360):
            tf = fc(i, q, j)
            rf = actfc(i, q, j)
            xx.append(rf[0])
            yy.append(j)
            print(str(tf[0]) + '-' + str(rf[0]))
        print(sp.mathieu_a(i, q))
        plt.plot(yy, xx, label='m-' + str(i) + ';q-' + str(q))
        plt.legend()
        plt.show()
        q = q + dq
Exemple #9
0
def test_distributed_mathieu():
    q_min = 0
    q_max = 15
    q_N = 50
    m = 3
    
    t0 = 0
    t1 = 2*np.pi
    
    N = q_N
    
    # t0, t1, N, f, args, x0, integrator, verbose
    const_arg = jm.hashDict()
    const_arg['t0'] = t0
    const_arg['t1'] = t1
    const_arg['N'] = N
    const_arg['f'] = dgl_mathieu
    const_arg['integrator'] = 'vode'
    const_arg['atol'] = 1e-10
    const_arg['rtol'] = 1e-10
    const_arg['verbose'] = 0
    
    authkey = 'integration_jm'
    
    with jm.JobManager_Local(client_class = jm.clients.Integration_Client_REAL,
                             authkey = authkey,
                             port = 42525,
                             const_arg = const_arg,
                             nproc=1,
                             verbose_client=2,
                             niceness_clients=0,
                             show_statusbar_for_jobs=False) as jm_int:
        q_list = np.linspace(q_min, q_max, q_N)
        for q in q_list:
            arg = jm.hashDict()
            a = mathieu_a(m, q)
            arg['args'] = (a, q)
            arg['x0'] = mathieu_cem(m, q, 0) # gives value and its derivative
            jm_int.put_arg(a=arg)        
        
        jm_int.start()
        
    data = np.empty(shape=(3, q_N*N), dtype=np.float64)
    
    t_ref = np.linspace(t0, t1, N)
    
    tot_time = 0
    
    max_diff_x = 0
    max_diff_x_dot = 0
    
        
    for i, f in enumerate(jm_int.final_result):
        arg = f[0]
        res = f[1]
        
        a, q = arg['args']
        t, x_t = f[1]
        
        assert np.max(np.abs(t_ref - t)) < 1e-15
        time1 = time.time()
        res = solve_mathiue_dgl(t0, t1, N, m, q)
        time2 = time.time()
        tot_time += (time2 - time1)
        
        max_diff_x = max(max_diff_x, np.max(np.abs(x_t[:,0] - res[1,:])))
        max_diff_x_dot = max(max_diff_x_dot, np.max(np.abs(x_t[:,1] - res[2,:])))        
        
        data[0, i*q_N: (i+1)*q_N] = t
        data[1, i*q_N: (i+1)*q_N] = q
        data[2, i*q_N: (i+1)*q_N] = np.real(x_t[:,0])

    assert max_diff_x < 1e-6, max_diff_x       
    assert max_diff_x_dot < 1e-6, max_diff_x_dot 
    print("time normal integration:", tot_time)
Exemple #10
0
    return float(i == j)


# physical constants
# plank constant
hplank = 6.626e-34
# reduced plank constant
hbar = hplank / 2 / pi
# electron charge
e = 1.6e-19
# magnetic flux quantum
Fi0 = hplank / 2 / e
GHz = 1e9

cattet = lambda x: x + 1 - (x + 1) % 2
Ek_func = lambda x, Ec, Ej: mathieu_a(cattet(x), -2 * Ej / Ec) * Ec / 4


class Qubit(object):
    def __init__(self, Cq=1.01e-13, Cx=1e-16, Cg=1e-14, Ic=30e-9):
        self.Cx = Cx
        self.Cq = Cq
        self.Cg = Cg
        self.C = self.Cq + self.Cx + self.Cg
        self.Ic = 30e-9


def dummyExternalDrive2D(t, epsilon, f_c):
    theta = pi / 2 - (2 * pi * epsilon + f_c) * t
    return [-sin(theta), cos(theta)]