Skip to content

fix DCDWriter angle cosines #5071

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

fix DCDWriter angle cosines #5071

wants to merge 2 commits into from

Conversation

orbeckst
Copy link
Member

@orbeckst orbeckst commented Jun 27, 2025

Fixes #5069

Changes made in this Pull Request:

  • DCDWriter is now writing unit cell angles as cos(angle) to the DCD file as written in the docs (NAMD >= 2.5 convention)
  • add test
  • update CHANGELOG

PR Checklist

  • Issue raised/referenced?
  • Tests updated/added?
  • Documentation updated/added?
  • package/CHANGELOG file updated?
  • Is your name in package/AUTHORS? (If it is not, add it!)

Developers Certificate of Origin

I certify that I can submit this code contribution as described in the Developer Certificate of Origin, under the MDAnalysis LICENSE.


📚 Documentation preview 📚: https://mdanalysis--5071.org.readthedocs.build/en/5071/

- fix #5069
- DCDWriter is now writing unit cell angles as cos(angle) to the DCD file
  as written in the docs (NAMD >= 2.5 convention)
- add test
- update CHANGELOG
@orbeckst
Copy link
Member Author

FYI: I tried out AI assisted coding with Cursor, using the default model:

Look at issue @https://github.com/MDAnalysis/mdanalysis/issues/5069 . Propose a fix to DCDWriter that addresses the problem of incorrectly writing unitcell angles to the DCD file. Propose tests (see @test_dcd.py ).

I rewrote basically everything; the only key thing that survived was the idea to write the cosines as sin(90 - angle), which it picked up from reading the DCDReader code. For the tests, it did not properly use my suggestions from the issue report to use the DCDFrame that the underlying dcd reading code provides. Still, it was helpful as a starting point.

It had a really hard time formatting the CHANGELOG entry, trying 5 different ways, finally writing a sed script to do it, ... poor thing. (It also tried to delete half of CHANGELOG in the process....)

- Original test only passed at rtol=1e-4 due to some angles close to 0,
  which is where the sin(90-angle) storage is much less accurate.
  Changed the test range of angles to between 5 and 120 (from 0 to 80)
  to be more realistic and exclude very small angles where we would
  see precision issues
- formatted with black
Copy link

codecov bot commented Jun 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.62%. Comparing base (d4456f1) to head (36d7b4e).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5071   +/-   ##
========================================
  Coverage    93.62%   93.62%           
========================================
  Files          177      177           
  Lines        22001    22002    +1     
  Branches      3114     3114           
========================================
+ Hits         20599    20600    +1     
  Misses         947      947           
  Partials       455      455           

☔ View full report in Codecov by Sentry.
📢 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.

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.

DCDWriter writes unit cell angles instead of documented cos(angles)
1 participant