Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mag-core
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
mag-core
Commits
215891e4
Commit
215891e4
authored
Jan 13, 2020
by
Tobias WEBER
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
space group test
parent
8c97e82d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
153 additions
and
4 deletions
+153
-4
tools/cif2xml/CMakeLists.txt
tools/cif2xml/CMakeLists.txt
+7
-2
tools/cif2xml/findsg.cpp
tools/cif2xml/findsg.cpp
+90
-0
tools/moldyn/CMakeLists.txt
tools/moldyn/CMakeLists.txt
+1
-1
tools/structfact/loadcif.h
tools/structfact/loadcif.h
+55
-1
No files found.
tools/cif2xml/CMakeLists.txt
View file @
215891e4
...
...
@@ -13,7 +13,7 @@ set(CMAKE_VERBOSE_MAKEFILE TRUE)
find_package
(
Boost REQUIRED
)
set
(
CMAKE_CXX_STANDARD
20
)
set
(
CMAKE_CXX_STANDARD
17
)
add_definitions
(
-std=c++2a -fconcepts
)
add_definitions
(
${
Boost_CXX_FLAGS
}
)
...
...
@@ -27,6 +27,11 @@ include_directories(
add_executable
(
cif2xml
cif2xml.cpp ../structfact/loadcif.h
)
target_link_libraries
(
cif2xml
target_link_libraries
(
cif2xml
# -static-libstdc++ -static-libgcc
)
add_executable
(
findsg
findsg.cpp ../structfact/loadcif.h
)
target_link_libraries
(
findsg
)
tools/cif2xml/findsg.cpp
0 → 100644
View file @
215891e4
/**
* finds a matching space group
* @author Tobias Weber <tweber@ill.fr>
* @date jan-2020
* @license GPLv3, see 'LICENSE' file
*/
#include "../structfact/loadcif.h"
#include "libs/_cxx20/math_algos.h"
#include <gemmi/version.hpp>
#include <iostream>
#include <memory>
using
t_real
=
double
;
using
t_vec
=
std
::
vector
<
t_real
>
;
using
t_mat
=
m
::
mat
<
t_real
,
std
::
vector
>
;
constexpr
t_real
g_eps
=
1e-6
;
constexpr
int
g_prec
=
6
;
/**
* find matching spacegroup
*/
std
::
vector
<
std
::
tuple
<
int
,
std
::
string
,
std
::
vector
<
t_mat
>>>
find_sgs
(
const
std
::
vector
<
t_vec
>&
vecInit
,
const
std
::
vector
<
t_vec
>&
vecFinal
)
{
return
find_matching_sgs
<
t_vec
,
t_mat
,
t_real
>
(
vecInit
,
vecFinal
);
}
/**
* entry point
*/
int
main
(
int
argc
,
char
**
argv
)
{
// TODO: read input data
// test data
std
::
vector
<
t_vec
>
vecInit
{{
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
}),
}};
std
::
vector
<
t_vec
>
vecFinal
{{
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
}),
}};
std
::
cout
<<
"Full set of positions to match:
\n
"
;
std
::
size_t
ctr
=
1
;
for
(
const
auto
&
pos
:
vecFinal
)
std
::
cout
<<
"
\t
("
<<
ctr
++
<<
") "
<<
pos
<<
"
\n
"
;
std
::
cout
<<
std
::
endl
;
while
(
1
)
{
std
::
cout
<<
"
\n
--------------------------------------------------------------------------------
\n
"
;
std
::
cout
<<
"Base set of positions:
\n
"
;
ctr
=
1
;
for
(
const
auto
&
pos
:
vecInit
)
std
::
cout
<<
"
\t
("
<<
ctr
++
<<
") "
<<
pos
<<
"
\n
"
;
std
::
cout
<<
std
::
endl
;
auto
matchingSGs
=
find_sgs
(
vecInit
,
vecFinal
);
std
::
cout
<<
"Matching space groups:
\n
"
;
ctr
=
1
;
for
(
const
auto
&
sg
:
matchingSGs
)
std
::
cout
<<
"
\t
("
<<
ctr
++
<<
") "
<<
std
::
get
<
1
>
(
sg
)
<<
"
\n
"
;
std
::
cout
<<
"--------------------------------------------------------------------------------
\n
"
;
std
::
cout
<<
std
::
endl
;
vecInit
.
pop_back
();
if
(
vecInit
.
size
()
==
0
)
break
;
}
return
0
;
}
tools/moldyn/CMakeLists.txt
View file @
215891e4
...
...
@@ -21,7 +21,7 @@ find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL)
set
(
CMAKE_AUTOUIC TRUE
)
set
(
CMAKE_AUTOMOC TRUE
)
set
(
CMAKE_CXX_STANDARD
20
)
set
(
CMAKE_CXX_STANDARD
17
)
add_definitions
(
-std=c++2a -fconcepts
)
add_definitions
(
${
Boost_CXX_FLAGS
}
)
add_definitions
(
-DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_ERROR_CODE_HEADER_ONLY
)
...
...
tools/structfact/loadcif.h
View file @
215891e4
...
...
@@ -264,7 +264,11 @@ load_cif(const std::string& filename, t_real eps=1e-6)
* gets space group description strings and symmetry operations
*/
template
<
class
t_mat
,
class
t_real
=
typename
t_mat
::
value_type
>
std
::
vector
<
std
::
tuple
<
int
,
std
::
string
,
std
::
vector
<
t_mat
>>>
std
::
vector
<
std
::
tuple
<
int
,
// sg number
std
::
string
,
// description
std
::
vector
<
t_mat
>
// symops
>>
get_sgs
(
bool
bAddNr
=
true
,
bool
bAddHall
=
true
)
{
std
::
vector
<
std
::
tuple
<
int
,
std
::
string
,
std
::
vector
<
t_mat
>>>
sgs
;
...
...
@@ -302,4 +306,54 @@ get_sgs(bool bAddNr=true, bool bAddHall=true)
}
/**
* finds all space groups which transform the initial positions into the final ones
*/
template
<
class
t_vec
,
class
t_mat
,
class
t_real
=
typename
t_mat
::
value_type
>
std
::
vector
<
std
::
tuple
<
int
,
// sg number
std
::
string
,
// description
std
::
vector
<
t_mat
>
// symops
>>
find_matching_sgs
(
const
std
::
vector
<
t_vec
>&
posInit
,
const
std
::
vector
<
t_vec
>&
_posFinal
,
t_real
eps
=
1e-6
)
{
std
::
vector
<
t_vec
>
posFinal
=
m
::
keep_atoms_in_uc
<
t_vec
,
t_real
>
(
_posFinal
);
std
::
vector
<
std
::
tuple
<
int
,
std
::
string
,
std
::
vector
<
t_mat
>>>
matchingSGs
;
auto
sgs
=
get_sgs
<
t_mat
,
t_real
>
();
// iterate spacegroups
for
(
const
auto
&
[
sgNum
,
sgName
,
sgOps
]
:
sgs
)
{
// generate symmetry-equivalent positions
std
::
vector
<
t_vec
>
generatedpos
;
for
(
const
t_vec
&
pos
:
posInit
)
{
std
::
vector
<
t_vec
>
newpos
=
m
::
apply_ops_hom
<
t_vec
,
t_mat
,
t_real
>
(
pos
,
sgOps
,
eps
);
generatedpos
.
insert
(
generatedpos
.
end
(),
newpos
.
begin
(),
newpos
.
end
());
}
//for(const auto& thepos : generatedpos)
// std::cout << thepos << std::endl;
// filter multiple occupancies in generatedpos
generatedpos
=
m
::
remove_duplicates
<
t_vec
>
(
generatedpos
,
eps
);
// no match
if
(
!
m
::
equals_all
<
t_vec
>
(
generatedpos
,
posFinal
,
eps
,
3
))
continue
;
matchingSGs
.
emplace_back
(
std
::
make_tuple
(
sgNum
,
sgName
,
sgOps
));
}
return
matchingSGs
;
}
#endif
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