Skip to content

Command line

Installing the package provides the nanofoams command (also available as python -m nanofoams).

Configuration file

A TOML file with flat keys. Give either h2 or ligament_diameter:

foam.toml
lattice = "bcc"
lattice_parameter = 3.303
cells = 100
solid_fraction = 0.30

h2 = 54                    # ...or:
# ligament_diameter = 25.0
# min_directions = 48      # only with ligament_diameter
# h2_max = 500             # only with ligament_diameter

n_waves = 10000            # default 10000
seed = 42                  # default: random, recorded in the log
# period_cells = 50        # default: cells (must divide cells)

nanofoams generate

$ nanofoams generate foam.toml
nanofoams 0.1.0 - generating foam.toml
  lattice            bcc, a0 = 3.303
  box                100^3 cells, L_box = 330.3 (2,000,000 sites)
  ...
  measured solid fraction  0.2950 (589,906 solid atoms)
  wrote foam.data
  wrote foam.json
option effect
-o NAME output base name (default: the config name)
--format data\|dump\|both LAMMPS data file (default), text dump with f, or both
--all-atoms data file with every site, type 1 (solid) / 2 (pore)
--masses M [M] write a Masses section
--backend NAME fft (default), collapsed, direct, cupy
--seed N override the seed of the config
-q quiet

The .json log records the version, the resolved parameters (seed included), the predicted morphology, the measured solid fraction, timings and warnings. It is itself a valid config: nanofoams generate foam.json regenerates identical files.

nanofoams info

Prints the predicted morphology and warnings without generating anything:

$ nanofoams info foam.toml --json

nanofoams suggest-h2

Lists the \(H^2\) values closest to a target ligament diameter:

$ nanofoams suggest-h2 --ligament-diameter 50.2 --period 330.3 --solid-fraction 0.3 --min-directions 1
   H^2  dirs   diameter    error
    14    24      50.23    +0.1%
    13    12      52.13    +3.8%
    ...

nanofoams directions

$ nanofoams directions 54 --list

nanofoams convert-legacy

Translates an input file of the original thesis scripts into a TOML config. The \(H^2\) choice reproduces the legacy database (\(H^2 < 500\), at least 48 directions):

$ nanofoams convert-legacy nanofoams_input.txt -o foam.toml

The phases come from a different random generator, so the converted config gives a foam with the same statistics, not the same realisation.