Skip to content

Expand features of Polymer() to improve accessible polymer chain configurations. #1212

Open
@chrisjonesBSU

Description

@chrisjonesBSU

As mentioned in #1205 I've been throwing around some ideas and making some changes to improve the polymer building experience with mBuild. With this, there are a few things to think about, so I'm starting a discussion as a place to get feedback and input before making a PR.

  1. I think Polymer() is becoming more than a recipe, but a core class of mBuild, that has a lot of room for further development of polymer-specific methods and properties that don't need to (or can't) be included in Compound. We should move Polymer() out of lib/recipes and up to the same “level” as Compound(). There are arguments to do this for some other classes we have in lib/recipes but we can focus on Polymer for now.

  2. Initializing molecules and systems involves generating starting configurations at different length scales. Right now, packing.py has several methods designed to initialize bulk systems of several molecules. However, some initialization problems are limited to just a single molecule (e.g. a chain configuration of a single polymer), so I'm proposing we have a file analogous to packing.py but with methods to produce starting molecular configurations. Maybe we call this configuration.py or conformation.py...any other ideas?

  3. In order to use the idea of number 2 in the polymer class, we could add some polymer specific methods and properties. For example, a method that returns the set of backbone bond vectors (monomer-monomer bonds, not atomistic ones), another that gets the bond lengths of these vectors, a method that can change the monomer center of mass position, etc...

The most immediately obvious applications for this are generating polymer chain configurations. Right now, we often get some pretty whacky and unwieldy chain configurations from the polymer builder that make things like packing a box, or building a lattice difficult. Some examples of polymer configurations of a single chain would be a random coil, a lamellar structure, or enforcing a straight chain. Here are some examples:

from mbuild import Polymer
from conformations import random_walk

polymer = Polymer(..)
polymer.build(n=30) # Current configuration is a "bad" one
coords = random_walk(n=30, bond_L=0.25)
polymer.set_monomer_coordinates(coordinates=coords) # Now, a "good" configuraiton

chain-rw-example

from mbuild import Polymer
from conformations import lamellar 

polymer = Polymer(..)
polymer.build(n=30) # Current configuration is a "bad" one
coords = lamellar(n_layers=10, layer_length=7, layer_separation=0.7)
polymer.set_monomer_coordinates(coordinates=coords) # Now, a "good" configuraiton

lamellar-example

In both of these cases, the methods in conformations are creating a coarse-grain chain configuration, which we then map the atomistic structure onto with set_monomer_coordinates. These snapshots were obtained using the changes on my fork here, and a gist of the notebook can be found here

These multistep workflows could individually have wrapper build() methods in Polymer in addition to current build() method. For example:

# I want a lamellar structure with given dimensions, but I don't know the exact chain length that requires.
mon = mb.load("CC", smiles=True)
pe = Polymer()
pe.add_monomer(compound=mon, indices=[2, 6], replace=True, separation=0.15)
pe.build_lamellae(num_layers=5, layer_length=3, layer_separation=0.70)


# I want to build a random polymer configuration
mon = mb.load("CC", smiles=True)
pe = Polymer()
pe.add_monomer(compound=mon, indices=[2, 6], replace=True, separation=0.15)
pe.build_random_configuration(n=30, min_angle=np.pi/2, max_angle=np.pi, seed=32)


# I want a straight chain to use in a lattice builder later
mon = mb.load("CC", smiles=True)
pe = Polymer()
pe.add_monomer(compound=mon, indices=[2, 6], replace=True, separation=0.15)
pe.build_straight_chain(n=30, axis=(1,0,0))

conformations.py would be very extensible. Any algorithm that generates a set of bonded coordinates could be added. It could hold more types of random walks, building in complexity, maybe some combination of lamellar layers and random walks to create semi-crystalline chains, etc.

I'd love to hear any ideas and thoughts!

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.0Additions for mBuild 2.0feature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions