DiagMC
Diagrammatic Monte Carlo simulation of a 2-level spin system in a magnetic field
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Diagram_core Class Reference

This class is the base class of Diagram, and should not be used directly, aside from testing functionalities. It contains the variables defining the diagram and the DETERMINISTIC part of the routines to perform updates, excluding the random number extraction, which is instead handled by the Diagram class. More...

#include <diagram.h>

Inheritance diagram for Diagram_core:
Inheritance graph
[legend]

Public Member Functions

 Diagram_core (double beta, int s0, double H, double GAMMA, std::list< double > vertices=std::list< double >())
 Construct a new diagram, setting its defining parameters. The list of vertices is optional: by default it is the 0-th order diagram [0]----—[beta]. More...
 
bool operator== (const Diagram_core &other) const
 operator to test wether two Diagram_core objects are equal. It is intended for TESTING purposes only, and not to be used within the program. It checks that all values defining a diagram (beta, s0, H, GAMMA and each vertex in the vertices list) of the two Diagram_core objects are within EPSILON = 1e-10 from each other. EPSILON is defined at the beginning of diagram.h More...
 
bool operator!= (const Diagram_core &other) const
 operator to test wether two Diagram_core objects are different. It is the negation of operator==. It is intended for TESTING purposes only, and not to be used within the program. More...
 
double operator/ (const Diagram_core &other) const
 Returns the ratio of the weights of the two diagrams, i.e. this->value()/other.value() More...
 
double sum_deltatau () const
 Small helper function, performing the sum (... +t4-t3 + t2-t1) More...
 
double value () const
 Returns the value ("weight") of the current diagram. More...
 
size_t order () const
 Get the order of the diagram (number of _vertices) More...
 
double get_beta () const
 Get the value of _beta (length of the diagram) More...
 
int get_s0 () const
 Get the value of the spin of the 0-th segment of the diagram [0—t1]. More...
 
double get_H () const
 Get the value of the longitudinal field _H. More...
 
double get_GAMMA () const
 Get the value of the transverse field _GAMMA. More...
 
std::list< double > get_vertices () const
 Get a copy of the list of _vertices. More...
 
double acceptance_rate_add (double tau1, double tau2, double tau2max, double new_segment_spin) const
 Returns the acceptance rate for the ADD_SEGMENT update for the given parameters. More...
 
double acceptance_rate_remove (double tau1, double tau2, double tau2max, double segment_toberemoved_spin) const
 Returns the acceptance rate for the REMOVE_SEGMENT update for the given parameters. More...
 
double acceptance_rate_flip () const
 Returns the acceptance rate for the SPIN_FLIP update for the given parameter. More...
 
bool attempt_add_segment (double RN1, double RN2, double RNacc)
 Attemps the ADD_SEGMENT update for the current status of the diagram, using the three random numbers given in input. More...
 
bool attempt_remove_segment (double RN1, double RNacc)
 Attemps the REMOVE_SEGMENT update for the current status of the diagram, using the two random numbers given in input. More...
 
bool attempt_spin_flip (double RNacc)
 Attemps the SPIN_FLIP update for the current status of the diagram, using the random number given in input. More...
 

Protected Member Functions

void assert_parameters_validity (double beta, int s0, double H, double GAMMA, std::list< double > vertices) const
 Internal (non-public) member function that checks wether all the parameters are within the allowed values. Throws an std::invalid_argument exception otherwise. It is used in the Diagram_core constructor and in Diagram::reset_diagram. More...
 

Protected Attributes

double _beta
 length of the diagram (here representing the thermondinamical beta = 1/T)). Must be > 0. More...
 
int _s0
 spin of the 0-th segment of the diagram [0—t1]. Must be +1 or -1 More...
 
double _H
 value of the longitudinal component of magnetic field More...
 
double _GAMMA
 Value of the transversal component of magnetic field. Must be != 0. More...
 
std::list< double > _vertices
 list containing the times of the diagram vertices More...
 

Detailed Description

This class is the base class of Diagram, and should not be used directly, aside from testing functionalities. It contains the variables defining the diagram and the DETERMINISTIC part of the routines to perform updates, excluding the random number extraction, which is instead handled by the Diagram class.

Definition at line 23 of file diagram.h.

Constructor & Destructor Documentation

◆ Diagram_core()

Diagram_core::Diagram_core ( double  beta,
int  s0,
double  H,
double  GAMMA,
std::list< double >  vertices = std::list< double >() 
)

Construct a new diagram, setting its defining parameters. The list of vertices is optional: by default it is the 0-th order diagram [0]----—[beta].

Parameters
betaLength of the diagram (here representing the thermondinamical $\beta$ = 1/T). Must be > 0.
s0Spin of the 0-th segment of the diagram [0—t1]. Must be +1 or -1.
HValue of the longitudinal component of magnetic field
GAMMAValue of the transversal component of magnetic field. Must be != 0.
vertices(optional) List containing the times of diagram _vertices, with t1<t2<t3... < _beta (they need to be already sorted)

Member Function Documentation

◆ acceptance_rate_add()

double Diagram_core::acceptance_rate_add ( double  tau1,
double  tau2,
double  tau2max,
double  new_segment_spin 
) const

Returns the acceptance rate for the ADD_SEGMENT update for the given parameters.

Parameters
tau1time of the first vertex of the segment to be added
tau2time of the second vertex of the segment to be added
tau2maxmaximum value of tau2 for the random extraction
new_segment_spinspin of the segment to be added
Returns
double

◆ acceptance_rate_flip()

double Diagram_core::acceptance_rate_flip ( ) const

Returns the acceptance rate for the SPIN_FLIP update for the given parameter.

Returns
double

◆ acceptance_rate_remove()

double Diagram_core::acceptance_rate_remove ( double  tau1,
double  tau2,
double  tau2max,
double  segment_toberemoved_spin 
) const

Returns the acceptance rate for the REMOVE_SEGMENT update for the given parameters.

Parameters
tau1time of the first vertex of the segment to be removed
tau2time of the second vertex of the segment to be removed
tau2maxmaximum value of tau2 for the random extraction
segment_toberemoved_spinspin of the segment to be removed
Returns
double

◆ assert_parameters_validity()

void Diagram_core::assert_parameters_validity ( double  beta,
int  s0,
double  H,
double  GAMMA,
std::list< double >  vertices 
) const
protected

Internal (non-public) member function that checks wether all the parameters are within the allowed values. Throws an std::invalid_argument exception otherwise. It is used in the Diagram_core constructor and in Diagram::reset_diagram.

Parameters
betaLength of the diagram (here representing the thermondinamical $\beta$ = 1/T). Must be > 0.
s0Spin of the 0-th segment of the diagram [0—t1]. Must be +1 or -1.
HValue of the longitudinal component of magnetic field
GAMMAValue of the transversal component of magnetic field. Must be != 0.
vertices(optional) List containing the times of diagram _vertices, with t1<t2<t3... < _beta (they need to be already sorted)

◆ attempt_add_segment()

bool Diagram_core::attempt_add_segment ( double  RN1,
double  RN2,
double  RNacc 
)

Attemps the ADD_SEGMENT update for the current status of the diagram, using the three random numbers given in input.

Parameters
RN1Random number for the extraction of tau1, must be in range [0, 1]
RN2Random number for the extraction of tau2, must be in range [0, 1]
RNaccRandom number for the acceptance, should be in range [0,1]
Returns
true if update was accepted,
false if update was rejected

◆ attempt_remove_segment()

bool Diagram_core::attempt_remove_segment ( double  RN1,
double  RNacc 
)

Attemps the REMOVE_SEGMENT update for the current status of the diagram, using the two random numbers given in input.

Parameters
RN1Random number for the extraction of first vertex, must be in range [0, 1]
RNaccRandom number for the acceptance, should be in range [0,1]
Returns
true if update was accepted,
false if update was rejected

◆ attempt_spin_flip()

bool Diagram_core::attempt_spin_flip ( double  RNacc)

Attemps the SPIN_FLIP update for the current status of the diagram, using the random number given in input.

Parameters
RNaccRandom number for the acceptance, should be in range [0,1]
Returns
true if update was accepted,
false if update was rejected

◆ get_beta()

double Diagram_core::get_beta ( ) const

Get the value of _beta (length of the diagram)

Returns
double (>0)

◆ get_GAMMA()

double Diagram_core::get_GAMMA ( ) const

Get the value of the transverse field _GAMMA.

Returns
double

◆ get_H()

double Diagram_core::get_H ( ) const

Get the value of the longitudinal field _H.

Returns
double

◆ get_s0()

int Diagram_core::get_s0 ( ) const

Get the value of the spin of the 0-th segment of the diagram [0—t1].

Returns
int (+1 or -1)

◆ get_vertices()

std::list< double > Diagram_core::get_vertices ( ) const

Get a copy of the list of _vertices.

Returns
std::list<double>

◆ operator!=()

bool Diagram_core::operator!= ( const Diagram_core other) const

operator to test wether two Diagram_core objects are different. It is the negation of operator==. It is intended for TESTING purposes only, and not to be used within the program.

Parameters
otherother Diagram_core object
Returns
true
false

◆ operator/()

double Diagram_core::operator/ ( const Diagram_core other) const

Returns the ratio of the weights of the two diagrams, i.e. this->value()/other.value()

Returns
double

◆ operator==()

bool Diagram_core::operator== ( const Diagram_core other) const

operator to test wether two Diagram_core objects are equal. It is intended for TESTING purposes only, and not to be used within the program. It checks that all values defining a diagram (beta, s0, H, GAMMA and each vertex in the vertices list) of the two Diagram_core objects are within EPSILON = 1e-10 from each other. EPSILON is defined at the beginning of diagram.h

Parameters
otherother Diagram_core object
Returns
true
false

◆ order()

size_t Diagram_core::order ( ) const

Get the order of the diagram (number of _vertices)

Returns
size_t

◆ sum_deltatau()

double Diagram_core::sum_deltatau ( ) const

Small helper function, performing the sum (... +t4-t3 + t2-t1)

Returns
double

◆ value()

double Diagram_core::value ( ) const

Returns the value ("weight") of the current diagram.

Returns
double

Member Data Documentation

◆ _beta

double Diagram_core::_beta
protected

length of the diagram (here representing the thermondinamical beta = 1/T)). Must be > 0.

Definition at line 28 of file diagram.h.

◆ _GAMMA

double Diagram_core::_GAMMA
protected

Value of the transversal component of magnetic field. Must be != 0.

Definition at line 31 of file diagram.h.

◆ _H

double Diagram_core::_H
protected

value of the longitudinal component of magnetic field

Definition at line 30 of file diagram.h.

◆ _s0

int Diagram_core::_s0
protected

spin of the 0-th segment of the diagram [0—t1]. Must be +1 or -1

Definition at line 29 of file diagram.h.

◆ _vertices

std::list<double> Diagram_core::_vertices
protected

list containing the times of the diagram vertices

Definition at line 32 of file diagram.h.


The documentation for this class was generated from the following file: