Skip to content

Output and analysis

fes_ml.output

Window output files.

Each window of a run writes one HDF5 file, <output_prefix>_window_<k>.h5. It holds:

  • reduced_potentials: an array of shape (states, samples). Column n is the reduced potential u = U / kT of sample n of this window, evaluated in every state. A column is added and written to disk at each iteration.
  • provenance: the provenance records of the window (JSON text, see :mod:fes_ml.provenance).
  • attributes: format, window, temperature_K, state_labels and lambda_schedule (JSON text).

:mod:fes_ml.analysis reads these files.

WindowData dataclass

The content of a window output file.

WindowWriter

Write the output file of one window, one sample at a time.

Parameters:

Name Type Description Default
path str

The file to write.

required
window int

The index of the window.

required
temperature_K float

The temperature of the window, in kelvin.

required
state_labels list of str

One label for each state in which the samples are evaluated.

required
lambda_schedule dict

The lambda schedule of the run.

None
keep_samples int

None starts a new file. A number continues the existing file after its first keep_samples samples, and removes the samples after them: a restart continues from the checkpoint, so the samples after the checkpoint are made again.

None

add_sample(reduced_potentials)

Add one sample: its reduced potential in every state.

add_provenance(record)

Add a provenance record.

close()

Close the file.

window_file(output_prefix, window)

The path of the output file of window.

read_window(path)

Read a window output file.

fes_ml.analysis

Free energies from the window outputs, with MBAR.

:func:load_windows reads the output files of the windows and checks that they belong to one run: one file for each window, the same states, the same temperature and lambda schedule, and the same setup in the provenance. :func:mbar gives the free energies. The fes-ml-analyse command does both::

fes-ml-analyse OUTPUT_*/fes_window_*.h5

It also reads the .npy files of fes-ml 0.3 and earlier: one file of shape (states, samples) for each window, in window order, or one file of shape (windows, states, samples). These files have no temperature, so give it with temperature_K.

Windows dataclass

The samples of all the windows of a run.

MBARResult dataclass

The result of :func:mbar.

delta_f[i, j] is the free energy of state j minus that of state i, in kT, and d_delta_f[i, j] its statistical uncertainty.

free_energy(first=0, last=-1, unit='kJ/mol')

The free energy of state last minus that of state first, in kJ/mol, kcal/mol or kT.

uncertainty(first=0, last=-1, unit='kJ/mol')

The statistical uncertainty of :meth:free_energy.

summary()

The result as JSON data.

load_windows(paths, temperature_K=None, strict=True)

Read the output files of the windows of a run, and check that they belong together.

Parameters:

Name Type Description Default
paths list of str

Window output files (.h5), in any order, or .npy files of fes-ml 0.3 and earlier, in window order.

required
temperature_K float

The temperature. Needed for .npy files. For .h5 files it must agree with the files.

None
strict bool

Raise a ValueError when the provenance shows that the windows ran with other package versions, another fes-ml commit, or another platform or integrator. With False, log a warning.

True

Returns:

Type Description
Windows

select_samples(windows, discard=0, stride=1, decorrelate=False)

The samples of each window that go to MBAR.

Parameters:

Name Type Description Default
discard int

Remove the first discard samples of each window (equilibration).

0
stride int

Then keep every stride-th sample.

1
decorrelate bool

Then find the equilibrated part of each window and keep uncorrelated samples, with pymbar.timeseries. The time series is the reduced potential in the state of the window.

False

mbar(windows, discard=0, stride=1, decorrelate=False)

The free energies of the states, with MBAR (pymbar).

The samples are chosen with :func:select_samples. Window k must sample state k.

main(argv=None)

The fes-ml-analyse command.