Hello,
I am new to python and I am taking a computational simulation class and my professor suggested to me to use python. I am an ESL, maybe I do not understand what does he want from me for the homework. Here is the question:
For each thermostat, do the following:
a) Plot the trajectory of the particle movement in x-y plane.
b) Test your two thermostat implementations by making a histogram of the probability of nding the
system in a small window around x=0.5 as a function of y. Compare your histograms to canonical
distribution (plot canonical distribution along with the histogram).
Implement the following thermostats:
I am able to draw the plot for the part a. However, I could not draw the right histogram for part b. The professor showed in the class that the probability distribution should also include a Boltzmann distribution line. I attached my codes. I hope that somebody helps me to clarify this situation. Thank you in advance.
I am new to python and I am taking a computational simulation class and my professor suggested to me to use python. I am an ESL, maybe I do not understand what does he want from me for the homework. Here is the question:
For each thermostat, do the following:
a) Plot the trajectory of the particle movement in x-y plane.
b) Test your two thermostat implementations by making a histogram of the probability of nding the
system in a small window around x=0.5 as a function of y. Compare your histograms to canonical
distribution (plot canonical distribution along with the histogram).
Implement the following thermostats:
I am able to draw the plot for the part a. However, I could not draw the right histogram for part b. The professor showed in the class that the probability distribution should also include a Boltzmann distribution line. I attached my codes. I hope that somebody helps me to clarify this situation. Thank you in advance.
import numpy as np import matplotlib.pyplot as plt t = 0 #initial time N = 10 #duration of simulation dt = 0.01 #timestep of integration m = 1 #mass of a single single particle x1 = 0.5 vx1 = 0.3 y1 = 0 vy1 = 0.3 while t <= N: Fx0=(2*(np.pi)*np.sin(2*(np.pi)*x1))*((4*y1) + 1) Fy0=(-4*np.cos(2*(np.pi)*x1)) - (4*y1*((np.pi)**2)) x1 = x1 + dt*vx1 + ((dt**2)*0.5*(Fx0/m)) #positons at current time y1 = y1 + dt*vy1 + ((dt**2)*0.5*(Fy0/m)) Fx=2*(np.pi)*np.sin(2*(np.pi)*x1)*((4*y1) + 1) Fy=(-4*np.cos(2*(np.pi)*x1)) - (4*y1*((np.pi)**2)) vx1 = vx1 + 0.5*dt*(Fx+Fx0)/m #calculate new velocities vy1 = vy1 + 0.5*dt*(Fy+Fy0)/m plt.scatter(x1,y1) # Plot function t = t + dt plt.title('Particle Movement') plt.xlabel('x') plt.ylabel('y') plt.savefig('hw3_traj.tiff',dpi=300) plt.show()