xnn.ffnn.models.ffield.write_ffield#

xnn.ffnn.models.ffield.write_ffield(lib, path=None, *, digits=None)[source]#

Write a classical library as a ReaxFF ffield text file (LAMMPS format).

The classical column layout read by LAMMPS pair_style reaxff (and other ReaxFF codes): general parameters, then atom, bond, off-diagonal, angle, torsion and hydrogen-bond blocks, with atom types numbered in library order and 0 for torsion wildcards. Columns the model does not evaluate carry the library’s own values (unused, heat_increment). Use it for a refit field with write_ffield(model.export_library(), "ffield.refit").

Parameters:
  • lib (FFieldLibrary) – The library; must be classical (not lib.is_nn).

  • path (str or Path, optional) – Destination file; when omitted only the text is returned.

  • digits (int, optional) – Decimals of every value. Default: 15 significant digits, which keeps every value to float64 precision; 4 gives the traditional fixed layout.

Returns:

The file content.

Return type:

str

Raises:

ValueError – For a ReaxFF-nn library (network weights have no place in the format; use FFieldLibrary.save()).