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

Add a SingleChain system class. #188

Open
chrisjonesBSU opened this issue Feb 21, 2025 · 3 comments · May be fixed by #192
Open

Add a SingleChain system class. #188

chrisjonesBSU opened this issue Feb 21, 2025 · 3 comments · May be fixed by #192
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@chrisjonesBSU
Copy link
Member

chrisjonesBSU commented Feb 21, 2025

I often need a single chain in a vacuum, and using Pack for this isn't a great option, since the density you have to choose isn't intuitive. Also, for single chain simulations it is helpful for visualization purposes that the chain starts the in the center of the volume, which will almost never happen when using Pack.

@chrisjonesBSU chrisjonesBSU added enhancement New feature or request good first issue Good for newcomers labels Feb 21, 2025
@chrisjonesBSU
Copy link
Member Author

Here is an example of a custom one I was using in a project

    class SingleChainSystem(System):
        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]
            head = chain.children[0]
            tail = chain.children[-1]
            chain_length = np.linalg.norm(tail.pos - head.pos)
            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

@chrisjonesBSU
Copy link
Member Author

chrisjonesBSU commented Feb 27, 2025

We might need to think about automating finding the chain length rather than hard coding first and last indices, but also without requiring that the user manually finds them. We could just take the largest pair distance between particles and call that the "chain length"

SciPy has this method which is pretty fast

https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.distance.pdist.html

@StephMcCallum
Copy link
Contributor

  • doc strings
  • add to library/systems.py
  • make it work for AA atom models and atom indices (different ways to get length of polymer or mbuild compound, spicy.pdist)
  • unit tests

StephMcCallum added a commit to StephMcCallum/flowerMD that referenced this issue Feb 28, 2025
@chrisjonesBSU chrisjonesBSU linked a pull request Feb 28, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants