$npx -y skills add jinzhezenggroup/computational-chemistry-agent-skills --skill packmol-generate-mixtureA 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
| 1 | # packmol-generate-mixture |
| 2 | |
| 3 | Use Packmol to generate an initial **packed** configuration for a molecular mixture. |
| 4 | |
| 5 | ## Agent responsibilities (do these in order) |
| 6 | |
| 7 | 1. **Collect inputs** (ask if missing; do not guess): |
| 8 | |
| 9 | - component structure files (XYZ), one per species (e.g. `species1.xyz`, `species2.xyz`) |
| 10 | - molecule counts for each species (e.g. `species1: 100`, `species2: 650`) |
| 11 | - **either** target density (g/cm^3) **or** a fixed cubic box length (Å) |
| 12 | - Packmol `tolerance` (Å) |
| 13 | - **output location**: output directory + output filename prefix (system name) |
| 14 | |
| 15 | 1. **Validate inputs**: |
| 16 | |
| 17 | - confirm XYZ files exist and are readable |
| 18 | - confirm the first line (atom count) matches the number of coordinate lines |
| 19 | - if density-based box estimation is requested: confirm each molecule’s elemental composition can be inferred from the XYZ symbols |
| 20 | |
| 21 | 1. **Decide box size**: |
| 22 | |
| 23 | - If user provides `box_length_A`: use it. |
| 24 | - Else compute `box_length_A` from density (see formula below). |
| 25 | |
| 26 | 1. **Create a working folder** at the requested output location: |
| 27 | |
| 28 | - copy the component XYZ files into it (or reference them with absolute paths) |
| 29 | |
| 30 | 1. **Write Packmol input** `${system_name}.inp`: |
| 31 | |
| 32 | - one `structure ... end structure` block per component |
| 33 | - all components share the same `inside box 0 0 0 L L L` |
| 34 | |
| 35 | 1. **Run Packmol locally**: |
| 36 | |
| 37 | - Prefer: `uvx packmol -i ${system_name}.inp` |
| 38 | - If you need to force the source package: `uvx --from packmol packmol -i ${system_name}.inp` |
| 39 | |
| 40 | 1. **Report results**: |
| 41 | |
| 42 | - exact output paths (inp, xyz, log) |
| 43 | - final box length (Å) and the parameters used (counts, density or fixed L, tolerance) |
| 44 | - basic sanity checks (total molecules, total atoms) |
| 45 | |
| 46 | 1. **(Optional) Post-process for LAMMPS** |
| 47 | |
| 48 | If the user plans to run LAMMPS (especially ReaxFF), they often need a LAMMPS data file with correct box bounds. |
| 49 | |
| 50 | - If you convert XYZ -> LAMMPS data with dpdata, dpdata may write default box bounds (e.g., 0..100 Å). |
| 51 | - Fix the bounds to match the Packmol cubic box length using `lammps-md-tools` from PyPI: |
| 52 | |
| 53 | ```bash |
| 54 | uvx --from lammps-md-tools lammps-fix-box \ |
| 55 | --in input.data \ |
| 56 | --out output.boxfix.data \ |
| 57 | --L 60.690 \ |
| 58 | --wrap |
| 59 | ``` |
| 60 | |
| 61 | This rewrites `xlo/xhi`, `ylo/yhi`, `zlo/zhi` to `0..L`, zeroes tilt factors, and optionally wraps atoms into the box. |
| 62 | |
| 63 | ## What to ask the user (plain language) |
| 64 | |
| 65 | If the user didn’t specify them, ask **at minimum**: |
| 66 | |
| 67 | - **Packing counts**: how many molecules of each species? (e.g., `species1=100, species2=650`) |
| 68 | - **Box definition**: do you want to estimate a cubic box from a target density (g/cm^3), or do you want to provide a fixed cubic box length L (Å)? |
| 69 | - **Tolerance**: what Packmol `tolerance` (Å) should be used? (common starting point: 2.0 Å) |
| 70 | - **Output location**: which directory should receive the results, and what system name / filename prefix should be used? |
| 71 | |
| 72 | If the user says “use defaults”, propose defaults: |
| 73 | |
| 74 | - `tolerance = 2.0 Å` |
| 75 | - output dir: a `packed/` subfolder under the folder containing the input XYZ |
| 76 | - (density) **do not assume**; ask for it, but you may suggest a starting value the user can confirm. |
| 77 | |
| 78 | ## Input schema (recommended) |
| 79 | |
| 80 | Example (replace with your own species/files): |
| 81 | |
| 82 | ```yaml |
| 83 | system_name: mixture_pack |
| 84 | output_dir: /path/to/output/packed |
| 85 | # Choose ONE of the following: |
| 86 | density_g_cm3: 0.25 |
| 87 | # box_length_A: 60.69 |
| 88 | |
| 89 | tolerance_A: 2.0 |
| 90 | components: |
| 91 | - name: species1 |
| 92 | structure_file: /path/to/species1.xyz |
| 93 | number: 100 |
| 94 | - name: species2 |
| 95 | structure_file: /path/to/species2.xyz |
| 96 | number: 650 |
| 97 | ``` |
| 98 | |
| 99 | ## Density → cubic box length (Å) |
| 100 | |
| 101 | When `density_g_cm3` is provided and `box_length_A` is not, estimate L from total mass: |
| 102 | |
| 103 | - infer each molecule’s elemental composition from its XYZ symbols |
| 104 | - use standard atomic masses (g/mol) |
| 105 | - compute total molar mass of the whole configuration (g/mol) |
| 106 | - convert to mass per configuration: `m_cfg = M_total / N_A` (g) |
| 107 | - compute volume in cm^3: `V_cm3 = m_cfg / density_g_cm3` |
| 108 | - convert to Å^3: `V_A3 = V_cm3 * 1e24` |
| 109 | - cubic length: `L_A = V_A3 ** (1/3)` |
| 110 | |
| 111 | This is an **initial packing estimate** (geometry construction), not an equilibrated density. |
| 112 | |
| 113 | ## Output contract |