def data(i): lmp1 = lammps() polymer = PyLammps(ptr=lmp1) x = 60 y = 30 z = 30 t = 1 polymer.units("lj") polymer.dimension(3) polymer.atom_style("bond") polymer.bond_style("harmonic") polymer.pair_style("lj/cut", 3) polymer.read_data("data.polymer") polymer.region("void cylinder x", 15, 15, 2, 29, 31) polymer.pair_coeff(1, 2, 2.5, 3) polymer.pair_coeff(1, 3, 2.5, 1.12) polymer.pair_coeff(2, 3, 2.5, 1.12) polymer.velocity("all create", t, 97287) polymer.group("polymer type", 1, 2) polymer.group("first type", 1) polymer.region("box block", 0, x, 0, y, 0, z) polymer.region("spherein sphere", 29, 15, 15, 2) polymer.region("boxin block", 27, 29, 13, 17, 13, 17) polymer.region("hemiin intersect", 2, "boxin spherein") x0 = polymer.atoms[0].position[0] y0 = polymer.atoms[0].position[1] z0 = polymer.atoms[0].position[2] r = lambda x0, y0, z0: np.sqrt((x0 - 29)**2 + (y0 - 15)**2 + (z0 - 15)**2) fx = lambda x0, y0, z0: 5 * (x0 - 29) / r(x0, y0, z0) fy = lambda x0, y0, z0: 5 * (y0 - 15) / r(x0, y0, z0) fz = lambda x0, y0, z0: 5 * (z0 - 15) / r(x0, y0, z0) polymer.fix(1, "polymer nve") polymer.fix(2, "polymer langevin", t, t, 1.5, np.random.randint(2, high=200000)) polymer.fix(3, "polymer spring tether", 10, i, "NULL NULL", 0) polymer.timestep(0.01) polymer.compute("com polymer com") polymer.variable("ftotal equal fcm(polymer,x)") polymer.variable("c equal c_com[1]") polymer.thermo_style("custom v_ftotal v_c") polymer.thermo(1) polymer.run(500000) l = polymer.runs[0][0][1][20000:] + [i] u = [np.mean(polymer.runs[0][0][0][20000:]), i] np.savetxt("trial%dmean.txt" % i, u) np.savetxt("trial%dall.txt" % i, l) return u
# L.pair_coeff("* * eam Au_u3.eam") # L.pair_coeff(1,2,"lj/cut",epsAuC,sigAuC,10.0) # L.pair_coeff("* * tersoff SiC.tersoff NULL C") (nPart1, nPart2, nPartsub, coords1, coords2, coordssub, indices1, indices2, indicessub) = getcoords() print("no. of atoms in the system: {} Au, {} Ni, {} C".format( nPart1, nPart2, nPartsub)) scaleF = nPart1 * cdf1[-1] / (nPart2 * cdf2[-1]) print(scaleF) L.minimize(1e-6, 1e-7, 5000, 50000) print("initial minimization completed.") L.compute("K", "all", "ke/atom") L.compute("P", "all", "pe/atom") L.compute( "coordno", "all", "coord/atom", "cutoff", NNthresh ) # calculate coordination no between all atoms of type 1 or 2 (exclude substrate atoms (type 3) #L.dump("d1","all","xyz",1000,"output.xyz") #L.dump("d1","all","custom",1000,"output.out", "id", "type","x","y","z","vx","vy","vz","c_K","c_P","c_coordno") #L.dump("d1","xtc","atom",100,"T" + str(Temp) + "_Fulltrajectories.xtc",100) # last value gives precision, a value of 100 means that coordinates are stored to 1/100 nanometer accuracy #L.dump_modify("d1","element","Au","Ni","C") #L.dump_modify("d1","pbc","yes") # remap atoms via periodic boundary conditions #L.dump("trajectory","all","atom",100, "T" + str(Temp) + "_Fulltrajectories.lammpstrj") # Set thermo output to log file L.thermo_style("custom", "step", "atoms", "temp", "etotal", "pe", "ke", "dt")
# GROUPS & COMPUTES if hasattr(run_args, 'label_micelles'): micelle_group = 'sol_tips' sol_tip_bead_type = model.state_structures[0][0][-1] py_lmp.variable(micelle_group, 'atom', '"type == {:d}"'.format(sol_tip_bead_type)) py_lmp.group(micelle_group, 'dynamic', simulation.rods_group, 'var', micelle_group, 'every', out_freq) micelle_compute = "micelle_ID" if hasattr(run_args, 'micelle_cutoff'): micelle_cutoff = run_args.micelle_cutoff else: SS_tip_int_key = model.eps[(sol_tip_bead_type, sol_tip_bead_type)][1] SS_tip_int_range = model.int_types[SS_tip_int_key][1] micelle_cutoff = 2 * model.rod_radius + SS_tip_int_range py_lmp.compute(micelle_compute, micelle_group, 'aggregate/atom', micelle_cutoff) # OUTPUT dump_elems = "id x y z type mol" try: dump_elems += " c_" + micelle_compute except: pass py_lmp.dump("dump_cmd", "all", "custom", out_freq, '"' + dump_path + '"', dump_elems) py_lmp.dump_modify("dump_cmd", "sort id") py_lmp.thermo_style("custom", "step atoms", "pe temp") py_lmp.thermo(out_freq) # RUN ... py_lmp.run(args.simlen)
# GROUPS & COMPUTES if hasattr(run_args, 'label_micelles'): micelle_group = 'sol_tips' sol_tip_bead_type = model.state_structures[0][0][-1] py_lmp.variable(micelle_group, 'atom', '"type == {:d}"'.format(sol_tip_bead_type)) py_lmp.group(micelle_group, 'dynamic', simulation.rods_group, 'var', micelle_group, 'every', out_freq) micelle_compute = "micelle_ID" if hasattr(run_args, 'micelle_cutoff'): micelle_cutoff = run_args.micelle_cutoff else: SS_tip_int_key = model.eps[(sol_tip_bead_type, sol_tip_bead_type)][1] SS_tip_int_range = model.int_types[SS_tip_int_key][1] micelle_cutoff = 2 * model.rod_radius + SS_tip_int_range py_lmp.compute(micelle_compute, micelle_group, 'aggregate/atom', micelle_cutoff) #TODO label_fibrils ?? # FIXES & DYNAMICS thermo_fix = 'thermostat' py_lmp.fix(thermo_fix, 'all', 'langevin', run_args.temp, run_args.temp, run_args.damp, seed) #, "zero yes") simulation.set_rod_dynamics('nve', opt=['mol', model.rod_states[0]]) py_lmp.region('gcmc_init', 'block', membrane.xmin + model.rod_length / 2, membrane.xmax - model.rod_length / 2, membrane.ymin + model.rod_length / 2, membrane.ymax - model.rod_length / 2, 0.0 + model.rod_length / 2, run_args.Lz - model.rod_length / 2)
else: fibril_cutoff = 0 i = -1 for t1 in beta_active_patch_types: i += 1 for t2 in beta_active_patch_types[i:]: try: int_key = model.eps[(t1, t2)][1] except: continue int_range = model.int_types[int_key][1] cutoff = model.bead_radii[t1] + model.bead_radii[ t2] + int_range * 2 / 3 if cutoff > fibril_cutoff: fibril_cutoff = cutoff py_lmp.compute(fibril_compute, fibril_group, 'aggregate/atom', fibril_cutoff) # OUTPUT py_lmp.thermo_style("custom", "step atoms", "pe temp") dump_elems = "id x y z type mol" try: dump_elems += " c_" + fibril_compute except: pass py_lmp.dump("dump_cmd", "all", "custom", out_freq, dump_path, dump_elems) py_lmp.dump_modify("dump_cmd", "sort id") py_lmp.thermo(out_freq) # RUN... if model.num_states == 1 or run_args.mc_moves == 0: raise Exception(