Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
parser-dl-poly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nomad-lab
parser-dl-poly
Commits
ae97cd46
Commit
ae97cd46
authored
Feb 25, 2019
by
Daniel Speckhard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ready for Nomad-Faird
parent
0ad9cb3f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
184 additions
and
157 deletions
+184
-157
.gitignore
.gitignore
+1
-0
dlpolyparser/SimpleDL_POLYParser.py
dlpolyparser/SimpleDL_POLYParser.py
+59
-32
dlpolyparser/__init__.py
dlpolyparser/__init__.py
+15
-0
dlpolyparser/dlPolyParser.py
dlpolyparser/dlPolyParser.py
+76
-38
dlpolyparser/libDlPolyParser.py
dlpolyparser/libDlPolyParser.py
+0
-0
dlpolyparser/libMomo.py
dlpolyparser/libMomo.py
+0
-0
dlpolyparser/setup_paths.py
dlpolyparser/setup_paths.py
+0
-0
setup.py
setup.py
+33
-0
src/main/scala/eu/nomad_lab/parsers/DlPolyParser.scala
src/main/scala/eu/nomad_lab/parsers/DlPolyParser.scala
+0
-57
src/test/scala/eu/nomad_lab/parsers/DlPolyParserSpec.scala
src/test/scala/eu/nomad_lab/parsers/DlPolyParserSpec.scala
+0
-30
No files found.
.gitignore
View file @
ae97cd46
...
@@ -9,6 +9,7 @@ syntax: glob
...
@@ -9,6 +9,7 @@ syntax: glob
*.pyc
*.pyc
*.bk
*.bk
*.swp
*.swp
*.egg-info
.DS_Store
.DS_Store
# eclipse conf file
# eclipse conf file
...
...
parser/parser-dl_poly
/SimpleDL_POLYParser.py
→
dlpolyparser
/SimpleDL_POLYParser.py
View file @
ae97cd46
# Copyright 2016-2018 Carl Poelking, Fawzi Mohamed, Ankit Kariryaa
# Copyright 2016-2018 Carl Poelking, Fawzi Mohamed, Ankit Kariryaa
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
from
__future__
import
print_function
from
__future__
import
print_function
from
builtins
import
range
from
builtins
import
range
from
builtins
import
object
from
builtins
import
object
import
setup_paths
import
numpy
as
np
import
numpy
as
np
import
math
import
math
from
nomadcore.simple_parser
import
mainFunction
from
nomadcore.simple_parser
import
mainFunction
...
@@ -38,7 +37,7 @@ class DL_POLYParserContext(object):
...
@@ -38,7 +37,7 @@ class DL_POLYParserContext(object):
def
onClose_section_system
(
self
,
backend
,
gIndex
,
section
):
def
onClose_section_system
(
self
,
backend
,
gIndex
,
section
):
print
(
"<onClose_section_system>"
)
print
(
"<onClose_section_system>"
)
return
return
def
onClose_dl_poly_section_md_molecule_type
(
self
,
backend
,
gIndex
,
section
):
def
onClose_
x_
dl_poly_section_md_molecule_type
(
self
,
backend
,
gIndex
,
section
):
print
(
"<onClose_molecule_type>"
)
print
(
"<onClose_molecule_type>"
)
return
return
...
@@ -55,7 +54,7 @@ mainFileDescription = SM(name = 'root',
...
@@ -55,7 +54,7 @@ mainFileDescription = SM(name = 'root',
weak
=
True
,
weak
=
True
,
startReStr
=
""
,
startReStr
=
""
,
subMatchers
=
[
subMatchers
=
[
SM
(
name
=
'newRun'
,
SM
(
name
=
'newRun'
,
startReStr
=
r
" \*\* DL_POLY \*\* authors: i.t.todorov & w.smith \** P \**"
,
startReStr
=
r
" \*\* DL_POLY \*\* authors: i.t.todorov & w.smith \** P \**"
,
repeats
=
False
,
repeats
=
False
,
...
@@ -67,26 +66,26 @@ mainFileDescription = SM(name = 'root',
...
@@ -67,26 +66,26 @@ mainFileDescription = SM(name = 'root',
SM
(
name
=
'progHeader'
,
SM
(
name
=
'progHeader'
,
startReStr
=
r
" \*\* DL_POLY \*\* authors: i.t.todorov & w.smith \** P \**"
,
startReStr
=
r
" \*\* DL_POLY \*\* authors: i.t.todorov & w.smith \** P \**"
,
subMatchers
=
[
subMatchers
=
[
SM
(
r
"\s*\*\*\s*\*\* version: (?P<program_version>[0-9a-zA-Z_.]*) / \s* (?P<dl_poly_program_version_date>[\w]*\s*[\w]*)\s*\** O \**"
),
SM
(
r
"\s*\*\*\s*\*\* version: (?P<program_version>[0-9a-zA-Z_.]*) / \s* (?P<
x_
dl_poly_program_version_date>[\w]*\s*[\w]*)\s*\** O \**"
),
SM
(
r
"\s*\** when publishing research data obtained using (?P<program_name>[0-9a-zA-Z_.]*) \**"
),
SM
(
r
"\s*\** when publishing research data obtained using (?P<program_name>[0-9a-zA-Z_.]*) \**"
),
SM
(
r
"\s*\**\s*(?P<dl_poly_system_description>[0-9a-zA-Z_()]*)\s*\**"
)
SM
(
r
"\s*\**\s*(?P<
x_
dl_poly_system_description>[0-9a-zA-Z_()]*)\s*\**"
)
]),
]),
SM
(
name
=
'mdParams'
,
SM
(
name
=
'mdParams'
,
startReStr
=
r
"\s*SIMULATION CONTROL PARAMETERS\s*"
,
startReStr
=
r
"\s*SIMULATION CONTROL PARAMETERS\s*"
,
required
=
True
,
required
=
True
,
sections
=
[
'section_method'
],
sections
=
[
'section_method'
],
subMatchers
=
[
subMatchers
=
[
SM
(
r
"\s*simulation temperature \(K\)\s*(?P<dl_poly_thermostat_temperature>[-+0-9.eEdD]*)\s*"
),
SM
(
r
"\s*simulation temperature \(K\)\s*(?P<
x_
dl_poly_thermostat_temperature>[-+0-9.eEdD]*)\s*"
),
SM
(
r
"\s*equilibration period \(steps\)\s*(?P<dl_poly_step_number_equilibration>[0-9]*)\s*"
),
SM
(
r
"\s*equilibration period \(steps\)\s*(?P<
x_
dl_poly_step_number_equilibration>[0-9]*)\s*"
),
SM
(
r
"\s*selected number of timesteps\s*(?P<dl_poly_step_number>[0-9]*)\s*"
)
SM
(
r
"\s*selected number of timesteps\s*(?P<
x_
dl_poly_step_number>[0-9]*)\s*"
)
]),
]),
# Open system
# Open system
# ... open topology
# ... open topology
# ... ... store <numberofmoleculetypes>
# ... ... store <numberofmoleculetypes>
# ... ... open molecule type id1
# ... ... open molecule type id1
# ... ... open molecule type ...
# ... ... open molecule type ...
SM
(
name
=
'mdSystem'
,
SM
(
name
=
'mdSystem'
,
startReStr
=
r
"\s*SYSTEM SPECIFICATION\s*"
,
startReStr
=
r
"\s*SYSTEM SPECIFICATION\s*"
,
required
=
True
,
required
=
True
,
...
@@ -96,18 +95,18 @@ mainFileDescription = SM(name = 'root',
...
@@ -96,18 +95,18 @@ mainFileDescription = SM(name = 'root',
startReStr
=
r
"\s*number of molecular types\s*[0-9]*\s*"
,
startReStr
=
r
"\s*number of molecular types\s*[0-9]*\s*"
,
required
=
True
,
required
=
True
,
forwardMatch
=
True
,
forwardMatch
=
True
,
sections
=
[
'dl_poly_section_md_topology'
],
sections
=
[
'
x_
dl_poly_section_md_topology'
],
subMatchers
=
[
subMatchers
=
[
SM
(
r
"\s*number of molecular types\s*(?P<dl_poly_md_molecular_types>[0-9]*)"
),
SM
(
r
"\s*number of molecular types\s*(?P<
x_
dl_poly_md_molecular_types>[0-9]*)"
),
SM
(
name
=
'mdTopologyMolecule'
,
SM
(
name
=
'mdTopologyMolecule'
,
startReStr
=
r
"\s*molecular species type\s*[0-9]*\s*"
,
startReStr
=
r
"\s*molecular species type\s*[0-9]*\s*"
,
repeats
=
True
,
repeats
=
True
,
required
=
True
,
required
=
True
,
forwardMatch
=
True
,
forwardMatch
=
True
,
sections
=
[
'dl_poly_section_md_molecule_type'
],
sections
=
[
'
x_
dl_poly_section_md_molecule_type'
],
subMatchers
=
[
subMatchers
=
[
SM
(
r
"\s*molecular species type\s*(?P<dl_poly_md_molecule_type_id>[0-9]*)\s*"
),
SM
(
r
"\s*molecular species type\s*(?P<
x_
dl_poly_md_molecule_type_id>[0-9]*)\s*"
),
SM
(
r
"\s*name of species:\s*(?P<dl_poly_md_molecule_type_name>[\w]* [\w]*)\s*"
)
SM
(
r
"\s*name of species:\s*(?P<
x_
dl_poly_md_molecule_type_name>[\w]* [\w]*)\s*"
)
])
])
])
])
#SM(r"\s*number of molecular types\s*(?P<dl_poly_molecular_types_number>[0-9]*)\s*"),
#SM(r"\s*number of molecular types\s*(?P<dl_poly_molecular_types_number>[0-9]*)\s*"),
...
@@ -118,7 +117,7 @@ mainFileDescription = SM(name = 'root',
...
@@ -118,7 +117,7 @@ mainFileDescription = SM(name = 'root',
#sections = ['dl_poly_section_molecule_types'],
#sections = ['dl_poly_section_molecule_types'],
#subMatchers = [\
#subMatchers = [\
#])
#])
])
])
])
])
])
])
...
@@ -182,11 +181,11 @@ mainFileDescription = SM(name = 'root',
...
@@ -182,11 +181,11 @@ mainFileDescription = SM(name = 'root',
]), # CLOSING section_eigenvalues
]), # CLOSING section_eigenvalues
]), # CLOSING section_eigenvalues_group
]), # CLOSING section_eigenvalues_group
]), # CLOSING section_single_configuration_calculation
]), # CLOSING section_single_configuration_calculation
]), # CLOSING section_system
]), # CLOSING section_system
]), # CLOSING SM newRun
]), # CLOSING SM newRun
...
@@ -196,22 +195,50 @@ mainFileDescription = SM(name = 'root',
...
@@ -196,22 +195,50 @@ mainFileDescription = SM(name = 'root',
# THIS PARSER
# THIS PARSER
parserInfo
=
{
'name'
:
'dl_poly-parser'
,
'version'
:
'0.0'
}
parserInfo
=
{
'name'
:
'dl_poly-parser'
,
'version'
:
'0.0'
}
# LOAD METADATA
#
#
LOAD METADATA
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
"../../../../nomad-meta-info/meta_info/nomad_meta_info/dl_poly.nomadmetainfo.json"
))
#
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../../../../nomad-meta-info/meta_info/nomad_meta_info/dl_poly.nomadmetainfo.json"))
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
#
metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
# CUSTOMIZE CACHING
# CUSTOMIZE CACHING
cachingLevelForMetaName
=
{}
cachingLevelForMetaName
=
{}
import
nomad_meta_info
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
nomad_meta_info
.
__file__
)),
"dl_poly.nomadmetainfo.json"
))
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
class
DlPolyParser
():
""" A proper class envolop for running this parser from within python. """
def
__init__
(
self
,
backend
,
**
kwargs
):
self
.
backend_factory
=
backend
def
parse
(
self
,
mainfile
):
from
unittest.mock
import
patch
logging
.
info
(
'dl-poly parser started'
)
logging
.
getLogger
(
'nomadcore'
).
setLevel
(
logging
.
WARNING
)
backend
=
self
.
backend_factory
(
metaInfoEnv
)
with
patch
.
object
(
sys
,
'argv'
,
[
'<exe>'
,
'--uri'
,
'nmd://uri'
,
mainfile
]):
mainFunction
(
mainFileDescription
=
mainFileDescription
,
metaInfoEnv
=
metaInfoEnv
,
parserInfo
=
parserInfo
,
cachingLevelForMetaName
=
cachingLevelForMetaName
,
superContext
=
DL_POLYParserContext
(),
superBackend
=
backend
,
onClose
=
{},
defaultSectionCachingLevel
=
True
)
return
backend
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
mainFunction
(
mainFileDescription
,
mainFunction
(
mainFileDescription
,
metaInfoEnv
,
metaInfoEnv
,
parserInfo
,
parserInfo
,
superContext
=
DL_POLYParserContext
(),
superContext
=
DL_POLYParserContext
(),
cachingLevelForMetaName
=
cachingLevelForMetaName
,
cachingLevelForMetaName
=
cachingLevelForMetaName
,
onClose
=
{},
onClose
=
{},
defaultSectionCachingLevel
=
False
)
defaultSectionCachingLevel
=
False
)
dlpolyparser/__init__.py
0 → 100644
View file @
ae97cd46
# Copyright 2015-2018 Lauri Himanen, Fawzi Mohamed, Ankit Kariryaa
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
dlpolyparser.dlPolyParser
import
DlPolyParserWrapper
parser/parser-dl_poly
/dlPolyParser.py
→
dlpolyparser
/dlPolyParser.py
View file @
ae97cd46
# Copyright 2016-2018 Carl Poelking, Fawzi Mohamed, Ankit Kariryaa
# Copyright 2016-2018 Carl Poelking, Fawzi Mohamed, Ankit Kariryaa
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -17,30 +17,29 @@ import os
...
@@ -17,30 +17,29 @@ import os
import
sys
import
sys
import
re
import
re
import
json
import
json
#import logging
import
logging
import
setup_paths
import
numpy
as
np
import
numpy
as
np
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.parser_backend
import
JsonParseEventsWriterBackend
from
nomadcore.parser_backend
import
JsonParseEventsWriterBackend
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
libDlPolyParser
import
*
from
dlpolyparser.
libDlPolyParser
import
*
try
:
try
:
from
libMomo
import
osio
,
endl
,
flush
from
dlpolyparser.
libMomo
import
osio
,
endl
,
flush
osio
.
ConnectToFile
(
'parser.osio.log'
)
osio
.
ConnectToFile
(
'parser.osio.log'
)
green
=
osio
.
mg
green
=
osio
.
mg
except
:
except
:
osio
=
endl
=
flush
=
None
osio
=
endl
=
flush
=
None
green
=
None
green
=
None
parser_info
=
{
"name"
:
"parser-dl-poly"
,
# parser_info = {
"version"
:
"0.0"
,
# "name": "parser-dl-poly",
"json"
:
"../../../../nomad-meta-info/meta_info/nomad_meta_info/dl_poly.nomadmetainfo.json"
# "version": "0.0",
}
# "json": "../../../../nomad-meta-info/meta_info/nomad_meta_info/dl_poly.nomadmetainfo.json"
# }
# LOGGING
# LOGGING
def
log
(
msg
,
highlight
=
None
,
enter
=
endl
):
def
log
(
msg
,
highlight
=
None
,
enter
=
endl
):
...
@@ -54,7 +53,7 @@ def log(msg, highlight=None, enter=endl):
...
@@ -54,7 +53,7 @@ def log(msg, highlight=None, enter=endl):
def
open_section
(
p
,
name
):
def
open_section
(
p
,
name
):
gid
=
p
.
openSection
(
name
)
gid
=
p
.
openSection
(
name
)
yield
gid
yield
gid
p
.
closeSection
(
name
,
gid
)
p
.
closeSection
(
name
,
gid
)
def
push
(
jbe
,
terminal
,
key1
,
fct
=
lambda
x
:
x
.
As
(),
key2
=
None
,
conv
=
None
):
def
push
(
jbe
,
terminal
,
key1
,
fct
=
lambda
x
:
x
.
As
(),
key2
=
None
,
conv
=
None
):
if
key2
==
None
:
key2
=
key1
if
key2
==
None
:
key2
=
key1
...
@@ -82,27 +81,64 @@ def push_value(jbe, value, key, conv=None):
...
@@ -82,27 +81,64 @@ def push_value(jbe, value, key, conv=None):
return
value
return
value
def
push_array_values
(
jbe
,
value
,
key
,
conv
=
None
):
def
push_array_values
(
jbe
,
value
,
key
,
conv
=
None
):
if
conv
:
if
conv
:
jbe
.
addArrayValues
(
key
,
value
*
conv
)
jbe
.
addArrayValues
(
key
,
value
*
conv
)
else
:
else
:
jbe
.
addArrayValues
(
key
,
value
)
jbe
.
addArrayValues
(
key
,
value
)
return
value
return
value
def
parse
(
output_file_name
):
jbe
=
JsonParseEventsWriterBackend
(
meta_info_env
)
# class DlPolyParser():
# """ A proper class envolop for running this parser from within python. """
# def __init__(self, backend, **kwargs):
# self.backend_factory = backend
# from unittest.mock import patch
# logging.info('dl-poly parser started')
# logging.getLogger('nomadcore').setLevel(logging.WARNING)
# backend = self.backend_factory(metaInfoEnv)
# # Rename parser
# def parse(self, mainfile):
logger
=
logging
.
getLogger
(
"nomad.DLPolyParser"
)
class
DlPolyParserWrapper
():
""" A proper class envolop for running this parser using Noamd-FAIRD infra. """
def
__init__
(
self
,
backend
,
**
kwargs
):
self
.
backend_factory
=
backend
def
parse
(
self
,
mainfile
):
import
nomad_meta_info
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
nomad_meta_info
.
__file__
)),
"dl_poly.nomadmetainfo.json"
))
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
from
unittest.mock
import
patch
logging
.
info
(
'dl-poly parser started'
)
logging
.
getLogger
(
'nomadcore'
).
setLevel
(
logging
.
WARNING
)
backend
=
self
.
backend_factory
(
metaInfoEnv
)
# Call the old parser without a class.
parserInfo
=
{
'name'
:
'dl_poly-parser'
,
'version'
:
'0.0'
}
backend
=
parse_without_class
(
mainfile
,
backend
,
parserInfo
)
return
backend
def
parse_without_class
(
output_file_name
,
backend
,
parser_info
):
""" Parse method to parse mainfile and write output to backend."""
jbe
=
backend
jbe
.
startedParsingSession
(
output_file_name
,
parser_info
)
jbe
.
startedParsingSession
(
output_file_name
,
parser_info
)
base_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
output_file_name
))
base_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
output_file_name
))
# PARSE CONTROLS ...
# PARSE CONTROLS ...
ctrl_file_name
=
os
.
path
.
join
(
base_dir
,
'CONTROL'
)
ctrl_file_name
=
os
.
path
.
join
(
base_dir
,
'CONTROL'
)
terminal_ctrls
=
DlPolyControls
(
osio
)
terminal_ctrls
=
DlPolyControls
(
osio
)
terminal_ctrls
.
ParseControls
(
ctrl_file_name
)
terminal_ctrls
.
ParseControls
(
ctrl_file_name
)
# PARSE OUTPUT / TOPOLOGY ...
# PARSE OUTPUT / TOPOLOGY ...
output_file_name
=
os
.
path
.
join
(
base_dir
,
'OUTPUT'
)
output_file_name
=
os
.
path
.
join
(
base_dir
,
'OUTPUT'
)
terminal
=
DlPolyParser
(
osio
)
terminal
=
DlPolyParser
(
osio
)
terminal
.
ParseOutput
(
output_file_name
)
terminal
.
ParseOutput
(
output_file_name
)
# PARSE CONFIG ...
# PARSE CONFIG ...
cfg_file_name
=
os
.
path
.
join
(
base_dir
,
'CONFIG'
)
cfg_file_name
=
os
.
path
.
join
(
base_dir
,
'CONFIG'
)
...
@@ -126,7 +162,7 @@ def parse(output_file_name):
...
@@ -126,7 +162,7 @@ def parse(output_file_name):
out
=
terminal
out
=
terminal
top
=
terminal
.
topology
top
=
terminal
.
topology
cfg
=
terminal_cfg
cfg
=
terminal_cfg
trj
=
terminal_trj
trj
=
terminal_trj
terminals
=
[
ctr
,
out
,
top
,
cfg
,
trj
]
terminals
=
[
ctr
,
out
,
top
,
cfg
,
trj
]
# ESTABLISH (ENERGY) UNITS
# ESTABLISH (ENERGY) UNITS
...
@@ -143,13 +179,13 @@ def parse(output_file_name):
...
@@ -143,13 +179,13 @@ def parse(output_file_name):
ofs
.
write
(
'[%s] %s = %s
\n
'
%
(
t
.
logtag
,
key
,
t
[
key
].
As
(
str
)))
ofs
.
write
(
'[%s] %s = %s
\n
'
%
(
t
.
logtag
,
key
,
t
[
key
].
As
(
str
)))
ofs
.
write
(
'
\n
'
)
ofs
.
write
(
'
\n
'
)
ofs
.
close
()
ofs
.
close
()
# PUSH TO BACKEND
# PUSH TO BACKEND
with
open_section
(
jbe
,
'section_run'
)
as
gid_run
:
with
open_section
(
jbe
,
'section_run'
)
as
gid_run
:
push
(
jbe
,
out
,
'program_name'
)
push
(
jbe
,
out
,
'program_name'
)
push
(
jbe
,
out
,
'program_version'
)
push
(
jbe
,
out
,
'program_version'
)
#push(jbe, out, 'program_info', key2='program_version_date')
#push(jbe, out, 'program_info', key2='program_version_date')
# TOPOLOGY SECTION
# TOPOLOGY SECTION
with
open_section
(
jbe
,
'section_topology'
)
as
gid_top
:
with
open_section
(
jbe
,
'section_topology'
)
as
gid_top
:
# Cross-referencing is done on-the-fly (as gid's become available)
# Cross-referencing is done on-the-fly (as gid's become available)
...
@@ -157,7 +193,7 @@ def parse(output_file_name):
...
@@ -157,7 +193,7 @@ def parse(output_file_name):
# b) <atom_in_molecule_to_atom_type_ref> : shape=(number_of_atoms_in_molecule, [<gid>])
# b) <atom_in_molecule_to_atom_type_ref> : shape=(number_of_atoms_in_molecule, [<gid>])
# c) <atom_to_molecule> : shape=(number_of_topology_atoms, [<molidx>, <atomidx>])
# c) <atom_to_molecule> : shape=(number_of_topology_atoms, [<molidx>, <atomidx>])
push
(
jbe
,
top
,
'number_of_topology_molecules'
,
lambda
s
:
s
.
As
(
int
))
push
(
jbe
,
top
,
'number_of_topology_molecules'
,
lambda
s
:
s
.
As
(
int
))
push
(
jbe
,
top
,
'number_of_topology_atoms'
,
lambda
s
:
s
.
As
(
int
))
push
(
jbe
,
top
,
'number_of_topology_atoms'
,
lambda
s
:
s
.
As
(
int
))
# Atom types
# Atom types
mol_type_atom_type_id_to_atom_type_gid
=
{}
mol_type_atom_type_id_to_atom_type_gid
=
{}
for
mol
in
top
.
molecules
:
for
mol
in
top
.
molecules
:
...
@@ -170,7 +206,7 @@ def parse(output_file_name):
...
@@ -170,7 +206,7 @@ def parse(output_file_name):
mol_type_atom_type_id_to_atom_type_gid
[
mol_name
][
atom_id
]
=
gid_atom
mol_type_atom_type_id_to_atom_type_gid
[
mol_name
][
atom_id
]
=
gid_atom
push
(
jbe
,
atom
,
'atom_type_name'
,
lambda
s
:
s
.
As
(),
'atom_name'
)
push
(
jbe
,
atom
,
'atom_type_name'
,
lambda
s
:
s
.
As
(),
'atom_name'
)
push
(
jbe
,
atom
,
'atom_type_mass'
,
lambda
s
:
s
.
As
(
float
),
'atom_mass'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'mass'
])
push
(
jbe
,
atom
,
'atom_type_mass'
,
lambda
s
:
s
.
As
(
float
),
'atom_mass'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'mass'
])
push
(
jbe
,
atom
,
'atom_type_charge'
,
lambda
s
:
s
.
As
(
float
),
'atom_charge'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'charge'
])
push
(
jbe
,
atom
,
'atom_type_charge'
,
lambda
s
:
s
.
As
(
float
),
'atom_charge'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'charge'
])
# Molecule types
# Molecule types
molecule_type_name_to_type_gid
=
{}
molecule_type_name_to_type_gid
=
{}
for
mol
in
top
.
molecules
:
for
mol
in
top
.
molecules
:
...
@@ -181,12 +217,12 @@ def parse(output_file_name):
...
@@ -181,12 +217,12 @@ def parse(output_file_name):
for
atom
in
mol
.
atoms
:
for
atom
in
mol
.
atoms
:
atom_id
=
atom
[
'atom_id'
].
As
(
int
)
atom_id
=
atom
[
'atom_id'
].
As
(
int
)
atom_gid_list
.
append
(
atom_type_id_to_atom_type_gid
[
atom_id
])
atom_gid_list
.
append
(
atom_type_id_to_atom_type_gid
[
atom_id
])
# Add molecule
# Add molecule
with
open_section
(
jbe
,
'section_molecule_type'
)
as
gid_mol
:
with
open_section
(
jbe
,
'section_molecule_type'
)
as
gid_mol
:
molecule_type_name_to_type_gid
[
mol
[
'molecule_type_name'
].
As
()]
=
gid_mol
molecule_type_name_to_type_gid
[
mol
[
'molecule_type_name'
].
As
()]
=
gid_mol
push
(
jbe
,
mol
,
'molecule_type_name'
)
push
(
jbe
,
mol
,
'molecule_type_name'
)
push
(
jbe
,
mol
,
'number_of_atoms_in_molecule'
,
lambda
s
:
s
.
As
(
int
))
push
(
jbe
,
mol
,
'number_of_atoms_in_molecule'
,
lambda
s
:
s
.
As
(
int
))
push_array
(
jbe
,
mol
,
'atom_in_molecule_name'
)
push_array
(
jbe
,
mol
,
'atom_in_molecule_name'
)
push_array
(
jbe
,
mol
,
'atom_in_molecule_charge'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'charge'
])
push_array
(
jbe
,
mol
,
'atom_in_molecule_charge'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'charge'
])
push_array_values
(
jbe
,
np
.
asarray
(
atom_gid_list
),
'atom_in_molecule_to_atom_type_ref'
)
push_array_values
(
jbe
,
np
.
asarray
(
atom_gid_list
),
'atom_in_molecule_to_atom_type_ref'
)
...
@@ -219,7 +255,7 @@ def parse(output_file_name):
...
@@ -219,7 +255,7 @@ def parse(output_file_name):
with
open_section
(
jbe
,
'section_sampling_method'
)
as
gid_sec_sampling_method
:
with
open_section
(
jbe
,
'section_sampling_method'
)
as
gid_sec_sampling_method
:
sec_sampling_method_ref
=
gid_sec_sampling_method
sec_sampling_method_ref
=
gid_sec_sampling_method
# Ensemble
# Ensemble
ensemble
=
push
(
jbe
,
out
,
'ensemble_type'
,
lambda
s
:
s
.
As
().
split
()[
0
].
upper
())
ensemble
=
push
(
jbe
,
out
,
'ensemble_type'
,
lambda
s
:
s
.
As
().
split
()[
0
].
upper
())
# Method
# Method
push
(
jbe
,
out
,
'sampling_method'
)
push
(
jbe
,
out
,
'sampling_method'
)
push
(
jbe
,
out
,
'x_dl_poly_integrator_type'
)
push
(
jbe
,
out
,
'x_dl_poly_integrator_type'
)
...
@@ -230,7 +266,7 @@ def parse(output_file_name):
...
@@ -230,7 +266,7 @@ def parse(output_file_name):
push
(
jbe
,
out
,
'x_dl_poly_thermostat_target_temperature'
,
lambda
s
:
s
.
As
(
float
),
conv
=
UNITCONV_DLPOLY_TO_SI
[
'temperature'
])
push
(
jbe
,
out
,
'x_dl_poly_thermostat_target_temperature'
,
lambda
s
:
s
.
As
(
float
),
conv
=
UNITCONV_DLPOLY_TO_SI
[
'temperature'
])
push
(
jbe
,
out
,
'x_dl_poly_thermostat_tau'
,
lambda
s
:
s
.
As
(
float
))
push
(
jbe
,
out
,
'x_dl_poly_thermostat_tau'
,
lambda
s
:
s
.
As
(
float
))
pass
pass
if
'P'
in
ensemble
:
if
'P'
in
ensemble
:
push
(
jbe
,
out
,
'x_dl_poly_barostat_target_pressure'
,
lambda
s
:
s
.
As
(
float
),
conv
=
UNITCONV_DLPOLY_TO_SI
[
'pressure_katm'
])
push
(
jbe
,
out
,
'x_dl_poly_barostat_target_pressure'
,
lambda
s
:
s
.
As
(
float
),
conv
=
UNITCONV_DLPOLY_TO_SI
[
'pressure_katm'
])
push
(
jbe
,
out
,
'x_dl_poly_barostat_tau'
,
lambda
s
:
s
.
As
(
float
),
conv
=
UNITCONV_DLPOLY_TO_SI
[
'time'
])
push
(
jbe
,
out
,
'x_dl_poly_barostat_tau'
,
lambda
s
:
s
.
As
(
float
),
conv
=
UNITCONV_DLPOLY_TO_SI
[
'time'
])
pass
pass
...
@@ -241,19 +277,21 @@ def parse(output_file_name):
...
@@ -241,19 +277,21 @@ def parse(output_file_name):
with
open_section
(
jbe
,
'section_method'
)
as
gid_sec_method
:
with
open_section
(
jbe
,
'section_method'
)
as
gid_sec_method
:
sec_method_ref
=
gid_sec_method
sec_method_ref
=
gid_sec_method
push_value
(
jbe
,
'force_field'
,
'calculation_method'
)
push_value
(
jbe
,
'force_field'
,
'calculation_method'
)
# TODO Store state variables in frames/system description (temperature, pressure)
# TODO Store state variables in frames/system description (temperature, pressure)
# TODO Store interactions
# TODO Store interactions
# SYSTEM DESCRIPTION
# SYSTEM DESCRIPTION
refs_system_description
=
[]
refs_system_description
=
[]
all_frames
=
[
cfg
]
+
trj
.
frames
# <- Initial config + trajectory
all_frames
=
[
cfg
]
+
trj
.
frames
# <- Initial config + trajectory
for
frame
in
all_frames
:
for
frame
in
all_frames
:
with
open_section
(
jbe
,
'section_system'
)
as
gid
:
with
open_section
(
jbe
,
'section_system'
)
as
gid
:
refs_system_description
.
append
(
gid
)
refs_system_description
.
append
(
gid
)
# Configuration core
# Configuration core
atom_labels
=
np
.
array
([
atom
[
'atom_name'
].
As
()
for
atom
in
frame
.
atoms
])
atom_labels
=
np
.
array
(
[
atom
[
'atom_name'
].
As
().
replace
(
'+'
,
''
).
replace
(
'-'
,
''
)
for
atom
in
frame
.
atoms
])
push_array_values
(
jbe
,
atom_labels
,
'atom_labels'
)
push_array_values
(
jbe
,
atom_labels
,
'atom_labels'
)
# push_array_values(jbe, atom_species, 'atom_atom_numbers')
push_array_values
(
jbe
,
frame
.
position_matrix
,
'atom_positions'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'length'
])
push_array_values
(
jbe
,
frame
.
position_matrix
,
'atom_positions'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'length'
])
push_array_values
(
jbe
,
frame
.
box_matrix
,
'simulation_cell'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'length'
])
push_array_values
(
jbe
,
frame
.
box_matrix
,
'simulation_cell'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'length'
])
push_array_values
(
jbe
,
frame
.
pbc_booleans
,
'configuration_periodic_dimensions'
)
push_array_values
(
jbe
,
frame
.
pbc_booleans
,
'configuration_periodic_dimensions'
)
...
@@ -263,7 +301,7 @@ def parse(output_file_name):
...
@@ -263,7 +301,7 @@ def parse(output_file_name):
# TODO Wouldn't it be simpler if forces were added here?
# TODO Wouldn't it be simpler if forces were added here?
pass
pass
pass
pass
# SINGLE CONFIGURATIONS
# SINGLE CONFIGURATIONS
refs_single_configuration
=
[]
refs_single_configuration
=
[]
i_frame
=
-
1
i_frame
=
-
1
...
@@ -282,8 +320,8 @@ def parse(output_file_name):
...
@@ -282,8 +320,8 @@ def parse(output_file_name):
push_array_values
(
jbe
,
frame
.
force_matrix
,
'atom_forces'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'mass'
]
*
UNITCONV_DLPOLY_TO_SI
[
'length'
]
/
UNITCONV_DLPOLY_TO_SI
[
'time'
]
**
2
)
push_array_values
(
jbe
,
frame
.
force_matrix
,
'atom_forces'
,
conv
=
UNITCONV_DLPOLY_TO_SI
[
'mass'
]
*
UNITCONV_DLPOLY_TO_SI
[
'length'
]
/
UNITCONV_DLPOLY_TO_SI
[
'time'
]
**
2
)
# Method reference
# Method reference
push_value
(
jbe
,
sec_method_ref
,
'single_configuration_to_calculation_method_ref'
)
push_value
(
jbe
,
sec_method_ref
,
'single_configuration_to_calculation_method_ref'
)
pass
pass
# FRAME-SEQUENCE SECTION
# FRAME-SEQUENCE SECTION
with
open_section
(
jbe
,
'section_frame_sequence'
):
with
open_section
(
jbe
,
'section_frame_sequence'
):
push_value
(
jbe
,
len
(
all_frames
),
'number_of_frames_in_sequence'
)
push_value
(
jbe
,
len
(
all_frames
),
'number_of_frames_in_sequence'
)
...
@@ -296,7 +334,7 @@ def parse(output_file_name):
...
@@ -296,7 +334,7 @@ def parse(output_file_name):
pass
pass
jbe
.
finishedParsingSession
(
"ParseSuccess"
,
None
)
jbe
.
finishedParsingSession
(
"ParseSuccess"
,
None
)
return