|
TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
|
#include <triqs/mc_tools/mc_move.hpp>
Type erasure class for MC moves.
It takes any type that models the triqs::mc_tools::MCMove concept and erases its type.
The sign of the new configuration, if accepted, is calculated as new_sign = old_sign * sgn(attempt()) * accept(). If attempt() returns the full MC acceptance ratio (including all signs), then accept() should always return \( 1 \). Otherwise, the calculation of the sign can be partially or fully done in the accept() method.
Optionally, the following methods can be defined:
Optionally, the following free functions can be defined:
| MCSignType | Type of the sign/weight of a MC configuration (triqs::mc_tools::DoubleOrComplex). |
Definition at line 68 of file mc_move.hpp.
Public Member Functions | |
| move (move &&)=default | |
| Default move constructor leaves the moved from object in an empty state. | |
| move (move const &)=delete | |
| Deleted copy constructor. | |
| template<typename T> requires (MCMove<T, MCSignType> && !std::is_same_v<T, move>) | |
| move (T m) | |
| Constructor takes an object that models the triqs::mc_tools::MCMove concept and erases its type. | |
| MCSignType | accept () |
| Accept the new MC configuration. | |
| auto | acceptance_rate () const |
| Get the acceptance rate of the move. You need to call collect_statistics() first. | |
| MCSignType | attempt () |
| Propose a new MC configuration. | |
| void | calibrate (mpi::communicator const &c) |
| Optional callback function to calibrate the move. | |
| void | clear_statistics () |
| Reset the gathered statistics to their initial states. | |
| void | collect_statistics (mpi::communicator const &c) |
| Collect statistics from multiple MPI processes. | |
| double | duration () const |
| Get the duration of the cumulative attempt(), accept(), and reject() calls. | |
| std::map< std::string, double > | get_acceptance_rates () const |
| Get the acceptance rates of all moves in case it is a move set. | |
| std::string | get_statistics (std::string const &name, std::string const &prefix="") const |
| Get a formatted string showing the statistics of the move (and other moves if it is a move set). | |
| std::string | get_timings (std::string const &name, std::string const &prefix="") const |
| Get a formatted string showing the runtime of the move. | |
| auto | is_set () const |
| Is the move object a move set? | |
| auto | n_accepted_config () const |
| Get the number of accepted configurations, i.e. the number of times accept() has been called. | |
| auto | n_proposed_config () const |
| Get the number of proposed configurations, i.e. the number of times attempt() has been called. | |
| move & | operator= (move &&)=default |
| Default move assignment operator leaves the moved from object in an empty state. | |
| move & | operator= (move const &)=delete |
| Deleted copy assignment operator. | |
| void | reject () |
| Optional callback function if the proposed move is rejected. | |
Friends | |
| void | h5_read (h5::group g, std::string const &name, move &m) |
| Read the move object from HDF5. | |
| void | h5_write (h5::group g, std::string const &name, move const &m) |
| Write the move object to HDF5. | |
|
inline |
Constructor takes an object that models the triqs::mc_tools::MCMove concept and erases its type.
| T | Original type of the MC move object. |
| m | MC move object to have its type erased. |
Definition at line 140 of file mc_move.hpp.
|
inline |
Accept the new MC configuration.
Definition at line 170 of file mc_move.hpp.
|
inline |
Propose a new MC configuration.
Definition at line 158 of file mc_move.hpp.
|
inline |
Optional callback function to calibrate the move.
Does nothing if the original type does not implement a calibrate(mpi::communicator const &) method.
| c | MPI communicator. |
Definition at line 193 of file mc_move.hpp.
| void triqs::mc_tools::move< MCSignType >::clear_statistics | ( | ) |
Reset the gathered statistics to their initial states.
If the move is a move set, it calls the clear_statistics() method for all moves in the set.
Definition at line 44 of file mc_move.cpp.
| void triqs::mc_tools::move< MCSignType >::collect_statistics | ( | mpi::communicator const & | c | ) |
Collect statistics from multiple MPI processes.
It sets the total (over all MPI processes) acceptance rate and optionally calls the collect_statistics(mpi::communicator const &) method of the original type.
| c | MPI communicator. |
Definition at line 37 of file mc_move.cpp.
|
inlinenodiscard |
Get the acceptance rates of all moves in case it is a move set.
Definition at line 246 of file mc_move.hpp.
|
nodiscard |
Get a formatted string showing the statistics of the move (and other moves if it is a move set).
| name | Name of the move. |
| prefix | Prefix string to be added to the beginning of each line. |
Definition at line 52 of file mc_move.cpp.
|
nodiscard |
Get a formatted string showing the runtime of the move.
| name | Name of the move. |
| prefix | Prefix string to be added to the beginning of each line. |
Definition at line 61 of file mc_move.cpp.
|
inline |
Optional callback function if the proposed move is rejected.
Does nothing if the original type does not implement a reject() method.
Definition at line 182 of file mc_move.hpp.
|
friend |
Read the move object from HDF5.
Does nothing if there is no specialized h5_read function for the original move object.
| g | h5::group to be read from. |
| name | Name of the dataset/subgroup. |
| m | Move object to be read into. |
Definition at line 271 of file mc_move.hpp.
|
friend |
Write the move object to HDF5.
Does nothing if there is no specialized h5_write function for the original move object.
| g | h5::group to be written to. |
| name | Name of the dataset/subgroup. |
| m | Move object to be written. |
Definition at line 260 of file mc_move.hpp.