Ejemplo n.º 1
0
def test_3():
    '''Make this much more interactive'''
    from chemlab.graphics.processviewer import ProcessViewer
    boxsize = 30.0
    nmol = 1000
    sys = MonatomicSystem.random("Ar", nmol, boxsize)
    v = ProcessViewer()
    pr = v.add_renderer(SphereRenderer, sys.atoms)
    v.add_renderer(CubeRenderer, boxsize)
    
    for i in range(100):
        # Let's try to make periodic boundary conditions
        farray = forces.lennard_jones(sys.r_array, "Ar", periodic=boxsize)
        # Just this time let's assume masses are 1
        sys.r_array, sys.varray = integrators.euler(sys.r_array, sys.varray, farray/30.17, 0.01)
        
        # Add more periodic conditions
        rarray = sys.r_array
        
        i_toopositive = rarray > boxsize * 0.5
        rarray[i_toopositive] -= boxsize  
        i_toonegative = rarray < - boxsize * 0.5
        rarray[i_toonegative] += boxsize
        
        sys.r_array = rarray
        pr.update(rarray)
    
    v._p.join()
Ejemplo n.º 2
0
def test_1():
    boxsize = 50.0
    sys = MonatomicSystem.random("Ne",500, boxsize)
    #x, y = pair_correlation(sys, 20)
    #pl.plot(x, y)
    for i in range(1000):
        print "Step ", i
        farray = forces.lennard_jones(sys.r_array, "Ne", periodic=boxsize)
        # Just this time let's assume masses are 1
        sys.r_array, sys.varray = integrators.euler(sys.r_array, sys.varray, farray/300.17, 0.011)
        
        # Add more periodic conditions
        rarray = sys.r_array
        
        i_toopositive = rarray > boxsize * 0.5
        rarray[i_toopositive] -= boxsize  
        i_toonegative = rarray < - boxsize * 0.5
        rarray[i_toonegative] += boxsize
        
        sys.r_array = rarray