Monitor

class jaxrens.postprocess.monitor.Monitor(*, dead_energies, dead_volumes, live_energies, live_volumes, log_evidence, iteration, n_live, n_cull=1, symbol_map=None, energy_trace=None, iteration_trace=None, adaptation_trace=None, re_trace=None, max_neighbors_trace=None, label='', path=None)[source]

Bases: object

Load and analyze a single jaxrens NS run.

Reads the checkpoint HDF5 (preferred) plus the .energies file for the iteration trace. All scientific computations delegate to postprocess.thermodynamics.

In NPT the stored energies are already enthalpies H = U + P V (EnsembleTerm adds P V during sampling), so the observables use them as they are. The cell volumes are kept as data only: they set is_npt and feed <V>(T) via expectation(volume_trace, T).

Variables:
  • dead_energies – Dead-point energies, shape (n_dead,); enthalpies in NPT.

  • dead_volumes – Dead-point cell volumes for NPT runs, shape (n_dead,), or None.

  • live_energies – Live-walker energies at run end, shape (n_live_actual,).

  • live_volumes – Live-walker cell volumes for NPT, shape (n_live_actual,), or None.

  • log_evidence – Scalar log Z stored in the checkpoint.

  • iteration – Iteration number at checkpoint.

  • n_live – Number of live walkers used in the run.

  • n_cull – Number of walkers culled per iteration.

  • symbol_map – Mapping from integer type codes to element symbols, or None.

  • energy_trace – Per-iteration culled energy from .energies file, or None.

  • iteration_trace – Iteration indices matching energy_trace, or None.

  • adaptation_trace – Per-move step sizes and acceptance rates, or None.

  • re_trace – Per-fire inter-replica swap counts and acceptance rates, or None.

  • max_neighbors_trace – Per-iteration neighbor-bucket diagnostics (per-walker max_neighbor_count + bucket size + overflow), or None. Loaded from <prefix>.max_neighbors.h5 when the run opted in via output.save_max_neighbors.

  • label – Human-readable label for plots.

  • path – Source directory, or None.

  • volume_trace – Cell volume of each dead point from the .energies log, shape (n_dead,). Set by from_directory (and by MonitorCollection.from_multi_run_directory) only.

Parameters:
  • dead_energies (np.ndarray)

  • dead_volumes (np.ndarray | None)

  • live_energies (np.ndarray)

  • live_volumes (np.ndarray | None)

  • log_evidence (float)

  • iteration (int)

  • n_live (int)

  • n_cull (int)

  • symbol_map (dict[int, str] | None)

  • energy_trace (np.ndarray | None)

  • iteration_trace (np.ndarray | None)

  • label (str)

  • path (Path | None)

classmethod from_directory(path, label=None, *, prefix='ns', prefer_final=True)[source]

Load a run from a directory.

Picks <prefix>.final.checkpoint.h5 if it exists and prefer_final=True, otherwise falls back to <prefix>.checkpoint.h5. Raises FileNotFoundError if neither exists.

Parameters:
  • path (Path | str) – Directory produced by jaxrens run.

  • label (str | None) – Display label. Defaults to the directory name.

  • prefix (str) – File prefix used by the run (matches output.out_file_prefix in the config, default "ns").

  • prefer_final (bool) – Prefer the .final.checkpoint.h5 over the periodic checkpoint.

Returns:

Populated Monitor.

Return type:

Monitor

property n_dead: int

Number of dead points.

property is_npt: bool

True if volume information is present (NPT ensemble).

log_Z(T)[source]

Compute log partition function at each temperature.

Parameters:

T (ndarray | float)

Return type:

ndarray

heat_capacity(T, k_B=1.0)[source]

Compute heat capacity C_v at each temperature.

Parameters:
Return type:

ndarray

expectation(observable, T, k_B=1.0)[source]

Compute thermal expectation <O>(T) for a per-dead-point observable.

Parameters:
  • observable (ndarray) – Per-dead-point values, shape (n_dead,).

  • T (ndarray | float) – Temperature(s), scalar or array.

  • k_B (float) – Boltzmann constant in the same energy units as the stored dead_energies. Defaults to 1.0; pass e.g. 8.617e-5 (eV/K) when T is in Kelvin and the energies are in eV.

Return type:

ndarray

free_energy(T, k_B=1.0)[source]

Compute Helmholtz free energy F = -log Z / beta at each temperature.

Parameters:
Return type:

ndarray

partition_function(T, k_B=1.0)[source]

Compute log Z(T) at each temperature.

Parameters:
Return type:

ndarray