def initialize_ra(Nx,Ny,dx,dy,lx,ly):
rx=[]
ry=[]
# rx.append(lx/4.0-lx/2)
# ry.append(ly/2.0-ly/2)
for i in range(Nx):
for j in range(Ny):
rx.append(i*dx-lx/2+dx/2)
ry.append(j*dy-ly/2+dy/2)
return rx,ry
shear=float(sys.argv[1])
rho=float(sys.argv[2])
dx=np.sqrt(1.0/rho)
dy=dx
lx=100
ly=300
Nx=int(lx/dx)
Ny=int(ly/dy)
N=Nx*Ny
sigma=1.0
kbT=1.0
m=1.0
epsilon=1.0
ver=str(shear)+"_"+str(rho)
main_dir="./"+ver
if not os.path.exists(main_dir): os.makedirs(main_dir)
real_time=100
dt = 1e-4
nsteps=int(real_time/dt)
pos_hout=int(nsteps/500)
rx,ry=initialize_ra(Nx,Ny,dx,dy,lx,ly)
position=[]
for i in range(len(rx)):
position.append((rx[i],ry[i],0.0))
snapshot = gsd.hoomd.Frame()
snapshot.particles.N = N
snapshot.particles.position = position[0:N]
snapshot.particles.typeid = (N)*[0]
snapshot.particles.types = ['Move']
snapshot.particles.diameter=(N)*[1.0]
snapshot.particles.mass = np.ones((N))
snapshot.configuration.box = [lx, ly, 0, 0, 0, 0]
sim = hoomd.Simulation(device=hoomd.device.GPU(), seed=12)
sim.create_state_from_snapshot(snapshot)
cell = hoomd.md.nlist.Cell(buffer=0.4)
lj = hoomd.md.pair.LJ(nlist=cell, mode="shift")
lj.params[("Move", "Move")] = dict(epsilon=epsilon, sigma=sigma)
lj.r_cut[("Move", "Move")] = 2**(1/6)*sigma
nve = hoomd.md.methods.ConstantVolume(filter=hoomd.filter.All())
integrator = hoomd.md.Integrator(
dt=dt,
methods=[nve],
forces=[lj],
)
# const integrated flow with 0.1 slope for max 1e8 timesteps
ramp = hoomd.variant.Ramp(0.0, shear*nsteps, 0, int(nsteps))
# velocity gradient in z direction and shear flow in x direction.
mpf = hoomd.md.update.ReversePerturbationFlow(filter=hoomd.filter.All(),
flow_target=ramp,
slab_direction="Y",
flow_direction="X",
n_slabs=200)
sim.operations+=mpf
sim.operations.integrator = integrator
# logger定義
pos_logger = hoomd.logging.Logger()
pos_logger.add(mpf, quantities=[ 'summed_exchanged_momentum'])
# pos_logger.add(thermodynamic_properties,quantities=["kinetic_temperature","kinetic_energy","potential_energy","volume"])
gsd_writer_pos = hoomd.write.GSD(filename=main_dir+"/log_pos.gsd",
trigger=hoomd.trigger.Periodic(pos_hout),
mode='xb',
filter=hoomd.filter.All())
gsd_writer_pos.log = pos_logger
sim.operations.writers.append(gsd_writer_pos)
sim.state.thermalize_particle_momenta(filter=hoomd.filter.All(), kT=kbT)
sim.run(0)