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")
def main(): parser = argparse.ArgumentParser() parser.add_argument("fname", default="POSCAR", nargs="?", help="geo file name") parser.add_argument("-n", type=int, help="number of fixed atoms") parser.add_argument("-r", action='store_true', help="reverse the fixing order") args = parser.parse_args() if args.n: n_fixed = int(args.n) else: n_fixed = int(input("number of fixed atoms: ")) 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 shutil.copy(poscar_file, poscar_file + ".1") coords = [] for i in range(len(b.atoms)): coords.append([]) for i in range(len(b.atoms)): coords[i].append(i) for j in b.atoms[i].x: coords[i].append(j) coords.sort(key=lambda x: x[3]) if args.r: coords.sort(key=lambda x: x[3], reverse=True) for i in range(len(coords)): if i < n_fixed: coords[i].append("F") else: coords[i].append("T") coords.sort(key=lambda x: x[0]) for i in range(len(b.atoms)): b.atoms[i].xr = [0, 0, 0] if coords[i][-1] == "F": b.atoms[i].xr = [1, 1, 1] toPoscar(b, "POSCAR_new")
def toPOSCAR(t0, conf, steps): if not os.path.exists("poscars"): os.mkdir("poscars") os.chdir("poscars") for i in range(len(conf)): fname = "POSCAR_%06d"%steps[i] t0.name = "step = %d"%steps[i] for j in range(len(conf[i])): tokens = conf[i][j].strip().split() t0.atoms[j].xFrac[0] = float(tokens[0]) t0.atoms[j].xFrac[1] = float(tokens[1]) t0.atoms[j].xFrac[2] = float(tokens[2]) toPoscar(t0, fname) os.chdir("..")
def toPOSCAR(t0, conf, steps): if not os.path.exists("poscars"): os.mkdir("poscars") os.chdir("poscars") for i in range(len(conf)): fname = "POSCAR_%06d" % steps[i] t0.name = "step = %d" % steps[i] for j in range(len(conf[i])): tokens = conf[i][j].strip().split() t0.atoms[j].xFrac[0] = float(tokens[0]) t0.atoms[j].xFrac[1] = float(tokens[1]) t0.atoms[j].xFrac[2] = float(tokens[2]) toPoscar(t0, fname) os.chdir("..")
def gen_input(scan, poscar): n = len(scan.scan_points) n_ref = scan.ref_atom - 1 for i in range(n): folder = "s%02d"%i if not os.path.exists(folder): os.mkdir(folder) os.chdir(folder) z0 = poscar.atoms[n_ref].xFrac[2] z1 = scan.scan_points[i] dz = z1 - z0 # update the coords poscar.atoms[n_ref].xFrac[2] += dz for j in range(len(scan.grp_atoms)): n_grp = scan.grp_atoms[j] - 1 poscar.atoms[n_grp].xFrac[2] += dz # output the coords toPoscar(poscar) os.chdir("..")
def gen_input(scan, poscar): n = len(scan.scan_points) n_ref = scan.ref_atom - 1 for i in range(n): folder = "s%02d" % i if not os.path.exists(folder): os.mkdir(folder) os.chdir(folder) z0 = poscar.atoms[n_ref].xFrac[2] z1 = scan.scan_points[i] dz = z1 - z0 # update the coords poscar.atoms[n_ref].xFrac[2] += dz for j in range(len(scan.grp_atoms)): n_grp = scan.grp_atoms[j] - 1 poscar.atoms[n_grp].xFrac[2] += dz # output the coords toPoscar(poscar) os.chdir("..")
def gen_scan(s, args): start = 0.7 end = 1.3 start = np.power(start, 1/3.0) end = np.power(end, 1/3.0) n = 11 x = np.linspace(start, end, n) for i in range(n): folder = "scan_%02d"%i if not os.path.exists(folder): os.mkdir(folder) os.chdir(folder) shutil.copy("../INCAR", ".") shutil.copy("../POTCAR", ".") shutil.copy("../KPOINTS", ".") if os.path.exists('../pbs'): shutil.copy("../pbs", ".") s_new = copy.copy(s) xx, xy, xz, yy, yz, zz = lattice2v(s.pbc) a = np.array([xx, 0.0, 0.0]) b = np.array([xy, yy, 0.0]) c = np.array([xz, yz, zz]) if args.xyz: tmp = args.xyz[0] if tmp == "xy": a = a * x[i] b = b * x[i] elif tmp == "z": c = c * x[i] else: a = a * x[i] b = b * x[i] c = c * x[i] pbc = v2lattice(a, b, c) s_new.pbc = pbc toPoscar(s_new, "POSCAR") os.chdir("..")
def withPbc(testfile="supper.pdb", args=''): a = Pdb(testfile) b = a.parser() b.assignAtomTypes() print b.atomtypes 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") toPoscar(b,) if args: if args.element: toPdb(b, "out.pdb", 1) else: toPdb(b, "out.pdb")
def gen_scan(s, args): start = 0.8 end = 1.2 start = np.power(start, 1/3.0) end = np.power(end, 1/3.0) n = 11 x = np.linspace(start, end, n) for i in range(n): folder = "scan_%02d"%i if not os.path.exists(folder): os.mkdir(folder) os.chdir(folder) shutil.copy("../INCAR", ".") shutil.copy("../POTCAR", ".") shutil.copy("../KPOINTS", ".") shutil.copy("../pbs", ".") s_new = copy.copy(s) xx, xy, xz, yy, yz, zz = lattice2v(s.pbc) a = np.array([xx, 0.0, 0.0]) b = np.array([xy, yy, 0.0]) c = np.array([xz, yz, zz]) if args.xyz: tmp = args.xyz[0] if tmp == "xy": a = a * x[i] b = b * x[i] elif tmp == "z": c = c * x[i] else: a = a * x[i] b = b * x[i] c = c * x[i] pbc = v2lattice(a, b, c) s_new.pbc = pbc toPoscar(s_new, "POSCAR") os.chdir("..")
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,)
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, )
from mytype import System, Molecule, Atom from poscar import Poscar from output_conf import toPoscar 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() toPoscar(b)