Example #1
0
def test():
    testfile = "e_2_pdb.pdb"
    a = Pdb(testfile)
    b = a.parser()
    b.assignAtomTypes()
    b.pbc = [20.80, 20.80, 20.80, 90.0, 90.0, 90.0]
    toReaxLammps(b)
Example #2
0
def test():
    testfile = "e_2_pdb.pdb"
    a = Pdb(testfile)
    b = a.parser()
    b.assignAtomTypes()
    b.pbc = [20.80, 20.80, 20.80, 90.0, 90.0, 90.0]
    toReaxLammps(b)
Example #3
0
def withPbc(testfile="supper.pdb", args=''):
    a = Pdb(testfile)
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    b.assignIdNumbers()
    b.toFrac()
    #b.translate(12.0, "z")
    toXyz(b, "out.xyz")
    toMusic(b, "out.music")
    if len(b.pbc) == 0:
        b.geotag = "BIOGRF 200"
    else:
        b.geotag = "XTLGRF 200"
    toReaxLammps(b, "lammps.data")
    toGeo(b, "sim.geo")
    toMsd(b, "sim.msd")
    toPoscar(b, )
    toCfg(b, )
    toJdft(b, )
    toTowheecoords(b)
    if args:
        if args.element:
            toPdb(b, "out.pdb", 1)
    else:
        toPdb(b, "out.pdb")
Example #4
0
def monte_carlo():
    """ a python shell for Monte Carlo reaxFF simulation'
    """
    welcome()
    mc = MC()
    # read the pdb file
    print("Reading input pdbfile")
    pdbfile = "model.pdb"
    a = Pdb(pdbfile)
    sim = a.parser()
    sim.assignEleTypes()
    sim.assignAtomTypes()
    # read the control file
    read_control(mc)
    # read index file
    indexfile = "index.ndx"
    grp = Group(indexfile)

    # system init
    log = open(mc.log, "w")

    if mc.swap_flag == 1:
        assign_swap_grps(mc, sim, grp)

    print "Starting simulation:"
    for i in range(mc.nsteps):
        print("Running step %d" % i)
        log.write("step %-6d" % i)
        mc_moves(mc, sim, grp, log)
        shutil.copy("out.data", "out.data.%06d" % i)
        shutil.copy("dump.lmp", "dump.lmp.%06d" % i)

    toReaxLammps(sim, "lammps.data.final")
    log.close()
Example #5
0
def monte_carlo():
    """ a python shell for Monte Carlo reaxFF simulation'
    """
    welcome()
    mc = MC()
    # read the pdb file
    print("Reading input pdbfile")
    pdbfile = "model.pdb"
    a = Pdb(pdbfile)
    sim = a.parser()
    sim.assignEleTypes()
    sim.assignAtomTypes()
    # read the control file
    read_control(mc)
    # read index file
    indexfile = "index.ndx"
    grp = Group(indexfile)

    # system init
    log = open(mc.log, "w")

    if mc.swap_flag == 1:
        assign_swap_grps(mc, sim, grp)
    
    print "Starting simulation:"
    for i in range(mc.nsteps):
        print("Running step %d"%i)
        log.write("step %-6d"%i)
        mc_moves(mc, sim, grp, log)
        shutil.copy("out.data", "out.data.%06d"%i)
        shutil.copy("dump.lmp", "dump.lmp.%06d"%i)

    toReaxLammps(sim, "lammps.data.final")
    log.close()
Example #6
0
File: add.py Project: tarbaig/simpy
def read_pdb(pdbfile):
    """read pdb file
    """

    a = Pdb(pdbfile)
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    return b
Example #7
0
def test():
    testfile = "test.pdb"
    a = Pdb(testfile)
    b = a.parser()
    atoms = b.atoms
    print atoms[0].x
    b.sortZ()
    atoms = b.atoms
    print atoms[0].x
Example #8
0
def read_pdb(control):
    print "    Reading pdb file ..."
    a = Pdb(control.pdbfile)
    b = a.parser()
    b.assignAtomTypes2()
    print "        cell parameters:"
    print "            a = %8.3f: "%b.pbc[0]
    print "            a = %8.3f: "%b.pbc[1]
    print "            a = %8.3f: "%b.pbc[2]
    return b
Example #9
0
def getBoxl(pdbfile, n, density):

    density = density * 1000
    a = Pdb(pdbfile)
    b = a.parser()
    b.getMass()
    mass = b.mass
    print "Molecule mass: ", mass
    total = mass * n
    vol = total * amc / density * 1e30  # here length is in A
    print "Volume: ", vol
    l = math.pow(vol, 1 / 3.0)
    print "box a, b, c =", l

    return l
Example #10
0
def fortranOut(testfile="output.pdb", args=''):
    a = Pdb(testfile)
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    b.pbc = [50.00, 50.00, 50.00, 90.0, 90.0, 90.0]
    b.geotag = "XTLGRF 200"
    toReaxLammps(b, "lammps.data")
    if args:
        if args.element:
            toPdb(b, "out.pdb", 1)
    else:
        toPdb(b, "out.pdb")
    toMsd(b, "sim.msd")
    toGeo(b, "sim.geo")
