示例#1
0
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
示例#2
0
    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")
    L.thermo(1000)
    L.thermo_modify("lost", "ignore", "flush", "yes")
    L.echo("none")

    L.velocity("all", "create", Temp, 12345, "dist", "gaussian", "mom", "yes",
               "rot", "yes")

    #L.fix("thermofix","all","temp/csvr",Temp,Temp,0.1,12345)	# does not perform time integration !
    L.fix("thermofix1", "allintegrategr", "langevin", 1, 1, 0.1, 699483,
          "zero", "yes")
    #L.fix("nveintegration","allintegrategr","nve/limit",0.05)	# performs time integration with modified velocities in micro-canonical ensemble
    L.fix("nveintegration", "allintegrategr", "nve")

    # initial equilibration:
    starttime = time.time()
示例#3
0
    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)

MPI.Finalize()
示例#4
0
    mc_tries,
    opt=['region', 'gcmc_box', 'tfac_insert', 1.65])
# OUTPUT
dump_elems = "id x y z type mol"
try:
    dump_elems += " c_" + micelle_compute
except:
    pass
try:
    dump_elems += " c_" + adsorbed_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.variable("area", "equal", "lx*ly")
py_lmp.thermo_style("custom", "step atoms", "pe temp", "press lx ly v_area")
py_lmp.thermo(out_freq)
# MSD data (only in x & y directions)
py_lmp.variable("top_msd", "equal",
                '"c_{0}[1] + c_{0}[2]"'.format(top_msd_compute))
py_lmp.fix("mem_top_msd", "all", "ave/time", 1, 1, out_freq, "v_top_msd",
           "file", os.path.join(output_folder, sim_ID + '_mem_top.msd'))
py_lmp.variable("bottom_msd", "equal",
                '"c_{0}[1] + c_{0}[2]"'.format(bottom_msd_compute))
py_lmp.fix("mem_bottom_msd", "all", "ave/time", 1, 1, out_freq, "v_bottom_msd",
           "file", os.path.join(output_folder, sim_ID + '_mem_bottom.msd'))
py_lmp.variable("full_msd", "equal",
                '"c_{0}[1] + c_{0}[2]"'.format(full_msd_compute))
py_lmp.fix("mem_full_msd", "all", "ave/time", 1, 1, out_freq, "v_full_msd",
           "file", os.path.join(output_folder, sim_ID + '_mem_full.msd'))
concentration = run_args.conc / run_args.cell_size**3
mc_exchange_tries = int(0.01 * mc_tries + 1)
simulation.set_state_concentration(0,
                                   concentration,
                                   run_args.mc_every,
                                   mc_exchange_tries,
                                   opt=["overlap_cutoff", overlap])

# OUTPUT
dump_elems = "id x y z type mol"
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",
    " ".join([
        "v_{}".format(group_var) for group_var in simulation.state_group_vars
    ]),
    "f_{}[2]".format(simulation.state_trans_fix),  # state change successes
    "f_{}[1]".format(simulation.state_trans_fix))  # state change attempts
py_lmp.thermo(out_freq)

# RUN
py_lmp.neigh_modify("every 1 delay 1")
py_lmp.timestep(run_args.dt)
py_lmp.run(args.simlen)

MPI.Finalize()