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
1498a80e
Commit
1498a80e
authored
1 month ago
by
mkirsz
Browse files
Options
Downloads
Patches
Plain Diff
Fix to const volume GO CASTEP parser
parent
9a0860d0
No related branches found
No related tags found
No related merge requests found
Pipeline
#51966
passed
1 month ago
Stage: build_debug
Stage: run_unit_tests
Stage: build_release
Stage: trigger
Pipeline: Tadah.MLIP
#51967
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/castep_castep_reader.cpp
+23
-0
23 additions, 0 deletions
src/castep_castep_reader.cpp
with
23 additions
and
0 deletions
src/castep_castep_reader.cpp
+
23
−
0
View file @
1498a80e
...
@@ -44,6 +44,8 @@ void CastepCastepReader::parse_data() {
...
@@ -44,6 +44,8 @@ void CastepCastepReader::parse_data() {
std
::
string
label
;
std
::
string
label
;
size_t
counter
=
0
;
size_t
counter
=
0
;
bool
debug
=
false
;
while
(
std
::
getline
(
stream
,
line
))
{
while
(
std
::
getline
(
stream
,
line
))
{
if
(
line
.
find
(
"type of calculation"
)
!=
std
::
string
::
npos
)
{
if
(
line
.
find
(
"type of calculation"
)
!=
std
::
string
::
npos
)
{
...
@@ -53,6 +55,7 @@ void CastepCastepReader::parse_data() {
...
@@ -53,6 +55,7 @@ void CastepCastepReader::parse_data() {
go_run
=
false
;
go_run
=
false
;
restart
=
false
;
restart
=
false
;
if
(
line
.
find
(
": geometry optimization"
)
!=
std
::
string
::
npos
)
{
if
(
line
.
find
(
": geometry optimization"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"GO run"
<<
std
::
endl
;
go_run
=
true
;
go_run
=
true
;
}
}
if
(
line
.
find
(
": molecular dynamics"
)
!=
std
::
string
::
npos
)
{
if
(
line
.
find
(
": molecular dynamics"
)
!=
std
::
string
::
npos
)
{
...
@@ -63,6 +66,7 @@ void CastepCastepReader::parse_data() {
...
@@ -63,6 +66,7 @@ void CastepCastepReader::parse_data() {
restart
=
true
;
restart
=
true
;
}
}
else
if
(
line
.
find
(
"Unit Cell"
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"Unit Cell"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"Unit Cell"
<<
std
::
endl
;
if
(
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
))
{
if
(
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
))
{
std
::
cerr
<<
"Warning, file"
<<
filename
<<
" line: "
<<
counter
<<
std
::
endl
;
std
::
cerr
<<
"Warning, file"
<<
filename
<<
" line: "
<<
counter
<<
std
::
endl
;
std
::
cerr
<<
"Warning: Unexpected end of data when reading atom information"
<<
std
::
endl
;
std
::
cerr
<<
"Warning: Unexpected end of data when reading atom information"
<<
std
::
endl
;
...
@@ -88,6 +92,7 @@ void CastepCastepReader::parse_data() {
...
@@ -88,6 +92,7 @@ void CastepCastepReader::parse_data() {
if
(
constant_volume
)
label
.
clear
();
if
(
constant_volume
)
label
.
clear
();
constant_volume
=
false
;
constant_volume
=
false
;
if
(
debug
)
std
::
cout
<<
s
.
cell
<<
std
::
endl
;
}
}
else
if
(
line
.
find
(
"Total number of ions in cell"
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"Total number of ions in cell"
)
!=
std
::
string
::
npos
)
{
...
@@ -109,14 +114,17 @@ void CastepCastepReader::parse_data() {
...
@@ -109,14 +114,17 @@ void CastepCastepReader::parse_data() {
std
::
cerr
<<
"Warning, file"
<<
filename
<<
" line: "
<<
counter
<<
std
::
endl
;
std
::
cerr
<<
"Warning, file"
<<
filename
<<
" line: "
<<
counter
<<
std
::
endl
;
std
::
cerr
<<
"Error: Line is too short to extract total number of ions in a cell. Line: "
<<
line
<<
std
::
endl
;
std
::
cerr
<<
"Error: Line is too short to extract total number of ions in a cell. Line: "
<<
line
<<
std
::
endl
;
}
}
if
(
debug
)
std
::
cout
<<
"Number of atoms: "
<<
natoms
<<
std
::
endl
;
}
}
else
if
(
line
.
find
(
"so fixing cell parameters"
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"so fixing cell parameters"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"so fixing cell parameters"
<<
std
::
endl
;
constant_volume
=
true
;
constant_volume
=
true
;
label
=
"CASTEP MD, const. volume: true, step: 0"
;
label
=
"CASTEP MD, const. volume: true, step: 0"
;
}
}
else
if
(
line
.
find
(
"Starting MD iteration"
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"Starting MD iteration"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"Starting MD iteration"
<<
std
::
endl
;
std
::
istringstream
iss
(
line
);
std
::
istringstream
iss
(
line
);
std
::
string
step
;
std
::
string
step
;
iss
>>
step
>>
step
>>
step
>>
step
;
iss
>>
step
>>
step
>>
step
>>
step
;
...
@@ -127,15 +135,23 @@ void CastepCastepReader::parse_data() {
...
@@ -127,15 +135,23 @@ void CastepCastepReader::parse_data() {
else
if
(
constant_volume
&&
line
.
find
(
"Cell Contents"
)
!=
std
::
string
::
npos
)
{
else
if
(
constant_volume
&&
line
.
find
(
"Cell Contents"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"Cell Contents"
<<
std
::
endl
;
if
(
restart
)
{
if
(
restart
)
{
if
(
debug
)
std
::
cout
<<
"Cell Contents restart"
<<
std
::
endl
;
s
.
atoms
.
clear
();
s
.
atoms
.
clear
();
}
else
{
}
else
{
if
(
debug
)
std
::
cout
<<
"Cell Contents no restart"
<<
std
::
endl
;
if
(
debug
)
std
::
cout
<<
line
<<
std
::
endl
;
s
=
Structure
();
s
=
Structure
();
s
.
cell
=
stdb
.
structures
.
back
().
cell
;
// copy last cell as it is not repeated in castep for const. volume
s
.
cell
=
stdb
.
structures
.
back
().
cell
;
// copy last cell as it is not repeated in castep for const. volume
}
}
}
}
else
if
(
line
.
find
(
"Fractional coordinates of atoms"
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"Fractional coordinates of atoms"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"Fractional coordinates of atoms"
<<
std
::
endl
;
// Ideally st.natoms() should be zero by now. However for constant volum GO this is not the case.
// Therfore we need to clear the atoms vector but we keep the st.cell as it is.
s
.
atoms
.
clear
();
if
(
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
))
{
if
(
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
))
{
std
::
cerr
<<
"Warning, file"
<<
filename
<<
" line: "
<<
counter
<<
std
::
endl
;
std
::
cerr
<<
"Warning, file"
<<
filename
<<
" line: "
<<
counter
<<
std
::
endl
;
std
::
cerr
<<
"Warning: Unexpected end of data when reading atom information"
<<
std
::
endl
;
std
::
cerr
<<
"Warning: Unexpected end of data when reading atom information"
<<
std
::
endl
;
...
@@ -161,9 +177,11 @@ void CastepCastepReader::parse_data() {
...
@@ -161,9 +177,11 @@ void CastepCastepReader::parse_data() {
s
.
add_atom
(
Atom
(
Element
(
type
),
px
,
py
,
pz
,
0
,
0
,
0
));
s
.
add_atom
(
Atom
(
Element
(
type
),
px
,
py
,
pz
,
0
,
0
,
0
));
s
.
atoms
[
i
].
position
=
s
.
cell
*
s
.
atoms
[
i
].
position
;
// convert to abs
s
.
atoms
[
i
].
position
=
s
.
cell
*
s
.
atoms
[
i
].
position
;
// convert to abs
}
}
if
(
debug
)
std
::
cout
<<
"natoms: "
<<
s
.
natoms
()
<<
std
::
endl
;
}
}
else
if
(
line
.
find
(
"Cartesian components (eV/A)"
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"Cartesian components (eV/A)"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"Cartesian components (eV/A)"
<<
std
::
endl
;
if
(
s
.
natoms
()
!=
natoms
)
continue
;
if
(
s
.
natoms
()
!=
natoms
)
continue
;
if
(
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
))
{
if
(
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
))
{
std
::
cerr
<<
"Warning, file"
<<
filename
<<
" line: "
<<
counter
<<
std
::
endl
;
std
::
cerr
<<
"Warning, file"
<<
filename
<<
" line: "
<<
counter
<<
std
::
endl
;
...
@@ -192,6 +210,7 @@ void CastepCastepReader::parse_data() {
...
@@ -192,6 +210,7 @@ void CastepCastepReader::parse_data() {
}
}
else
if
(
line
.
find
(
"Cartesian components (GPa)"
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"Cartesian components (GPa)"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"Cartesian components (GPa)"
<<
std
::
endl
;
if
(
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
))
{
if
(
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
)
||
!
std
::
getline
(
stream
,
line
))
{
std
::
cerr
<<
"Warning, file"
<<
filename
<<
" line: "
<<
counter
<<
std
::
endl
;
std
::
cerr
<<
"Warning, file"
<<
filename
<<
" line: "
<<
counter
<<
std
::
endl
;
std
::
cerr
<<
"Warning: Unexpected end of data when reading stress tensor"
<<
std
::
endl
;
std
::
cerr
<<
"Warning: Unexpected end of data when reading stress tensor"
<<
std
::
endl
;
...
@@ -220,6 +239,7 @@ void CastepCastepReader::parse_data() {
...
@@ -220,6 +239,7 @@ void CastepCastepReader::parse_data() {
// enthalpy= indicates end of iteration for GO
// enthalpy= indicates end of iteration for GO
else
if
(
line
.
find
(
"Final free energy (E-TS)"
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"Final free energy (E-TS)"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"Final free energy (E-TS)"
<<
std
::
endl
;
std
::
istringstream
iss
(
line
);
std
::
istringstream
iss
(
line
);
std
::
string
tmp
;
std
::
string
tmp
;
if
(
!
(
iss
>>
tmp
>>
tmp
>>
tmp
>>
tmp
>>
tmp
>>
s
.
energy
))
{
if
(
!
(
iss
>>
tmp
>>
tmp
>>
tmp
>>
tmp
>>
tmp
>>
s
.
energy
))
{
...
@@ -234,6 +254,7 @@ void CastepCastepReader::parse_data() {
...
@@ -234,6 +254,7 @@ void CastepCastepReader::parse_data() {
}
}
else
if
(
line
.
find
(
"enthalpy="
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"enthalpy="
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"enthalpy="
<<
std
::
endl
;
// GO: the last extracted free energy is correct one!
// GO: the last extracted free energy is correct one!
std
::
istringstream
iss
(
line
);
std
::
istringstream
iss
(
line
);
std
::
string
step
;
std
::
string
step
;
...
@@ -245,6 +266,7 @@ void CastepCastepReader::parse_data() {
...
@@ -245,6 +266,7 @@ void CastepCastepReader::parse_data() {
}
}
else
if
(
line
.
find
(
"Potential Energy:"
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"Potential Energy:"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"Potential Energy:"
<<
std
::
endl
;
std
::
istringstream
iss
(
line
);
std
::
istringstream
iss
(
line
);
std
::
string
tmp
;
std
::
string
tmp
;
if
(
!
(
iss
>>
tmp
>>
tmp
>>
tmp
>>
s
.
energy
))
{
if
(
!
(
iss
>>
tmp
>>
tmp
>>
tmp
>>
s
.
energy
))
{
...
@@ -253,6 +275,7 @@ void CastepCastepReader::parse_data() {
...
@@ -253,6 +275,7 @@ void CastepCastepReader::parse_data() {
}
}
}
}
else
if
(
line
.
find
(
"Temperature:"
)
!=
std
::
string
::
npos
)
{
else
if
(
line
.
find
(
"Temperature:"
)
!=
std
::
string
::
npos
)
{
if
(
debug
)
std
::
cout
<<
"Temperature:"
<<
std
::
endl
;
// MD: end of iteration
// MD: end of iteration
std
::
istringstream
iss
(
line
);
std
::
istringstream
iss
(
line
);
std
::
string
tmp
;
std
::
string
tmp
;
...
...
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