RASPA3 3.0.12
A molecular simulation code for computing adsorption and diffusion in nanoporous materials
|
Represents the transition matrix for TMMC simulations. More...
Public Member Functions | |
bool | operator== (TransitionMatrix const &) const =default |
void | initialize () |
Initializes the transition matrix and related data structures. | |
void | updateMatrix (double3 Pacc, std::size_t oldN) |
Updates the collection matrix with acceptance probabilities. | |
void | updateHistogram (std::size_t N) |
Updates the histogram of macrostate visits. | |
double | biasFactor (std::size_t newN, std::size_t oldN) |
Calculates the bias factor between two macrostates. | |
void | adjustBias () |
Adjusts the bias factors based on collected statistics. | |
void | clearCMatrix () |
Clears the collection matrix and resets counters. | |
void | writeStatistics () |
Writes the transition matrix statistics to a file. | |
Friends | |
Archive< std::ofstream > & | operator<< (Archive< std::ofstream > &archive, const TransitionMatrix &m) |
Archive< std::ifstream > & | operator>> (Archive< std::ifstream > &archive, TransitionMatrix &m) |
Represents the transition matrix for TMMC simulations.
The TransitionMatrix struct encapsulates the data and methods required for performing Transition Matrix Monte Carlo (TMMC) simulations. It maintains the collection matrix, bias factors, natural logarithm of probability distributions, and histograms to compute macrostates and adjust biases during the simulation. It provides methods to initialize data structures, update matrices and histograms, calculate bias factors, adjust biases, clear statistics, and write statistics to files.
void TransitionMatrix::adjustBias | ( | ) |
Adjusts the bias factors based on collected statistics.
Updates the bias vector and the natural logarithm of the probability distribution (lnpi) using the current state of the collection matrix and histogram. This method recalculates biases to improve sampling efficiency.
double TransitionMatrix::biasFactor | ( | std::size_t | newN, |
std::size_t | oldN | ||
) |
Calculates the bias factor between two macrostates.
Computes the bias factor used to adjust the acceptance probability of moves between macrostates. The bias factor is calculated as the exponential of the difference in bias between the new and old macrostate.
newN | The macrostate value after the move. |
oldN | The macrostate value before the move. |
void TransitionMatrix::clearCMatrix | ( | ) |
Clears the collection matrix and resets counters.
Resets the collection matrix, histogram, bias factors, and related counters to their initial values. Typically used after initialization cycles to reset statistics.
void TransitionMatrix::initialize | ( | ) |
Initializes the transition matrix and related data structures.
Sets up the collection matrix, bias vectors, and histograms based on the specified macrostate range. Initializes bias factors and probability distributions to default values. Should be called before starting the TMMC simulation.
void TransitionMatrix::updateHistogram | ( | std::size_t | N | ) |
Updates the histogram of macrostate visits.
Increments the histogram count for the given macrostate N, tracking how often each macrostate is visited during the simulation.
N | The current macrostate value. |
void TransitionMatrix::updateMatrix | ( | double3 | Pacc, |
std::size_t | oldN | ||
) |
Updates the collection matrix with acceptance probabilities.
Records the probabilities of transitions between macrostates in the collection matrix. The acceptance probabilities vector Pacc contains probabilities for deletion (x), no change (y), and insertion (z) moves.
Pacc | A double3 vector containing acceptance probabilities for deletion (x), no change (y), and insertion (z) moves. |
oldN | The macrostate value before the move. |
void TransitionMatrix::writeStatistics | ( | ) |
Writes the transition matrix statistics to a file.
Outputs the current state of the collection matrix, bias factors, probability distributions, and histogram data to a text file for analysis and debugging.