A tool for generating initial packed molecular configurations (XYZ format) from single-molecule structures by calculating box dimensions, writing input scripts, and executing Packmol. USE WHEN you need to randomly pack a specific number of molecules into a simulation box (defined by target density or fixed lengths) to create starting geometries for molecular dynamics or related computational chemistry workflows.
Use Packmol to generate an initial packed configuration for a molecular mixture.
Collect inputs (ask if missing; do not guess):
species1.xyz, species2.xyz)species1: 100, species2: 650)tolerance (Å)Validate inputs:
Decide box size:
box_length_A: use it.box_length_A from density (see formula below).Create a working folder at the requested output location:
Write Packmol input ${system_name}.inp:
structure ... end structure block per componentinside box 0 0 0 L L LRun Packmol locally:
uvx packmol -i ${system_name}.inpuvx --from packmol packmol -i ${system_name}.inpReport results:
(Optional) Post-process for LAMMPS
If the user plans to run LAMMPS (especially ReaxFF), they often need a LAMMPS data file with correct box bounds.
lammps-md-tools from PyPI:uvx --from lammps-md-tools lammps-fix-box \
--in input.data \
--out output.boxfix.data \
--L 60.690 \
--wrap
This rewrites xlo/xhi, ylo/yhi, zlo/zhi to 0..L, zeroes tilt factors, and optionally wraps atoms into the box.
If the user didn’t specify them, ask at minimum:
species1=100, species2=650)tolerance (Å) should be used? (common starting point: 2.0 Å)If the user says “use defaults”, propose defaults:
tolerance = 2.0 Åpacked/ subfolder under the folder containing the input XYZExample (replace with your own species/files):
system_name: mixture_pack
output_dir: /path/to/output/packed
# Choose ONE of the following:
density_g_cm3: 0.25
# box_length_A: 60.69
tolerance_A: 2.0