2 Dimensional Ising Model Simulate the change in energy and magnetization in a ferro magnet

Loading...
Searching...
No Matches
Macros | Functions
monte_carlo.hpp File Reference

Functions for monte carlo simulations. More...

`#include "IsingModel.hpp"`
`#include "data_type.hpp"`
`#include "utils.hpp"`
`#include <functional>`
`#include <string>`
`#include <omp.h>`

Go to the source code of this file.

## Macros
#define | BURN_IN_TIME 5000

## Functions
int | test_2x2_lattice (double tol, int max_cycles)
| Test numerical data with analytical data.
void | monte_carlo_progression (double T, int L, int cycles, const std::string filename)
| Write the expected values for each Monte Carlo cycles to file.
void | monte_carlo_progression (double T, int L, int cycles, int value, const std::string filename)
| Write the expected values for each Monte Carlo cycles to file.
void | pd_estimate (double T, int L, int cycles, const std::string filename)
| Estimate the probability distribution for the energy.
data_t | monte_carlo_serial (int L, double T, int cycles)
| Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles.
data_t | monte_carlo_parallel (int L, double T, int cycles)
| Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles in parallel.
void | phase_transition (int L, double start_T, double end_T, int points_T, std::function< data_t(int, double, int)> monte_carlo, std::string outfile)
| Perform the MCMC algorithm using a range of temperatures.

## Detailed Description

Functions for monte carlo simulations.

Author
  Cory Alexander Balaton (coryab)
  Janita Ovidie Sandtrøen Willumsen (janitaws)

Version
  1.0

Bug:
  No known bugs

Definition in file monte_carlo.hpp.

## Macro Definition Documentation

## ◆ BURN_IN_TIME

#define BURN_IN_TIME 5000

Definition at line 24 of file monte_carlo.hpp.

## Function Documentation

## ◆ monte_carlo_parallel()

data_t monte_carlo_parallel | ( | int | L,
|  | double | T,
|  | int | cycles
| ) |  |

Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles in parallel.

Parameters

  L | The size of the lattice
  T | The Temperature for the Ising model
  cycles | The amount of Monte Carlo cycles to do

Returns
  data_t

Definition at line 128 of file monte_carlo.cpp.

## ◆ monte_carlo_progression() [1/2]

void monte_carlo_progression | ( | double | T,
|  | int | L,
|  | int | cycles,
|  | const std::string | filename
| ) |  |

Write the expected values for each Monte Carlo cycles to file.

Parameters

  T | Temperature
  L | The size of the lattice
  cycles | The amount of Monte Carlo cycles to do
  filename | The file to write to

Definition at line 17 of file monte_carlo.cpp.

## ◆ monte_carlo_progression() [2/2]

void monte_carlo_progression | ( | double | T,
|  | int | L,
|  | int | cycles,
|  | int | value,
|  | const std::string | filename
| ) |  |

Write the expected values for each Monte Carlo cycles to file.

Parameters

  T | Temperature
  L | The size of the lattice
  cycles | The amount of Monte Carlo cycles to do
  value | The value to set the elements in the lattice
  filename | The file to write to

Definition at line 51 of file monte_carlo.cpp.

## ◆ monte_carlo_serial()

data_t monte_carlo_serial | ( | int | L,
|  | double | T,
|  | int | cycles
| ) |  |

Execute the Metropolis algorithm for a certain amount of Monte Carlo cycles.

Parameters

  L | The size of the lattice
  T | The Temperature for the Ising model
  cycles | The amount of Monte Carlo cycles to do

Returns
  data_t

Definition at line 111 of file monte_carlo.cpp.

## ◆ pd_estimate()

void pd_estimate | ( | double | T,
|  | int | L,
|  | int | cycles,
|  | const std::string | filename
| ) |  |

Estimate the probability distribution for the energy.

Parameters

  T | The temperature of the Ising model
  L | The size of the lattice
  cycles | The amount of Monte Carlo cycles to do
  filename | The file to write to

Definition at line 85 of file monte_carlo.cpp.

## ◆ phase_transition()

void phase_transition | ( | int | L,
|  | double | start_T,
|  | double | end_T,
|  | int | points_T,
|  | std::function< data_t(int, double, int)> | monte_carlo,
|  | std::string | outfile
| ) |  |

Perform the MCMC algorithm using a range of temperatures.

Parameters

  L | The size of the lattice
  start_T | The start temperature
  end_T | The end temperature
  point_T | The amount of point to measure
  monte_carlo | Which Monte Carlo implementation to use
  outfile | The file to write the data to

Definition at line 156 of file monte_carlo.cpp.

## ◆ test_2x2_lattice()

int test_2x2_lattice | ( | double | tol,
|  | int | max_cycles
| ) |  |

Test numerical data with analytical data.

Parameters

  tol | The tolerance between the analytical and numerical solution.
  max_cycles | The max number of Monte Carlo cycles.

return int