# Macrostate¶

class Macrostate

The macrostate is the statistical mechanical variable to which we apply bias using flat-histogram methods. Thus, for example, in the grand canonical ensemble with a single component, the macrostate is the number of particles. To apply the flat histogram methods, the macrostate is be broken into a contiguous series of “bins”.

Public Functions

Macrostate(const Histogram &histogram, const argtype &args = argtype())

args:

• soft_max : optionally, set a soft maximum (default: last histogram bin). These soft limits may be changed during a simulation. Note that this max is an integer bin number.

• soft_min : minimum as described above (default: same as histogram).

void set(const Histogram histogram)

Set the bins of the macrostate by providing a Histogram. This is required before the macrostate can be used for flat histogram methods. The histogram only serves to determine the bins, and should not be expanded or have values added during the course of the simulation.

const Histogram &histogram() const

Return the histogram.

const int soft_max() const

Return the soft maximum.

const int soft_min() const

Return the soft minimum.

virtual double value(const System &system, const Criteria &criteria, const Acceptance &acceptance) const = 0

Return the current value of the macrostate.

int bin(const System &system, const Criteria &criteria, const Acceptance &acceptance) const

Return the current bin of the macrostate.

double value(const int bin) const

Return the value of the bin.

bool is_allowed(const System &system, const Criteria &criteria, const Acceptance &acceptance) const

Return whether the current system macrostate is within permissible range given by the input histogram.

void swap_soft_bounds(Macrostate *macrostate)

Swap the soft bounds with another macrostate.