#number of particles
variable natom equal 1000
units lj
dimension 3
atom_style atomic
boundary p p p
# define 3D box region
region box block -100 100 -100 100 -100 100
#create the simulation box with one type of particle
create_box 1 box
#put particles with type 1 randomly into the box
create_atoms 1 random ${natom} 324523 box
#all particles has mass 1
mass * 1
#Lennard-Jones potential between all particles
pair_style lj/cut 2.5
pair_coeff * * 1 1
#=============================================================
# Step 1: minimize energy first to avoid overlapping particles
#=============================================================
minimize 1e-7 1e-7 10000 10000
reset_timestep 0
#save snapshots
#shell "mkdir img"
#shell "rm img/*"
#dump img all image 1000 img/t*.jpg type type adiam 1.0 zoom 1.0
#dump_modify img backcolor white boxcolor black
#dump_modify img pad 6
# dump for OVITO to postprocess
shell "mkdir geo"
shell "rm geo/*"
dump 1 all custom 250 geo/dump.* id type x y z
#initialize velocity distribution corresponding to a temperature of 2
velocity all create 2 34234123 dist gaussian
# evolve system using Nose-Hoover themostat (an NVT simulation)
fix 1 all nve
#output time step, temperature, average kinetic and potential energy for plotting
thermo_style custom step temp ke pe
thermo 100
#time step of integrator
timestep 0.001
#start the simulation
run 100000
#!/bin/bash
#SBATCH --job-name=lammps
#SBATCH --time=1-00:00:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=24
#SBATCH --cpus-per-task=1
module load lammps
srun lmp_hpcc -in input.lammps > output.out
If you are working on the PFGP project, we first need to correct the Lammps input file with the following function:
#scratch is the path of the folder containing the file
#The original file is scratch+'in.'+fil
#here fil is a variable that contains the name
#home is a different folder
import os
def RW(fil, scratch, home):
with open(scratch+'in.'+fil, 'r') as f:
w = open(home+'in.'+fil,'w')
for line in f:
w.write(line)
if '500 steps CG Minimization' in line:
w.write('fix 1 all box/relax iso 0.0 vmax 0.001\n')
if 'undump' in line:
w.close()
break
os.rename(home+'in.'+fil,scratch+'in.'+fil)
After that we use the following script:
-------------------------------------------------
#!/bin/bash
#SBATCH --job-name='lammps'
#SBATCH -n 1
#SBATCH -t 01:00:00
#SBATCH -p mendoza_q
#SBATCH -o 'output.out'
#SBATCH -e 'error.e'
lmp < in.LammpsInputfFlleName
Following submit script will use 4 processes to run this example.
#!/bin/bash
#SBATCH -J "in.lammps"
#SBATCH -N 1
#SBATCH --ntasks-per-node=4
#SBATCH -p mendoza_q
#SBATCH -t 200:10:00
module purge all
module load gnu-openmpi
mpirun -np 4 lmp < in.lammps
Suggestion from Prasad Maddumage
#!/bin/bash
#SBATCH -J "in.lammps"
#SBATCH -N 1
#SBATCH --ntasks-per-node=4
#SBATCH -p mendoza_q
#SBATCH -t 200:10:00
module purge all
module load gnu-openmpi
mpirun -np 4 lmp
Also, using srun instead of mpirun is a good practice (srun -n 4 instead of mpirun -np 4).
ITEM: TIMESTEP
0
ITEM: NUMBER OF ATOMS
196
ITEM: BOX BOUNDS pp pp pp (x_initial, x_final, y_initial, y_final, z_initial, z_final are all periodic)
0.0000000000000000e+00 2.1883970000000001e+01 (x initial, x final)
0.0000000000000000e+00 2.1883970000000001e+01 (y initial, y final)
0.0000000000000000e+00 1.7868350000000000e+01 (z initial, z final)
ITEM: ATOMS id type xs ys zs ix iy iz (atom id, atom type, 3 scaled coordinates, box images that the atom is in)
33 5 5.02651e-05 0.288646 0.161259 1 0 0
34 5 0.0314248 0.342989 0.294371 1 0 0
Scaled coordinates are numbers from 0 to 1, a value of .25 means the atom is at 1/4 of the distance from x_initial to x_final.
For periodic dimensions, ix, iy, iz specify which image of the simulation box the atom is considered to be in. An image of (0,0,0) means it is inside the box defined. A value of (-1,0,0) means substract 1 x-length to get the true value.