Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
MonteCarlo Class Reference

Classes

struct  FieldRealArray
 
struct  FlipHistory
 
struct  PackedSpin
 
struct  Quartet
 [mu_B/site] More...
 
struct  Vector3
 

Public Member Functions

 MonteCarlo (int num_threads)
 
double exec (double temp, Vector3< double > field, int *flips, long double *tests, double *DUav, Vector3< double > *Mav)
 
void randomize ()
 randomize spins
 
Vector3< double > magnetization ()
 [mu_B/A site]
 
Quartet siteMagnetization ()
 
double internalEnergy ()
 internal energy U [J/A site]
 
void read (std::istream &)
 read snapshot.
 
void read (const char *spins, double temp, Vector3< double > field)
 
void write (std::ostream &)
 write snapshot.
 
void write (char *spins, double *fields=0, double *probabilities=0)
 
void write_bsite (Vector3< double > *fields)
 
void write_8asite (Vector3< double > *fields)
 
void write_48fsite (Vector3< double > *fields)
 
void write_flips (std::deque< FlipHistory > &buf)
 

Static Public Member Functions

static int setupField (int size, double dfactor, double cutoff_real, double cutoff_rec, double alpha)
 
static int length ()
 

Static Public Attributes

static volatile bool s_bAborting = false
 true if user interrupts.
 

Private Types

typedef Vector3< int > VectorInt
 
typedef float Spin
 
typedef std::vector< Spin > FieldRealArray
 

Private Member Functions

void execute ()
 
long double accelFlipping ()
 
void doTests (int *flips, long double tests)
 
void flipSpin (int site, int lidx, double du, long double tests_after_check)
 
double flippingProbability (int site, int lidx, double field, double *du)
 
struct MonteCarlo::PackedSpin __attribute__ ((__aligned__(16)))
 
Spin readSpin (int site, int sidx)
 
void writeSpin (Spin v, int site, int sidx)
 
void makeReciprocalImage ()
 
void modifyReciprocalImage (Spin diff, int site, int i, int j, int k)
 
double hinteraction (int site, int lidx)
 internal field from surrounding spins along ising axis [T].
 
double hinteraction_miscache (int sec_cache_miss_cnt, int site, int lidx)
 
double iterate_interactions (int site1, int lidx, int site2)
 
Vector3< double > iterate_real_generic (const FieldRealArray[16][3], int i, int j, int k)
 
double iterate_real_redirected (int cnt, const FieldRealArray &, int i, int j, int k, int site2)
 
double iterate_real (int site1, int i, int j, int k, int site2)
 
Vector3< double > iterate_rec_generic (Vector3< double > pos1, int i, int j, int k)
 
Vector3< double > iterate_rec_generic (Vector3< double > pos1, int i, int j, int k, int site2)
 
double iterate_rec_redirected (int cutoff, int site1, int i, int j, int k, int site2)
 
double iterate_rec (int site1, int i, int j, int k, int site2)
 
void takeThermalAverage (long double tests_after_check)
 

Static Private Member Functions

static VectorInt distance (int site1, int site2, int di, int dj, int dk)
 unit is 1/4 lattice const.
 
static int dipoleFieldReal (const Vector3< double > &dist_times_4, int site2, Vector3< double > *ret)
 
static int dipoleFieldRec (const Vector3< double > &k, int site2, Vector3< double > *ret)
 
static int lattice_index (int i, int j, int k)
 
static void addFieldsReal (MonteCarlo::Spin v, FieldRealArray &array, int di, int dj, int dk)
 
static int reciprocal_index (int kx, int ky, int kz)
 
static int spins_real_index (int i, int j, int k)
 
static int spins_real_index (int lidx)
 
static void * xthread_start_routine (void *)
 

Private Attributes

volatile bool m_bTerminated
 thread pool.
 
XCondition m_thread_pool_cond
 
XCondition m_hint_site2_last_cond
 
atomic< int > m_hint_site2_left
 target spin for concurrent calc. of interactions.
 
atomic< int > m_hint_site2_not_done
 
int m_hint_spin1_site
 
int m_hint_spin1_lattice_index
 
double m_hint_fields [16]
 store calculated fields.
 
int m_hint_sec_cache_miss [16]
 
int m_last_probability_buffer
 
int m_last_flipped_site
 
int m_last_flipped_lattice_index
 
bool m_play_back_buffer
 
std::vector< double > m_probability_buffers [2][16]
 
long m_hinteractions_called
 
bool m_sec_cache_enabled
 
bool m_third_cache_enabled
 
bool m_sec_cache_firsttime
 
bool m_third_cache_firsttime
 
long m_sec_cache_hit
 total hittings to caches.
 
atomic< long > m_third_cache_hit
 
std::vector< double > m_field_pri_cached [16]
 cached interaction energy.
 
std::vector< uint16_t > m_field_pri_cached_sane
 true if cached data is valid.
 
std::vector< double > m_field_sec_cached [16][16]
 cached interaction energy.
 
std::vector< uint16_t > m_field_sec_cached_sane [16]
 true if cached data is valid.
 
std::vector< double > m_field_third_cached [16][16]
 cached interaction energy.
 
std::vector< uint16_t > m_field_third_cached_sane [16]
 true if cached data is valid.
 
struct MonteCarlo::FieldRealArray __attribute__
 
std::vector< PackedSpinm_spins_real [16]
 
std::vector< Spin > m_spins_real [16]
 
std::vector< std::complex< Spin > > m_spins_rec [16]
 For reciprocal space. with q-cutoff.
 
double m_beta
 temperature. 1/k_B T [1/J].
 
double m_ext_field [16]
 Along Ising direction [T].
 
long double m_DeltaU
 Delta U [J].
 
long double m_SumDeltaU
 Sum Delta U [J].
 
long double m_SumSpin [16]
 Sum Spin Polarization.
 
long double m_SumTests
 
long double m_SumTestsAtLastFlip
 
std::deque< pthread_t > m_threads
 
std::deque< FlipHistorym_flipHistory
 

Static Private Attributes

static int s_cutoff_real
 max interaction distance for real space.
 
static double s_cutoff_real_radius
 
static int s_cutoff_rec
 For reciprocal space. i.e. Ewald term.
 
static double s_cutoff_rec_radius
 
static double s_alpha
 Ewald convergence factor [1/m].
 
static double s_dfactor
 Demagnetization D factor.
 
static FieldRealArray s_fields_real [16][16]
 
static FieldRealArray s_fields_real_B [16][16][3]
 
static FieldRealArray s_fields_real_8a [8][16][3]
 
static FieldRealArray s_fields_real_48f [48][16][3]
 
static std::vector< Spin > s_fields_rec [16][16]
 For reciprocal space. i.e. Ewald term.
 
static std::vector< Vector3
< Spin > > 
s_fields_rec_generic [16]
 
static double s_fields_rec_sum
 For self-energy caclulation.
 
static std::vector
< std::complex
< MonteCarlo::Spin > > 
s_exp_ph [16]
 
static int s_L
 size of lattices
 
static int s_num_spins
 

of spins


 
static std::vector< int > s_4r2_neighbor
 4*r^2 to nth neighbor.
 
static Vector3< double > s_ASiteIsingVector [16]
 

Detailed Description

Definition at line 62 of file montecarlo.h.

Member Function Documentation

long double MonteCarlo::accelFlipping ( )
private

Accelerate flipping.

Returns
tests to flip.

Definition at line 315 of file montecarlo.cpp.

int MonteCarlo::dipoleFieldReal ( const Vector3< double > &  dist_times_4,
int  site2,
Vector3< double > *  ret 
)
staticprivate
Returns
true if included.

Definition at line 44 of file interaction.cpp.

References s_alpha.

Referenced by setupField().

void MonteCarlo::doTests ( int *  flips,
long double  tests 
)
private

many tests until fixed number of flipping is performed.

See Also
exec()

Definition at line 457 of file montecarlo.cpp.

double MonteCarlo::exec ( double  temp,
Vector3< double >  field,
int *  flips,
long double *  tests,
double *  DUav,
Vector3< double > *  Mav 
)
Returns
Delta U [J/A site].
Parameters
flips# of flipping to be performed. # done is returned.
testsMin # of tests to be performed. # done is returned.

Definition at line 268 of file montecarlo.cpp.

void MonteCarlo::modifyReciprocalImage ( Spin  diff,
int  site,
int  i,
int  j,
int  k 
)
inlineprivate
Parameters
diffe.g. -2, -1, 1, 2.

Definition at line 592 of file montecarlo.cpp.

int MonteCarlo::setupField ( int  size,
double  dfactor,
double  cutoff_real,
double  cutoff_rec,
double  alpha 
)
static

prepare interactions.

Parameters
size# of lattices for one direction.
dfactorBulk demagnetization factor D (0 < D < 1).
cutoff_real[L.U.].
cutoff_rec[2pi/L].
alphaEwald convergence factor [1/L].
Returns
# of interactions.

Definition at line 99 of file interaction.cpp.

References dipoleFieldReal(), distance(), s_4r2_neighbor, s_alpha, s_bAborting, s_cutoff_real, s_cutoff_rec, s_dfactor, s_fields_rec, s_fields_rec_sum, s_L, and s_num_spins.

Referenced by XMonteCarloDriver::start().

Member Data Documentation

long MonteCarlo::m_hinteractions_called
private

Cache systems Primary cache: field at the target site. Secondary cache: field from a certain site at the target site. Third cache : field from a certain site with real space calc. at the target site.

Definition at line 221 of file montecarlo.h.

Referenced by hinteraction().

std::vector<PackedSpin> MonteCarlo::m_spins_real[16]
private

spin orientations. in real space. images are repeated outside boundary along x.

Definition at line 316 of file montecarlo.h.


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

Generated for KAME4 by  doxygen 1.8.3