Project-4/docs/IsingModel_8hpp_source.html
2023-12-04 22:23:30 +01:00

277 lines
37 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.6"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>2 Dimensional Ising Model: include/IsingModel.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">2 Dimensional Ising Model
</div>
<div id="projectbrief">Simulate the change in energy and magnetization in a ferro magnet</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.6 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('IsingModel_8hpp_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="headertitle"><div class="title">IsingModel.hpp</div></div>
</div><!--header-->
<div class="contents">
<a href="IsingModel_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="comment">/** @file IsingModel.hpp</span></div>
<div class="line"><span class="lineno"> 2</span><span class="comment"> *</span></div>
<div class="line"><span class="lineno"> 3</span><span class="comment"> * @author Cory Alexander Balaton (coryab)</span></div>
<div class="line"><span class="lineno"> 4</span><span class="comment"> * @author Janita Ovidie Sandtrøen Willumsen (janitaws)</span></div>
<div class="line"><span class="lineno"> 5</span><span class="comment"> *</span></div>
<div class="line"><span class="lineno"> 6</span><span class="comment"> * @version 0.1</span></div>
<div class="line"><span class="lineno"> 7</span><span class="comment"> *</span></div>
<div class="line"><span class="lineno"> 8</span><span class="comment"> * @brief The definition of the Ising model.</span></div>
<div class="line"><span class="lineno"> 9</span><span class="comment"> *</span></div>
<div class="line"><span class="lineno"> 10</span><span class="comment"> * @bug No known bugs</span></div>
<div class="line"><span class="lineno"> 11</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span><span class="preprocessor">#</span><span class="preprocessor">ifndef</span> <span class="preprocessor">__ISING_MODEL__</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span><span class="preprocessor">#</span><span class="preprocessor">define</span> <span class="preprocessor">__ISING_MODEL__</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span> </div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span><span class="preprocessor">#</span><span class="preprocessor">include</span> <a class="code" href="data__type_8hpp.html" title="Header for the data_t type.">&quot;data_type.hpp&quot;</a></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span><span class="preprocessor">#</span><span class="preprocessor">include</span> <a class="code" href="utils_8hpp.html" title="Function prototypes and macros that are useful.">&quot;utils.hpp&quot;</a></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</span> </div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span><span class="preprocessor">#</span><span class="preprocessor">include</span> <span class="preprocessor">&lt;</span><span class="preprocessor">armadillo</span><span class="preprocessor">&gt;</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span><span class="preprocessor">#</span><span class="preprocessor">include</span> <span class="preprocessor">&lt;</span><span class="preprocessor">cstdint</span><span class="preprocessor">&gt;</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span><span class="preprocessor">#</span><span class="preprocessor">include</span> <span class="preprocessor">&lt;</span><span class="preprocessor">random</span><span class="preprocessor">&gt;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span><span class="preprocessor">#</span><span class="preprocessor">include</span> <span class="preprocessor">&lt;</span><span class="preprocessor">unordered_map</span><span class="preprocessor">&gt;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> </div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"><a class="line" href="IsingModel_8hpp.html#a3039ac753f46401767c38f867787fae6"> 23</a></span><span class="preprocessor">#</span><span class="preprocessor">define</span> <span class="preprocessor">INDEX</span><span class="preprocessor">(</span><span class="preprocessor">I</span><span class="preprocessor">,</span> <span class="preprocessor">N</span><span class="preprocessor">)</span> <span class="preprocessor">(</span><span class="preprocessor">I</span> <span class="preprocessor">+</span> <span class="preprocessor">N</span><span class="preprocessor">)</span> <span class="preprocessor">%</span> <span class="preprocessor">N</span> <span class="comment">///&lt; I modulo N</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> </div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span><span class="comment">// Indeces for the neighbor matrix.</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"><a class="line" href="IsingModel_8hpp.html#a1965eaca47dbf3f87acdafc2208f04eb"> 26</a></span><span class="preprocessor">#</span><span class="preprocessor">define</span> <span class="preprocessor">UP</span> 0 <span class="comment">///&lt; Used for the neighbor matrix in the class</span></div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"><a class="line" href="IsingModel_8hpp.html#a437ef08681e7210d6678427030446a54"> 27</a></span><span class="preprocessor">#</span><span class="preprocessor">define</span> <span class="preprocessor">LEFT</span> 0 <span class="comment">///&lt; Used for the neighbor matrix in the class</span></div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"><a class="line" href="IsingModel_8hpp.html#a4193cd1c8c2e6ebd0e056fa2364a663f"> 28</a></span><span class="preprocessor">#</span><span class="preprocessor">define</span> <span class="preprocessor">DOWN</span> 1 <span class="comment">///&lt; Used for the neighbor matrix in the class</span></div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"><a class="line" href="IsingModel_8hpp.html#a80fb826a684cf3f0d306b22aa100ddac"> 29</a></span><span class="preprocessor">#</span><span class="preprocessor">define</span> <span class="preprocessor">RIGHT</span> 1 <span class="comment">///&lt; Used for the neighbor matrix in the class</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> </div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span><span class="comment">/** @brief The Ising model in 2 dimensions.</span></div>
<div class="line"><span class="lineno"> 32</span><span class="comment"> *</span></div>
<div class="line"><span class="lineno"> 33</span><span class="comment"> * @details None of the methods are parallelized, as there is very little</span></div>
<div class="line"><span class="lineno"> 34</span><span class="comment"> * benefit in doing so.</span></div>
<div class="line"><span class="lineno"> 35</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"><a class="line" href="classIsingModel.html"> 36</a></span><span class="keyword">class</span> <a class="code hl_class" href="classIsingModel.html">IsingModel</a> {</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span><span class="keyword">private</span>:</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> <span class="comment">/** @brief Give access to private members to the test class IsingModelTest.</span></div>
<div class="line"><span class="lineno"> 39</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"><a class="line" href="classIsingModel.html#a2b1cf104e0bda1fce78ed366e1ec7287"> 40</a></span> <span class="keyword">friend</span> <span class="keyword">class</span> <a class="code hl_class" href="classIsingModelTest.html">IsingModelTest</a>;</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> </div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <span class="comment">/** @brief \f$ L \times L \f$ matrix where element \f$ x \in {-1, 1}\f$.</span></div>
<div class="line"><span class="lineno"> 43</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"><a class="line" href="classIsingModel.html#a2c3c76c79717c968d7c227c58b46df41"> 44</a></span> arma::Mat&lt;<span class="keywordtype">int</span>&gt; <a class="code hl_variable" href="classIsingModel.html#a2c3c76c79717c968d7c227c58b46df41">lattice</a>;</div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> <span class="comment">/** @brief \f$ L \times 2 \f$ matrix with the neighbors of each element</span></div>
<div class="line"><span class="lineno"> 47</span><span class="comment"> * \f$ x_i \f$.</span></div>
<div class="line"><span class="lineno"> 48</span><span class="comment"> *</span></div>
<div class="line"><span class="lineno"> 49</span><span class="comment"> * @details The reason why it&#39;s \f$ L \times 2 \f$ instead of</span></div>
<div class="line"><span class="lineno"> 50</span><span class="comment"> * \f$ L \times 2 \f$, is that we can see that we can use the same column</span></div>
<div class="line"><span class="lineno"> 51</span><span class="comment"> * for the left and upper neighbor, and we can use the same column for the</span></div>
<div class="line"><span class="lineno"> 52</span><span class="comment"> * right and lower neighbor.</span></div>
<div class="line"><span class="lineno"> 53</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"><a class="line" href="classIsingModel.html#a94093aaf30facca62737f2ac381fdbcd"> 54</a></span> arma::Mat&lt;<span class="keywordtype">int</span>&gt; <a class="code hl_variable" href="classIsingModel.html#a94093aaf30facca62737f2ac381fdbcd">neighbors</a>;</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> </div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> <span class="comment">/** @brief An array containing all possible energy differences.</span></div>
<div class="line"><span class="lineno"> 57</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"><a class="line" href="classIsingModel.html#a7112dd6433b1bb9512150cbdc1a0b77e"> 58</a></span> <span class="keywordtype">double</span> <a class="code hl_variable" href="classIsingModel.html#a7112dd6433b1bb9512150cbdc1a0b77e">energy_diff</a>[17];</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> </div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="comment">/** @brief The temperature of the model.</span></div>
<div class="line"><span class="lineno"> 61</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"><a class="line" href="classIsingModel.html#a20fc4c0c99d8a119f70a1614784d4e5c"> 62</a></span> <span class="keywordtype">double</span> <a class="code hl_variable" href="classIsingModel.html#a20fc4c0c99d8a119f70a1614784d4e5c">T</a>;</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> </div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> <span class="comment">/** @brief Size of the lattice.</span></div>
<div class="line"><span class="lineno"> 65</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"><a class="line" href="classIsingModel.html#a2b8ac43baefeb386186266d5aa4de348"> 66</a></span> <span class="keywordtype">int</span> <a class="code hl_variable" href="classIsingModel.html#a2b8ac43baefeb386186266d5aa4de348">L</a>;</div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> </div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="comment">/** @brief The current energy state. unit: \f$ J \f$.</span></div>
<div class="line"><span class="lineno"> 69</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"><a class="line" href="classIsingModel.html#a1c8a2a4331c7e60c3e1350c0cf8300b9"> 70</a></span> int64_t <a class="code hl_variable" href="classIsingModel.html#a1c8a2a4331c7e60c3e1350c0cf8300b9">E</a>;</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> </div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> <span class="comment">/** @brief The current magnetic strength. unit: Unitless.</span></div>
<div class="line"><span class="lineno"> 73</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"><a class="line" href="classIsingModel.html#aef7232b28df08e064ef58eb5ef32f738"> 74</a></span> int64_t <a class="code hl_variable" href="classIsingModel.html#aef7232b28df08e064ef58eb5ef32f738">M</a>;</div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> </div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> <span class="comment">/** @brief The RNG that is used for the Metropolis algorithm</span></div>
<div class="line"><span class="lineno"> 77</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"><a class="line" href="classIsingModel.html#a1bbe0cb10abee98058e7b45b22b9cd0a"> 78</a></span> std::mt19937 <a class="code hl_variable" href="classIsingModel.html#a1bbe0cb10abee98058e7b45b22b9cd0a">engine</a>;</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> </div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> <span class="comment">/** @brief Initialize the RNG.</span></div>
<div class="line"><span class="lineno"> 81</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classIsingModel.html#aaedc25b7284e04849269f31291590bf5">initialize_engine</a>();</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> </div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> <span class="comment">/** @brief Initialize the lattice with a random distribution of 1s and</span></div>
<div class="line"><span class="lineno"> 85</span><span class="comment"> * -1s.</span></div>
<div class="line"><span class="lineno"> 86</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classIsingModel.html#a34a4710949b4a70f3e37ca223aefcf8a">initialize_lattice</a>();</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> </div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> <span class="comment">/** @brief Initialize the lattice with a specific value.</span></div>
<div class="line"><span class="lineno"> 90</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno"> 91</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classIsingModel.html#acc86effd6889bea199a3d70a9f38dc78">initialize_lattice</a>(<span class="keywordtype">int</span> val);</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"> 92</span> </div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno"> 93</span> <span class="comment">/** @brief initialize the neighbors matrix.</span></div>
<div class="line"><span class="lineno"> 94</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"> 95</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classIsingModel.html#a6776109105051597c275670dabd0054a">initialize_neighbors</a>();</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> </div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> <span class="comment">/** @brief Initialize the energy_diff array with the correct values.</span></div>
<div class="line"><span class="lineno"> 98</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classIsingModel.html#aff9a1201933fd5408845a1447e4895b4">initialize_energy_diff</a>();</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> </div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> <span class="comment">/** @brief Initialize the magnetization of the system.</span></div>
<div class="line"><span class="lineno"> 102</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classIsingModel.html#a926cf4964d190d2ce23e5a17201787a4">initialize_magnetization</a>();</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> </div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> <span class="comment">/** @brief Initialize the energy of the system.</span></div>
<div class="line"><span class="lineno"> 106</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span> <span class="keywordtype">void</span> <a class="code hl_function" href="classIsingModel.html#a59fced38c695e2fa647f53be81b9d2a1">initialize_energy</a>();</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> </div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> <span class="comment">/** @brief Constructor used for testing.</span></div>
<div class="line"><span class="lineno"> 110</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span> <a class="code hl_function" href="classIsingModel.html#acf281f6f5ed02911ca6ab07004449864">IsingModel</a>();</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span> </div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span><span class="keyword">public</span>:</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <span class="comment">/** @brief Constructor for the Ising model.</span></div>
<div class="line"><span class="lineno"> 115</span><span class="comment"> *</span></div>
<div class="line"><span class="lineno"> 116</span><span class="comment"> * @param L The size of the lattice.</span></div>
<div class="line"><span class="lineno"> 117</span><span class="comment"> * @param T The temperature for the system.</span></div>
<div class="line"><span class="lineno"> 118</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span> <a class="code hl_function" href="classIsingModel.html#a4a39ee7fbfbbf566f75bc28900ca9ea5">IsingModel</a>(<span class="keywordtype">int</span> L, <span class="keywordtype">double</span> T);</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"> 120</span> </div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno"> 121</span> <span class="comment">/** @brief Constructor for the Ising model.</span></div>
<div class="line"><span class="lineno"> 122</span><span class="comment"> *</span></div>
<div class="line"><span class="lineno"> 123</span><span class="comment"> * @param L The size of the lattice.</span></div>
<div class="line"><span class="lineno"> 124</span><span class="comment"> * @param T The temperature for the system.</span></div>
<div class="line"><span class="lineno"> 125</span><span class="comment"> * @param val The value to set for all spins.</span></div>
<div class="line"><span class="lineno"> 126</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"> 127</span> <a class="code hl_function" href="classIsingModel.html#a46c9446e94854452f715d307c77c1c15">IsingModel</a>(<span class="keywordtype">int</span> L, <span class="keywordtype">double</span> T, <span class="keywordtype">int</span> val);</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> </div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <span class="comment">/** @brief The Metropolis algorithm.</span></div>
<div class="line"><span class="lineno"> 130</span><span class="comment"> * */</span></div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> <a class="code hl_class" href="classdata__t.html">data_t</a> <a class="code hl_function" href="classIsingModel.html#a56559d68dc9aaff1976d84b157f43488">Metropolis</a>();</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span>};</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> </div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span><span class="preprocessor">#</span><span class="preprocessor">endif</span></div>
<div class="ttc" id="aIsingModel_8hpp_html_a1965eaca47dbf3f87acdafc2208f04eb"><div class="ttname"><a href="IsingModel_8hpp.html#a1965eaca47dbf3f87acdafc2208f04eb">UP</a></div><div class="ttdeci">#define UP</div><div class="ttdoc">Used for the neighbor matrix in the class.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00026">IsingModel.hpp:26</a></div></div>
<div class="ttc" id="aIsingModel_8hpp_html_a3039ac753f46401767c38f867787fae6"><div class="ttname"><a href="IsingModel_8hpp.html#a3039ac753f46401767c38f867787fae6">INDEX</a></div><div class="ttdeci">#define INDEX(I, N)</div><div class="ttdoc">I modulo N.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00023">IsingModel.hpp:23</a></div></div>
<div class="ttc" id="aIsingModel_8hpp_html_a4193cd1c8c2e6ebd0e056fa2364a663f"><div class="ttname"><a href="IsingModel_8hpp.html#a4193cd1c8c2e6ebd0e056fa2364a663f">DOWN</a></div><div class="ttdeci">#define DOWN</div><div class="ttdoc">Used for the neighbor matrix in the class.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00028">IsingModel.hpp:28</a></div></div>
<div class="ttc" id="aIsingModel_8hpp_html_a437ef08681e7210d6678427030446a54"><div class="ttname"><a href="IsingModel_8hpp.html#a437ef08681e7210d6678427030446a54">LEFT</a></div><div class="ttdeci">#define LEFT</div><div class="ttdoc">Used for the neighbor matrix in the class.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00027">IsingModel.hpp:27</a></div></div>
<div class="ttc" id="aIsingModel_8hpp_html_a80fb826a684cf3f0d306b22aa100ddac"><div class="ttname"><a href="IsingModel_8hpp.html#a80fb826a684cf3f0d306b22aa100ddac">RIGHT</a></div><div class="ttdeci">#define RIGHT</div><div class="ttdoc">Used for the neighbor matrix in the class.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00029">IsingModel.hpp:29</a></div></div>
<div class="ttc" id="aclassIsingModelTest_html"><div class="ttname"><a href="classIsingModelTest.html">IsingModelTest</a></div><div class="ttdoc">Test class for the Ising model.</div><div class="ttdef"><b>Definition:</b> <a href="test__suite_8cpp_source.html#l00036">test_suite.cpp:36</a></div></div>
<div class="ttc" id="aclassIsingModel_html"><div class="ttname"><a href="classIsingModel.html">IsingModel</a></div><div class="ttdoc">The Ising model in 2 dimensions.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00036">IsingModel.hpp:36</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a1bbe0cb10abee98058e7b45b22b9cd0a"><div class="ttname"><a href="classIsingModel.html#a1bbe0cb10abee98058e7b45b22b9cd0a">IsingModel::engine</a></div><div class="ttdeci">std::mt19937 engine</div><div class="ttdoc">The RNG that is used for the Metropolis algorithm.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00078">IsingModel.hpp:78</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a1c8a2a4331c7e60c3e1350c0cf8300b9"><div class="ttname"><a href="classIsingModel.html#a1c8a2a4331c7e60c3e1350c0cf8300b9">IsingModel::E</a></div><div class="ttdeci">int64_t E</div><div class="ttdoc">The current energy state. unit: .</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00070">IsingModel.hpp:70</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a20fc4c0c99d8a119f70a1614784d4e5c"><div class="ttname"><a href="classIsingModel.html#a20fc4c0c99d8a119f70a1614784d4e5c">IsingModel::T</a></div><div class="ttdeci">double T</div><div class="ttdoc">The temperature of the model.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00062">IsingModel.hpp:62</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a2b8ac43baefeb386186266d5aa4de348"><div class="ttname"><a href="classIsingModel.html#a2b8ac43baefeb386186266d5aa4de348">IsingModel::L</a></div><div class="ttdeci">int L</div><div class="ttdoc">Size of the lattice.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00066">IsingModel.hpp:66</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a2c3c76c79717c968d7c227c58b46df41"><div class="ttname"><a href="classIsingModel.html#a2c3c76c79717c968d7c227c58b46df41">IsingModel::lattice</a></div><div class="ttdeci">arma::Mat&lt; int &gt; lattice</div><div class="ttdoc">matrix where element .</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00044">IsingModel.hpp:44</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a34a4710949b4a70f3e37ca223aefcf8a"><div class="ttname"><a href="classIsingModel.html#a34a4710949b4a70f3e37ca223aefcf8a">IsingModel::initialize_lattice</a></div><div class="ttdeci">void initialize_lattice()</div><div class="ttdoc">Initialize the lattice with a random distribution of 1s and -1s.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00049">IsingModel.cpp:49</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a46c9446e94854452f715d307c77c1c15"><div class="ttname"><a href="classIsingModel.html#a46c9446e94854452f715d307c77c1c15">IsingModel::IsingModel</a></div><div class="ttdeci">IsingModel(int L, double T, int val)</div><div class="ttdoc">Constructor for the Ising model.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00031">IsingModel.cpp:31</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a4a39ee7fbfbbf566f75bc28900ca9ea5"><div class="ttname"><a href="classIsingModel.html#a4a39ee7fbfbbf566f75bc28900ca9ea5">IsingModel::IsingModel</a></div><div class="ttdeci">IsingModel(int L, double T)</div><div class="ttdoc">Constructor for the Ising model.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00019">IsingModel.cpp:19</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a56559d68dc9aaff1976d84b157f43488"><div class="ttname"><a href="classIsingModel.html#a56559d68dc9aaff1976d84b157f43488">IsingModel::Metropolis</a></div><div class="ttdeci">data_t Metropolis()</div><div class="ttdoc">The Metropolis algorithm.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00110">IsingModel.cpp:110</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a59fced38c695e2fa647f53be81b9d2a1"><div class="ttname"><a href="classIsingModel.html#a59fced38c695e2fa647f53be81b9d2a1">IsingModel::initialize_energy</a></div><div class="ttdeci">void initialize_energy()</div><div class="ttdoc">Initialize the energy of the system.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00096">IsingModel.cpp:96</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a6776109105051597c275670dabd0054a"><div class="ttname"><a href="classIsingModel.html#a6776109105051597c275670dabd0054a">IsingModel::initialize_neighbors</a></div><div class="ttdeci">void initialize_neighbors()</div><div class="ttdoc">initialize the neighbors matrix.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00070">IsingModel.cpp:70</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a7112dd6433b1bb9512150cbdc1a0b77e"><div class="ttname"><a href="classIsingModel.html#a7112dd6433b1bb9512150cbdc1a0b77e">IsingModel::energy_diff</a></div><div class="ttdeci">double energy_diff[17]</div><div class="ttdoc">An array containing all possible energy differences.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00058">IsingModel.hpp:58</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a926cf4964d190d2ce23e5a17201787a4"><div class="ttname"><a href="classIsingModel.html#a926cf4964d190d2ce23e5a17201787a4">IsingModel::initialize_magnetization</a></div><div class="ttdeci">void initialize_magnetization()</div><div class="ttdoc">Initialize the magnetization of the system.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00088">IsingModel.cpp:88</a></div></div>
<div class="ttc" id="aclassIsingModel_html_a94093aaf30facca62737f2ac381fdbcd"><div class="ttname"><a href="classIsingModel.html#a94093aaf30facca62737f2ac381fdbcd">IsingModel::neighbors</a></div><div class="ttdeci">arma::Mat&lt; int &gt; neighbors</div><div class="ttdoc">matrix with the neighbors of each element .</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00054">IsingModel.hpp:54</a></div></div>
<div class="ttc" id="aclassIsingModel_html_aaedc25b7284e04849269f31291590bf5"><div class="ttname"><a href="classIsingModel.html#aaedc25b7284e04849269f31291590bf5">IsingModel::initialize_engine</a></div><div class="ttdeci">void initialize_engine()</div><div class="ttdoc">Initialize the RNG.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00043">IsingModel.cpp:43</a></div></div>
<div class="ttc" id="aclassIsingModel_html_acc86effd6889bea199a3d70a9f38dc78"><div class="ttname"><a href="classIsingModel.html#acc86effd6889bea199a3d70a9f38dc78">IsingModel::initialize_lattice</a></div><div class="ttdeci">void initialize_lattice(int val)</div><div class="ttdoc">Initialize the lattice with a specific value.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00059">IsingModel.cpp:59</a></div></div>
<div class="ttc" id="aclassIsingModel_html_acf281f6f5ed02911ca6ab07004449864"><div class="ttname"><a href="classIsingModel.html#acf281f6f5ed02911ca6ab07004449864">IsingModel::IsingModel</a></div><div class="ttdeci">IsingModel()</div><div class="ttdoc">Constructor used for testing.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00014">IsingModel.cpp:14</a></div></div>
<div class="ttc" id="aclassIsingModel_html_aef7232b28df08e064ef58eb5ef32f738"><div class="ttname"><a href="classIsingModel.html#aef7232b28df08e064ef58eb5ef32f738">IsingModel::M</a></div><div class="ttdeci">int64_t M</div><div class="ttdoc">The current magnetic strength. unit: Unitless.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8hpp_source.html#l00074">IsingModel.hpp:74</a></div></div>
<div class="ttc" id="aclassIsingModel_html_aff9a1201933fd5408845a1447e4895b4"><div class="ttname"><a href="classIsingModel.html#aff9a1201933fd5408845a1447e4895b4">IsingModel::initialize_energy_diff</a></div><div class="ttdeci">void initialize_energy_diff()</div><div class="ttdoc">Initialize the energy_diff array with the correct values.</div><div class="ttdef"><b>Definition:</b> <a href="IsingModel_8cpp_source.html#l00081">IsingModel.cpp:81</a></div></div>
<div class="ttc" id="aclassdata__t_html"><div class="ttname"><a href="classdata__t.html">data_t</a></div><div class="ttdoc">Type to use with the IsingModel class and montecarlo module.</div><div class="ttdef"><b>Definition:</b> <a href="data__type_8hpp_source.html#l00019">data_type.hpp:19</a></div></div>
<div class="ttc" id="aclassdata__t_html_a3f2d19ab309e696ba91a2000479bcb83"><div class="ttname"><a href="classdata__t.html#a3f2d19ab309e696ba91a2000479bcb83">data_t::data_t</a></div><div class="ttdeci">data_t(double E, double E2, double M, double M2, double M_abs)</div><div class="ttdoc">Constructor with parameters.</div><div class="ttdef"><b>Definition:</b> <a href="data__type_8hpp_source.html#l00045">data_type.hpp:45</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="IsingModel_8hpp.html">IsingModel.hpp</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.6 </li>
</ul>
</div>
</body>
</html>