Exemplo n.º 1
0
        # ===== molecular ids
        Nmol = Nw + Nelb + Nc  # total num of molecules
        mol_ids = list(range(1, Nw+Nelb+1))
        for i in range(Nw+Nelb+1, Nmol+1): #(1, Nc+1):   # chains
            mol_ids += [i]*Nbc

        xyz_str = ll.atoms2str(np.hstack((np.matrix(mol_ids).T,\
                               np.matrix(atom_ids_n).T, xyz)))
        # ===== bonds
        bond_mat = gen_bonds(Nmc, Nc, mono_beads, start=Nw+Nelb)
        bonds_str = ll.bonds2str2(bond_mat)
        print("%i bonds created." % len(bond_mat))

        data_string = ll.header2str(len(xyz), len(bond_mat), Nbt, len(k_ij), L) + \
                      ll.mass2str(masses) + \
                      ll.pair_dpd_coeffs2str(a_ij_lmp) + \
                      ll.bond_coeffs2str(k_ij) + \
                      "Atoms\n\n" + xyz_str + \
                      "Bonds\n\n" + bonds_str

        fname = "nafion.data"
        open(fname, "w").write(data_string)
        print("Data file saved in", fname)

    if args["--xyz"]:
        fname = "nafion.xyz"
        ll.save_xyzfile(fname, np.c_[atom_ids_n, xyz])
        print("xyz file saved in", fname)
 
 
Exemplo n.º 2
0
    rc = 1.0
    
    print("=== Creating LAMMPS data file for diblock copolymer melt ===")
    print("Set interaction params in the input file")
    print("Box: %s | Rho: %.1f | Chain length: %i | A beads/chain: %i" % \
          (L, rho, N, int(N*f) ))
    
    poly_xyz = grow_polymer(L, f, N, Nc, mu=1.0)
    xyz_str = ll.atoms2str(poly_xyz)
    print(len(poly_xyz), "beads created, density:", len(poly_xyz) / L**3)

    bonds = gen_bonds(N, Nc)
    bonds_str = ll.bonds2str(bonds)
    print(len(bonds), "bonds created")

    final_string = ll.header2str(len(poly_xyz), len(bonds), 2, 1, L[0]) + \
                   ll.mass2str({1: 1.0, 2: 1.0}) + \
                   "\nAtoms\n\n" + xyz_str +  \
                   "\nBonds\n\n" + bonds_str
    
    fname = "diblock.data"
    open(fname, "w").write(final_string)
    print("Data file written in", fname)

    if args["--xyz"]:
        fname = args["--xyz"]
        ll.save_xyzfile(fname, poly_xyz[:, 1:])
        print("xyz file saved in", fname)


Exemplo n.º 3
0
    N = int(rho * L**3)
    if f < 0.0 or f > 1.0:
        print("Fraction f of A beads must be between 0 and 1.")
        sys.exit()

    print("=== LAMMPS data file for binary mixture ====")
    print("L: %.1f | rho: %.1f | f: %.2f" % (L, rho, f))

    xyz = np.random.rand(N, 3) * L
    names = [1] * int(f * N) + [2] * int((1 - f) * N)

    header = header2str(N, L)
    final_string = header + \
                   mass2str(1.0, 1.0) + \
                   atoms2str(names, xyz)

    if args["--vel"]:
        T = float(args["--vel"])
        print("Initialising velocities, temperature: %.1f" % T)
        vel = np.random.randn(N, 3) * T
        final_string += vel2str(vel)

    fname = "binmixt.data"
    open(fname, "w").write(final_string)
    print("Data file written in", fname)

    if args["--xyz"]:
        fname = "binmixt.xyz"
        ll.save_xyzfile(fname, np.hstack((np.matrix(names).T, xyz)))
        print("xyz file written in", fname)
Exemplo n.º 4
0
        print("L: %.2f | Beadtype: %i | Beads: %i" % (L, bead, len(xyz)))
    print("Nx: %i | Total cells %i | Cell size: %.2f" % (Nx, Nx**3, Lx))
    print("Smearing sigma: %.2f | Cutoff: %.2f" % (sigma, rc))
    print("Density grid size: %.2f | Total points: %i" % (dx, Ngrid**2))


    if args["test"]:
        n = 10
        print("Atoms in link cell %i\n" % n, lc[n].atoms)
        print("Number of atoms in link cells:")
        natoms = np.array([len(lc[i].atoms) for i in range(Nx**3)])
        print(natoms)
        print("Total: %i" % sum(natoms))
        temp_xyz = xyz[lc[n].atoms]
        temp_A = np.vstack((bead*np.ones(len(temp_xyz)), temp_xyz.T)).T
        ll.save_xyzfile("test_cell.xyz", temp_A)
        print("===========")
        test_neighbour_cells()
        print("===========")


    if args["2d"]:
        planes = {"xy": (0, 1), "yz": (1, 2), "xz": (0, 2)}
        try:
            plane = planes[args["<plane>"]]
        except KeyError:
            sys.exit("Choose plane from 'xy', 'yz', 'xz'.")
        ax = set([0, 1, 2]).difference(plane)
        ax = list(ax)[0]

        d = float(args["--depth"])
Exemplo n.º 5
0
    Nc = int(Nb / N)
    rc = 1.0
    mu = rc / 2.0

    print("=== Creating LAMMPS data file for diblock copolymer melt ===")
    print("Set interaction params in the input file")
    print("Box: %.1f | Rho: %.1f | Chain length: %i | A beads/chain: %i" % \
          (L, rho, N, int(N*f) ))

    poly_xyz = grow_polymer(L, f, N, Nc, mu)
    xyz_str = ll.atoms2str(poly_xyz)
    print(len(poly_xyz), "beads created, density:", len(poly_xyz) / L**3)

    bonds = gen_bonds(N, Nc)
    bonds_str = ll.bonds2str(bonds)
    print(len(bonds), "bonds created")

    final_string = ll.header2str(len(poly_xyz), len(bonds), 2, 1, L) + \
                   ll.mass2str({1: 1.0, 2: 1.0}) + \
                   "\nAtoms\n\n" + xyz_str +  \
                   "\nBonds\n\n" + bonds_str

    fname = "diblock.data"
    open(fname, "w").write(final_string)
    print("Data file written in", fname)

    if args["--xyz"]:
        fname = args["--xyz"]
        ll.save_xyzfile(fname, poly_xyz[:, 1:])
        print("xyz file saved in", fname)
Exemplo n.º 6
0
    NA = int(f * N)
    NB = N - NA
    names = [1] * NA + [2] * NB
    xyz = np.random.rand(N, 3) * L
    if args["--loc"]:
        xyz[:NA, 0] = np.random.rand(NA) * f * L[0]
        xyz[NA:, 0] = np.random.rand(NB) * (1 - f) * L[0] + f * L[0]

    header = header2str(N, L)
    final_string = header + \
                   mass2str(1.0, 1.0) + \
                   atoms2str(names, xyz)

    if args["--vel"]:
        T = float(args["--vel"])
        print("Initialising velocities, temperature: %.1f" % T)
        vel = np.random.randn(N, 3) * T
        vel -= np.sum(vel, 0) / N
        final_string += vel2str(vel)

    fname = "binmixt.data"
    open(fname, "w").write(final_string)
    print("Data file written in", fname)

    if args["--xyz"]:
        fname = "binmixt.xyz"
        save_xyzfile(fname, np.c_[names, xyz])
        print("xyz file written in", fname)


Exemplo n.º 7
0
        Nmol = Nw + Nelb + Nc  # total num of molecules
        mol_ids = list(range(1, Nw+Nelb+1))
        for i in range(Nw+Nelb+1, Nmol+1): #(1, Nc+1):   # chains
            mol_ids += [i]*Nbc

        xyz_str = ll.atoms2str(np.hstack((np.matrix(mol_ids).T,\
                               np.matrix(atom_ids_n).T, xyz)))
        # ===== bonds
        bond_mat = gen_bonds(Nmc, Nc, mono_beads, start=Nw+Nelb)
        bonds_str = ll.bonds2str2(bond_mat)
        print("%i bonds created." % len(bond_mat))

        data_string = ll.header2str(len(xyz), len(bond_mat), Nbt, len(k_ij), L) + \
                      ll.mass2str(masses) + \
                      ll.pair_dpd_coeffs2str(a_ij_lmp) + \
                      ll.bond_coeffs2str(k_ij) + \
                      "Atoms\n\n" + xyz_str + \
                      "Bonds\n\n" + bonds_str

        fname = "nafion.data"
        open(fname, "w").write(data_string)
        print("Data file saved in", fname)

    if args["--xyz"]:
        fname = args["--xyz"]
        xyz = np.hstack((np.matrix(atom_ids_n).T, xyz))
        ll.save_xyzfile(fname, xyz)
        print("xyz file saved in", fname)
 
 
Exemplo n.º 8
0
#!/usr/bin/env python
"""Usage:
   si2dpd.py <infile> [--rc <rc>]

[AD HOC] Modify xyz files by converting metres to DPD units
to conform with VMD standards.

Options:
    --rc <rc>      DPD units [default: 8.14e-10]
    

[email protected], 11/01/16
"""
import numpy as np
from docopt import docopt
import lmp_lib as ll

args = docopt(__doc__)
rc = float(args["--rc"])
print("rc = %.2e" % rc)

A = ll.read_xyzfile(args["<infile>"])
A[:, 1:] /= rc
outfile = "converted.xyz"
ll.save_xyzfile(outfile, A)
print("xyz frame in DPD units saved in", outfile)
Exemplo n.º 9
0
        print("Fraction f of A beads must be between 0 and 1.")
        sys.exit()

    print("=== LAMMPS data file for binary mixture ====")
    print("L: %.1f | rho: %.1f | f: %.2f" % (L, rho, f))

    xyz = np.random.rand(N, 3)*L
    names = [1]*int(f*N) + [2]*int((1-f)*N)

    header = header2str(N, L)
    final_string = header + \
                   mass2str(1.0, 1.0) + \
                   atoms2str(names, xyz)

    if args["--vel"]:
        T = float(args["--vel"])
        print("Initialising velocities, temperature: %.1f" % T)
        vel = np.random.randn(N, 3)*T
        final_string += vel2str(vel)

    fname = "binmixt.data"
    open(fname, "w").write(final_string)
    print("Data file written in", fname)

    if args["--xyz"]:
        fname = "binmixt.xyz"
        ll.save_xyzfile(fname, np.hstack((np.matrix(names).T, xyz)) )
        print("xyz file written in", fname)


Exemplo n.º 10
0
    # ===== pair and bond parameters
    Nbt = len(bead_types)
    r0 = 0.85 * rc     # from Dorenbos, JCP, 2015
    a_ij = gen_pair_coeffs(bead_types, data["ksi-params"], gamma, rc, a_ii)
    k_ij = gen_bond_coeffs(bead_types, data["bond-coeffs"], r0)
    masses = {1: m_PMMA*MAU, 2: m_sol*MAU}

    final_string = ll.header2str(len(final_xyz), len(bonds), Nbt, len(k_ij), L) + \
                   ll.mass2str(masses) + \
                   ll.pair_dpd_coeffs2str(a_ij) + \
                   ll.bond_coeffs2str(k_ij) + \
                   "Atoms\n\n" + xyz_str + \
                   "Bonds\n\n" + bonds_str

    if args["--save"]:
        fname = args["--save"]
        open(fname, "w").write(final_string)
        print "Data file saved in", fname
    else:
        print final_string

    if args["--xyz"]:
        fname = args["--xyz"]
        ll.save_xyzfile(fname, final_xyz[:, 1:])
        print "xyz file saved in", fname