Exemplo n.º 1
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()
Exemplo n.º 2
0
def convertors(b):
    #toGeo(b, b.name+'.geo')
    toGeo(b, 'geo')
    toXyz(b, b.name+'.xyz')
    toGjf(b, b.name+'.gjf')
    toPdb(b, b.name+'.pdb')
    toReaxLammps(b)
Exemplo n.º 3
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)
Exemplo n.º 4
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")
Exemplo n.º 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()
Exemplo n.º 6
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)
Exemplo n.º 7
0
def convert(fname):
    a = Jaguar(fname)
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    toXyz(b, "out.xyz")
    toPdb(b, "output.pdb", 1)
    toReaxLammps(b, "lammps.data")
Exemplo n.º 8
0
def convert(fname):
    a = Jaguar(fname)
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    toXyz(b, "out.xyz")
    toPdb(b, "output.pdb", 1)
    toReaxLammps(b, "lammps.data")
Exemplo n.º 9
0
def main(log):
    d1_file = "lammps.data.3"
    d2_file = "./slice_03/conf2/lammps.data"
    d1 = read_data(d1_file)
    d2 = read_data(d2_file)
    logfile = "./slice_03/conf2/build.log"
    z0, ndx = read_build_log(logfile)
    toPdb(d1, "t0.pdb")
    update_coords(d1, d2, z0, ndx)
    toPdb(d1, "t1.pdb")
    toReaxLammps(d1, "lammps.data.4")
Exemplo n.º 10
0
def main(log):
    d1_file = "lammps.data.3"
    d2_file = "./slice_03/conf2/lammps.data"
    d1 = read_data(d1_file)
    d2 = read_data(d2_file)
    logfile = "./slice_03/conf2/build.log"
    z0, ndx = read_build_log(logfile)
    toPdb(d1, "t0.pdb")
    update_coords(d1, d2, z0, ndx)
    toPdb(d1, "t1.pdb")
    toReaxLammps(d1, "lammps.data.4")
Exemplo n.º 11
0
def get_energy(mc, sim, grp):
    """get reaxFF energy by calling LAMMPS externally
    """
    ener = 0.0
    toReaxLammps(sim)
    f1, f2, f3 = popen2.popen3("%s %s -in lammps_input"%(mc.mpicode, mc.code))
    for i in f1:
        if i.strip().startswith("PotEng"):
            tokens = i.strip().split()
            n = tokens.index("PotEng")
            ener = float(tokens[n + 2])
    return ener
Exemplo n.º 12
0
def get_energy(mc, sim, grp):
    """get reaxFF energy by calling LAMMPS externally
    """
    ener = 0.0
    toReaxLammps(sim)
    f1, f2, f3 = popen2.popen3("%s %s -in lammps_input" %
                               (mc.mpicode, mc.code))
    for i in f1:
        if i.strip().startswith("PotEng"):
            tokens = i.strip().split()
            n = tokens.index("PotEng")
            ener = float(tokens[n + 2])
    return ener
Exemplo n.º 13
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")
Exemplo n.º 14
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")
Exemplo n.º 15
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)
Exemplo n.º 16
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)
Exemplo n.º 17
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("fname", default="POSCAR", nargs="?", help="geo file name")
    args = parser.parse_args()
    
    poscar_file = args.fname
    a = Poscar(poscar_file)
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    print b.getVol()
    #print b.pbc
    
    toXyz(b)
    toGeo(b, "geo")
    toPdb(b, "sim.pdb")
    toReaxLammps(b, "lammps.data")
    toJdft(b, "coords")
Exemplo n.º 18
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")
Exemplo n.º 19
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("fname", default="POSCAR", nargs="?", help="geo file name")
    args = parser.parse_args()
    
    poscar_file = args.fname
    a = Poscar(poscar_file)
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    vol = b.getVol()
    mass = b.getMass()
    density = mass/vol*ATOMIC_MASS_CONSTANT*1e27
    print density
    #print b.pbc
    
    toXyz(b, "contcar.xyz")
    toGeo(b, "geo")
    toPdb(b, "sim.pdb")
    toReaxLammps(b, "lammps.data")
    toJdft(b, "coords")
Exemplo n.º 20
0
""" Replace the Ca in CaO crystal to creat a Ca-rich LDO (Ca:Al=7:1)
This is for LDH project
"""

from data import ReaxData
from output_conf import toReaxLammps
from tools import LdhProject

for i in range(100):
    testfile = "a666.data"
    a = ReaxData(testfile)
    b = a.parser()
    c = LdhProject(b)
    c.re_al = 8
    c.re1()
    b.assignAtomTypes()
    toReaxLammps(b, "case%02d.data" % i)
