Skip to main content

packmol_util

en ja

GitHub GitHub Pages Ohara Lab

packmol_util is a Python library for generating initial amorphous structures from composition, atom count, and density. Built on Packmol, it automates input preparation, structure packing, and conversion to VASP POSCAR files for first-principles and molecular dynamics simulations.

It supports both individual atoms and predefined structural units, such as PO4 tetrahedra, and can generate FNC constraint files for RMC_POT. For RMC_POT input preparation, calculation automation, and result analysis, see the independent rmc_util package.


💡 Features

  1. Intuitive density specification
    • Packmol itself does not interpret density or atomic weights, but this tool performs the required internal calculations and determines the cubic cell length $L$ that satisfies the specified density.
  2. Exclusion radius specification by element symbol
    • This hides Packmol's inconvenient atom-index-based specification inside XYZ files. Interatomic avoidance distances can be controlled using an intuitive element-name-based dictionary, such as {"P": 0.25, "O": 1.05}.
  3. Preservation of molecular units (geometries)
    • For systems such as $\text{Li}_3\text{PO}_4$, amorphization through mixing and packing can be performed while preserving intramolecular bond lengths, such as those in $\text{PO}_4$ tetrahedra.
  4. Extremely simple high-level API
    • By using AmorphousBuilder, the cumbersome file relay workflow (.inp construction $\rightarrow$ external execution $\rightarrow$ coordinate conversion) can be condensed into only a few lines of script.

📁 Directory structure

src/
├── packmol_util/
│
│   ├── __init__.py          # Package initialization file
│   ├── builder.py           # High-level integrated builder (AmorphousBuilder) ★NEW
│   ├── model.py             # Template XYZ generation and structure-definition module
│   ├── packmol.py           # Core density calculation, Packmol execution, and POSCAR conversion
│   ├── packmol_inp.py       # Parsing engine for constructing packmol.inp
│   ├── param.py             # Atomic weights and physical constants for the periodic table

└── example/                 # Location for material-specific generation scripts
    ├── Li3PO4/
    │   └── make_Li3PO4.py
    └── FeSiB/
        └── make_FeSiB.py

Example

from packmol_util.builder import AmorphousBuilder
from packmol_util.model import write_single_atom_xyz

for symbol in ("Fe", "Si", "B"):
    write_single_atom_xyz(f"{symbol}.xyz", symbol)

builder = AmorphousBuilder(
    symbols=["Fe", "Si", "B"], ratios=[80, 9, 11],
    total_atom_count=500, minimum_separation=2.0,
    mass_density=7.35,
)
for symbol, ratio in zip(builder.symbols, builder.ratios):
    builder.add_template(f"{symbol}.xyz", ratio * builder.multiplier)
builder.build("FeSiB")

The outputs are FeSiB_packmol.inp, FeSiB_packmol.xyz, FeSiB_packmol.log, POSCAR, and POSCAR.vasp. An .fnc file is written when FNC pairs are registered. The POSCAR filenames are fixed. AmorphousBuilder adjusts the requested atom count to a nearby integer multiple of the stoichiometric ratio sum when needed.

Packmol and documentation

The Packmol executable must be installed separately. See the English tutorial for installation and input format, the reference for API and FNC details, and the design philosophy for component responsibilities.

Installing bundled scripts and examples

After pip install packmol-util, run the following commands in the working directory where you want the files:

packmol_util install scripts
packmol_util install example

The first command copies the contents of the repository's scripts/ directory, while the second copies example/. Subdirectory structures are preserved. For example, example/Li3PO4/non_builder/make_Li3PO4.py becomes ./Li3PO4/non_builder/make_Li3PO4.py.

Existing files are not overwritten by default. To overwrite files with the same name, use --force:

packmol_util install scripts --force
packmol_util install example --force

Files are copied into the current working directory. Unrelated files are not deleted. This feature does not install the external Packmol executable.

Metadata

Release files for packmol-util 0.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for packmol-util 0.2.10
File Size Uploaded Provenance Actions
packmol_util-0.2.10.tar.gz 42.0 kB With provenance Details for packmol_util-0.2.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for packmol-util 0.2.10
File Interpreter ABI Platform Actions
packmol_util-0.2.10-py3-none-any.whl Python 3 none any Details for packmol_util-0.2.10-py3-none-any.whl

Total release size: 92.5 kB

Release files / packmol_util-0.2.10.tar.gz

Download URL packmol_util-0.2.10.tar.gz
Size 42.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cf99596d94233c887cd92547b1929b1ef9fbf85e22369b126150dc3ddafb43b6
BLAKE2b-256 checksum
How to use checksums
24a4f14fa6163c14b2cf13fc7f4ba5682658b368ab6ae6ffd51d9a5b49eb029c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / packmol_util-0.2.10-py3-none-any.whl

Download URL packmol_util-0.2.10-py3-none-any.whl
Size 50.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
322cb016553700aac1b425f2a3ec93803940cbae9ef967735617c12419df9de2
BLAKE2b-256 checksum
How to use checksums
04d9bebff929cc49557f1e15d211be80478cd2f635199ae4b86683432c9d91b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for packmol-util 0.2.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for packmol_util-0.2.10.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page