xs = [] ys = [] # screenshot_schedule = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1] # screen_index = 0 # sleep(5) while not problem.is_finished(): prev_time = problem._time problem.iterate() # if prev_time <= screenshot_schedule[screen_index] and \ # problem._time >= screenshot_schedule[screen_index]: # getoutput("xwd -name \"Chimera Graph\" | convert xwd:- images/image_{0:03}.png".format(int(problem._time * 100))) # screen_index += 1 energy = problem.hamiltonian() xs.append(problem._time) ys.append(energy) print(problem._time, energy) xs = np.array(xs) ys = np.array(ys) np.save("times", xs) np.save("energy", ys) plt.title("Ground State Energy Over Time (A = A(1), B = B(1))") plt.xlabel("Time $(t / t_f)$") plt.ylabel("Energy (GHz)") plt.plot(xs, ys) plt.savefig("plot.png")