Skip to content

Add a method to create Compounds from coxeter shape objects - #1353

Open
chrisjonesBSU wants to merge 16 commits into
mosdef-hub:developfrom
chrisjonesBSU:from_coexter
Open

Add a method to create Compounds from coxeter shape objects#1353
chrisjonesBSU wants to merge 16 commits into
mosdef-hub:developfrom
chrisjonesBSU:from_coexter

Conversation

@chrisjonesBSU

@chrisjonesBSU chrisjonesBSU commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This PR adds a new loader method to conversion.py that generates an mBuild compound from a Coxeter shape object. Coxeter comes from the Glotzer lab, and is a great tool that generates vertices and edges of tons of different kinds of geometries ranging in complexity, which are converted to particles and bonds to create an mBuild Compound. Coxeter shapes provide relative coordinates, so the loader provides a scaling option to shift everything close enough to a target coordinate unit (which for mBuild is always nanometers). It also lets you set an element for the particles if desired, but this can be left blank so the particles are treated as generic beads.

Note: We might have to wait for a new release before we can use the coxeter conda-package as a dependency. I opened an issue asking about a new release timeline.

I still need to add unit tests

PR Checklist


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

pre-commit-ci Bot and others added 16 commits July 20, 2026 22:22
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.15.21 → v0.15.22](astral-sh/ruff-pre-commit@v0.15.21...v0.15.22)
…te-config

[pre-commit.ci] pre-commit autoupdate
np.object was removed in NumPy 1.24, but the project requires numpy>=2.0
(environment.yml). Calling PeriodicKDTree.query_ball_point() with an array
of multiple points therefore raises AttributeError. Use the builtin object
dtype, which is NumPy's documented replacement.
Popen was called with shell=True and an f-string interpolating a temp-file
path (f"{PACKMOL} < {packmol_inp.name}"). This is a shell-injection
anti-pattern and breaks whenever the temp path contains spaces or shell
metacharacters (e.g. a TMPDIR with spaces).

Pass the executable as an argument list and feed the input file directly as
stdin instead of relying on a shell redirection. Behavior is unchanged (the
shell was only used for the '<' redirection), and PACKMOL is a resolved path
from shutil.which().
…-removed-numpy

Fix np.object AttributeError in PeriodicKDTree.query_ball_point
* Update readthedocs build os to supported version

* update python to mambaforge-latest

* docs build os to 24.04
…hell-injection

Avoid shell=True when invoking PACKMOL
@chrisjonesBSU chrisjonesBSU added the 2.0 Additions for mBuild 2.0 label Jul 28, 2026
@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 16.00000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.14%. Comparing base (52a0897) to head (e786acb).

Files with missing lines Patch % Lines
mbuild/conversion.py 4.76% 20 Missing ⚠️
mbuild/periodic_kdtree.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1353      +/-   ##
===========================================
- Coverage    82.37%   82.14%   -0.24%     
===========================================
  Files           64       64              
  Lines         6977     6999      +22     
===========================================
+ Hits          5747     5749       +2     
- Misses        1230     1250      +20     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chrisjonesBSU

Copy link
Copy Markdown
Contributor Author

We might think about adding a to_coxeter method too, so we can take advantage of some of its analysis methods. Also, the coxeter shapes have a .is_inside() method that accepts a set of points, just like we have in constraints. We can add a .from_coexter() method to Constaint to create some interesting packing possibilities..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.0 Additions for mBuild 2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants