v[1], v[2] = v[2], v[1] # swap gamma/rc # ===== 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)
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)
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)
xyz_str = ll.atoms2str(final_xyz) print len(final_xyz), "beads created, density:", len(final_xyz) / (L/rc)**3 # ===== bonds bonds = create_bonds(n, Nc) bonds_str = ll.bonds2str(bonds) print len(bonds), "bonds created" # ===== 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"]