Loading...
Searching...
No Matches
plot_single_particle.py
import matplotlib.pyplot as plt
import numpy as np
def z(t):
V_0 = 25.*9.64852558 * 10**4
m = 40.
d = 500.
w_z = np.sqrt((2.*V_0)/(m*d*d))
return 20.*np.cos(w_z*t)
def main():
filename = "output/simulate_single_particle/particle_0_r.txt"
r = t = []
with open(filename) as f:
lines = f.readlines()
t = np.linspace(0, 50, len(lines))
r = np.array([list(map(float, line.strip().split(","))) for line in lines])
plt.plot(t, r[:, 2], label="approximation")
plt.plot(t, z(t), label="analytical")
plt.xlabel(r"time $(\mu s)$")
plt.ylabel(r"z $(\mu m)$")
plt.title(r"Movement of a single particle in the x direction")
plt.legend()
# plt.savefig("../latex/images/single_particle.pdf")
plt.show()
if __name__ == "__main__":
main()