Ejemplo n.º 1
0
def create_disp_op_tf(betas, N_large=100, N=7):
    from simulator import operators as ops

    D = ops.DisplacementOperator(N_large)
    # Convert to lower-dimentional Hilbert space; shape=[N_alpha,N,N]
    disp_op = D(betas)[:, :N, :N]
    return disp_op
def create_disp_op_tf():
    from simulator import operators as ops
    N_large = 100 # dimension used to compute the tomography matrix
    D = ops.DisplacementOperator(N_large)
    # Convert to lower-dimentional Hilbert space; shape=[N_alpha,N,N]
    disp_op = D(grid_flat)[:,:N,:N] 
    return real(disp_op), imag(disp_op)
Ejemplo n.º 3
0
def create_displaced_parity_tf(alphas, N_large=100, N=7):
    from simulator import operators as ops

    D = ops.DisplacementOperator(N_large)
    P = ops.parity(N_large)

    displaced_parity = matmul(matmul(D(alphas), P), D(-alphas))
    # Convert to lower-dimentional Hilbert space; shape=[N_alpha,N,N]
    displaced_parity = displaced_parity[:, :N, :N]

    displaced_parity_re = real(displaced_parity)
    displaced_parity_im = imag(displaced_parity)
    return (displaced_parity_re, displaced_parity_im)
Ejemplo n.º 4
0
def create_displaced_parity_tf():
    from simulator import operators as ops
    N_large = 100 # dimension used to compute the tomography matrix
    D = ops.DisplacementOperator(N_large)
    P = ops.parity(N_large)

    displaced_parity = matmul(matmul(D(grid_flat), P), D(-grid_flat))
    # Convert to lower-dimentional Hilbert space; shape=[N_alpha,N,N]
    displaced_parity = displaced_parity[:,:N,:N] 
    
    displaced_parity_re = real(displaced_parity)
    displaced_parity_im = imag(displaced_parity)
    return (displaced_parity_re, displaced_parity_im)
Ejemplo n.º 5
0
    return np.mean(W - wigner['avg'])


background, norm, wigner_corrected, max_val = {}, {}, {}, {}
for s in ['g', 'e', 'avg']:
    # the integral in phase space is supposed to be 1
    background[s] = background_diff(wigner[s])
    norm[s] = np.sum(wigner[s] - background[s]) * A
    wigner_corrected[s] = (wigner[s] - background[s]) / norm[s]
    max_val[s] = np.max(np.abs(wigner_corrected[s]) / scale)

# Now find target Wigner
N = 100
fock = 4
state = utils.basis(fock, N)
D = operators.DisplacementOperator(N)
P = operators.parity(N)

x = tf.constant(xs, dtype=c64)
y = tf.constant(ys, dtype=c64)
one = tf.constant([1] * len(y), dtype=c64)
onej = tf.constant([1j] * len(x), dtype=c64)
grid = tf.tensordot(x, one, axes=0) + tf.tensordot(onej, y, axes=0)
grid_flat = tf.reshape(grid, [-1])

state = tf.broadcast_to(state, [grid_flat.shape[0], state.shape[1]])
state_translated = tf.linalg.matvec(D(-grid_flat), state)
W = scale * utils.expectation(state_translated, P, reduce_batch=False)
W_grid = tf.reshape(W, grid.shape)
wigner_target = W_grid.numpy().real
Ejemplo n.º 6
0
    res = minimize(cost_fn,
                   x0=[Ej, Ec, freq_a, V],
                   method='Nelder-Mead',
                   options=dict(maxiter=300))
    Ej, Ec, freq_a, V = res.x
else:
    Ec = 188598981
    Ej = 21608836632
    freq_a = 4481053074
    V = 23249563

# create operators in the joint Hilbert space
H0, H = Hamiltonian(Ej, Ec, freq_a, V)
U = ops.HamiltonianEvolutionOperator(H)
U0 = ops.HamiltonianEvolutionOperator(H0)
D = ops.DisplacementOperator(N_cav, tensor_with=[ops.identity(L), None])
q = tensor([ops.identity(L), ops.position(N_cav)])
p = tensor([ops.identity(L), ops.momentum(N_cav)])

SIMULATE_TIME_EVOLUTION = False
# simulate rotation of the displaced state
# Because H=const, this can be done with large steps in time
if SIMULATE_TIME_EVOLUTION:
    dt = 10e-9
    STEPS = 100
    times = tf.range(STEPS, dtype=tf.float32) * dt

    alpha = 20
    vac = Kronecker_product([basis(0, L), basis(0, N_cav)])
    psi0 = tf.linalg.matvec(D(alpha), vac)
    psi, psi_int = psi0, psi0