Esempio n. 1
0
def make_sqz_trunc_osc_src_integrator(n_max, E, g_cavity, c_sys, H_sys):
    total_SLH = series_SLH(
        {
            'S': np.eye(c_sys.shape[0], dtype=c_sys.dtype),
            'L': c_sys,
            'H': H_sys
        }, sqz_trunc_osc_src_SLH(n_max, E, g_cavity))
    return integ.UncondGaussIntegrator(total_SLH['L'], 0, 0, total_SLH['H'])
Esempio n. 2
0
def test_against_random_spin1_gauss_matrix_euler_test_vector():
    with open('tests/random-spin1-gauss-matrix-euler-test-vector.npz', 'rb') as f:
        test_vec = np.load(f)
        c_op = test_vec['c_op']
        H = test_vec['H']
        rho0 = test_vec['rho0']
        times = test_vec['times']
        loaded_rhos = test_vec['rhos']
        N = float(test_vec['N'])
        M = complex(test_vec['M'])
    integrator = integrate.UncondGaussIntegrator(c_op, M, N, H)
    soln = integrator.integrate(rho0, times)
    rhos = soln.get_density_matrices()
    errors = rhos - loaded_rhos
    error_norms = [sb.norm_squared(errors[j])
                   for j in range(errors.shape[0])]
    # Normally I'm checking to 7 decimal places, but my Euler integrator
    # seems to only be able to get within 6 decimal places of the vectorized
    # solution. Analytic solution for a random instance like this is probably
    # not going to happen.
    assert_almost_equal(max(error_norms), 0.0, 6)
Esempio n. 3
0
 def make_integrator(self, c_op, E, g, H):
     total_SLH = series_SLH(
         {
             'S': np.eye(c_op.shape[0], dtype=c_op.dtype),
             'L': c_op,
             'H': H
         }, sqz_trunc_osc_src_SLH(self.n_max, E, g))
     c_total = total_SLH['L']
     H_total = total_SLH['H']
     common_dict = self.basis_common_dict.copy()
     common_dict['C_vector'] = sb.vectorize(c_total, common_dict['basis'])
     common_dict['H_vector'] = sb.vectorize(H_total, common_dict['basis'])
     D_c = sb.diffusion_op(**common_dict)
     F = sb.hamiltonian_op(**common_dict)
     drift_rep = D_c + F
     return integ.UncondGaussIntegrator(c_total,
                                        0,
                                        0,
                                        H_total,
                                        basis=common_dict['basis'],
                                        drift_rep=drift_rep)
Esempio n. 4
0
def check_system_builder_double_comm_op():
    sx = np.array([[0, 1], [1, 0]], dtype=np.complex)
    sm = np.array([[0, 0], [1, 0]], dtype=np.complex)
    Id = np.eye(2, dtype=np.complex)
    zero = np.zeros((2, 2), dtype=np.complex)
    r = np.log(2)
    N = np.sinh(r)**2
    M = -np.sinh(r) * np.cosh(r)
    H = zero
    c_op = sm
    c_op_dag = c_op.conjugate().T
    rho0 = (Id + sx) / 2
    integrator = integrate.UncondGaussIntegrator(c_op, M, N, H)
    rho0_vec = sb.vectorize(rho0, integrator.basis)
    partial_basis = integrator.basis[:-1]
    common_dict = sb.op_calc_setup(c_op, M, N, H, partial_basis)
    E = sb.double_comm_op(**common_dict)
    vec_double_comm = E @ rho0_vec
    matrix_double_comm = ((M / 2) * mf.comm(c_op_dag, mf.comm(c_op_dag, rho0))
                          + (M.conjugate() / 2) * mf.comm(c_op,
                                                          mf.comm(c_op, rho0)))
    check_mat_eq(np.einsum('k,kmn->mn', vec_double_comm, integrator.basis),
                 matrix_double_comm)