Packing with Packmol has a practical tradeoff:
- If the initial box is too small, packing can be very slow and difficult.
- If the initial box is too large, molecules can agglomerate and create vacuum-like regions, making NPT density convergence unstable or slow.
The in.equilibration.lmp script helps by relaxing overlaps first, then gradually compressing and equilibrating the system so density converges more reliably.
This repository contains one prepared LAMMPS data file:
ethanol_300_box100A.data- System: Ethanol
- Number of molecules: 300
- Box size:
100 x 100 x 100 A
- The simulation was run on a cluster.
- The LAMMPS simulation output is available in
cluster.output.
- Target density is controlled by
variable target_density. - Compression speed is controlled by
variable rate_per_step. - Larger
rate_per_stepgives faster compression (fewer steps). - Smaller
rate_per_stepgives slower, gentler compression (more steps). fix balanceis included for parallel runs to improve load balance across MPI ranks during deformation and equilibration.- For single-core runs,
fix balanceis usually not necessary. - A final
NPTstage is included afterNVTto relax pressure at fixed target temperature.
units real
dimension 3
boundary p p p
atom_style full
bond_style harmonic
angle_style harmonic
dihedral_style fourier
special_bonds amber
read_data ethanol_300_box100A.data
pair_style lj/cut/coul/long 10
kspace_style pppm 1.0e-4
pair_modify mix arithmetic tail yes
include parm.lammps
neighbor 2.0 bin
neigh_modify delay 0 every 1 check yes
comm_style brick
comm_modify mode single
comm_modify vel no
thermo 5000
thermo_style custom step temp epair emol etotal press vol density
timestep 1.0
variable temperature equal 300.0
velocity all create ${temperature} 12345 mom yes rot yes dist gaussian
fix nve_limit all nve/limit 0.1
fix lang all langevin ${temperature} ${temperature} 100.0 12345
fix bal0 all balance 1000 1.05 shift xyz 10 1.05
run 1000
unfix bal0
unfix nve_limit
unfix lang
variable target_density equal 1.2
variable total_mass equal mass(all)
variable target_vol equal v_total_mass/(v_target_density/1.66054)
variable target_box equal v_target_vol^(1.0/3.0)
variable scale_factor equal v_target_box/lx
# Compression speed control:
# Larger rate_per_step -> fewer steps (faster compression)
# Smaller rate_per_step -> more steps (slower, gentler compression)
variable rate_per_step equal 0.0001
variable nsteps_compress equal round((1.0-v_scale_factor)/v_rate_per_step)
fix nvt1 all nvt temp ${temperature} ${temperature} 100.0
fix compress all deform 1 x scale ${scale_factor} y scale ${scale_factor} z scale ${scale_factor} remap x
fix bal1 all balance 1000 1.05 shift xyz 10 1.05
run ${nsteps_compress}
unfix bal1
unfix compress
unfix nvt1
fix nve_limit all nve/limit 0.1
fix lang all langevin ${temperature} ${temperature} 100.0 12345
fix bal0 all balance 1000 1.05 shift xyz 10 1.05
run 1000
unfix bal0
unfix nve_limit
unfix lang
fix nvt2 all nvt temp ${temperature} ${temperature} 100.0
run 10000
unfix nvt2
fix npt1 all npt temp ${temperature} ${temperature} 100.0 iso 1.0 1.0 1000.0
run 1000000
unfix npt1
write_data data.compressed