Skip to content

Commit

Permalink
Merge pull request #11 from molssi-seamm/viewing-structure
Browse files Browse the repository at this point in the history
Viewing structure
  • Loading branch information
paulsaxe committed Jul 21, 2020
2 parents a5e7c4f + b14e9bf commit 6303d6a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
32 changes: 32 additions & 0 deletions loop_step/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

import configargparse
import logging
import os.path

import loop_step
import seamm
from seamm_util import ureg, Q_, units_class # noqa: F401
import seamm_util.printing as printing
from seamm_util.printing import FormattedText as __
from seamm_util import to_mmcif, to_cif

logger = logging.getLogger(__name__)
job = printing.getPrinter()
Expand Down Expand Up @@ -170,6 +173,8 @@ def run(self):
self.set_variable('_loop_indices', (self._loop_value,))
self.set_variable('_loop_index', self._loop_value)
else:
self.write_final_structure()

self._loop_value += P['step']
self.set_variable(P['variable'], self._loop_value)

Expand Down Expand Up @@ -223,6 +228,9 @@ def run(self):
else:
self.set_variable('_loop_indices', (None,))

if self._loop_value >= 0:
self.write_final_structure()

self._loop_value += 1

if self._loop_value >= self._loop_length:
Expand Down Expand Up @@ -276,6 +284,10 @@ def run(self):
))
else:
self.set_variable('_loop_indices', (None,))

if self._loop_value >= 0:
self.write_final_structure()

self._loop_value += 1
if self._loop_value >= self.table.shape[0]:
self._loop_value = None
Expand Down Expand Up @@ -343,6 +355,26 @@ def run(self):
# No loop body? just go on?
return self.exit_node()

def write_final_structure(self):
"""Write the final structure"""
if seamm.data.structure is not None:
system = seamm.data.structure
# MMCIF file has bonds
filename = os.path.join(
self.directory, f'iter_{self._loop_value}',
'final_structure.mmcif'
)
with open(filename, 'w') as fd:
print(to_mmcif(system), file=fd)
# CIF file has cell
if system['periodicity'] == 3:
filename = os.path.join(
self.directory, f'iter_{self._loop_value}',
'final_structure.cif'
)
with open(filename, 'w') as fd:
print(to_cif(seamm.data.structure), file=fd)

def default_edge_subtype(self):
"""Return the default subtype of the edge. Usually this is 'next'
but for nodes with two or more edges leaving them, such as a loop, this
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Pmw==2.0.1
seamm==0.9.2
seamm-util==0.9.1
seamm>=0.9.5
seamm-util>=0.9.3
seamm-widgets==0.9.1

0 comments on commit 6303d6a

Please sign in to comment.