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

Patches for element reading in lattice builder #1066

Merged

Conversation

CalCraven
Copy link
Contributor

PR Summary:

This is a small patch to check for element information from the lattice reader. This is relevant if the user doesn't pass a compund dict of the form {name(STR): compound(mb.Compound)} to map the lattice points to a specific compound. In this case, the only information the populate function has is the key for each lattice point, which is a string. We can then use the ele package to check if that is supposed to be an element. Like always, if this is a coarse grained bead without element information, use an _NAME syntax to denote that, and no element information will be found.

Usage:

lattice = mb.Lattice(
             lattice_spacing=[0.5, 0.5, 1],
             angles=[90, 90, 120],
             lattice_points={"O": [[0, 0, 0]]},
 )
 cpd_lat = lattice.populate(x=1, y=1, z=1)
 for part in cpd_lat:
     assert part.element.name == "oxygen" # the oxygen is identified from the lattice_points dict.

PR Checklist


  • Includes appropriate unit test(s)
  • Appropriate docstring(s) are added/updated
  • Code is (approximately) PEP8 compliant
  • Issue(s) raised/addressed?

Closes #1065.

@CalCraven CalCraven self-assigned this Dec 5, 2022
Copy link
Member

@daico007 daico007 left a comment

Choose a reason for hiding this comment

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

LGTM!

@codecov
Copy link

codecov bot commented Dec 5, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.71%. Comparing base (ee91caa) to head (2b2b86a).
Report is 140 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1066      +/-   ##
==========================================
+ Coverage   90.69%   90.71%   +0.02%     
==========================================
  Files          57       57              
  Lines        5500     5513      +13     
==========================================
+ Hits         4988     5001      +13     
  Misses        512      512              

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

match=r"Element assumed from cif file to be Element: silicon, symbol: Si, atomic number: 14, mass: 28.085.",
):
lattice_cif = load_cif(file_or_path=get_fn("ETV_triclinic.cif"))
periodic_boxed_molecule = lattice_cif.populate(x=1, y=1, z=1)

Check notice

Code scanning / CodeQL

Unused local variable

Variable periodic_boxed_molecule is not used.
@daico007
Copy link
Member

daico007 commented Dec 6, 2022

Failing tests come from the new energy minimization with Windows (py39). I might have overlooked this when merging the other PR, but I think we should just skip those test on windows run.

Copy link
Contributor

@bc118 bc118 left a comment

Choose a reason for hiding this comment

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

LGTM

@daico007 daico007 merged commit 82977a2 into mosdef-hub:main Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The lattice builder won't check for element information if loaded from CIF
3 participants