Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
Takin
mag-core
Commits
75626e5f
Verified
Commit
75626e5f
authored
Jun 03, 2020
by
Tobias WEBER
Browse files
adapted to tlibs2 changes
parent
50d83dbb
Changes
23
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
75626e5f
...
...
@@ -53,6 +53,8 @@ tools/magstructfact/build/**
tools/magsgbrowser/build/**
tools/pol/build/**
tools/moldyn/build/**
tools/main/build/**
tools/setup/build/**
*.pyc
.DS_Store
*.csv
...
...
tools/cif2xml/CMakeLists.txt
View file @
75626e5f
...
...
@@ -13,8 +13,8 @@ set(CMAKE_VERBOSE_MAKEFILE TRUE)
find_package
(
Boost REQUIRED
)
set
(
CMAKE_CXX_STANDARD
17
)
add_definitions
(
-std=c++2
a -fconcepts
)
set
(
CMAKE_CXX_STANDARD
20
)
add_definitions
(
-std=c++2
0
)
add_definitions
(
${
Boost_CXX_FLAGS
}
)
...
...
tools/cif2xml/cif2xml.cpp
View file @
75626e5f
...
...
@@ -6,7 +6,7 @@
*/
#include "../structfact/loadcif.h"
#include "libs/math
_algos
.h"
#include "libs/math
20
.h"
#include <gemmi/version.hpp>
#include <iostream>
...
...
@@ -15,7 +15,7 @@
using
t_real
=
double
;
using
t_vec
=
std
::
vector
<
t_real
>
;
using
t_mat
=
m
::
mat
<
t_real
,
std
::
vector
>
;
using
t_mat
=
tl2
::
mat
<
t_real
,
std
::
vector
>
;
constexpr
t_real
g_eps
=
1e-6
;
constexpr
int
g_prec
=
6
;
...
...
tools/cif2xml/findsg.cpp
View file @
75626e5f
...
...
@@ -6,7 +6,7 @@
*/
#include "../structfact/loadcif.h"
#include "libs/math
_algos
.h"
#include "libs/math
20
.h"
#include <gemmi/version.hpp>
#include <boost/algorithm/string.hpp>
...
...
@@ -16,7 +16,7 @@
using
t_real
=
double
;
using
t_vec
=
std
::
vector
<
t_real
>
;
using
t_mat
=
m
::
mat
<
t_real
,
std
::
vector
>
;
using
t_mat
=
tl2
::
mat
<
t_real
,
std
::
vector
>
;
constexpr
t_real
g_eps
=
1e-6
;
...
...
@@ -30,10 +30,10 @@ int main(int argc, char** argv)
std
::
vector
<
t_vec
>
vecFinal
;
/*{{ // test data
m
::create<t_vec>({ 0.1, 0.1, 0.1}),
m
::create<t_vec>({ 0.4, -0.1, -0.4}),
m
::create<t_vec>({-0.1, -0.4, 0.4}),
m
::create<t_vec>({-0.4, 0.4, -0.1}),
tl2
::create<t_vec>({ 0.1, 0.1, 0.1}),
tl2
::create<t_vec>({ 0.4, -0.1, -0.4}),
tl2
::create<t_vec>({-0.1, -0.4, 0.4}),
tl2
::create<t_vec>({-0.4, 0.4, -0.1}),
}}*/
;
std
::
size_t
atomnr
=
1
;
...
...
tools/magsgbrowser/CMakeLists.txt
View file @
75626e5f
...
...
@@ -12,8 +12,8 @@ find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)
set
(
CMAKE_AUTOUIC ON
)
set
(
CMAKE_AUTOMOC ON
)
set
(
CMAKE_CXX_STANDARD
17
)
add_definitions
(
-std=c++
17 -fconcepts
)
set
(
CMAKE_CXX_STANDARD
20
)
add_definitions
(
-std=c++
20
)
include_directories
(
"
${
PROJECT_SOURCE_DIR
}
"
"../.."
"../../ext/gemmi/include"
"../../ext/gemmi/third_party"
)
...
...
tools/magsgbrowser/browser.h
View file @
75626e5f
...
...
@@ -17,15 +17,15 @@
#include <QtWidgets/QListWidgetItem>
#include "libs/magsg.h"
#include "libs/math
_algos
.h"
#include "libs/math
20
.h"
#include "ui_browser.h"
using
t_real_sg
=
double
;
using
t_vec_sg
=
m
::
qvec_adapter
<
int
,
3
,
t_real_sg
,
QGenericMatrix
>
;
using
t_mat_sg
=
m
::
qmat_adapter
<
int
,
3
,
3
,
t_real_sg
,
QGenericMatrix
>
;
using
t_mat44_sg
=
m
::
qmat_adapter
<
int
,
4
,
4
,
t_real_sg
,
QGenericMatrix
>
;
using
t_vec_sg
=
tl2
::
qvec_adapter
<
int
,
3
,
t_real_sg
,
QGenericMatrix
>
;
using
t_mat_sg
=
tl2
::
qmat_adapter
<
int
,
3
,
3
,
t_real_sg
,
QGenericMatrix
>
;
using
t_mat44_sg
=
tl2
::
qmat_adapter
<
int
,
4
,
4
,
t_real_sg
,
QGenericMatrix
>
;
class
SgBrowserDlg
:
public
QDialog
,
Ui
::
SgBrowserDlg
...
...
tools/magstructfact/CMakeLists.txt
View file @
75626e5f
...
...
@@ -16,8 +16,8 @@ find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL)
set
(
CMAKE_AUTOUIC TRUE
)
set
(
CMAKE_AUTOMOC TRUE
)
set
(
CMAKE_CXX_STANDARD
17
)
add_definitions
(
-std=c++
17 -fconcepts
)
set
(
CMAKE_CXX_STANDARD
20
)
add_definitions
(
-std=c++
20
)
add_definitions
(
${
Boost_CXX_FLAGS
}
)
include_directories
(
...
...
@@ -32,11 +32,11 @@ if(BUILD_LIB)
add_definitions
(
-DBUILD_LIB
)
add_library
(
magstructfact SHARED
magstructfact.cpp magstructfact.h
../../libs/
_cxx20/
glplot.cpp ../../libs/
_cxx20/
glplot.h
)
../../libs/glplot.cpp ../../libs/glplot.h
)
else
()
add_executable
(
magstructfact
magstructfact.cpp magstructfact.h
../../libs/
_cxx20/
glplot.cpp ../../libs/
_cxx20/
glplot.h
)
../../libs/glplot.cpp ../../libs/glplot.h
)
endif
()
target_link_libraries
(
magstructfact
${
Boost_LIBRARIES
}
)
...
...
tools/magstructfact/magstructfact.cpp
View file @
75626e5f
...
...
@@ -43,8 +43,8 @@ namespace consts = si::constants;
#include "libs/helper.h"
//using namespace
m
;
using
namespace
m
_ops
;
//using namespace
tl2
;
using
namespace
tl2
_ops
;
constexpr
t_real
g_eps
=
1e-6
;
...
...
@@ -536,11 +536,11 @@ MagStructFactDlg::MagStructFactDlg(QWidget* pParent) : QDialog{pParent},
m_dlgPlot
->
setWindowTitle
(
"Unit Cell"
);
m_plot
=
std
::
make_shared
<
GlPlot
>
(
this
);
m_plot
->
GetImpl
()
->
SetLight
(
0
,
m
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
1
,
m
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
0
,
tl2
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
1
,
tl2
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
GetImpl
()
->
SetCoordMax
(
1.
);
m_plot
->
GetImpl
()
->
SetCamBase
(
m
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
m
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
m
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
m_plot
->
GetImpl
()
->
SetCamBase
(
tl2
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
tl2
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
auto
labCoordSys
=
new
QLabel
(
"Coordinate System:"
,
/*m_dlgPlot*/
this
);
...
...
@@ -596,11 +596,11 @@ MagStructFactDlg::MagStructFactDlg(QWidget* pParent) : QDialog{pParent},
m_dlgPlotSC
->
setWindowTitle
(
"Super Cell"
);
m_plotSC
=
std
::
make_shared
<
GlPlot
>
(
this
);
m_plotSC
->
GetImpl
()
->
SetLight
(
0
,
m
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plotSC
->
GetImpl
()
->
SetLight
(
1
,
m
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plotSC
->
GetImpl
()
->
SetLight
(
0
,
tl2
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plotSC
->
GetImpl
()
->
SetLight
(
1
,
tl2
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plotSC
->
GetImpl
()
->
SetCoordMax
(
1.
);
m_plotSC
->
GetImpl
()
->
SetCamBase
(
m
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
m
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
m
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
m_plotSC
->
GetImpl
()
->
SetCamBase
(
tl2
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
tl2
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
auto
labCoordSys
=
new
QLabel
(
"Coordinate System:"
,
/*m_dlgPlotSC*/
this
);
...
...
@@ -802,30 +802,30 @@ void MagStructFactDlg::Sync3DItem(int row)
QColor
col
{
itemCol
->
text
()};
col
.
getRgbF
(
&
r
,
&
g
,
&
b
);
t_mat_gl
matSphere
=
m
::
hom_translation
<
t_mat_gl
>
(
posx
,
posy
,
posz
)
*
m
::
hom_scaling
<
t_mat_gl
>
(
M
*
scale
,
M
*
scale
,
M
*
scale
);
t_mat_gl
matSphere
=
tl2
::
hom_translation
<
t_mat_gl
>
(
posx
,
posy
,
posz
)
*
tl2
::
hom_scaling
<
t_mat_gl
>
(
M
*
scale
,
M
*
scale
,
M
*
scale
);
auto
vecReM
=
m
::
create
<
t_vec_gl
>
({
t_real_gl
(
ReMX
),
t_real_gl
(
ReMY
),
t_real_gl
(
ReMZ
)});
auto
vecImM
=
m
::
create
<
t_vec_gl
>
({
t_real_gl
(
ImMX
),
t_real_gl
(
ImMY
),
t_real_gl
(
ImMZ
)});
auto
normReM
=
m
::
norm
<
t_vec_gl
>
(
vecReM
);
auto
normImM
=
m
::
norm
<
t_vec_gl
>
(
vecImM
);
auto
vecReM
=
tl2
::
create
<
t_vec_gl
>
({
t_real_gl
(
ReMX
),
t_real_gl
(
ReMY
),
t_real_gl
(
ReMZ
)});
auto
vecImM
=
tl2
::
create
<
t_vec_gl
>
({
t_real_gl
(
ImMX
),
t_real_gl
(
ImMY
),
t_real_gl
(
ImMZ
)});
auto
normReM
=
tl2
::
norm
<
t_vec_gl
>
(
vecReM
);
auto
normImM
=
tl2
::
norm
<
t_vec_gl
>
(
vecImM
);
t_mat_gl
matArrowRe
=
GlPlot_impl
::
GetArrowMatrix
(
vecReM
,
// to
1
,
// post-scale
m
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
m
::
create
<
t_vec_gl
>
({
0
,
0
,
1
}),
// from
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
1
}),
// from
M
*
scale
,
// pre-scale
m
::
create
<
t_vec_gl
>
({
posx
,
posy
,
posz
})
// pre-translate
tl2
::
create
<
t_vec_gl
>
({
posx
,
posy
,
posz
})
// pre-translate
);
t_mat_gl
matArrowIm
=
GlPlot_impl
::
GetArrowMatrix
(
vecImM
,
// to
1
,
// post-scale
m
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
m
::
create
<
t_vec_gl
>
({
0
,
0
,
1
}),
// from
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
1
}),
// from
M
*
scale
,
// pre-scale
m
::
create
<
t_vec_gl
>
({
posx
,
posy
,
posz
})
// pre-translate
tl2
::
create
<
t_vec_gl
>
({
posx
,
posy
,
posz
})
// pre-translate
);
m_plot
->
GetImpl
()
->
SetObjectMatrix
(
objSphere
,
matSphere
);
...
...
@@ -835,8 +835,8 @@ void MagStructFactDlg::Sync3DItem(int row)
m_plot
->
GetImpl
()
->
SetObjectCol
(
objSphere
,
r
,
g
,
b
,
1
);
m_plot
->
GetImpl
()
->
SetObjectCol
(
objArrowRe
,
r
,
g
,
b
,
1
);
m_plot
->
GetImpl
()
->
SetObjectCol
(
objArrowIm
,
1.
-
r
,
1.
-
g
,
1.
-
b
,
1
);
m_plot
->
GetImpl
()
->
SetObjectVisible
(
objArrowRe
,
!
m
::
equals
<
t_real_gl
>
(
normReM
,
0
,
g_eps
));
m_plot
->
GetImpl
()
->
SetObjectVisible
(
objArrowIm
,
!
m
::
equals
<
t_real_gl
>
(
normImM
,
0
,
g_eps
));
m_plot
->
GetImpl
()
->
SetObjectVisible
(
objArrowRe
,
!
tl2
::
equals
<
t_real_gl
>
(
normReM
,
0
,
g_eps
));
m_plot
->
GetImpl
()
->
SetObjectVisible
(
objArrowIm
,
!
tl2
::
equals
<
t_real_gl
>
(
normImM
,
0
,
g_eps
));
m_plot
->
update
();
}
...
...
@@ -1509,8 +1509,8 @@ void MagStructFactDlg::GenerateFromSG()
std
::
string
name
=
m_nuclei
->
item
(
row
,
COL_NAME
)
->
text
().
toStdString
();
std
::
string
col
=
m_nuclei
->
item
(
row
,
COL_COL
)
->
text
().
toStdString
();
t_vec
nucl
=
m
::
create
<
t_vec
>
({
x
,
y
,
z
,
1
});
auto
newnuclei
=
m
::
apply_ops_hom
<
t_vec
,
t_mat
,
t_real
>
(
nucl
,
ops
,
g_eps
);
t_vec
nucl
=
tl2
::
create
<
t_vec
>
({
x
,
y
,
z
,
1
});
auto
newnuclei
=
tl2
::
apply_ops_hom
<
t_vec
,
t_mat
,
t_real
>
(
nucl
,
ops
,
g_eps
);
for
(
const
auto
&
newnucl
:
newnuclei
)
{
...
...
@@ -1606,19 +1606,19 @@ void MagStructFactDlg::CalcB(bool bFullRecalc)
std
::
istringstream
{
m_editBeta
->
text
().
toStdString
()}
>>
beta
;
std
::
istringstream
{
m_editGamma
->
text
().
toStdString
()}
>>
gamma
;
m_crystB
=
m
::
B_matrix
<
t_mat
>
(
a
,
b
,
c
,
alpha
/
180.
*
m
::
pi
<
t_real
>
,
beta
/
180.
*
m
::
pi
<
t_real
>
,
gamma
/
180.
*
m
::
pi
<
t_real
>
);
m_crystB
=
tl2
::
B_matrix
<
t_mat
>
(
a
,
b
,
c
,
alpha
/
180.
*
tl2
::
pi
<
t_real
>
,
beta
/
180.
*
tl2
::
pi
<
t_real
>
,
gamma
/
180.
*
tl2
::
pi
<
t_real
>
);
bool
ok
=
true
;
std
::
tie
(
m_crystA
,
ok
)
=
m
::
inv
(
m_crystB
);
std
::
tie
(
m_crystA
,
ok
)
=
tl2
::
inv
(
m_crystB
);
if
(
!
ok
)
{
m_crystA
=
m
::
unit
<
t_mat
>
();
m_crystA
=
tl2
::
unit
<
t_mat
>
();
std
::
cerr
<<
"Error: Cannot invert B matrix."
<<
std
::
endl
;
}
else
{
m_crystA
*=
t_real_gl
(
2
)
*
m
::
pi
<
t_real_gl
>
;
m_crystA
*=
t_real_gl
(
2
)
*
tl2
::
pi
<
t_real_gl
>
;
}
if
(
m_plot
)
...
...
@@ -1665,7 +1665,7 @@ void MagStructFactDlg::Calc()
std
::
istringstream
{
m_propvecs
->
item
(
row
,
PROP_COL_Z
)
->
text
().
toStdString
()}
>>
z
;
std
::
istringstream
{
m_propvecs
->
item
(
row
,
PROP_COL_CONJ
)
->
text
().
toStdString
()}
>>
iConj
;
propvecs
.
emplace_back
(
m
::
create
<
t_vec
>
({
x
,
y
,
z
}));
propvecs
.
emplace_back
(
tl2
::
create
<
t_vec
>
({
x
,
y
,
z
}));
conjFCs
.
push_back
(
iConj
!=
0
);
}
...
...
@@ -1682,7 +1682,7 @@ void MagStructFactDlg::Calc()
bool
foundQ
=
false
;
for
(
auto
&
line
:
powderlines
)
{
if
(
m
::
equals
<
t_real
>
(
line
.
Q
,
Q
,
g_eps
))
if
(
tl2
::
equals
<
t_real
>
(
line
.
Q
,
Q
,
g_eps
))
{
line
.
I
+=
I
;
line
.
peaks
+=
ostrPeak
.
str
();
...
...
@@ -1714,8 +1714,8 @@ void MagStructFactDlg::Calc()
for
(
const
auto
&
nucl
:
GetNuclei
())
{
pos
.
emplace_back
(
m
::
create
<
t_vec
>
({
nucl
.
pos
[
0
],
nucl
.
pos
[
1
],
nucl
.
pos
[
2
]
}));
Ms
.
emplace_back
(
nucl
.
MAbs
*
m
::
create
<
t_vec_cplx
>
({
pos
.
emplace_back
(
tl2
::
create
<
t_vec
>
({
nucl
.
pos
[
0
],
nucl
.
pos
[
1
],
nucl
.
pos
[
2
]
}));
Ms
.
emplace_back
(
nucl
.
MAbs
*
tl2
::
create
<
t_vec_cplx
>
({
t_cplx
{
nucl
.
ReM
[
0
],
nucl
.
ImM
[
0
]},
t_cplx
{
nucl
.
ReM
[
1
],
nucl
.
ImM
[
1
]},
t_cplx
{
nucl
.
ReM
[
2
],
nucl
.
ImM
[
2
]}
}));
...
...
@@ -1760,28 +1760,28 @@ void MagStructFactDlg::Calc()
{
for
(
const
auto
&
prop
:
propvecs
)
{
auto
Q
=
m
::
create
<
t_vec
>
({
h
,
k
,
l
})
+
prop
;
auto
Q
=
tl2
::
create
<
t_vec
>
({
h
,
k
,
l
})
+
prop
;
auto
Q_invA
=
m_crystB
*
Q
;
auto
Qabs_invA
=
m
::
norm
(
Q_invA
);
auto
Qabs_invA
=
tl2
::
norm
(
Q_invA
);
// magnetic structure factor
auto
Fm
=
p
*
m
::
structure_factor
<
t_vec
,
t_vec_cplx
>
(
Ms
,
pos
,
Q
,
nullptr
);
auto
Fm
=
p
*
tl2
::
structure_factor
<
t_vec
,
t_vec_cplx
>
(
Ms
,
pos
,
Q
,
nullptr
);
bool
Fm_is_zero
=
1
;
for
(
auto
&
comp
:
Fm
)
{
if
(
m
::
equals
<
t_real
>
(
comp
.
real
(),
t_real
(
0
),
g_eps
))
comp
.
real
(
0.
);
else
Fm_is_zero
=
0
;
if
(
m
::
equals
<
t_real
>
(
comp
.
imag
(),
t_real
(
0
),
g_eps
))
comp
.
imag
(
0.
);
else
Fm_is_zero
=
0
;
if
(
tl2
::
equals
<
t_real
>
(
comp
.
real
(),
t_real
(
0
),
g_eps
))
comp
.
real
(
0.
);
else
Fm_is_zero
=
0
;
if
(
tl2
::
equals
<
t_real
>
(
comp
.
imag
(),
t_real
(
0
),
g_eps
))
comp
.
imag
(
0.
);
else
Fm_is_zero
=
0
;
}
if
(
Fm
.
size
()
==
0
)
Fm
=
m
::
zero
<
t_vec_cplx
>
(
3
);
Fm
=
tl2
::
zero
<
t_vec_cplx
>
(
3
);
// neutron scattering: orthogonal projection onto plane with normal Q.
auto
Fm_perp
=
m
::
ortho_project
<
t_vec_cplx
>
(
Fm
,
m
::
create
<
t_vec_cplx
>
({
Q
[
0
],
Q
[
1
],
Q
[
2
]}),
false
);
auto
Fm_perp
=
tl2
::
ortho_project
<
t_vec_cplx
>
(
Fm
,
tl2
::
create
<
t_vec_cplx
>
({
Q
[
0
],
Q
[
1
],
Q
[
2
]}),
false
);
for
(
auto
&
comp
:
Fm_perp
)
{
if
(
m
::
equals
<
t_real
>
(
comp
.
real
(),
t_real
(
0
),
g_eps
))
comp
.
real
(
0.
);
if
(
m
::
equals
<
t_real
>
(
comp
.
imag
(),
t_real
(
0
),
g_eps
))
comp
.
imag
(
0.
);
if
(
tl2
::
equals
<
t_real
>
(
comp
.
real
(),
t_real
(
0
),
g_eps
))
comp
.
real
(
0.
);
if
(
tl2
::
equals
<
t_real
>
(
comp
.
imag
(),
t_real
(
0
),
g_eps
))
comp
.
imag
(
0.
);
}
t_real
I
=
(
std
::
conj
(
Fm
[
0
])
*
Fm
[
0
]
+
...
...
@@ -1877,7 +1877,7 @@ void MagStructFactDlg::Calc()
<<
std
::
setw
(
g_prec
*
1.2
)
<<
std
::
right
<<
"sc_z"
<<
"
\n
"
;
//std::vector<t_vec_cplx> moments;
auto
vecCentring
=
m
::
create
<
t_vec
>
({
0
,
0
,
0
});
auto
vecCentring
=
tl2
::
create
<
t_vec
>
({
0
,
0
,
0
});
for
(
t_real
sc_x
=-
maxSCx
;
sc_x
<=
maxSCx
;
++
sc_x
)
{
...
...
@@ -1885,7 +1885,7 @@ void MagStructFactDlg::Calc()
{
for
(
t_real
sc_z
=-
maxSCz
;
sc_z
<=
maxSCz
;
++
sc_z
)
{
auto
vecCellCentre
=
m
::
create
<
t_vec
>
({
sc_x
,
sc_y
,
sc_z
})
+
vecCentring
;
auto
vecCellCentre
=
tl2
::
create
<
t_vec
>
({
sc_x
,
sc_y
,
sc_z
})
+
vecCentring
;
for
(
std
::
size_t
nuclidx
=
0
;
nuclidx
<
Ms
.
size
();
++
nuclidx
)
{
...
...
@@ -1895,9 +1895,9 @@ void MagStructFactDlg::Calc()
auto
thepos
=
pos
[
nuclidx
]
+
vecCellCentre
;
auto
scale
=
scales
[
nuclidx
];
auto
posGL
=
m
::
convert
<
t_vec_gl
>
(
thepos
);
auto
moment
=
m
::
create
<
t_vec_cplx
>
({
0
,
0
,
0
});
auto
fourier_conj
=
m
::
conj
(
fourier
);
auto
posGL
=
tl2
::
convert
<
t_vec_gl
>
(
thepos
);
auto
moment
=
tl2
::
create
<
t_vec_cplx
>
({
0
,
0
,
0
});
auto
fourier_conj
=
tl2
::
conj
(
fourier
);
qreal
r
=
1
,
g
=
1
,
b
=
1
;
QColor
col
{
colstr
.
c_str
()};
...
...
@@ -1907,13 +1907,13 @@ void MagStructFactDlg::Calc()
{
const
auto
&
propvec
=
propvecs
[
propidx
];
auto
*
pfourier
=
conjFCs
[
propidx
]
?
&
fourier_conj
:
&
fourier
;
moment
+=
*
pfourier
*
std
::
exp
(
t_cplx
{
0
,
1
}
*
m
::
pi
<
t_real
>*
t_real
{
2
}
*
m
::
inner
<
t_vec
>
(
propvec
,
vecCellCentre
));
moment
+=
*
pfourier
*
std
::
exp
(
t_cplx
{
0
,
1
}
*
tl2
::
pi
<
t_real
>*
t_real
{
2
}
*
tl2
::
inner
<
t_vec
>
(
propvec
,
vecCellCentre
));
}
for
(
auto
&
comp
:
moment
)
{
if
(
m
::
equals
<
t_real
>
(
comp
.
real
(),
t_real
(
0
),
g_eps
))
comp
.
real
(
0.
);
if
(
m
::
equals
<
t_real
>
(
comp
.
imag
(),
t_real
(
0
),
g_eps
))
comp
.
imag
(
0.
);
if
(
tl2
::
equals
<
t_real
>
(
comp
.
real
(),
t_real
(
0
),
g_eps
))
comp
.
real
(
0.
);
if
(
tl2
::
equals
<
t_real
>
(
comp
.
imag
(),
t_real
(
0
),
g_eps
))
comp
.
imag
(
0.
);
}
...
...
@@ -1923,18 +1923,18 @@ void MagStructFactDlg::Calc()
auto
objArrowRe
=
m_plotSC
->
GetImpl
()
->
AddLinkedObject
(
m_arrowSC
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
auto
objArrowIm
=
m_plotSC
->
GetImpl
()
->
AddLinkedObject
(
m_arrowSC
,
0
,
0
,
0
,
1
,
1
,
1
,
1
);
auto
[
_vecReM
,
_vecImM
]
=
m
::
split_cplx
<
t_cplx
>
(
moment
);
auto
vecReM
=
m
::
convert
<
t_vec_gl
>
(
_vecReM
);
auto
vecImM
=
m
::
convert
<
t_vec_gl
>
(
_vecImM
);
auto
[
_vecReM
,
_vecImM
]
=
tl2
::
split_cplx
<
t_cplx
>
(
moment
);
auto
vecReM
=
tl2
::
convert
<
t_vec_gl
>
(
_vecReM
);
auto
vecImM
=
tl2
::
convert
<
t_vec_gl
>
(
_vecImM
);
auto
normReM
=
m
::
norm
<
t_vec_gl
>
(
vecReM
);
auto
normImM
=
m
::
norm
<
t_vec_gl
>
(
vecImM
);
auto
normReM
=
tl2
::
norm
<
t_vec_gl
>
(
vecReM
);
auto
normImM
=
tl2
::
norm
<
t_vec_gl
>
(
vecImM
);
t_mat_gl
matArrowRe
=
GlPlot_impl
::
GetArrowMatrix
(
vecReM
,
// to
1
,
// post-scale
m
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
m
::
create
<
t_vec_gl
>
({
0
,
0
,
1
}),
// from
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
1
}),
// from
normReM
*
scale
,
// pre-scale
posGL
// pre-translate
);
...
...
@@ -1942,8 +1942,8 @@ void MagStructFactDlg::Calc()
t_mat_gl
matArrowIm
=
GlPlot_impl
::
GetArrowMatrix
(
vecImM
,
// to
1
,
// post-scale
m
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
m
::
create
<
t_vec_gl
>
({
0
,
0
,
1
}),
// from
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
0
}),
// post-translate
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
1
}),
// from
normImM
*
scale
,
// pre-scale
posGL
// pre-translate
);
...
...
@@ -1964,8 +1964,8 @@ void MagStructFactDlg::Calc()
//m_plotSC->GetImpl()->SetObjectLabel(objArrowIm, name + " (imag)");
m_plotSC
->
GetImpl
()
->
SetObjectDataString
(
objArrowRe
,
name
+
" (real); "
+
ostrMom
.
str
());
m_plotSC
->
GetImpl
()
->
SetObjectDataString
(
objArrowIm
,
name
+
" (imag); "
+
ostrMom
.
str
());
m_plotSC
->
GetImpl
()
->
SetObjectVisible
(
objArrowRe
,
!
m
::
equals
<
t_real_gl
>
(
normReM
,
0
,
g_eps
));
m_plotSC
->
GetImpl
()
->
SetObjectVisible
(
objArrowIm
,
!
m
::
equals
<
t_real_gl
>
(
normImM
,
0
,
g_eps
));
m_plotSC
->
GetImpl
()
->
SetObjectVisible
(
objArrowRe
,
!
tl2
::
equals
<
t_real_gl
>
(
normReM
,
0
,
g_eps
));
m_plotSC
->
GetImpl
()
->
SetObjectVisible
(
objArrowIm
,
!
tl2
::
equals
<
t_real_gl
>
(
normImM
,
0
,
g_eps
));
m_3dobjsSC
.
push_back
(
objArrowRe
);
m_3dobjsSC
.
push_back
(
objArrowIm
);
...
...
@@ -2027,7 +2027,7 @@ void MagStructFactDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objI
auto
*
itemY
=
m_nuclei
->
item
(
row
,
COL_Y
);
auto
*
itemZ
=
m_nuclei
->
item
(
row
,
COL_Z
);
t_vec
r
=
m
::
create
<
t_vec
>
({
0
,
0
,
0
});
t_vec
r
=
tl2
::
create
<
t_vec
>
({
0
,
0
,
0
});
std
::
istringstream
{
itemX
->
text
().
toStdString
()}
>>
r
[
0
];
std
::
istringstream
{
itemY
->
text
().
toStdString
()}
>>
r
[
1
];
std
::
istringstream
{
itemZ
->
text
().
toStdString
()}
>>
r
[
2
];
...
...
tools/magstructfact/magstructfact.h
View file @
75626e5f
...
...
@@ -26,7 +26,7 @@
#include <complex>
#include "libs/glplot.h"
#include "libs/math
_algos
.h"
#include "libs/math
20
.h"
#include "../structfact/numerictablewidgetitem.h"
...
...
@@ -35,8 +35,8 @@ using t_real = double;
using
t_cplx
=
std
::
complex
<
t_real
>
;
using
t_vec
=
std
::
vector
<
t_real
>
;
using
t_vec_cplx
=
std
::
vector
<
t_cplx
>
;
using
t_mat
=
m
::
mat
<
t_real
,
std
::
vector
>
;
using
t_mat_cplx
=
m
::
mat
<
t_cplx
,
std
::
vector
>
;
using
t_mat
=
tl2
::
mat
<
t_real
,
std
::
vector
>
;
using
t_mat_cplx
=
tl2
::
mat
<
t_cplx
,
std
::
vector
>
;
struct
NuclPos
...
...
@@ -102,8 +102,8 @@ protected:
QCheckBox
*
m_RemoveZeroes
=
nullptr
;
QSpinBox
*
m_maxSC
[
3
]
=
{
nullptr
,
nullptr
,
nullptr
};
t_mat
m_crystA
=
m
::
unit
<
t_mat
>
(
3
);
t_mat
m_crystB
=
m
::
unit
<
t_mat
>
(
3
);
t_mat
m_crystA
=
tl2
::
unit
<
t_mat
>
(
3
);
t_mat
m_crystB
=
tl2
::
unit
<
t_mat
>
(
3
);
protected:
// general table operations
...
...
tools/main/CMakeLists.txt
View file @
75626e5f
...
...
@@ -15,8 +15,8 @@ if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
endif
()
set
(
CMAKE_CXX_STANDARD
17
)
add_definitions
(
-std=c++
17
)
set
(
CMAKE_CXX_STANDARD
20
)
add_definitions
(
-std=c++
20
)
...
...
tools/main/data.cpp
View file @
75626e5f
...
...
@@ -8,7 +8,7 @@
#include "data.h"
#include "globals.h"
#include "libs/instr.h"
#include "libs/mat.h"
#include "libs/mat
h20
.h"
#include "libs/algos.h"
...
...
@@ -102,7 +102,7 @@ std::tuple<bool, Dataset> Dataset::convert_instr_file(const char* pcFile)
std
::
transform
(
thedat
.
begin
(),
thedat
.
end
(),
std
::
back_inserter
(
theerr
),
[](
t_real
y
)
->
t_real
{
if
(
tl2
::
float_
equal
<
t_real
>
(
y
,
0
))
if
(
tl2
::
equal
s
<
t_real
>
(
y
,
0
))
return
1
;
return
std
::
sqrt
(
y
);
});
...
...
@@ -119,7 +119,7 @@ std::tuple<bool, Dataset> Dataset::convert_instr_file(const char* pcFile)
std
::
transform
(
thedat
.
begin
(),
thedat
.
end
(),
std
::
back_inserter
(
theerr
),
[](
t_real
y
)
->
t_real
{
if
(
tl2
::
float_
equal
<
t_real
>
(
y
,
0
))
if
(
tl2
::
equal
s
<
t_real
>
(
y
,
0
))
return
1
;
return
std
::
sqrt
(
y
);
});
...
...
@@ -154,7 +154,7 @@ Data Data::add_pointwise(const Data& dat1, const Data& dat2)
{
for
(
std
::
size_t
i
=
0
;
i
<
dat2
.
m_x
.
size
();
++
i
)
{
if
(
!
tl2
::
vec_
equal
(
dat1
.
m_x
[
i
],
dat2
.
m_x
[
i
],
eps
))
if
(
!
tl2
::
equal
s
(
dat1
.
m_x
[
i
],
dat2
.
m_x
[
i
],
eps
))
{
compatible
=
false
;
break
;
...
...
tools/moldyn/CMakeLists.txt
View file @
75626e5f
...
...
@@ -21,8 +21,8 @@ find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL)
set
(
CMAKE_AUTOUIC TRUE
)
set
(
CMAKE_AUTOMOC TRUE
)
set
(
CMAKE_CXX_STANDARD
17
)
add_definitions
(
-std=c++2
a -fconcepts
)
set
(
CMAKE_CXX_STANDARD
20
)
add_definitions
(
-std=c++2
0
)
add_definitions
(
${
Boost_CXX_FLAGS
}
)
add_definitions
(
-DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_ERROR_CODE_HEADER_ONLY
)
add_definitions
(
-D_GL_MAJ_VER=3 -D_GL_MIN_VER=2
)
...
...
@@ -36,7 +36,7 @@ include_directories(
add_executable
(
moldyn
moldyn.cpp moldyn.h
../../libs/
_cxx20/
glplot.cpp ../../libs/
_cxx20/
glplot.h
)
../../libs/glplot.cpp ../../libs/glplot.h
)
target_link_libraries
(
moldyn
${
Boost_LIBRARIES
}
)
qt5_use_modules
(
moldyn Core Gui Widgets OpenGL
)
tools/moldyn/moldyn.cpp
View file @
75626e5f
...
...
@@ -22,7 +22,7 @@
#include "libs/algos.h"
#include "libs/helper.h"
using
namespace
m
_ops
;
using
namespace
tl2
_ops
;
constexpr
t_real
g_eps
=
1e-6
;
constexpr
int
g_prec
=
6
;
...
...
@@ -217,11 +217,11 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
m_plot
->
setSizePolicy
(
QSizePolicy
{
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
});
m_plot
->
GetImpl
()
->
EnablePicker
(
1
);
m_plot
->
GetImpl
()
->
SetLight
(
0
,
m
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
1
,
m
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
0
,
tl2
::
create
<
t_vec3_gl
>
({
5
,
5
,
5
}));
m_plot
->
GetImpl
()
->
SetLight
(
1
,
tl2
::
create
<
t_vec3_gl
>
({
-
5
,
-
5
,
-
5
}));
m_plot
->
GetImpl
()
->
SetCoordMax
(
1.
);
m_plot
->
GetImpl
()
->
SetCamBase
(
m
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
m
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
m
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
m_plot
->
GetImpl
()
->
SetCamBase
(
tl2
::
create
<
t_mat_gl
>
({
1
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
-
1
,
0
,
-
1.5
,
0
,
0
,
0
,
1
}),
tl2
::
create
<
t_vec_gl
>
({
1
,
0
,
0
,
0
}),
tl2
::
create
<
t_vec_gl
>
({
0
,
0
,
1
,
0
}));
connect
(
m_plot
,
&
GlPlot
::
AfterGLInitialisation
,
this
,
&
MolDynDlg
::
AfterGLInitialisation
);
connect
(
m_plot
,
&
GlPlot
::
GLInitialisationFailed
,
this
,
&
MolDynDlg
::
GLInitialisationFailed
);
...
...
@@ -318,8 +318,10 @@ void MolDynDlg::Change3DItem(std::size_t obj, const t_vec *vec, const t_vec *col
{
if
(
vec
)
{
t_mat_gl
mat
=
m
::
hom_translation
<
t_mat_gl
>
((
*
vec
)[
0
],
(
*
vec
)[
1
],
(
*
vec
)[
2
]);
if
(
scale
)
mat
*=
m
::
hom_scaling
<
t_mat_gl
>
(
*
scale
,
*
scale
,
*
scale
);
t_mat_gl
mat
=
tl2
::
hom_translation
<
t_mat_gl
>
(
t_real_gl
((
*
vec
)[
0
]),
t_real_gl
((
*
vec
)[
1
]),
t_real_gl
((
*
vec
)[
2
]));
if
(
scale
)
mat
*=
tl2
::
hom_scaling
<
t_mat_gl
>
(
t_real_gl
(
*
scale
),
t_real_gl
(
*
scale
),
t_real_gl
(
*
scale
));
m_plot
->
GetImpl
()
->
SetObjectMatrix
(
obj
,
mat
);
}
...
...
@@ -423,7 +425,7 @@ void MolDynDlg::CalculateDistanceBetweenAtoms()
for
(
std
::
size_t
frameidx
=
0
;
frameidx
<
m_mol
.
GetFrameCount
();
++
frameidx
)
{
t_real
dist
=
m
::
get_dist_uc
(
m_crystA
,
firstObjCoords
[
frameidx
],
objCoords
[
frameidx
]);
t_real
dist
=
tl2
::
get_dist_uc
(
m_crystA
,
firstObjCoords
[
frameidx
],
objCoords
[
frameidx
]);
ofstr
<<
std
::
left
<<
std
::
setw
(
g_prec
*
1.5
)
<<
frameidx
<<
" "
...