You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add option to evaluate unit cells symbolically (#45)
<!-- Provide a general summary of your changes in the Title above -->
## Description
Unit cells can now be build symbolically, using `sympy`'s Rational
numbers to determine the correct atomic coordinates. This reduces
rounding errors for large and complicated unit cells and allows for more
accurate deduplication of atoms.
## Motivation and Context
As in #42 and #44, floating point errors can accumulate to result in
imperfect deduplication of atoms for complex structures. The new
implementation has a few changes:
- Fractional coordinates are rounded before PBC wrapping, reducing the
number of duplicate points near the edges of a cell
- Symmetry operation expressions can be evaluated symbolically by
setting the `parse_mode` flag of `build_unit_cell` to `sympy`. The
previous implementation is accessible by setting that value to
`python_float`
- New `sympy` evaluation mode is enabled by default only if sympy is
installed on the system.
### Notes on the method
Symbolically evaluating every site is slow relative to the performance
of the pure python implementation - however, the total runtime per
crystal is on the order of tens of milliseconds and should be fast
enough for most users.
Symbolic evaluation of sites is NOT guaranteed to accurately reconstruct
every crystal! While `parsnip` works for 1102/1103 of the files in my
test suite, some tuning of `n_decimal_places` may be required. For
really degenerate systems (orthorhombic, monoclinic, or triclinic
crystals with >100 atoms and sites represented with 3 or fewer decimal
places), even symbolic evaluation may not be able to properly
deduplicate a crystal.
## Types of Changes
<!-- Please select all items that apply, either now or after creating
the pull request: -->
- [ ] Documentation update
- [x] Bug fix
- [x] New feature
- [ ] Breaking change<sup>1</sup>
<sup>1</sup>The change breaks (or has the potential to break) existing
functionality and should be merged into the `breaking` branch
## Checklist:
<!-- Please select all items that apply either now or after creating the
pull request. -->
- [x] I am familiar with the [Development
Guidelines](https://github.com/glotzerlab/parsnip/blob/main/doc/source/development.rst)
- [x] The changes introduced by this pull request are covered by
existing or newly introduced tests.
- [ ] I have updated the
[changelog](https://github.com/glotzerlab/parsnip/blob/main/ChangeLog.rst)
and added my name to the
[credits](https://github.com/glotzerlab/parsnip/blob/main/doc/source/credits.rst).
0 commit comments