Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
e0865e2f
Commit
e0865e2f
authored
May 03, 2017
by
eric pellegrini
Browse files
removed recursive parsing of XTD file
parent
c19167d7
Pipeline
#1690
passed with stages
in 10 minutes and 33 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
MDANSE/Framework/Jobs/MaterialsStudio.py
View file @
e0865e2f
...
@@ -154,24 +154,6 @@ class XTDFile(object):
...
@@ -154,24 +154,6 @@ class XTDFile(object):
self
.
_atoms
[
idx1
][
"bonded_to"
].
add
(
idx2
)
self
.
_atoms
[
idx1
][
"bonded_to"
].
add
(
idx2
)
self
.
_atoms
[
idx2
][
"bonded_to"
].
add
(
idx1
)
self
.
_atoms
[
idx2
][
"bonded_to"
].
add
(
idx1
)
def
_build_universe
(
self
,
idx
,
clustered
,
cluster
):
"""
"""
clustered
[
idx
]
=
True
cluster
.
append
(
idx
)
at
=
self
.
_atoms
[
idx
]
for
nidx
in
at
[
"bonded_to"
]:
if
nidx
in
clustered
:
continue
self
.
_build_universe
(
nidx
,
clustered
,
cluster
)
def
build_universe
(
self
):
def
build_universe
(
self
):
if
self
.
_pbc
:
if
self
.
_pbc
:
...
@@ -180,36 +162,46 @@ class XTDFile(object):
...
@@ -180,36 +162,46 @@ class XTDFile(object):
else
:
else
:
self
.
_universe
=
InfiniteUniverse
()
self
.
_universe
=
InfiniteUniverse
()
clustered
=
{}
configuration
=
numpy
.
empty
((
self
.
_nAtoms
,
3
),
dtype
=
numpy
.
float64
)
nclusters
=
0
cluster
=
[]
cluster
s
=
{}
configuration
=
numpy
.
empty
((
self
.
_nAtoms
,
3
),
dtype
=
numpy
.
float64
)
equivalences
=
{}
for
idx
in
self
.
_atoms
.
key
s
():
for
idx
,
atom
in
self
.
_atoms
.
item
s
():
if
idx
in
clustered
:
if
not
clusters
.
has_key
(
idx
):
continue
nclusters
+=
1
clusters
[
idx
]
=
nclusters
self
.
_build_universe
(
idx
,
clustered
,
cluster
)
for
neighbor
in
atom
[
"bonded_to"
]:
if
(
neighbor
in
clusters
)
and
(
clusters
[
idx
]
!=
clusters
[
neighbor
]):
equivalences
[
clusters
[
neighbor
]]
=
equivalences
.
get
(
clusters
[
idx
],
clusters
[
idx
])
cluster
name
=
collections
.
defaultdict
(
lambda
:
0
)
cluster
s
[
neighbor
]
=
clusters
[
idx
]
ac
=
[]
mergedClusters
=
{}
for
idx
in
cluster
:
for
idx
,
clusterId
in
clusters
.
items
():
if
equivalences
.
has_key
(
clusterId
):
mergedClusters
.
setdefault
(
equivalences
[
clusterId
],[]).
append
(
idx
)
else
:
mergedClusters
.
setdefault
(
clusterId
,[]).
append
(
idx
)
for
k
,
indexes
in
mergedClusters
.
items
():
atomCluster
=
AtomCluster
([])
bruteFormula
=
collections
.
defaultdict
(
lambda
:
0
)
for
idx
in
indexes
:
element
=
self
.
_atoms
[
idx
][
"element"
]
element
=
self
.
_atoms
[
idx
][
"element"
]
name
=
self
.
_atoms
[
idx
][
"name"
]
name
=
self
.
_atoms
[
idx
][
"name"
]
at
=
Atom
(
element
,
name
=
name
,
xtdIndex
=
idx
)
at
=
Atom
(
element
,
name
=
name
,
xtdIndex
=
idx
)
at
.
index
=
self
.
_atoms
[
idx
][
"mmtk_index"
]
at
.
index
=
self
.
_atoms
[
idx
][
"mmtk_index"
]
configuration
[
at
.
index
]
=
self
.
_atoms
[
idx
][
"xyz"
]
configuration
[
at
.
index
]
=
self
.
_atoms
[
idx
][
"xyz"
]
ac
.
append
(
at
)
atomCluster
.
atoms
.
append
(
at
)
clustername
[
element
]
+=
1
bruteFormula
[
element
]
+=
1
clustername
=
""
.
join
([
"%s%d"
%
(
k
,
v
)
for
k
,
v
in
sorted
(
clustername
.
items
())])
atomCluster
.
name
=
""
.
join
([
"%s%d"
%
(
k
,
v
)
for
k
,
v
in
sorted
(
bruteFormula
.
items
())])
cluster
=
[]
self
.
_universe
.
addObject
(
atomCluster
)
ac
=
AtomCluster
(
ac
,
name
=
clustername
)
self
.
_universe
.
addObject
(
ac
)
if
self
.
_pbc
:
if
self
.
_pbc
:
configuration
=
self
.
_universe
.
_boxToRealPointArray
(
configuration
)
configuration
=
self
.
_universe
.
_boxToRealPointArray
(
configuration
)
...
...
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