def test_4atoms(): a = Atom("Ar", [ 0.5, 0.5, 0]) b = Atom("Ar", [ 0.5,-0.5, 0]) c = Atom("Ar", [-0.2,-0.5, 0]) d = Atom("Ar", [-0.5, 0.5, 0.5]) sys = MonatomicSystem([a,b,c,d], 6.0) v = Viewer() sr = v.add_renderer(SphereRenderer, sys.atoms) v.add_renderer(CubeRenderer, sys.boxsize) # evo takes times in picoseconds evo = evolve_generator(sys, t=1e3, tstep=0.002, periodic=True) def update_pos(): try: for i in range(100): sys, t = evo.next() sr.update(sys.r_array) except StopIteration: pass #import pylab as pl #pl.plot(distances, pitentials, 'o') #pl.show() v.schedule(update_pos) v.run()
def test_4atoms(): a = Atom("Ar", [0.5, 0.5, 0]) b = Atom("Ar", [0.5, -0.5, 0]) c = Atom("Ar", [-0.2, -0.5, 0]) d = Atom("Ar", [-0.5, 0.5, 0.5]) sys = MonatomicSystem([a, b, c, d], 6.0) v = Viewer() sr = v.add_renderer(SphereRenderer, sys.atoms) v.add_renderer(CubeRenderer, sys.boxsize) # evo takes times in picoseconds evo = evolve_generator(sys, t=1e3, tstep=0.002, periodic=True) def update_pos(): try: for i in range(100): sys, t = evo.next() sr.update(sys.r_array) except StopIteration: pass #import pylab as pl #pl.plot(distances, pitentials, 'o') #pl.show() v.schedule(update_pos) v.run()
def test_periodic(): '''Now let's try to implement the periodic boundaries, we should try to put the molecules near the border and see if one molecule 'passes' the wall. ''' import pyglet pyglet.options['vsync'] = False # Let's say we have to store this in nm and picoseconds # I setup argon atoms pretty overlapping a = Atom("Ar", [0.5, 0.0, 0.0]) b = Atom("Ar", [-1.4, 0.0, 0.0]) sys = MonatomicSystem([a, b], 3.0) v = Viewer() sr = v.add_renderer(SphereRenderer, sys.atoms) v.add_renderer(CubeRenderer, sys.boxsize) # evo takes times in picoseconds evo = evolve_generator(sys, t=1e3, tstep=0.002, periodic=True) distances = [np.linalg.norm(sys.r_array[0] - sys.r_array[1])] pitentials = [ cenergy.lennard_jones(sys.r_array * 1e-9, 'Ar', periodic=False) ] def update_pos(): try: for i in range(100): sys, t = evo.next() dist = np.linalg.norm(sys.r_array[0] - sys.r_array[1]) pot = cenergy.lennard_jones(sys.r_array * 1e-9, 'Ar', periodic=False) distances.append(dist) pitentials.append(pot) sr.update(sys.r_array) except StopIteration: pass #import pylab as pl #pl.plot(distances, pitentials, 'o') #pl.show() v.schedule(update_pos) v.run()
def test_forces(): '''This test simply shows two atoms that are subject to a lennard jones potential. you can modulate the distance between atoms and see if this physically makes sense. For example two atoms at a distance of about 1.5sigma should bounce. ''' import pyglet pyglet.options['vsync'] = False # Let's say we have to store this in nm and picoseconds # I setup argon atoms pretty overlapping a = Atom("Ar", [0.0, 0.0, 0.0]) b = Atom("Ar", [1.00, 0.0, 0.0]) sys = MonatomicSystem([a, b], 3.0) v = Viewer() sr = v.add_renderer(SphereRenderer, sys.atoms) v.add_renderer(CubeRenderer, sys.boxsize) # evo takes times in picoseconds evo = evolve_generator(sys, t=1e2, tstep=0.002, periodic=False) distances = [np.linalg.norm(sys.r_array[0] - sys.r_array[1])] pitentials = [ cenergy.lennard_jones(sys.r_array * 1e-9, 'Ar', periodic=False) ] def update_pos(): try: for i in range(100): sys, t = evo.next() dist = np.linalg.norm(sys.r_array[0] - sys.r_array[1]) pot = cenergy.lennard_jones(sys.r_array * 1e-9, 'Ar', periodic=False) distances.append(dist) pitentials.append(pot) sr.update(sys.r_array) except StopIteration: import pylab as pl pl.plot(distances, pitentials, 'o') pl.show() v.schedule(update_pos) v.run()
def test_periodic(): '''Now let's try to implement the periodic boundaries, we should try to put the molecules near the border and see if one molecule 'passes' the wall. ''' import pyglet pyglet.options['vsync'] = False # Let's say we have to store this in nm and picoseconds # I setup argon atoms pretty overlapping a = Atom("Ar", [ 0.5, 0.0, 0.0]) b = Atom("Ar", [ -1.4, 0.0, 0.0]) sys = MonatomicSystem([a,b], 3.0) v = Viewer() sr = v.add_renderer(SphereRenderer, sys.atoms) v.add_renderer(CubeRenderer, sys.boxsize) # evo takes times in picoseconds evo = evolve_generator(sys, t=1e3, tstep=0.002, periodic=True) distances = [np.linalg.norm(sys.r_array[0] - sys.r_array[1])] pitentials = [cenergy.lennard_jones( sys.r_array * 1e-9, 'Ar', periodic=False)] def update_pos(): try: for i in range(100): sys, t = evo.next() dist = np.linalg.norm(sys.r_array[0] - sys.r_array[1]) pot = cenergy.lennard_jones( sys.r_array * 1e-9, 'Ar', periodic=False) distances.append(dist) pitentials.append(pot) sr.update(sys.r_array) except StopIteration: pass #import pylab as pl #pl.plot(distances, pitentials, 'o') #pl.show() v.schedule(update_pos) v.run()
def test_forces(): '''This test simply shows two atoms that are subject to a lennard jones potential. you can modulate the distance between atoms and see if this physically makes sense. For example two atoms at a distance of about 1.5sigma should bounce. ''' import pyglet pyglet.options['vsync'] = False # Let's say we have to store this in nm and picoseconds # I setup argon atoms pretty overlapping a = Atom("Ar", [ 0.0, 0.0, 0.0]) b = Atom("Ar", [ 1.00, 0.0, 0.0]) sys = MonatomicSystem([a,b], 3.0) v = Viewer() sr = v.add_renderer(SphereRenderer, sys.atoms) v.add_renderer(CubeRenderer, sys.boxsize) # evo takes times in picoseconds evo = evolve_generator(sys, t=1e2, tstep=0.002, periodic=False) distances = [np.linalg.norm(sys.r_array[0] - sys.r_array[1])] pitentials = [cenergy.lennard_jones( sys.r_array * 1e-9, 'Ar', periodic=False)] def update_pos(): try: for i in range(100): sys, t = evo.next() dist = np.linalg.norm(sys.r_array[0] - sys.r_array[1]) pot = cenergy.lennard_jones( sys.r_array * 1e-9, 'Ar', periodic=False) distances.append(dist) pitentials.append(pot) sr.update(sys.r_array) except StopIteration: import pylab as pl pl.plot(distances, pitentials, 'o') pl.show() v.schedule(update_pos) v.run()