made some changes here.

This commit is contained in:
Daniel Knüttel 2020-04-14 18:43:59 +02:00
parent 513dacb44a
commit 173de67820

View File

@ -33,6 +33,7 @@ measure_coefficient_mask = [False if (i & measure) else True for i in range(2**n
results_qc = []
results_np = []
errors_sampling = []
amplitudes_qc = []
print()
for t in np.arange(0, t_stop, delta_t):
@ -46,10 +47,10 @@ for t in np.arange(0, t_stop, delta_t):
result = sample(state, measure, n_sample)
results_qc.append(result[0] / n_sample)
errors_sampling.append(bootstrap(result[0], n_sample, n_sample // 4, n_sample // 10, np.average))
errors_sampling.append(bootstrap(result[0], n_sample, n_sample, n_sample // 2, np.average))
#amplitude = np.sqrt(np.sum(np.abs(state._qm_state[measure_coefficient_mask])**2))
#results_qc.append(amplitude)
#amplitude = np.sum(np.abs(state._qm_state[measure_coefficient_mask])**2)
#amplitudes_qc.append(amplitude)
# Simulation using matrices
np_zero_state = np.zeros(2**nqbits)
@ -68,16 +69,17 @@ print("done.")
results_qc = np.array(results_qc)
errors_trotter = (np.arange(0, t_stop, delta_t) * g)**2 / N_trot**2
errors_trotter = (np.arange(0, t_stop, delta_t) * g)**3 / N_trot**3
errors_sampling = np.array(errors_sampling)
h0 = plt.errorbar(np.arange(0, t_stop, delta_t)
, results_qc
, yerr=(errors_trotter + errors_sampling)
, yerr=errors_sampling
, label=f"Quantum computing ({n_sample} samples, {N_trot} trotterization steps)"
, )
h1, = plt.plot(np.arange(0, t_stop, delta_t), results_np, label="Classical simulation using explicit transfer matrix")
#h2, = plt.plot(np.arange(0, t_stop, delta_t), amplitudes_qc, label="QC amplitude")
plt.xlabel("t")
plt.ylabel(r"$|0\rangle$ probability amplitude for second spin")
plt.title(f"{nqbits} site spin chain with g={g} coupling to external field")