Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tlibs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Scientific Software
Takin
tlibs
Commits
77946749
Verified
Commit
77946749
authored
Jul 19, 2020
by
Tobias WEBER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made my old ising code run again
parent
63c1967c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
14 deletions
+76
-14
gfx/gil.h
gfx/gil.h
+10
-4
phys/mag.h
phys/mag.h
+1
-1
tools/misc/metrop.cpp
tools/misc/metrop.cpp
+3
-3
tools/misc/metrop_series_1d.cpp
tools/misc/metrop_series_1d.cpp
+49
-0
tools/misc/metrop_series_2d.cpp
tools/misc/metrop_series_2d.cpp
+13
-6
No files found.
gfx/gil.h
View file @
77946749
...
...
@@ -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
...
...
phys/mag.h
View file @
77946749
...
...
@@ -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
]);
}
...
...
tools/misc/metrop.cpp
View file @
77946749
...
...
@@ -4,11 +4,11 @@
* @date 8-oct-16
* @license GPLv2 or GPLv3
*/
// g
cc -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>
...
...
tools/misc/metrop_series_1d.cpp
0 → 100644
View file @
77946749
/**
* 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
;
}
tools/misc/metrop_series.cpp
→
tools/misc/metrop_series
_2d
.cpp
View file @
77946749
/**
* metropolis test
* metropolis test
(with phase transition)
* @author Tobias Weber <tobias.weber@tum.de>
* @date 8-oct-16
* @license GPLv2 or GPLv3
*/
// g
cc -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment