Skip to content

Commit

Permalink
addressing issue cmelab#188
Browse files Browse the repository at this point in the history
  • Loading branch information
StephMcCallum committed Feb 28, 2025
1 parent 929c173 commit 261ba54
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions flowermd/library/systems.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
"""Examples for the Systems class."""

# This is a placeholder for any class that inherits from base.system
import numpy
from scipy.spatial.distance import pdist

class SingleChainSystem(System):
"""Builds a box around a single chain.
Calculates the maximum distance of the chain using scipy.spatial.distance.pdist().
Parameters
----------
See System class.
"""

def __init__(self, molecules, base_units=dict()):
super(SingleChainSystem, self).__init__(
molecules=molecules,
base_units=base_units
)

def _build_system(self):
chain = self.all_molecules[0]
children_pos_array = np.zeros((len(chain.children),3))
for i in range(len(chain.children)):
children_pos_array[i] = chain.children[i].pos
eucl_dist = pdist(children_pos_array)
chain_length = np.max(eucl_dist)
box = mb.Box(lengths=np.array([chain_length] * 3) * 1.05)
comp = mb.Compound()
comp.add(chain)
comp.box = box
chain.translate_to((box.Lx / 2, box.Ly / 2, box.Lz / 2))
return comp

0 comments on commit 261ba54

Please sign in to comment.