Exemplo n.º 1
0
def test_merge_system():
    # take a protein
    from chemlab.io import datafile
    from chemlab.graphics import display_system

    from chemlab.db import ChemlabDB

    water = ChemlabDB().get("molecule", "example.water")

    prot = datafile("tests/data/3ZJE.pdb").read("system")

    # Take a box of water
    NWAT = 50000
    bsize = 20.0
    pos = np.random.random((NWAT, 3)) * bsize
    wat = water.copy()

    s = System.empty(NWAT, NWAT * 3, box_vectors=np.eye(3) * bsize)
    for i in range(NWAT):
        wat.move_to(pos[i])
        s.add(wat)

    prot.r_array += 10
    s = merge_systems(s, prot, 0.5)

    display_system(s, 'ball-and-stick')
Exemplo n.º 2
0
def test_merge_system():
    # take a protein
    from chemlab.io import datafile
    from chemlab.graphics import display_system

    from chemlab.db import ChemlabDB

    water = ChemlabDB().get("molecule", "example.water")

    prot = datafile("tests/data/3ZJE.pdb").read("system")

    # Take a box of water
    NWAT = 50000
    bsize = 20.0
    pos = np.random.random((NWAT, 3)) * bsize
    wat = water.copy()

    s = System.empty(NWAT, NWAT*3, box_vectors=np.eye(3)*bsize)
    for i in range(NWAT):
        wat.move_to(pos[i])
        s.add(wat)

    prot.r_array += 10
    s = merge_systems(s, prot, 0.5)

    display_system(s, 'ball-and-stick')
def test_canonical():
    '''test for Canonical Ensemble'''
    # Liquid argon Near experimental density
    sys = MonatomicSystem.spaced_lattice('Ar', 100, 5.0) 
    
    energies = []
    pot = []
    kin = []
    times = []
    
    display_system(sys)
    gen = evolve_generator(sys, 100.0, 0.002)

    count = 0
    
    for sys, t in gen:
        v = cenergy.lennard_jones(sys.r_array*1e-9, sys.type, periodic=sys.boxsize*1e-9)
        
        m = typetomass['Ar'] * 1.660538921e-27
        k = (0.5 * m * sys.varray * sys.varray * 1e6).sum()
        
        count +=1
        if (count % 1000) == 0:
            pot.append(v)
            kin.append(k)
            energies.append((v + k))
            times.append(t)
    
    display_system(sys)
    pl.plot(times, energies, label="H")
    pl.plot(times, pot, label='V')
    pl.plot(times, kin, label='K')
    pl.legend()
    pl.show()
    
Exemplo n.º 4
0
def test_random():
    '''Testing random made box'''
    from chemlab.db import ChemlabDB
    cdb = ChemlabDB()
    na = Molecule([Atom('Na', [0.0, 0.0, 0.0])])
    cl = Molecule([Atom('Cl', [0.0, 0.0, 0.0])])
    wat = cdb.get("molecule", 'gromacs.spce')
    
    s = random_lattice_box([na, cl, wat], [160, 160, 160], [4, 4, 4])
    display_system(s)
Exemplo n.º 5
0
from chemlab.core import Atom, Molecule, crystal
from chemlab.graphics import display_system

# Molecule templates
na = Molecule([Atom('Na', [0.0, 0.0, 0.0])])
cl = Molecule([Atom('Cl', [0.0, 0.0, 0.0])])

s = crystal(
    [[0.0, 0.0, 0.0], [0.5, 0.5, 0.5]],  # Fractional Positions
    [na, cl],  # Molecules
    225,  # Space Group
    cellpar=[.54, .54, .54, 90, 90, 90],  # unit cell parameters
    repetitions=[5, 5, 5])  # unit cell repetitions in each direction

display_system(s)