Example #11
0
def getBoxl(pdbfile, n, density):

    density = density * 1000
    a = Pdb(pdbfile)
    b = a.parser()
    b.getMass()
    mass = b.mass
    print "Molecule mass: ", mass
    total = mass * n
    vol = total*amc/density * 1e30 # here length is in A
    print "Volume: ", vol
    l = math.pow(vol, 1/3.0)
    print "box a, b, c =", l

    return l
Example #12
0
def fortranOut(testfile = "output.pdb", args=''):
    a = Pdb(testfile)
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    b.pbc = [50.00, 50.00, 50.00, 90.0, 90.0, 90.0]
    b.geotag = "XTLGRF 200"
    toReaxLammps(b, "lammps.data")
    if args:
        if args.element:
            toPdb(b, "out.pdb", 1)
    else:
        toPdb(b, "out.pdb")
    toMsd(b, "sim.msd")
    toGeo(b, "sim.geo")
Example #13
0
def main():
    if len(sys.argv) < 4:
        usage()
    else:
        pdbfile = sys.argv[1]
        n = int(sys.argv[2])
        density = float(sys.argv[3])
        l = getBoxl(pdbfile, n, density)
        writeInp(pdbfile, n, l)
        os.system("packmol < inp")
        if os.path.exists("sim.pdb"):
            os.system("editconf -f sim.pdb -o sim.pdb -box %.4f" % (l / 10))
            a = Pdb("sim.pdb")
            b = a.parser()
            b.assignAtomTypes()
            toReaxLammps(b)
Example #14
0
def main():
    if len(sys.argv) < 4:
        usage()
    else:
        pdbfile = sys.argv[1]
        n = int(sys.argv[2])
        density = float(sys.argv[3])
        l = getBoxl(pdbfile, n, density)
        writeInp(pdbfile, n, l)
        os.system("packmol < inp")
        if os.path.exists("sim.pdb"):
            os.system("editconf -f sim.pdb -o sim.pdb -box %.4f"%(l/10))
            a = Pdb("sim.pdb")
            b = a.parser()
            b.assignAtomTypes()
            toReaxLammps(b)
Example #15
0
def make_ndx(atp, lo, hi):
    assert lo < hi
    a = Pdb("model.pdb")
    b = a.parser()
    b.assignEleTypes()
    b.assignAtomTypes()
    n = 0
    counter = 0
    for i in b.atoms:
        if i.element == atp:
            z = i.x[2]
            if z > lo and z <= hi:
                print "%5d"%(n + 1),
                if (counter + 1) % 15 == 0:
                    print ''
                counter += 1
        n+= 1
    print ''
Example #16
0
def make_ndx(atp, lo, hi):
    assert lo < hi
    a = Pdb("model.pdb")
    b = a.parser()
    b.assignEleTypes()
    b.assignAtomTypes()
    n = 0
    counter = 0
    for i in b.atoms:
        if i.element == atp:
            z = i.x[2]
            if z > lo and z <= hi:
                print "%5d" % (n + 1),
                if (counter + 1) % 15 == 0:
                    print ''
                counter += 1
        n += 1
    print ''
Example #17
0
def withPbc(testfile="supper.pdb", args=''):
    a = Pdb(testfile)
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    #b.translate(12.0, "z")
    toXyz(b, "out.xyz")
    toMusic(b, "out.music")
    if len(b.pbc) == 0:
        b.geotag = "BIOGRF 200"
    else:
        b.geotag = "XTLGRF 200"
    toReaxLammps(b, "lammps.data")
    toGeo(b, "sim.geo")
    toMsd(b, "sim.msd")
    if args:
        if args.element:
            toPdb(b, "out.pdb", 1)
    else:
        toPdb(b, "out.pdb")
Example #18
0
def sortXYZ(testfile="input.pdb", axis="z"):
    a = Pdb(testfile)
    b = a.parser()
    atoms = b.atoms
    b.sortXYZ(axis)
    toPdb(b, "out_sorted.pdb")
Example #19
0
1 3
improper
0
unit ntype
3    'H_'  0.4d0
vibration
1
2
improper
0
"""

if len(sys.argv) > 2:
    nmol = int(sys.argv[2])
    a = Pdb(sys.argv[1])
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    toTowheecoords(b)
    rcut = 3.5

    xx, xy, xz, yy, yz, zz = lattice2v(b.pbc)
    la = [xx, 0.0, 0.0]
    lb = [xy, yy, 0.0]
    lc = [xz, yz, zz]
    print la
    print lb
    print lc

    o = open("towhee_input", "w")
    o.write("inputformat\n")
Example #20
0
def read_pdb():
    a = Pdb("out_sorted.pdb")
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    return b
Example #21
0
def sortXYZ(testfile="input.pdb", axis="z"):
    a = Pdb(testfile)
    b = a.parser()
    atoms = b.atoms
    b.sortXYZ(axis)
    toPdb(b, "out_sorted.pdb")
Example #22
0
def read_pdb():
    a = Pdb("out_sorted.pdb")
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    return b