Metadata-Version: 2.5
Name: nanofoams
Version: 0.1.0
Summary: Generation of periodic stochastic bicontinuous (nanoporous) atomistic samples, after Soyarslan et al. (2018).
Project-URL: Homepage, https://github.com/nicolasvazquez95/nanofoams
Project-URL: Documentation, https://nicolasvazquez95.github.io/nanofoams/
Project-URL: Changelog, https://github.com/nicolasvazquez95/nanofoams/blob/main/CHANGELOG.md
Project-URL: Source, https://github.com/nicolasvazquez95/nanofoams
Project-URL: Issues, https://github.com/nicolasvazquez95/nanofoams/issues
Author: Nicolás Vazquez von Bibow, Carlos J. Ruestes
License-Expression: MIT
License-File: LICENSE
Keywords: bicontinuous,gaussian random field,lammps,materials science,molecular dynamics,nanoporous,spinodal
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Chemistry
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Requires-Dist: tomli>=1.1; python_version < '3.11'
Provides-Extra: analysis
Requires-Dist: scikit-image>=0.21; extra == 'analysis'
Provides-Extra: dev
Requires-Dist: ase>=3.22; extra == 'dev'
Requires-Dist: matplotlib>=3.7; extra == 'dev'
Requires-Dist: pre-commit>=3; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Requires-Dist: scikit-image>=0.21; extra == 'dev'
Provides-Extra: docs
Requires-Dist: matplotlib>=3.7; extra == 'docs'
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.26; extra == 'docs'
Provides-Extra: gpu
Requires-Dist: cupy-cuda12x>=13; extra == 'gpu'
Provides-Extra: legacy
Requires-Dist: loky; extra == 'legacy'
Requires-Dist: tqdm; extra == 'legacy'
Provides-Extra: test
Requires-Dist: ase>=3.22; extra == 'test'
Requires-Dist: matplotlib>=3.7; extra == 'test'
Requires-Dist: pytest>=8; extra == 'test'
Requires-Dist: scikit-image>=0.21; extra == 'test'
Description-Content-Type: text/markdown

# nanofoams

[![CI](https://github.com/nicolasvazquez95/nanofoams/actions/workflows/ci.yml/badge.svg)](https://github.com/nicolasvazquez95/nanofoams/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

**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)](https://doi.org/10.1016/j.actamat.2018.01.005), and
writes them as LAMMPS data files ready for molecular dynamics.

<img src="https://raw.githubusercontent.com/nicolasvazquez95/nanofoams/main/docs/assets/foam_100a0_54.png" width="360" alt="Nanoporous bcc foam">

- **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

```console
pip install nanofoams
```

Until the first PyPI release:
`pip install "git+https://github.com/nicolasvazquez95/nanofoams"`.
Python 3.10+, NumPy and SciPy.

## Use

From the command line, with a TOML config:

```toml
# 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
```

```console
nanofoams generate foam.toml          # -> foam.data (+ foam.json log)
nanofoams info foam.toml              # predicted morphology and warnings
```

From Python:

```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`](examples/quickstart.ipynb) and the
[documentation](https://nicolasvazquez95.github.io/nanofoams/) (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](https://doi.org/10.1016/j.commatsci.2024.112884)

and the method, C. Soyarslan, S. Bargmann, M. Pradas, J. Weissmüller, Acta
Materialia 149 (2018) 326-340. BibTeX entries are in
[`references.bib`](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/`](legacy/) and serve as regression references for the test-suite.
[Changes from the thesis code](docs/legacy.md) 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](LICENSE)
