Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Single Chain system class #192

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions flowermd/library/systems.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
"""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().
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can expand here a little. We should say that the box lengths are chosen so that they are at least as long as the largest particle part distance. We could say that the chain is centered in the volume.


Parameters
----------
See System class.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a doc string for the buffer parameter.


"""

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
Loading