Quickstart¶
Generate a foam¶
Everything is described by a FoamParameters:
import nanofoams
params = nanofoams.FoamParameters(
lattice="bcc", # "sc", "bcc" or "fcc"
lattice_parameter=3.303, # any length unit; Angstrom for Ta here
cells=100, # box of 100^3 unit cells
solid_fraction=0.30, # phi_B
h2=54, # H^2 = h^2 + k^2 + l^2 sets the length scale
n_waves=10_000,
seed=42,
)
foam = nanofoams.generate(params)
foam holds every lattice site:
foam.positions # (2_000_000, 3) coordinates
foam.f # value of the random field at each site
foam.types # 1 = solid, 2 = pore
foam.solid_positions # the atoms you simulate
foam.measured_solid_fraction # ~0.30
Write LAMMPS files¶
foam.write_lammps_data("foam.data", masses=[180.95]) # solid atoms only
foam.write_lammps_dump("foam.dump") # all sites with type and f, for OVITO
The data file is read in LAMMPS with atom_style atomic and read_data foam.data.
Choose the length scale¶
h2 fixes the wave number \(q_0 = 2\pi H / a\), with \(a\) the box length. The
mean ligament diameter follows the Soyarslan fit
\(L = (a/H)(0.53\,\phi_B + 0.41)\). If you know the diameter you want, let
nanofoams pick \(H^2\):
params = nanofoams.FoamParameters.from_ligament_diameter(
25.0,
lattice="bcc",
lattice_parameter=3.303,
cells=100,
solid_fraction=0.30,
seed=42,
)
params.h2, params.ligament_diameter # (54, 25.58...)
Only \(H^2\) values with at least 48 directions are considered by default; see Choosing parameters.
Predicted morphology and warnings¶
m = foam.morphology # analytical predictions
m.surface_density, m.genus_density, m.mean_curvature
for warning in nanofoams.check(params):
print(warning)
Reproducibility¶
The seed determines the foam completely. If you omit it, a random seed is drawn
and stored in params.seed, so you can always regenerate the same foam later.
From the command line, the JSON log written next to the output does the same
(see Command line).