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
1a12c85d
Commit
1a12c85d
authored
5 months ago
by
mkirsz
Browse files
Options
Downloads
Patches
Plain Diff
Added dump to Structure
parent
ee7f5f41
No related branches found
Branches containing commit
No related tags found
1 merge request
!8
Develop
Pipeline
#48250
passed
5 months ago
Stage: build.debug
Stage: run.unit.tests
Stage: build_release
Stage: trigger
Pipeline: Tadah.MLIP
#48252
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/tadah/mlip/structure.h
+6
-0
6 additions, 0 deletions
include/tadah/mlip/structure.h
src/structure.cpp
+49
-0
49 additions, 0 deletions
src/structure.cpp
src/structure_db.cpp
+1
-39
1 addition, 39 deletions
src/structure_db.cpp
with
56 additions
and
39 deletions
include/tadah/mlip/structure.h
+
6
−
0
View file @
1a12c85d
...
...
@@ -271,6 +271,12 @@ struct Structure {
std
::
vector
<
Atom
>::
const_iterator
begin
()
const
;
std
::
vector
<
Atom
>::
const_iterator
end
()
const
;
/** Method to dump class content to a file */
void
dump_to_file
(
std
::
ostream
&
file
,
size_t
prec
=
12
)
const
;
/** Method to dump class content to a file */
void
dump_to_file
(
const
std
::
string
&
filepath
,
size_t
prec
=
12
)
const
;
private
:
const
static
size_t
w
=
15
;
// controls output width
const
static
size_t
p
=
6
;
// controls output precision
...
...
This diff is collapsed.
Click to expand it.
src/structure.cpp
+
49
−
0
View file @
1a12c85d
...
...
@@ -241,3 +241,52 @@ std::vector<Atom>::const_iterator Structure::begin() const {
std
::
vector
<
Atom
>::
const_iterator
Structure
::
end
()
const
{
return
atoms
.
cend
();
}
void
Structure
::
dump_to_file
(
std
::
ostream
&
file
,
size_t
prec
)
const
{
const
int
n
=
5
;
file
<<
label
<<
std
::
endl
;
file
<<
std
::
fixed
<<
std
::
setprecision
(
prec
);
file
<<
eweight
<<
" "
<<
fweight
<<
" "
<<
sweight
<<
std
::
endl
;
file
<<
energy
<<
std
::
endl
;
file
<<
std
::
setw
(
prec
+
n
)
<<
cell
(
0
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
cell
(
0
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
cell
(
0
,
2
)
<<
" "
<<
std
::
endl
<<
std
::
setw
(
prec
+
n
)
<<
cell
(
1
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
cell
(
1
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
cell
(
1
,
2
)
<<
" "
<<
std
::
endl
<<
std
::
setw
(
prec
+
n
)
<<
cell
(
2
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
cell
(
2
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
cell
(
2
,
2
)
<<
" "
<<
std
::
endl
;
file
<<
std
::
setw
(
prec
+
n
)
<<
stress
(
0
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
stress
(
0
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
stress
(
0
,
2
)
<<
" "
<<
std
::
endl
<<
std
::
setw
(
prec
+
n
)
<<
stress
(
1
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
stress
(
1
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
stress
(
1
,
2
)
<<
" "
<<
std
::
endl
<<
std
::
setw
(
prec
+
n
)
<<
stress
(
2
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
stress
(
2
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
stress
(
2
,
2
)
<<
" "
<<
std
::
endl
;
for
(
const
auto
&
a
:
atoms
)
{
file
<<
std
::
setw
(
2
)
<<
a
.
symbol
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
position
[
0
]
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
position
[
1
]
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
position
[
2
]
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
force
[
0
]
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
force
[
1
]
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
force
[
2
]
<<
std
::
endl
;
}
file
<<
std
::
endl
;
}
void
Structure
::
dump_to_file
(
const
std
::
string
&
filepath
,
size_t
prec
)
const
{
std
::
ofstream
file
(
filepath
,
std
::
ios
::
app
);
// Open in append mode
if
(
!
file
.
is_open
())
{
std
::
cerr
<<
"Error: Could not open file for writing: "
<<
filepath
<<
std
::
endl
;
return
;
}
dump_to_file
(
file
,
prec
);
file
.
close
();
}
This diff is collapsed.
Click to expand it.
src/structure_db.cpp
+
1
−
39
View file @
1a12c85d
...
...
@@ -254,46 +254,8 @@ void StructureDB::dump_to_file(const std::string& filepath, size_t prec) const {
std
::
cerr
<<
"Error: Could not open file for writing: "
<<
filepath
<<
std
::
endl
;
return
;
}
const
int
n
=
5
;
for
(
const
auto
&
s
:
structures
)
{
file
<<
s
.
label
<<
std
::
endl
;
file
<<
std
::
fixed
<<
std
::
setprecision
(
prec
);
file
<<
s
.
eweight
<<
" "
<<
s
.
fweight
<<
" "
<<
s
.
sweight
<<
std
::
endl
;
file
<<
s
.
energy
<<
std
::
endl
;
file
<<
std
::
setw
(
prec
+
n
)
<<
s
.
cell
(
0
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
cell
(
0
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
cell
(
0
,
2
)
<<
" "
<<
std
::
endl
<<
std
::
setw
(
prec
+
n
)
<<
s
.
cell
(
1
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
cell
(
1
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
cell
(
1
,
2
)
<<
" "
<<
std
::
endl
<<
std
::
setw
(
prec
+
n
)
<<
s
.
cell
(
2
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
cell
(
2
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
cell
(
2
,
2
)
<<
" "
<<
std
::
endl
;
file
<<
std
::
setw
(
prec
+
n
)
<<
s
.
stress
(
0
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
stress
(
0
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
stress
(
0
,
2
)
<<
" "
<<
std
::
endl
<<
std
::
setw
(
prec
+
n
)
<<
s
.
stress
(
1
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
stress
(
1
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
stress
(
1
,
2
)
<<
" "
<<
std
::
endl
<<
std
::
setw
(
prec
+
n
)
<<
s
.
stress
(
2
,
0
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
stress
(
2
,
1
)
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
s
.
stress
(
2
,
2
)
<<
" "
<<
std
::
endl
;
for
(
const
auto
&
a
:
s
.
atoms
)
{
file
<<
std
::
setw
(
2
)
<<
a
.
symbol
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
position
[
0
]
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
position
[
1
]
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
position
[
2
]
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
force
[
0
]
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
force
[
1
]
<<
" "
<<
std
::
setw
(
prec
+
n
)
<<
a
.
force
[
2
]
<<
std
::
endl
;
}
file
<<
std
::
endl
;
s
.
dump_to_file
(
file
,
prec
);
}
file
.
close
();
}
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