made my old ising code run again

parent 63c1967c
......@@ -19,13 +19,19 @@
#ifndef int_p_NULL
#define int_p_NULL reinterpret_cast<int*>(0)
#endif
#include <boost/gil/gil_all.hpp>
#include <boost/gil/extension/io/png_io.hpp>
#include <boost/gil.hpp>
#include <boost/gil/extension/io/png.hpp>
#include <boost/gil/extension/io/png/old.hpp>
#ifndef NO_JPEG
#include <boost/gil/extension/io/jpeg_io.hpp>
#include <boost/gil/extension/io/jpeg.hpp>
#include <boost/gil/extension/io/jpeg/old.hpp>
#endif
#ifndef NO_TIFF
#include <boost/gil/extension/io/tiff_io.hpp>
#include <boost/gil/extension/io/tiff.hpp>
#include <boost/gil/extension/io/tiff/old.hpp>
#endif
......
......@@ -371,7 +371,7 @@ void metrop(
*pS += (*(pDat+iElem) ? t_real(1) : t_real(-1));
// normalise
*pS /= std::pow(2., t_real(DIM)); // NN
*pS /= std::pow(2., t_real(DIM)); // NN
for(std::size_t iDim=0; iDim<DIM; ++iDim) // N
*pS /= t_real(arrDims[iDim]);
}
......
......@@ -4,11 +4,11 @@
* @date 8-oct-16
* @license GPLv2 or GPLv3
*/
// gcc -march=native -O3 -std=c++11 -DNO_JPEG -DNO_TIFF -o metrop metrop.cpp ../../log/log.cpp ../../math/rand.cpp -lstdc++ -lm -lpng
// g++ -march=native -O2 -std=c++11 -DNO_JPEG -DNO_TIFF -o metrop metrop.cpp ../../log/log.cpp ../../math/rand.cpp -lpng
#include "../../math/mag.h"
#include "../../phys/mag.h"
#include "../../math/rand.h"
#include "../../math/units.h"
#include "../../phys/units.h"
#include "../../gfx/gil.h"
#include "../../helper/array.h"
#include <iostream>
......
/**
* 1d metropolis test (without phase transition)
* @author Tobias Weber <tobias.weber@tum.de>
* @date 8-oct-16
* @license GPLv2 or GPLv3
*/
// g++ -march=native -O2 -std=c++11 -o metrop_series_1d metrop_series_1d.cpp ../../log/log.cpp ../../math/rand.cpp
#include "../../math/rand.h"
#include "../../phys/mag.h"
#include "../../phys/units.h"
#include "../../helper/array.h"
#include <iostream>
#include <fstream>
using t_real = double;
static const tl::t_energy_si<t_real> meV = tl::get_one_meV<t_real>();
static const tl::t_temperature_si<t_real> kelvin = tl::get_one_kelvin<t_real>();
static const t_real k = t_real(tl::get_kB<t_real>() / meV * kelvin);
int main()
{
tl::init_rand();
std::size_t iIter = 1e7;
long iW = 256;
t_real J = 2.5; // meV
boost::multi_array<bool, 1> arr
= tl::rand_array<bool, 1, boost::array, boost::multi_array>({ iW });
std::ofstream ofstrE("E1d.dat");
ofstrE << std::setw(16) << std::left << "#T" << " "
<< std::setw(16) << std::left << "E_t" << " "
<< std::setw(16) << std::left << "<S>" << std::endl;
for(t_real T=200.; T>=0.; T-=10.)
{
t_real Etot = 0., S = 0.;
tl::log_info("T = ", T, " K");
tl::metrop<t_real, 1>({iW}, iIter, J, k, T, arr, &Etot, &S);
ofstrE << std::setw(16) << std::left << T << " "
<< std::setw(16) << std::left << Etot << " "
<< std::setw(16) << std::left << S << std::endl;
}
return 0;
}
/**
* metropolis test
* metropolis test (with phase transition)
* @author Tobias Weber <tobias.weber@tum.de>
* @date 8-oct-16
* @license GPLv2 or GPLv3
*/
// gcc -march=native -O3 -std=c++11 -DNO_JPEG -DNO_TIFF -o metrop_series metrop_series.cpp ../../log/log.cpp ../../math/rand.cpp -lstdc++ -lm -lpng
// g++ -march=native -O2 -std=c++11 -DNO_JPEG -DNO_TIFF -o metrop_series_2d metrop_series_2d.cpp ../../log/log.cpp ../../math/rand.cpp -lpng
#include "../../math/mag.h"
#include "../../math/rand.h"
#include "../../math/units.h"
#include "../../phys/mag.h"
#include "../../phys/units.h"
#include "../../gfx/gil.h"
#include "../../helper/array.h"
#include <iostream>
......@@ -19,6 +19,7 @@ static const tl::t_energy_si<t_real> meV = tl::get_one_meV<t_real>();
static const tl::t_temperature_si<t_real> kelvin = tl::get_one_kelvin<t_real>();
static const t_real k = t_real(tl::get_kB<t_real>() / meV * kelvin);
int main()
{
tl::init_rand();
......@@ -32,14 +33,20 @@ int main()
boost::multi_array<bool, 2> arr
= tl::rand_array<bool, 2, boost::array, boost::multi_array>({iW, iH});
std::ofstream ofstrE("E.dat");
std::ofstream ofstrE("E2d.dat");
ofstrE << std::setw(16) << std::left << "#T" << " "
<< std::setw(16) << std::left << "E_t" << " "
<< std::setw(16) << std::left << "<S>" << std::endl;
for(t_real T=200.; T>=0.; T-=10.)
{
t_real Etot = 0., S = 0.;
tl::log_info("T = ", T, " K");
tl::metrop<t_real, 2>({iW,iH}, iIter, J, k, T, arr, &Etot, &S);
ofstrE << T << "\t" << Etot << "\t" << S << std::endl;
ofstrE << std::setw(16) << std::left << T << " "
<< std::setw(16) << std::left << Etot << " "
<< std::setw(16) << std::left << S << std::endl;
using t_view = tl::gil::gray8_view_t;
using t_pix = typename t_view::value_type;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment