amber-to-lammps 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 AMBER2LAMMPS Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,632 @@
1
+ Metadata-Version: 2.4
2
+ Name: amber-to-lammps
3
+ Version: 1.0.0
4
+ Summary: Convert AMBER topology and PDB files to LAMMPS data and parameter files
5
+ Author: Arun Sridhar
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/askforarun/AMBER2LAMMPS
8
+ Project-URL: Repository, https://github.com/askforarun/AMBER2LAMMPS
9
+ Project-URL: Issues, https://github.com/askforarun/AMBER2LAMMPS/issues
10
+ Project-URL: DOI, https://doi.org/10.5281/zenodo.18114886
11
+ Keywords: AMBER,LAMMPS,molecular dynamics,scientific computing
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: numpy
23
+ Requires-Dist: ParmEd
24
+ Dynamic: license-file
25
+
26
+ # Overview
27
+
28
+ Python utility that converts AMBER `.prmtop`/PDB files to LAMMPS data/parameter formats through CLI or Python API, featuring validation-first error handling. **Can handle multiple AMBER topology files for mixed molecular systems (e.g., drug + solvent mixtures).**
29
+
30
+ ## Key Features
31
+
32
+ - **๐Ÿ”ง Multi-Topology Conversion**: Convert mixed systems using multiple AMBER `.prmtop` files in a single run
33
+ - **๐Ÿงช Mixed & Replicated Systems**: Handle mixtures (e.g., drug + solvent) and multiple copies of one molecule via `-c`
34
+ - **โœ… Validation-First**: Clear errors for missing files, mismatched list lengths, and PDB atom-count/order issues
35
+ - **๐Ÿ”„ CLI + Python API**: Same conversion engine from the command line or `amber2lammps(...)` in Python
36
+ - **๐Ÿ“ฆ Debug Artifacts (`--keep-temp`)**: Optionally write `pairs.txt`, `bonds.txt`, `angles.txt`, `dihedrals.txt` grouped by topology
37
+
38
+ ## What This Tool Does
39
+
40
+ Run molecular dynamics simulations in **LAMMPS** using systems prepared in **AMBER** format. Supports both single-molecule and mixed molecular systems with multiple topology files.
41
+
42
+ **Typical workflow:**
43
+ 1. Start with a molecular structure (PDB file or SMILES string).
44
+ 2. Generate AMBER topology files (`.prmtop`) with AmberTools (and optionally `.crd` for other tools/validation).
45
+ 3. Convert (`.prmtop` + PDB coordinates) to LAMMPS format with this tool.
46
+ 4. Run your simulation in LAMMPS.
47
+
48
+ **Input โ†’ Output Mapping**
49
+ - **`.prmtop`**: Molecular topology (bonds, angles, atom types, force-field parameters) โ†’ LAMMPS data and parameter files. Supports multiple topologies for mixed systems.
50
+ - **PDB**: Atomic coordinates (single molecule or combined from PackMol) โ†’ LAMMPS coordinates with proper atom indexing.
51
+ - **Outputs**: `data.lammps` (coordinates, box, topology) and `parm.lammps` (bonded and nonbonded parameters).
52
+
53
+
54
+ ## Table of Contents
55
+ - [Open Source](#open-source)
56
+ - [Citation](#citation)
57
+ - [Platform Compatibility](#platform-compatibility)
58
+ - [What You Need](#what-you-need)
59
+ - [Installation](#installation)
60
+ - [Install AMBER2LAMMPS](#install-amber2lammps)
61
+ - [AmberTools](#ambertools)
62
+ - [LAMMPS](#lammps)
63
+ - [SMILES to PDB Workflow](#smiles-to-pdb-workflow)
64
+ - [Command Reference](#command-reference)
65
+ - [How It Works](#how-it-works)
66
+ - [Tutorial](#tutorial)
67
+ - [CLI with LAMMPS execution](#cli-with-lammps-execution)
68
+ - [Additional CLI examples](#additional-cli-examples)
69
+ - [Python API with LAMMPS execution](#python-api-with-lammps-execution)
70
+ - [Additional API examples](#additional-api-examples)
71
+ - [Multiple Copies and Mixed Molecular System Workflow](#multiple-copies-and-mixed-molecular-system-workflow)
72
+ - [Validation with InterMol](#validation-with-intermol)
73
+ - [Contributing](#contributing)
74
+ - [Acknowledgements](#acknowledgements)
75
+
76
+ ## Open Source
77
+
78
+ This is an open-source project. The source code is freely available for use, modification, and
79
+ distribution under the MIT License.
80
+
81
+ ## Citation
82
+
83
+ If you use this software in your research, please cite it as:
84
+
85
+ **DOI:** [10.5281/zenodo.18114886](https://doi.org/10.5281/zenodo.18114886)
86
+
87
+ ## Platform Compatibility
88
+
89
+ Tested and validated on:
90
+ - **Linux** (Ubuntu, CentOS, Red Hat, Debian)
91
+ - **macOS** (Intel and Apple Silicon)
92
+ - **Windows 10/11** (native Python or WSL2; WSL2 recommended)
93
+
94
+ ## What You Need
95
+
96
+ - **Structure input**: A PDB file of the molecular structure (or a SMILES string that you convert to PDB; see workflow below). For mixed systems, use a combined PDB file from PACKMOL containing all molecules.
97
+ - **AMBER prep**: AmberTools (`antechamber`, `tleap`) to generate `.prmtop`. For mixed systems, generate separate `.prmtop` files for each molecule type.
98
+ - **Python**: Python 3.8+ with `parmed` and `numpy`.
99
+ - **LAMMPS**: Build with `MOLECULE`, `KSPACE`, and `EXTRA-MOLECULE` packages on your `PATH` (`lmp -h` to confirm).
100
+
101
+ **Note**: If you are using a PDB file generated from SMILES or another source, it is recommended that you pass in the PDB file with the `antechamber -dr yes` option. PDB format note: The converter uses fixed-column parsing of ATOM/HETATM records. PackMol-style PDBs work well; non-standard PDBs (e.g., unusual formatting, multi-model files) may fail or require cleanup.
102
+
103
+ ## Installation
104
+
105
+ ### Install AMBER2LAMMPS
106
+
107
+ Install the released package from PyPI:
108
+
109
+ ```bash
110
+ python -m pip install amber-to-lammps
111
+ ```
112
+
113
+ This installs the `amber-to-lammps` command and the `amber_to_lammps` Python module, together with
114
+ the required Python dependencies (`ParmEd` and `NumPy`). Verify the command-line installation with:
115
+
116
+ ```bash
117
+ amber-to-lammps --help
118
+ ```
119
+
120
+ To install the latest source checkout instead, run this from the repository root:
121
+
122
+ ```bash
123
+ python -m pip install .
124
+ ```
125
+
126
+ ### PACKMOL
127
+
128
+ Required for running LAMMPS simulation multiple copies of the molecule or mixed molecular systems. Install from:
129
+ https://m3g.github.io/packmol/
130
+
131
+ PACKMOL creates combined PDB files with multiple molecules positioned in a simulation box.
132
+
133
+ Verify installation by running:
134
+ ```bash
135
+ which packmol
136
+ ```
137
+
138
+ ### AmberTools
139
+
140
+ Install AmberTools (e.g., AmberTools23) from https://ambermd.org/GetAmber.php#ambertools and
141
+ activate the environment:
142
+
143
+ ```bash
144
+ conda activate AmberTools23 # or your AmberTools version
145
+ ```
146
+
147
+ ### LAMMPS
148
+
149
+ Download LAMMPS (https://lammps.org/) and build a recent stable version with packages `MOLECULE`,
150
+ `KSPACE`, and `EXTRA-MOLECULE` enabled. Verify your installation with `lmp` or `which lmp`.
151
+
152
+ ## SMILES to PDB Workflow
153
+
154
+ Use Open Babel (`obabel`) to generate a 3D PDB from SMILES.
155
+
156
+ ### Installation
157
+
158
+ ```bash
159
+ # macOS
160
+ brew install open-babel
161
+
162
+ # conda
163
+ conda install -c openbabel openbabel
164
+
165
+ # Ubuntu/Debian
166
+ sudo apt-get install openbabel
167
+ ```
168
+
169
+ ### Generate PDB from SMILES
170
+
171
+ ```bash
172
+ # Basic conversion
173
+ obabel -:CCO -opdb -O ethanol.pdb --gen3d
174
+
175
+ # With explicit hydrogens (recommended)
176
+ obabel -:CCO -h -opdb -O ethanol.pdb --gen3d
177
+
178
+ # Other examples
179
+ obabel -:c1ccccc1 -opdb -O benzene.pdb --gen3d # Benzene
180
+ obabel -:"CC(=O)OC1=CC=CC=C1C(=O)O" -opdb -O aspirin.pdb --gen3d # Aspirin
181
+ ```
182
+
183
+ ## Command Reference
184
+
185
+ Outputs: a LAMMPS data file (`<data_file>`, e.g., `data.lammps`) and a separate parameter file
186
+ (`<param_file>`, e.g., `parm.lammps`).
187
+
188
+ | Argument | Required | Description |
189
+ |-----------|----------|-------------|
190
+ | `data_file` | yes | Output LAMMPS data file name |
191
+ | `param_file` | yes | Output LAMMPS parameter file name |
192
+ | `pdb_file` | yes | Combined PDB containing all molecules (e.g., from PackMol) |
193
+ | `-t, --topologies` | yes | One or more AMBER topology files (`.prmtop`) |
194
+ | `-c, --counts` | yes | Molecule counts for each topology (same order/length as `--topologies`) |
195
+ | `--charges` | yes | Target net charge per topology (list matching `--topologies`; use `0 0 ...` for neutrals) |
196
+ | `-b, --buffer` | optional | Vacuum padding (ร…) for the simulation box. Default: `3.8`. |
197
+ | `--verbose` | optional | Print step-by-step progress, counts, and box size. Default: `False`. |
198
+ | `--keep-temp` | optional | Keep temporary files (`pairs.txt`, `bonds.txt`, `angles.txt`, `dihedrals.txt`) grouped by topology. Default: `False`. |
199
+ | `--c4-cutoff` | optional | LJ/Coulomb/Lepton cutoff used for 12-6-4 output. Default: `9.0` ร…. |
200
+ | `--c4-coulomb` | optional | Coulomb style for 12-6-4 output: `long` or `cut`. Default: `long`. |
201
+ | `-h, --help` | optional | Show help message. |
202
+
203
+ ## How It Works
204
+
205
+ 1. **Input validation**: `validate_files` checks that `topologies`, `counts`, and `pdb_file` exist and lengths match. CLI does this automatically; Python API requires calling it yourself.
206
+ 2. **Load topology and parameters**: ParmEd reads atoms, bonds, angles, dihedrals, masses, and LJ parameters directly from each `.prmtop` (supports multiple topologies).
207
+ 3. **Atom types and masses**: Atom types are namespaced on conflict across topologies; masses and LJ params are captured per canonical type.
208
+ 4. **Coordinates and box**: Coordinates come from the combined PDB; the box is min/max of those coordinates expanded by `buffer`.
209
+ 5. **Charge normalization**: For each topology, charges are uniformly shifted to hit the user-provided `--charges` target (tolerance 1e-6). Totals are checked across all molecules.
210
+ 6. **Nonbonded coefficients**: Standard topologies emit likeโ€“like `pair_coeff` lines and use LAMMPS mixing. If AMBER contains nonzero 12-6-4 `LENNARD_JONES_CCOEF` values or off-diagonal A/B overrides, the complete Iโ€“J matrix is emitted explicitly. For 12-6-4, the parameter include configures `hybrid/overlay` with Lepton expressions for `-C4/r^4`; LAMMPS must be built with its LEPTON package.
211
+ 7. **Bonded coefficients (two-pass, deduplicated)**: A first pass iterates each topology **once** to build global type registries for bonds, angles, and dihedrals โ€” keyed by rounded parameter values so that identical force constants across different topologies or molecule copies share one type ID. Dihedrals are grouped by atom-index tuple first to correctly merge multi-term Fourier companions into a single `dihedral_coeff` line, then deduplicated by parameter signature across symmetry-equivalent instances. A second pass writes the connectivity rows (`Bonds`/`Angles`/`Dihedrals` sections) for all replicas, referencing the pre-computed type IDs. This means bond/angle/dihedral type counts stay constant regardless of how many copies (`-c N`) are used.
212
+ 8. **Export and cleanup**: Data/parameter files are written; debug files (`pairs.txt`, `bonds.txt`, `angles.txt`, `dihedrals.txt`) are kept if `--keep-temp` is set.
213
+
214
+ ### 12-6-4 and pair-specific Lennard-Jones parameters
215
+
216
+ Topologies containing nonzero `LENNARD_JONES_CCOEF` values are written using a LAMMPS `hybrid/overlay` pair style. The generated parameter include defines the ordinary 12-6 plus Coulomb sub-style and overlays each nonzero C4 interaction with a Lepton `-C4/r^4` expression. It also emits every I-J LJ coefficient explicitly, preserving off-diagonal changes made by tools such as ParmEd's `changeLJPair`.
217
+
218
+ LAMMPS must be compiled with the optional **LEPTON** package for 12-6-4 output. Choose the cutoff and Coulomb treatment during conversion, for example:
219
+
220
+ ```bash
221
+ amber-to-lammps znf.data znf.parm znf.pdb \
222
+ -t znf_1264.prmtop -c 1 --charges 5 \
223
+ --c4-cutoff 9.0 --c4-coulomb long
224
+ ```
225
+
226
+ With `--c4-coulomb long`, retain a compatible `kspace_style` command in the LAMMPS input. With `--c4-coulomb cut`, no long-range solver is required. Because the generated parameter file configures `pair_style` itself for 12-6-4 systems, do not add another `pair_style` command after including it.
227
+
228
+ ### Understanding Charge Schemes and Normalization
229
+
230
+ **AMBER Charge Schemes:**
231
+ AMBER uses various charge methods including:
232
+ - **RESP** (Restrained Electrostatic Potential): Derived from quantum mechanical electrostatic potential
233
+ - **AM1-BCC**: Semi-empirical charges with bond charge corrections
234
+ - **CM5** or **CM1A**: Charge models based on atomic charges
235
+
236
+
237
+ **Charge Normalization in AMBER2LAMMPS:**
238
+ - Most systems should typically be neutral for PME convergence; AM1-BCC charge calculations often leave small residuals (ยฑ0.003).
239
+ - For neutral molecules, run with `--charges 0` so AMBER2LAMMPS applies a uniform offset that removes the residual charge; this prevents the error from scaling up when the system is replicated in LAMMPS or when you have multiple copies of the same molecule.
240
+ - For intentionally charged species (e.g., protonated or deprotonated), add counterions in tleap/packmol before conversion. AMBER2LAMMPS never adds ions; it only shifts existing charges to your requested total.
241
+ - How the flag works:
242
+ - `--charges 0`: adds a uniform offset so total charge is 0 within 1e-6.
243
+ - `--charges +1` (or any integer): adds a uniform offset so the total matches that integer within 1e-6.
244
+ - The same constant is added to every atom, so relative charge differences are preserved.
245
+
246
+ **Example:** If your system has net charge +0.003 and you specify `--charges 0`, each atom's charge will be reduced by `(0.003 รท number_of_atoms)` to reach neutrality.
247
+
248
+
249
+ ## Tutorial
250
+
251
+ The tutorial assumes AMBER2LAMMPS is installed with `python -m pip install amber-to-lammps`.
252
+
253
+
254
+ ### CLI with LAMMPS execution
255
+
256
+ #### 1. Generate AMBER Topology (`.prmtop`)
257
+
258
+ Activate the AmberTools environment before running:
259
+
260
+ ```python
261
+ import subprocess
262
+
263
+ pdb_file = "epon.pdb" # Replace with your PDB filename
264
+ base_name = pdb_file.replace(".pdb", "")
265
+
266
+ # Generate MOL2 file with charges from PDB file
267
+ cmd1 = f"antechamber -j 4 -at gaff2 -dr yes -fi pdb -fo mol2 -i {pdb_file} -o {base_name}.mol2 -c bcc"
268
+ subprocess.run(cmd1, shell=True)
269
+ # -c flag specifies the charge method. bcc is used for AM1-BCC charges
270
+ # -nc flag specifies net charge (default: 0.0). Use for charged molecules (e.g., -nc 1 for +1 charge)
271
+
272
+ # Create tleap input file
273
+ with open("tleap.in", "w") as f:
274
+ f.write("source leaprc.gaff2\n") # Load the Gaff2 force field
275
+ f.write(f"MOLECULE = loadmol2 {base_name}.mol2\n") # Load the molecule
276
+ f.write("check MOLECULE\n") # Check the molecule
277
+ f.write(f"saveamberparm MOLECULE {base_name}.prmtop {base_name}.crd\n") # Save the AMBER files
278
+ f.write("quit")
279
+
280
+ # Run tleap to generate AMBER files
281
+ cmd3 = "tleap -f tleap.in"
282
+ subprocess.run(cmd3, shell=True)
283
+
284
+ # Output files generated: epon.prmtop, epon.crd, epon.mol2
285
+ # Note: amber_to_lammps.py uses epon.prmtop + epon.pdb; the .crd is optional (kept for validation/other tools).
286
+ ```
287
+
288
+ #### 2. Run the Conversion
289
+
290
+ ```bash
291
+ amber-to-lammps data.lammps parm.lammps epon.pdb \
292
+ -t epon.prmtop -c 1 --charges 0 --verbose -b 4.5
293
+ ```
294
+
295
+ #### 3. Run LAMMPS
296
+
297
+ Use the provided `example_lammps_input.lmp`:
298
+
299
+ ```bash
300
+ lmp < example_lammps_input.lmp
301
+ ```
302
+
303
+ **Note**: The LAMMPS input file `example_lammps_input.lmp` includes `parm.lammps` (force-field
304
+ parameters) and uses `read_data` to load `data.lammps` (coordinates). Keeping parameters separate
305
+ makes it easy to swap parameter sets without regenerating coordinates.
306
+
307
+ #### Additional CLI examples
308
+
309
+ ```bash
310
+ # Custom buffer and verbose logging (adds 5 ร… padding)
311
+ amber-to-lammps my_data.lammps my_params.lammps ethanol.pdb \
312
+ -t ethanol.prmtop -c 1 --charges 0 --verbose -b 5.0
313
+
314
+ # Custom output names
315
+ amber-to-lammps system.data system.parm system.pdb \
316
+ -t system.prmtop -c 1 --charges 0
317
+
318
+ # Minimal output without verbose logging
319
+ amber-to-lammps data.lammps parm.lammps ethanol.pdb \
320
+ -t ethanol.prmtop -c 1 --charges 0 -b 3.0
321
+
322
+ # Using absolute paths with custom buffer
323
+ amber-to-lammps /home/user/lammps/output/data.lammps /home/user/lammps/output/param.lammps /home/user/amber/packmol/combined.pdb \
324
+ -t /home/user/amber/topology.prmtop -c 1 --charges 0 -b 4.5
325
+
326
+ # Single topology with multiple copies (e.g., 10 ethanol molecules)
327
+ amber-to-lammps multi_ethanol_data.lammps multi_ethanol_parm.lammps multi_ethanol.pdb \
328
+ -t ethanol.prmtop -c 10 --charges 0 --verbose
329
+ ```
330
+ If you include `--keep-temp`, the converter will also write `pairs.txt`, `bonds.txt`, `angles.txt`, and `dihedrals.txt`, each grouped by topology (handy for debugging mixed systems).
331
+ `example_lammps_input.lmp` includes `parm.lammps` and reads `data.lammps`; adjust those paths and the file names in example_lammps_input.lmp if you rename outputs.
332
+
333
+ ### Python API with LAMMPS execution
334
+
335
+ ```python
336
+ from amber_to_lammps import amber2lammps, validate_files
337
+ import subprocess
338
+
339
+ data_file = 'data.lammps'
340
+ param_file = 'parm.lammps'
341
+ pdb_file = 'epon.pdb'
342
+ topologies = ['epon.prmtop']
343
+ counts = [1]
344
+ charges = [0]
345
+
346
+ # Optional validation
347
+ validate_files(topologies, counts, pdb_file)
348
+
349
+ # Convert
350
+ amber2lammps(
351
+ data_file=data_file,
352
+ param_file=param_file,
353
+ topologies=topologies,
354
+ molecule_counts=counts,
355
+ pdb_file=pdb_file,
356
+ charges_target=charges,
357
+ buffer=3.8,
358
+ verbose=True,
359
+ keep_temp=False
360
+ )
361
+
362
+ # Run LAMMPS
363
+ subprocess.run("lmp < example_lammps_input.lmp", shell=True)
364
+ print("Completed conversion")
365
+ ```
366
+
367
+
368
+ #### Additional API examples
369
+
370
+ ```python
371
+ # Example 1: Custom buffer and keep temporary files
372
+ from amber_to_lammps import amber2lammps
373
+
374
+ amber2lammps(
375
+ data_file='epon.data',
376
+ param_file='epon.parm',
377
+ topologies=['epon.prmtop'],
378
+ molecule_counts=[1],
379
+ pdb_file='epon.pdb',
380
+ charges_target=[0], # Target neutral charge
381
+ buffer=5.0,
382
+ verbose=True,
383
+ keep_temp=True # Keep temporary files for inspection
384
+ )
385
+
386
+
387
+
388
+ # Example 2: Batch processing multiple molecules
389
+ from amber_to_lammps import amber2lammps, validate_files
390
+
391
+ molecules = ['ethanol', 'benzene', 'aspirin']
392
+
393
+ for mol in molecules:
394
+ validate_files([f'{mol}.prmtop'], [1], f'{mol}.pdb')
395
+ amber2lammps(
396
+ data_file=f'{mol}.data',
397
+ param_file=f'{mol}.parm',
398
+ topologies=[f'{mol}.prmtop'],
399
+ molecule_counts=[1],
400
+ pdb_file=f'{mol}.pdb',
401
+ charges_target=[0],
402
+ verbose=True,
403
+ keep_temp=False
404
+ )
405
+ ```
406
+
407
+ ## Multiple Copies and Mixed Molecular System Workflow
408
+
409
+ For systems containing multiple molecule types (e.g., drug + solvent mixtures), use the following workflow.
410
+
411
+ ### Mixed Molecular System (Multiple Topologies)
412
+
413
+ #### 1. Prepare Individual Molecules
414
+ ```bash
415
+ # Generate MOL2 files with proper bond orders (Open Babel + Antechamber)
416
+ obabel aspirin.pdb -opdb -O aspirin_obabel.pdb -h --gen3d
417
+ obabel aspirin_obabel.pdb -omol2 -O aspirin_obabel.mol2 -h
418
+ antechamber -fi mol2 -fo mol2 -i aspirin_obabel.mol2 -o aspirin_final.mol2 -c bcc
419
+
420
+ # Repeat for benzene and ethanol
421
+ obabel benzene.pdb -opdb -O benzene_obabel.pdb -h --gen3d
422
+ obabel benzene_obabel.pdb -omol2 -O benzene_obabel.mol2 -h
423
+ antechamber -fi mol2 -fo mol2 -i benzene_obabel.mol2 -o benzene_final.mol2 -c bcc
424
+
425
+ obabel ethanol.pdb -opdb -O ethanol_obabel.pdb -h --gen3d
426
+ obabel ethanol_obabel.pdb -omol2 -O ethanol_obabel.mol2 -h
427
+ antechamber -fi mol2 -fo mol2 -i ethanol_obabel.mol2 -o ethanol_final.mol2 -c bcc
428
+ ```
429
+
430
+ #### 2. Generate AMBER Topologies
431
+ ```bash
432
+ # Create tleap input files and run for each molecule
433
+ tleap -f tleap_aspirin.in
434
+ tleap -f tleap_benzene.in
435
+ tleap -f tleap_ethanol.in
436
+ ```
437
+
438
+ #### 3. Build Mixed System with PackMol
439
+
440
+ ```bash
441
+ # Create PackMol input file
442
+ cat > packmol_mix.in << 'EOF'
443
+ tolerance 2.0
444
+ filetype pdb
445
+ output mixed_system.pdb
446
+
447
+ # Aspirin (1 molecule)
448
+ structure aspirin.pdb
449
+ number 1
450
+ inside box 0.0 0.0 0.0 10.0 10.0 10.0
451
+ end structure
452
+
453
+ # Benzene (2 molecules)
454
+ structure benzene.pdb
455
+ number 2
456
+ inside box 0.0 0.0 0.0 10.0 10.0 10.0
457
+ end structure
458
+
459
+ # Ethanol (5 molecules)
460
+ structure ethanol.pdb
461
+ number 5
462
+ inside box 0.0 0.0 0.0 10.0 10.0 10.0
463
+ end structure
464
+ EOF
465
+
466
+ # Run PackMol
467
+ packmol < packmol_mix.in
468
+
469
+ # The resulting mixed_system.pdb is a single combined PDB containing all molecules
470
+ # in the same order and counts you will pass to -t/-c. Keep residue/atom ordering intact.
471
+ ```
472
+
473
+ #### 4. Convert to LAMMPS
474
+
475
+ ```bash
476
+ # Convert the mixed molecular system to LAMMPS format
477
+ amber-to-lammps mixed_data.lammps mixed_parm.lammps mixed_system.pdb \
478
+ -t aspirin.prmtop benzene.prmtop ethanol.prmtop -c 1 2 5 --charges 0 0 0 --verbose
479
+ ```
480
+
481
+ #### Python API
482
+
483
+ ```python
484
+ from amber_to_lammps import amber2lammps, validate_files
485
+ import subprocess
486
+
487
+ # Validate all topology files
488
+ validate_files(['aspirin.prmtop', 'benzene.prmtop', 'ethanol.prmtop'], [1, 2, 5], 'mixed_system.pdb')
489
+
490
+ # Convert mixed system with multiple molecule types
491
+ amber2lammps(
492
+ data_file='mixed_data.lammps',
493
+ param_file='mixed_parm.lammps',
494
+ topologies=['aspirin.prmtop', 'benzene.prmtop', 'ethanol.prmtop'],
495
+ molecule_counts=[1, 2, 5], # 1 aspirin, 2 benzene, 5 ethanol
496
+ pdb_file='mixed_system.pdb',
497
+ charges_target=[0, 0, 0], # All neutral molecules
498
+ verbose=True,
499
+ keep_temp=False
500
+ )
501
+
502
+ # Run LAMMPS with mixed system
503
+ subprocess.run("lmp < test_mixed_system.in", shell=True)
504
+ ```
505
+
506
+ ### Multiple Copies (Single Topology)
507
+
508
+ #### 1. Prepare Individual Molecules
509
+ ```bash
510
+ # Generate MOL2 files with proper bond orders (Open Babel + Antechamber)
511
+ obabel ethanol.pdb -opdb -O ethanol_obabel.pdb -h --gen3d
512
+ obabel ethanol_obabel.pdb -omol2 -O ethanol_obabel.mol2 -h
513
+ antechamber -fi mol2 -fo mol2 -i ethanol_obabel.mol2 -o ethanol_final.mol2 -c bcc
514
+ ```
515
+
516
+ #### 2. Generate AMBER Topologies
517
+ ```bash
518
+ # Create tleap input files and run for the molecule
519
+ tleap -f tleap_ethanol.in
520
+ ```
521
+
522
+ #### 3. Build Multi-Copy System with PackMol
523
+
524
+ ```bash
525
+ # Create PackMol input file for multiple copies (packmol_multi_ethanol.in)
526
+ cat > packmol_multi_ethanol.in << 'EOF'
527
+ tolerance 2.0
528
+ filetype pdb
529
+ output multi_ethanol.pdb
530
+
531
+ # Ethanol (10 molecules)
532
+ structure ethanol.pdb
533
+ number 10
534
+ inside box 0.0 0.0 0.0 15.0 15.0 15.0
535
+ end structure
536
+ EOF
537
+
538
+ # Run PackMol
539
+ packmol < packmol_multi_ethanol.in
540
+
541
+ # The resulting multi_ethanol.pdb is a single combined PDB containing all molecules
542
+ # in the same order and counts you will pass to -t/-c. Keep residue/atom ordering intact.
543
+ ```
544
+
545
+ #### 4. Convert to LAMMPS
546
+
547
+ ```bash
548
+ # Convert the multi-copy molecular system to LAMMPS format
549
+ amber-to-lammps multi_ethanol_data.lammps multi_ethanol_parm.lammps multi_ethanol.pdb \
550
+ -t ethanol.prmtop -c 10 --charges 0 --verbose
551
+ ```
552
+
553
+ #### Python API
554
+
555
+ ```python
556
+ from amber_to_lammps import amber2lammps, validate_files
557
+
558
+ # Validate single topology with multiple copies
559
+ validate_files(['ethanol.prmtop'], [10], 'multi_ethanol.pdb')
560
+
561
+ # Convert multiple copies of the same molecule
562
+ amber2lammps(
563
+ data_file='multi_ethanol_data.lammps',
564
+ param_file='multi_ethanol_parm.lammps',
565
+ topologies=['ethanol.prmtop'],
566
+ molecule_counts=[10], # 10 ethanol molecules
567
+ pdb_file='multi_ethanol.pdb',
568
+ charges_target=[0],
569
+ verbose=True,
570
+ keep_temp=False
571
+ )
572
+ ```
573
+
574
+ ```python
575
+ # Use appropriate LAMMPS input for mixed systems
576
+ subprocess.run("lmp < test_mixed_system.in", shell=True)
577
+ ```
578
+
579
+ ## Validation with InterMol
580
+
581
+ Conversion results have been cross-checked with **InterMol**.
582
+
583
+ Install InterMol: https://github.com/shirtsgroup/InterMol
584
+
585
+ **Usage (InterMol):**
586
+ ```bash
587
+ python convert.py --amb_in epon.prmtop epon.crd --lammps --odir . --oname epon_converted
588
+ ```
589
+ InterMol expects an AMBER coordinate file (`.crd`); `amber_to_lammps.py` uses the PDB for coordinates.
590
+
591
+ **Committed validation assets:**
592
+ - `epon_converted.input` / `epon_converted.lmp` (InterMol reference)
593
+ - `epon_validation.input` / `epon_validation.data` / `epon_validation.parm` (AMBER2LAMMPS validation snapshot)
594
+
595
+ `epon_validation.data` is an AMBER2LAMMPS-generated snapshot with box bounds aligned to the
596
+ InterMol cell so the comparison isolates force-field conversion rather than box construction.
597
+
598
+ ```bash
599
+ lmp < epon_converted.input
600
+ lmp < epon_validation.input
601
+ ```
602
+
603
+ **Energy Comparison Results**
604
+
605
+ *Output from the committed InterMol and AMBER2LAMMPS validation assets above*
606
+
607
+ | Energy Component | InterMol | AMBER2LAMMPS | Difference |
608
+ |------------------|----------|---------------|------------|
609
+ | E_bond | 2.3161274 | 2.3161274 | 0.0000 |
610
+ | E_angle | 6.0940384 | 6.0940126 | 0.0000258 |
611
+ | E_dihed | 12.475809 | 12.475827 | -0.0000180 |
612
+ | E_impro | 0.0000 | 0.0000 | 0.0000 |
613
+ | E_pair | -8.8739005 | -8.8427535 | -0.0311470 |
614
+ | E_vdwl | 10.824738 | 10.824738 | 0.0000 |
615
+ | E_coul | 97.869973 | 97.927222 | -0.0572490 |
616
+ | E_long | -117.56861 | -117.59471 | 0.02610 |
617
+ | E_tail | -0.0044166818 | -0.0044166819 | 0.0000000001 |
618
+ | **PotEng** | **12.012074** | **12.043214** | **-0.03114** |
619
+
620
+
621
+ ## Contributing
622
+
623
+ When making changes:
624
+ 1. Create a branch: `git checkout -b feature-name`
625
+ 2. Implement the change
626
+ 3. Test with varied inputs
627
+ 4. Commit and push
628
+
629
+ ## Acknowledgements
630
+
631
+ Thanks to Dr. Axel Kohlmeyer and Dr. Germain Clavier for tutorial feedback, and to Dr. Andrew Jewitt
632
+ (author of moltemplate) for discussions via the mailing list and email.