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 cap hydrogens to head and tail compounds in the polymer builder #1196

Merged
merged 4 commits into from
Aug 19, 2024

Conversation

chrisjonesBSU
Copy link
Contributor

PR Summary:

This is a small PR that changes how the capping hydrogen compounds are added to the polymer that is built up in the polymer builder. Right now, we add the hydrogen compounds to the polymer compound, so they are at the same hierarchical level as the monomer compounds. This PR now adds them to the head and tail monomers. This is cleaner, and creates a more consistent hierarchy that we would expect with a polymer compound, where its children are the monomers, instead of particles. You can see in these 2 examples below:

import mbuild as mb
from mbuild.lib.recipes import Polymer

chain = Polymer()
chain.add_monomer(compound=mb.load("CC", smiles=True), indices=[4,7], separation=0.145)
chain.build(n=6, sequence="A")

Current behavior:

>>> chain.children
[<Compound 6 particles, 5 bonds, non-periodic, id: 123233398406080>,
 <Compound 6 particles, 5 bonds, non-periodic, id: 123233398257904>,
 <Compound 6 particles, 5 bonds, non-periodic, id: 123233397959872>,
 <Compound 6 particles, 5 bonds, non-periodic, id: 123233391797712>,
 <Compound 6 particles, 5 bonds, non-periodic, id: 123233391798384>,
 <Compound 6 particles, 5 bonds, non-periodic, id: 123233409902032>,
 <H 1 particles, 0 bonds, non-periodic, id: 123233398398928>,
 <H 1 particles, 0 bonds, non-periodic, id: 123233398286400>]

Behavior in this PR:

>>> chain.children
[<Compound 7 particles, 6 bonds, non-periodic, id: 136093088604928>,
 <Compound 6 particles, 5 bonds, non-periodic, id: 136093093706400>,
 <Compound 6 particles, 5 bonds, non-periodic, id: 136093088586192>,
 <Compound 6 particles, 5 bonds, non-periodic, id: 136093088592720>,
 <Compound 6 particles, 5 bonds, non-periodic, id: 136093088583648>,
 <Compound 7 particles, 6 bonds, non-periodic, id: 136093088608576>]

Side note:

This also has a quick fix for a flaky unit test that seems to have some inconsistent behavior (test_get_smiles). This test seems to randomly fail, but not because the behavior is wrong, but because sometimes different (but structurally identical) SMILES strings are being returned.

Copy link

codecov bot commented Aug 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.34%. Comparing base (87d659e) to head (8a04111).
Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1196      +/-   ##
==========================================
+ Coverage   85.54%   87.34%   +1.80%     
==========================================
  Files          62       62              
  Lines        6585     6584       -1     
==========================================
+ Hits         5633     5751     +118     
+ Misses        952      833     -119     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@chrisjonesBSU chrisjonesBSU merged commit 48127e3 into mosdef-hub:main Aug 19, 2024
21 checks passed
@chrisjonesBSU
Copy link
Contributor Author

Merged after discussing PR with Cal Craven on a mosdef dev call.

@chrisjonesBSU chrisjonesBSU deleted the polymerH branch August 19, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant