%pylab inline
Populating the interactive namespace from numpy and matplotlib
#Load the simulation
from pythonmd.simcore import MDSimulationSession
%%file effusion
[MD Simulation]
number_of_molecules: 400
box_width: 600
box_height: 300
wall: effusion
wall_pos: 300
wall_hole: 0
Overwriting effusion
time = []
n_left = []
n_right = []
t_left = []
t_right = []
session = MDSimulationSession('effusion')
session.run_until_t(4)
session.run(100)
session.run_until_t(2)
session.run_until_equilibrium(delta_t=1e-05)
current_time, t_l, _, _, n_l = session.get_left_stats()
_, t_r, _, _, n_r = session.get_right_stats()
time.append(current_time)
n_left.append(n_l)
n_right.append(n_r)
t_left.append(t_l)
t_right.append(t_r)
session.change_hole(10)
session.reset_statistics()
for _ in range(60000):
session.run(1)
current_time, t_l, _, _, n_l = session.get_left_stats()
_, t_r, _, _, n_r = session.get_right_stats()
time.append(current_time)
n_left.append(n_l)
n_right.append(n_r)
t_left.append(t_l)
t_right.append(t_r)
plt.plot(time, n_left, label='left')
plt.plot(time, n_right, color='red', label='right')
plt.xlabel("Time ($\sigma\sqrt{m/\epsilon}$)")
plt.ylabel("Number of Molecules")
plt.legend(loc='best')
<matplotlib.legend.Legend at 0x7f6d2109ae48>
plt.plot(time, t_left, label='left')
plt.plot(time, t_right, color='red', label='right')
plt.xlabel("Time ($\sigma\sqrt{m/\epsilon}$)")
plt.ylabel("Temperature ($\epsilon/k_b$)")
plt.legend(loc='best')
<matplotlib.legend.Legend at 0x7f6d21384898>
average_n_left = (sum(n_left[32000:])/len(n_left[32000:]))
average_t_left = (sum(t_left[32000:])/len(t_left[32000:]))
average_n_right = (sum(n_right[32000:])/len(n_right[32000:]))
average_t_right = (sum(t_right[32000:])/len(t_right[32000:]))
print("Initial time of equilibrium: %i" % time[32000])
print("Average n left: %.4f" % average_n_left)
print("Average T left: %.4f" % average_t_left)
print("Average n right: %.4f" % average_n_right)
print("Average T right: %.4f" % average_t_right)
print(average_n_left*math.sqrt(average_t_left)/(average_n_right*math.sqrt(average_t_right)))
Initial time of equilibrium: 59871 Average n left: 202.8934 Average T left: 1.6886 Average n right: 197.1066 Average T right: 1.7866 1.0007316671