Skip to main content

nanofoams

PyPI Python CI Docs DOI License: MIT Open In Colab

Periodic stochastic bicontinuous structures for atomistic simulations.

nanofoams builds atomistic samples of nanoporous metals with the Gaussian-random-field method of Soyarslan et al. (2018), and writes them as LAMMPS data files ready for molecular dynamics.

Nanoporous foam as the solid fraction changes

Try it without installing anything: the Colab notebook builds a sample of the metal you choose, shows it in 3-D and downloads it for LAMMPS. More pictures in the gallery.

  • Exactly periodic sc, bcc and fcc samples.
  • Fast. Exact FFT evaluation generates a 54-million-atom sample in ~3 s on a laptop CPU; the original implementation took ~32 h. Optional GPU backend.
  • Reproducible. One seed controls everything, and each run writes a JSON log that regenerates identical files.
  • Analytical morphology (surface density, curvatures, genus) and numerical measurement to check it.
  • Sanity checks for percolation, anisotropy and representative volume size.

Install

pip install nanofoams

Requires Python 3.10+, NumPy and SciPy. Optional extras: analysis (marching-cubes measurement) and gpu (CuPy backend), e.g. pip install "nanofoams[analysis]".

Use

From the command line, with a TOML config:

# foam.toml
lattice = "bcc"
lattice_parameter = 3.303   # Ta, Angstrom
cells = 100
solid_fraction = 0.30
h2 = 54                     # or: ligament_diameter = 25.0
seed = 42
nanofoams generate foam.toml          # -> foam.data (+ foam.json log)
nanofoams info foam.toml              # predicted morphology and warnings

From Python:

import nanofoams

foam = nanofoams.generate(
    lattice="bcc",
    lattice_parameter=3.303,
    cells=100,
    solid_fraction=0.30,
    h2=54,
    seed=42,
)
foam.write_lammps_data("foam.data")
foam.morphology.ligament_diameter  # 25.6 Angstrom

See examples/quickstart.ipynb and the documentation (theory, parameter guide, CLI, API, validation).

How to cite

If you use this code, please cite:

N. Vazquez von Bibow, E. N. Millán, C. J. Ruestes, Topological changes and deformation mechanisms of nanoporous Ta under compression, Computational Materials Science 236 (2024) 112884. doi:10.1016/j.commatsci.2024.112884

the software itself, archived on Zenodo (doi:10.5281/zenodo.24637867, all versions), and the method, C. Soyarslan, S. Bargmann, M. Pradas, J. Weissmüller, Acta Materialia 149 (2018) 326-340. BibTeX entries are in references.bib.

History

This package rewrites the code of the undergraduate thesis of N. Vazquez (FCEN-UNCuyo, 2023). The original scripts are kept, unmodified, in legacy/ and serve as regression references for the test-suite. Changes from the thesis code lists the corrections made since.

Acknowledgements

Python implementation by Nicolás Vazquez and Carlos J. Ruestes, based on the article by Soyarslan et al. Funded by ANPCyT PICT-2018-0773 and European Commission Grant Agreement 101062254 (MeNaWir, MSCA Postdoctoral Fellowships).

License

MIT

Metadata

Release files for nanofoams 0.1.2

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

Source distribution (sdist)

Source distribution for nanofoams 0.1.2
File Size Uploaded Provenance Actions
nanofoams-0.1.2.tar.gz 257.1 kB With provenance Details for nanofoams-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nanofoams 0.1.2
File Interpreter ABI Platform Actions
nanofoams-0.1.2-py3-none-any.whl Python 3 none any Details for nanofoams-0.1.2-py3-none-any.whl

Total release size: 289.4 kB

Release files / nanofoams-0.1.2.tar.gz

Download URL nanofoams-0.1.2.tar.gz
Size 257.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8b989227d4745d848a36aa3d300fd1e0e8bf2df762cef2af33a25d2f17f5be4e
BLAKE2b-256 checksum
How to use checksums
6b29ab32937a8aba2d5c59f36f87480ad95c312df687eff81f590529eaf05f18
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 Nov 29, 2026.

Transparency log

Release files / nanofoams-0.1.2-py3-none-any.whl

Download URL nanofoams-0.1.2-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4393275cb236838378cc2e6dbf404299a8dcc47fc499d640b1631e7d73da4687
BLAKE2b-256 checksum
How to use checksums
9e8e2ab85dbd4c5257405db2d98e9d1e244d721c9a24e2228b716ff6d6accfd9
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 Nov 29, 2026.

Transparency log

Security for nanofoams 0.1.2

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 nanofoams-0.1.2.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 Nov 29, 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