示例#1
0
def test_against_matrix_implementation():
    r'''Compare an Euler trajectory computed naively using matrices to the
    Euler trajectory computed by our implementation for a particular
    realization of noise.

    '''
    c_loaded = np.load('tests/matrix_euler_test_0/coupling_op.npy')
    MN_arr = np.load('tests/matrix_euler_test_0/M_N.npy')
    M_loaded = MN_arr[0]
    N_loaded = MN_arr[1]
    H_loaded = np.load('tests/matrix_euler_test_0/H.npy')
    times_loaded = np.load('tests/matrix_euler_test_0/times.npy')
    U1s_loaded = np.load('tests/matrix_euler_test_0/U1s.npy')
    rho0_loaded = np.load('tests/matrix_euler_test_0/rho_0.npy')
    rhos_loaded = np.load('tests/matrix_euler_test_0/rhos.npy')

    test_integrator = integrate.EulerHomodyneIntegrator(
        c_loaded, M_loaded, N_loaded, H_loaded)
    test_soln = test_integrator.integrate(rho0_loaded, times_loaded,
                                          U1s_loaded)
    test_rhos = test_soln.get_density_matrices()
    test_errors = test_rhos - rhos_loaded
    error_norms = [
        sb.norm_squared(test_errors[j]) for j in range(test_errors.shape[0])
    ]
    assert_almost_equal(max(error_norms), 0.0, 7)
示例#2
0
文件: tests.py 项目: CQuIC/pysme
def test_against_matrix_implementation():
    r'''Compare an Euler trajectory computed naively using matrices to the
    Euler trajectory computed by our implementation for a particular
    realization of noise.

    '''
    c_loaded = np.load('tests/matrix_euler_test_0/coupling_op.npy')
    MN_arr = np.load('tests/matrix_euler_test_0/M_N.npy')
    M_loaded = MN_arr[0]
    N_loaded = MN_arr[1]
    H_loaded = np.load('tests/matrix_euler_test_0/H.npy')
    times_loaded = np.load('tests/matrix_euler_test_0/times.npy')
    U1s_loaded = np.load('tests/matrix_euler_test_0/U1s.npy')
    rho0_loaded = np.load('tests/matrix_euler_test_0/rho_0.npy')
    rhos_loaded = np.load('tests/matrix_euler_test_0/rhos.npy')

    test_integrator = integrate.EulerHomodyneIntegrator(c_loaded, M_loaded,
                                                        N_loaded, H_loaded)
    test_soln = test_integrator.integrate(rho0_loaded, times_loaded,
                                          U1s_loaded)
    test_rhos = test_soln.get_density_matrices()
    test_errors = test_rhos - rhos_loaded
    error_norms = [sb.norm_squared(test_errors[j])
                   for j in range(test_errors.shape[0])]
    assert_almost_equal(max(error_norms), 0.0, 7)
示例#3
0
文件: tests.py 项目: eliegenois/pysme
def test_against_random_spin1_matrix_euler_test_vector():
    with open('tests/random-spin1-matrix-euler-test-vector.npz', 'rb') as f:
        test_vec = np.load(f)
        Ls = test_vec['Ls']
        H = test_vec['H']
        rho0 = test_vec['rho0']
        times = test_vec['times']
        loaded_rhos = test_vec['rhos']
    integrator = integrate.UncondLindbladIntegrator(Ls, 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)
示例#4
0
文件: tests.py 项目: eliegenois/pysme
def test_against_t1_t2_matrix_euler_test_vector():
    with open('tests/t1-t2-matrix-euler-test-vector.npz', 'rb') as f:
        test_vec = np.load(f)
        Ls = test_vec['Ls']
        H = test_vec['H']
        rho0 = test_vec['rho0']
        times = test_vec['times']
        loaded_rhos = test_vec['rhos']
    integrator = integrate.UncondLindbladIntegrator(Ls, 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. Maybe I'll bother to get an analytic expression one of these
    # days.
    assert_almost_equal(max(error_norms), 0.0, 6)
示例#5
0
 def get_phys_dual_basis(self, field_rho_0):
     return np.array([
         sb.dualize(np.kron(basis_el, field_rho_0), self.basis).real /
         sb.norm_squared(basis_el) for basis_el in self.basis_sys
     ])