Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MLIP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tadah
MLIP
Commits
00fe58b5
Commit
00fe58b5
authored
3 months ago
by
mkirsz
Browse files
Options
Downloads
Patches
Plain Diff
Helper methods for comparison
parent
dfa76e78
No related branches found
Branches containing commit
No related tags found
1 merge request
!11
Helper methods for comparison
Pipeline
#48499
failed
3 months ago
Stage: build.debug
Stage: run.unit.tests
Stage: build_release
Stage: trigger
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/tadah/mlip/atom.h
+6
-0
6 additions, 0 deletions
include/tadah/mlip/atom.h
include/tadah/mlip/structure.h
+14
-1
14 additions, 1 deletion
include/tadah/mlip/structure.h
src/atom.cpp
+21
-15
21 additions, 15 deletions
src/atom.cpp
src/structure.cpp
+17
-0
17 additions, 0 deletions
src/structure.cpp
with
58 additions
and
16 deletions
include/tadah/mlip/atom.h
+
6
−
0
View file @
00fe58b5
...
@@ -79,5 +79,11 @@ struct Atom: public Element {
...
@@ -79,5 +79,11 @@ struct Atom: public Element {
*/
*/
bool
operator
==
(
const
Atom
&
)
const
;
bool
operator
==
(
const
Atom
&
)
const
;
/** Return true if both atoms have the same position and type.
*
* This method compares chemical type and position only
*/
bool
is_the_same
(
const
Atom
&
,
double
thr
=
1e-6
)
const
;
};
};
#endif
#endif
This diff is collapsed.
Click to expand it.
include/tadah/mlip/structure.h
+
14
−
1
View file @
00fe58b5
...
@@ -251,10 +251,23 @@ struct Structure {
...
@@ -251,10 +251,23 @@ struct Structure {
* This operator compares cell, stress tensor, number of atoms,
* This operator compares cell, stress tensor, number of atoms,
* eweight, fweight and sweight, all atom positions and forces.
* eweight, fweight and sweight, all atom positions and forces.
*
*
* It does NOT compare labels/
* Assumes atoms have the same order.
*
* It does NOT compare labels.
*/
*/
bool
operator
==
(
const
Structure
&
st
)
const
;
bool
operator
==
(
const
Structure
&
st
)
const
;
/** Return true if both structures are the same.
*
* This method compares cell vectors, number of atoms,
* species and atomic coordinates
*
* Order ot atoms does not matter.
*
* It does NOT compare energies, stresses, forces and labels.
*/
bool
is_the_same
(
const
Structure
&
st
,
double
thr
=
1e-6
)
const
;
// move iterator forward to the next structure
// move iterator forward to the next structure
// return number of atoms in the structure
// return number of atoms in the structure
// return 0 if there is no more structures
// return 0 if there is no more structures
...
...
This diff is collapsed.
Click to expand it.
src/atom.cpp
+
21
−
15
View file @
00fe58b5
...
@@ -5,25 +5,31 @@
...
@@ -5,25 +5,31 @@
Atom
::
Atom
()
{}
Atom
::
Atom
()
{}
Atom
::
Atom
(
const
Element
&
element
,
Atom
::
Atom
(
const
Element
&
element
,
const
double
px
,
const
double
py
,
const
double
pz
,
const
double
px
,
const
double
py
,
const
double
pz
,
const
double
fx
,
const
double
fy
,
const
double
fz
)
:
const
double
fx
,
const
double
fy
,
const
double
fz
)
:
Element
(
element
),
Element
(
element
),
position
(
px
,
py
,
pz
),
position
(
px
,
py
,
pz
),
force
(
fx
,
fy
,
fz
)
force
(
fx
,
fy
,
fz
)
{}
{}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Atom
&
atom
)
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Atom
&
atom
)
{
{
os
<<
(
Element
&
)
atom
;
os
<<
(
Element
&
)
atom
;
os
<<
"Coordinates: "
<<
std
::
left
<<
atom
.
position
<<
std
::
endl
;
os
<<
"Coordinates: "
<<
std
::
left
<<
atom
.
position
<<
std
::
endl
;
os
<<
"Force: "
<<
std
::
left
<<
atom
.
force
<<
std
::
endl
;
os
<<
"Force: "
<<
std
::
left
<<
atom
.
force
<<
std
::
endl
;
return
os
;
return
os
;
}
}
bool
Atom
::
operator
==
(
const
Atom
&
a
)
const
{
bool
Atom
::
operator
==
(
const
Atom
&
a
)
const
{
double
EPSILON
=
std
::
numeric_limits
<
double
>::
epsilon
();
double
EPSILON
=
std
::
numeric_limits
<
double
>::
epsilon
();
return
return
position
.
isApprox
(
a
.
position
,
EPSILON
)
position
.
isApprox
(
a
.
position
,
EPSILON
)
&&
force
.
isApprox
(
a
.
force
,
EPSILON
)
&&
force
.
isApprox
(
a
.
force
,
EPSILON
)
&&
Element
::
operator
==
(
a
)
&&
Element
::
operator
==
(
a
)
;
;
}
bool
Atom
::
is_the_same
(
const
Atom
&
a
,
double
thr
)
const
{
return
position
.
isApprox
(
a
.
position
,
thr
)
&&
Element
::
operator
==
(
a
)
;
}
}
This diff is collapsed.
Click to expand it.
src/structure.cpp
+
17
−
0
View file @
00fe58b5
...
@@ -192,6 +192,23 @@ bool Structure::operator==(const Structure& st) const
...
@@ -192,6 +192,23 @@ bool Structure::operator==(const Structure& st) const
}
}
return
result
;
return
result
;
}
}
bool
Structure
::
is_the_same
(
const
Structure
&
st
,
double
thr
)
const
{
bool
result
=
cell
.
isApprox
(
st
.
cell
,
thr
)
&&
natoms
()
==
st
.
natoms
();
if
(
!
result
)
return
result
;
size_t
count
=
0
;;
for
(
size_t
i
=
0
;
i
<
natoms
();
++
i
)
{
for
(
size_t
j
=
i
;
j
<
natoms
();
++
j
)
{
result
=
atoms
[
i
].
is_the_same
(
st
.
atoms
[
j
],
thr
);
if
(
result
)
count
++
;
}
}
return
count
==
natoms
()
?
true
:
false
;
}
int
Structure
::
next_structure
(
std
::
ifstream
&
ifs
)
{
int
Structure
::
next_structure
(
std
::
ifstream
&
ifs
)
{
std
::
string
line
;
std
::
string
line
;
std
::
getline
(
ifs
,
line
);
std
::
getline
(
ifs
,
line
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment