forked from cmelab/flowerMD
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
929c173
commit 261ba54
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |