예제 #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()
예제 #2
0
파일: e_2_geo.py 프로젝트: tarbaig/simpy
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)
예제 #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)
예제 #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")
예제 #5
0
파일: mc_swap.py 프로젝트: tarbaig/simpy
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()
예제 #6
0
파일: e_2_pdb.py 프로젝트: karthipitt/simpy
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)
예제 #7
0
파일: e_2_jag.py 프로젝트: tarbaig/simpy
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")
예제 #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")
예제 #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")
예제 #10
0
파일: gether.py 프로젝트: erinshawusc/simpy
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")
예제 #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
예제 #12
0
파일: mc_swap.py 프로젝트: tarbaig/simpy
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
예제 #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")
예제 #14
0
파일: e_2_pdb.py 프로젝트: karthipitt/simpy
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")
예제 #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)
예제 #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)
예제 #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")
예제 #18
0
파일: e_2_pdb.py 프로젝트: karthipitt/simpy
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")
예제 #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")
예제 #20
0
파일: e_t_ldh.py 프로젝트: tarbaig/simpy
""" 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)
예제 #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")

예제 #22
0
파일: slice.py 프로젝트: tarbaig/simpy
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
예제 #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, )