pykappa.analysis

Functions

equilibrated(values[, times, tail_fraction, ...])

Checks whether the magnitude of the slope of the tail of the series relative to the mean is sufficiently small (below tolerance).

equilibration_time(values[, times, ...])

Earliest time from which the remaining series is equilibrated.

equilibrium_value(values[, times, ...])

Mean of the series from the equilibration point onward.

relative_slope(values[, times, tail_fraction])

Computes the magnitude of the slope of the tail of the series.

Classes

Monitor(system)

Records the history of the values of observables in a system.

class pykappa.analysis.Monitor(system)[source]

Records the history of the values of observables in a system.

Parameters:

system (System)

system

The system being monitored.

Type:

System

history

Dictionary mapping observable names to their value history.

Type:

dict[str, list[float | None]]

system: System
history: dict[str, list[float | None]]
update()[source]

Record current time and observable values.

Return type:

None

measure(observable_name, time=None)[source]

Get the value of an observable at a specific time.

Raises:

AssertionError – If simulation hasn’t reached the specified time.

Parameters:
  • observable_name (str)

  • time (float | None)

property dataframe: DataFrame

Get the history of observable values as a pandas DataFrame.

Returns:

DataFrame with time and observable columns.

tail_mean(observable_name, tail_fraction=0.1)[source]

Calculate the average value of an observable over a fraction of the tail.

Parameters:
  • observable_name (str) – Name of the observable to measure.

  • tail_fraction (float) – Fraction of the history to consider (from the end).

Raises:

AssertionError – If there are not enough measurements.

Return type:

float

equilibrated(observable_name=None, **equilibration_kwargs)[source]

Check if an observable (or all observables) has equilibrated based on whether the slope of recent values is sufficiently small relative to the mean.

Parameters:
  • observable_name (str | None) – Name of the observable to check. If None, checks all observables.

  • tail_fraction – Fraction of the history to consider.

  • tolerance – Maximum allowed fraction slope deviation from the mean.

Return type:

bool

plot(combined=False)[source]

Make a plot of all observables over time.

Parameters:

combined (bool) – Whether to plot all observables on the same axes.

Return type:

Figure

pykappa.analysis.relative_slope(values, times=None, tail_fraction=0.1)[source]

Computes the magnitude of the slope of the tail of the series. Time can be provided to account for non-uniform sampling intervals.

Raises:

AssertionError – If there are not enough measurements to compute the slope.

Parameters:
  • values (list[float])

  • times (list[float] | None)

  • tail_fraction (float)

Return type:

float

pykappa.analysis.equilibrated(values, times=None, tail_fraction=0.1, tolerance=0.01)[source]

Checks whether the magnitude of the slope of the tail of the series relative to the mean is sufficiently small (below tolerance). Time can be provided to account for non-uniform sampling intervals.

Parameters:
  • values (list[float])

  • times (list[float] | None)

  • tail_fraction (float)

  • tolerance (float)

Return type:

bool

pykappa.analysis.equilibration_time(values, times=None, min_tail_length=2, tolerance=0.01)[source]

Earliest time from which the remaining series is equilibrated.

Parameters:
  • values (list[float])

  • times (list[float] | None)

  • min_tail_length (int)

  • tolerance (float)

Return type:

float

pykappa.analysis.equilibrium_value(values, times=None, min_tail_length=2, tolerance=0.01)[source]

Mean of the series from the equilibration point onward.

Parameters:
  • values (list[float])

  • times (list[float] | None)

  • min_tail_length (int)

  • tolerance (float)

Return type:

float