Skip to content

Commit

Permalink
Polymer class revamp (#851)
Browse files Browse the repository at this point in the history
* added a couple new functions, moved existing code into build function

* added some doc strings

* added a default value to the port labels

* reworked the _add_port function

* saving my progress with the add_end_groups function

* made progress with end group funcitonality

* removing a couple print statements

* added 2 new attributes to port class

* removed changes from port.py, commented out orientation and separation lines

* changed method of removing hydrogens, added n_monomers var for finding last monomer

* adding to the doc strings

* added update_separation function

* update orientation func; separation property func

* added the up subports to the rotations

* fixed the change_orientation function

* fix handling when their is no anchor particle

* fix typo

* docstring: separation is None when port has no anchor

* added 3 unit tests

* remove the port updating stuff I was trying to use

* updating port separations for end groups

* fix the way clone is being called

* added some doc strings and comments

* updated doc strings

* including jupyter notebook example and walk through

* example notebook ready

* added to recipe examples

* expanded end_group options

* update alkane recipe to make tests pass

* cleaned up if statements when updating head/tail ports

* remove trailing whitespace

* allow use of compound with existing ports to be specified in init

whitespace/formatting

* update alkane to new schema

* update tests

* blacked, changed how head/tail port work

* remove debug print

* update notebook

* update notebook

* clear nb

* add back add_hydrogens

* add add_hydrogens=False

* add_hydrogens=False, all tests pass

* changed orientation of down port to face opposite direction of up port

* Few more examples added to show new functionality

* adding a few unit tests

* removing the example notebook from the PR

* test for errors, and manually passing in end group compounds

* expanded doc strings with more detailed explanations, and some examples

* fix a conflict that was sticking around in the port doc strings

* fix formatting in the doc strings

* Doc strings to explain implementation of sequence in the build function

* add unit test for value of n < 1

* 2 new tests to test for errors

* remove unused imports

* oops, typo

Co-authored-by: chrisjonesBSU <[email protected]>
Co-authored-by: Jenny <[email protected]>
Co-authored-by: Jenny Fothergill <[email protected]>
  • Loading branch information
4 people committed May 20, 2021
1 parent 88ed9b1 commit 219207b
Show file tree
Hide file tree
Showing 5 changed files with 444 additions and 72 deletions.
2 changes: 1 addition & 1 deletion mbuild/lib/moieties/ch2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self):
self.add(mb.Port(anchor=self[0]), "up")
self["up"].translate([0, 0.07, 0])

self.add(mb.Port(anchor=self[0]), "down")
self.add(mb.Port(anchor=self[0], orientation=[0, -1, 0]), "down")
self["down"].translate([0, -0.07, 0])


Expand Down
40 changes: 14 additions & 26 deletions mbuild/lib/recipes/alkane.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,33 +71,21 @@ def __init__(self, n=3, cap_front=True, cap_end=True):

# Handle general case of n >= 3
else:
end_groups = [None, None]
# Adjust length of Polmyer for absence of methyl terminations.
if not cap_front:
n += 1
if not cap_end:
n += 1
chain = mb.recipes.Polymer(
CH2(), n=n - 2, port_labels=("up", "down")
)
self.add(chain, "chain")
if cap_front:
self.add(CH3(), "methyl_front")
mb.force_overlap(
move_this=self["chain"],
from_positions=self["chain"]["up"],
to_positions=self["methyl_front"]["up"],
)
else:
# Hoist port label to Alkane level.
self.add(chain["up"], "up", containment=False)

n -= 1
end_groups[0] = CH3()
if cap_end:
self.add(CH3(), "methyl_end")
mb.force_overlap(
self["methyl_end"],
self["methyl_end"]["up"],
self["chain"]["down"],
)
else:
n -= 1
end_groups[1] = CH3()

chain = mb.recipes.Polymer(monomers=[CH2()], end_groups=end_groups)
chain.build(n, add_hydrogens=False)
self.add(chain, "chain")
if not cap_front:
# Hoist port label to Alkane level.
self.add(self["chain"]["up"], "up", containment=False)
if not cap_end:
# Hoist port label to Alkane level.
self.add(chain["down"], "down", containment=False)
self.add(self["chain"]["down"], "down", containment=False)
Loading

0 comments on commit 219207b

Please sign in to comment.