Exemplo n.º 21
0
from mytype import System, Molecule, Atom
from poscar import Poscar
from output_conf import toXyz, toGeo, toPdb, toReaxLammps

import sys

if len(sys.argv) > 1:
    fname = sys.argv[1]
else:
    fname = "CONTCAR"
a = Poscar(fname)
b = a.parser()
b.assignAtomTypes()
b.assignEleTypes()
print b.getVol()

toXyz(b)
toGeo(b, "geo")
toPdb(b, "sim.pdb")
toReaxLammps(b, "lammps.data")

Exemplo n.º 22
0
def get_slice(b, id0):
    logfile = "build.log"
    o = open(logfile, "w")
    
    a0 = b.atoms[id0-1]
    id0 = a0.an
    x0, y0, z0 = a0.x

    o.write("Reference atoms is %d.\n"%id0)
    o.write("The coordination of reference atom is %.4f %.4f %.4f.\n"%
            (x0, y0, z0))
    o.write("Cut from z direction.\n")

    zl = b.pbc[2]

    z0 = z0 - int(z0/zl)*zl
    dz1 = DELTA_Z1
    dz2 = DELTA_Z2
    z1 = z0 - dz1
    z2 = z0 + dz1
    z1 = z1 - math.floor(z1/zl)*zl
    z2 = z2 - math.floor(z2/zl)*zl

    b1 = copy.deepcopy(b)

    o.write("Starting from %.4f to %.4f.\n"%(z1, z2))
    o.write("Cut radius is %.4f.\n"%dz1)
    #o.write("Buffer distance is %.4f.\n"%dz2)
    #o.write("Fixed L1 from %.4f to %.4f\n"%(z1, z2))
    #o.write("Fixed L2 from %.4f to %.4f\n"%(z3, z4))
    
    ca = []
    a_ref = []
    
    for i in range(len(b.atoms)):
        id = b.atoms[i].an
        z = b.atoms[i].x[2]
        z = z - math.floor(z/zl)*zl #pbc
        b1.atoms[i].x[2] = z
        if id == id0:
            a_ref.append(b1.atoms[i])
        else:
            if z1 < z2:
                if z >= z1 and z < z2:
                    ca.append(b1.atoms[i])
            else:
                if z >= 0 and z < z2:
                    ca.append(b1.atoms[i])
                elif z >= z1 and z < zl:
                    ca.append(b1.atoms[i])

    # Shift the atoms according to reference atom
    for i in range(len(ca)):
        z = ca[i].x[2] 
        z = z - z1
        z = z - math.floor(z/zl)*zl
        ca[i].x[2] = z

    z = a_ref[0].x[2] 
    z = z - z1
    z = z - math.floor(z/zl)*zl
    a_ref[0].x[2] = z
    o.write("Sort the atom index according to z.\n")
    ca.sort(key=lambda x: x.x[2])

    c1 = []
    c2 = []
    for i in ca:
        z = i.x[2]
        if z <= dz2:
            c1.append(i)
        elif z > 2*dz1 - dz2:
            c1.append(i)
        else:
            c2.append(i)
            
    o.write("Fixed atoms is %d.\n"%(len(c1)))

    ca = ca + a_ref
    o.write("Total number of atoms is %d.\n"%len(ca))

    o.write("Index is as following:\n")
    counter = 0
    for i in ca:
        if counter % 10 == 0:
            o.write("\n")
        o.write("%8d"%i.an)
        counter += 1
    o.write("\n")
    
    b1.atoms = c1 + c2 + a_ref
    b1.pbc[2] = 2*dz1
    
    o.write("Output to pdb.\n")
    toPdb(b1, "input.pdb")
    toReaxLammps(b1)
    o.close()

    return ca, c1, c2, a_ref
Exemplo n.º 23
0
from block import dumpBlock
from dump import Dump
from output_conf import toXyz, toPdb, toPoscar, toReaxLammps

lmpfile = "dump.lammpstrj"
sepfile = "dump.sep"
dt = 1

# parse the dump file with multi configurations into seperated dump files
nframe = dumpBlock(lmpfile, sepfile, dt)
nframe += 1

for i in range(0, nframe, dt):
    #for i in range(10):
    a = Dump("%s%05d.dump" % (sepfile, i))
    b = a.parser()
    b.assignAtomTypes()
    b.assignEleTypes()
    b.toFrac()

    toXyz(b, "xyz%05d.xyz" % i)
    #b.sortXYZ("z")
    toPdb(b, "pdb%05d.pdb" % i)
    toReaxLammps(b, "lammps.data")
    toPoscar(b, )