Example #1
0
def anim(x,y,z):
    f = mlab.gcf()
    plt = mlab.points3d(x,y,z, colormap="copper", scale_factor=.25)
    while(True):
        # TODO: Paralelize
        md.evolve(25)
        x,y,z = md.get_positions()
        stats = md.system_stats()
        print('Temp',stats[-1])
        plt.mlab_source.set(x=x, y=y, z=z)
        f.scene.render()
        yield
Example #2
0
                   dt=dt)

x,y,z,px,py,pz = md.set_particles()

Ek = np.zeros(snapshots+1)
V  = np.zeros(snapshots+1)
Vs = np.zeros(snapshots+1)
T  = np.zeros(snapshots+1)
P  = np.zeros(snapshots+1)

t = np.arange(float(snapshots+1))
t *= dt*steps_per_snapshot
t_max = np.max(t)

# Oth step
stats = md.system_stats()
Ek[0] = stats[0]
V[0] = stats[1]
Vs[0] = stats[2]
P[0] = stats[3]
T[0] = stats[4]

# perform simulation and count statistics
for s in xrange(snapshots):
    print("step",s*steps_per_snapshot)
    s += 1
    
    md.evolve(steps_per_snapshot)
    
    stats = md.system_stats()
    Ek[s] = stats[0]
Example #3
0
plt.axvline(math.sqrt(2*kb*T0/m),color='red')
plt.title("velocity histogram")
plt.xlabel("velocity")
plt.ylabel("frequency")

#plt.show()
plt.savefig('velocity_histogram.pdf')
plt.clf()


print()
print('# SYSTEM STATISTICS')
print('mean momentum via Python: ({},{},{})'.format(np.mean(px),np.mean(py),np.mean(pz)))

sprinigness_pot_buff = L-np.sqrt(x**2+y**2+z**2);
stats = md.system_stats()
print('stats array shape:',stats.shape)
print('Kinetic energy   :\t',stats[0],'\t kinetic energy via Python',0.5*np.sum(px**2+py**2+pz**2)/m)
print('LJ potential     :\t',stats[1],'\t LJ pot. energy via Python')
print('spring. potential:\t',stats[2],'\t                via Python', 0.5*f*np.sum((sprinigness_pot_buff[np.where(sprinigness_pot_buff >= 0.)])**2))
print('pressure         :\t',stats[4],'\t                via Python')

# ###################################################################################### #
#                                                                                        #
#                              TESTING RESET LATTICE METHOD                              #
#                                                                                        #
# ###################################################################################### #

print()
md.reset_lattice()
stats_reset = md.system_stats()