elif args["lammps"]: # ===== pair coeffs a_ij_lmp = {} for k in a_ij.keys(): k_new = " ".join([str(bt2num[i]) for i in k.split()]) a_ij_lmp[k_new] = a_ij[k] for v in a_ij.values(): 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["--density"] == "real": print "Using real density, rho_PMMA = 1180, rho_water = 1000" Vw = pw * L**3 Nc = int(num_chains(rho_PMMA, L, n)) # number of PMMA chains if args["water"]: nw = int(rho_water * vw/(m_sol*mau)) elif args["meth"]: nw = int(rho_meth * vw/(m_sol*mau)) else: print "Using DPD bead density = 3" Nw = int(pw * rho_DPD/rc**3 * L**3) Nc = int((1-pw) * rho_DPD/rc**3 * L**3/n) poly_xyz = grow_polymer(L, n, Nc, mu=rc, sigma=rc/10) water_xyz = gen_water_beads(L, Nw, count=Nc+1) final_xyz = np.vstack((poly_xyz, water_xyz)) 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) + \
el_xyz = gen_electrodes(Nelb, L, Lcl, count=Nc+Nw+1) pt_xyz = gen_platinum(NPt, L, Lcl, count=Nc+Nw+Nelb+1) xyz = np.vstack((poly_xyz, wb_xyz, el_xyz, pt_xyz)) bead_types += "EP" Nbt = len(bead_types) else: xyz = np.vstack((poly_xyz, wb_xyz)) print(len(xyz), "beads created, density:", float(len(xyz)) / L**3) masses = dict( (i, 1.0) for i in range(1, Nbt+1) ) # all beads weigh the same if units == "SI": masses = dict( (i, m0) for i in range(1, Nbt+1) ) xyz *= rc L *= rc xyz_str = ll.atoms2str(xyz) # ===== bonds bonds = bonds_mat2(data["topology"], Nc) bonds_str = ll.bonds2str(bonds) print(len(bonds), "bonds created") # ===== pair and bond parameters a_ij = gen_pair_coeffs(bead_types, data["chi-params"], gamma, units) k_ij = gen_bond_coeffs(bead_types, data["bond-coeffs"], r0, units) # ===== putting it together final_string = ll.header2str(len(xyz), len(bonds), Nbt, len(k_ij), L) + \ ll.mass2str(masses) + \ ll.pair_dpd_coeffs2str(a_ij) + \ ll.bond_coeffs2str(k_ij) + \