made some changes here.
This commit is contained in:
parent
513dacb44a
commit
173de67820
|
@ -33,6 +33,7 @@ measure_coefficient_mask = [False if (i & measure) else True for i in range(2**n
|
||||||
results_qc = []
|
results_qc = []
|
||||||
results_np = []
|
results_np = []
|
||||||
errors_sampling = []
|
errors_sampling = []
|
||||||
|
amplitudes_qc = []
|
||||||
|
|
||||||
print()
|
print()
|
||||||
for t in np.arange(0, t_stop, delta_t):
|
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)
|
result = sample(state, measure, n_sample)
|
||||||
results_qc.append(result[0] / 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))
|
#amplitude = np.sum(np.abs(state._qm_state[measure_coefficient_mask])**2)
|
||||||
#results_qc.append(amplitude)
|
#amplitudes_qc.append(amplitude)
|
||||||
|
|
||||||
# Simulation using matrices
|
# Simulation using matrices
|
||||||
np_zero_state = np.zeros(2**nqbits)
|
np_zero_state = np.zeros(2**nqbits)
|
||||||
|
@ -68,16 +69,17 @@ print("done.")
|
||||||
|
|
||||||
results_qc = np.array(results_qc)
|
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)
|
errors_sampling = np.array(errors_sampling)
|
||||||
|
|
||||||
|
|
||||||
h0 = plt.errorbar(np.arange(0, t_stop, delta_t)
|
h0 = plt.errorbar(np.arange(0, t_stop, delta_t)
|
||||||
, results_qc
|
, results_qc
|
||||||
, yerr=(errors_trotter + errors_sampling)
|
, yerr=errors_sampling
|
||||||
, label=f"Quantum computing ({n_sample} samples, {N_trot} trotterization steps)"
|
, 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")
|
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.xlabel("t")
|
||||||
plt.ylabel(r"$|0\rangle$ probability amplitude for second spin")
|
plt.ylabel(r"$|0\rangle$ probability amplitude for second spin")
|
||||||
plt.title(f"{nqbits} site spin chain with g={g} coupling to external field")
|
plt.title(f"{nqbits} site spin chain with g={g} coupling to external field")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user