Skip to content

Conversation

@d-rel82
Copy link

@d-rel82 d-rel82 commented Nov 13, 2025

Summary

This pull request adds functionality to output the stress tensor at user-defined intervals during molecular dynamics (MD) simulations, enabling viscosity calculations using the Green-Kubo or Einstein relations.

Details

  • Introduces two new keywords:

    • SAVE-STRESS controls whether the full stress tensor is written during MD simulation.
    • STRESS-FREQ sets the number of MD steps between stress tensor writes.
  • Outputs components to a formatted .str file with a single-line, 7-column layout: the MD step followed by the 6 unique stress tensor components with labeled headers.

  • Adds new source files to support stress tensor output:

    • Module strvar.f defines variables for stress tensor output
    • Subroutine stresinit.f checks for stress output request from user
    • Subroutine prtstres.f writes tensor data to .str file
  • Updates existing source files to integrate new functionality:

    • dynamic.f updated to call stresinit.f
    • verlet.f updated to call prtstres.f
    • beeman.f updated to call prtstres.f
  • Updates CMakeLists.txt to include new source files in the build system

Sample Output

Appears in the .str file:

 MD Step     Stress(xx)     Stress(yy)     Stress(zz)     Stress(xy)     Stress(yz)     Stress(xz)
       5       752.4352       471.8455     -1486.1550      -553.0963       354.2783     -3115.6592
      10      -648.6845      2286.8894       561.1382       986.7980     -1678.7225     -1488.8422
      15      1237.5270       761.7150       488.3893      1241.9660       -95.4717       879.1930
      20       457.6210     -1230.6099      1084.2425      -621.4301      -130.1725      2553.5449

Performance

  • No significant effect on wall-clock time at 5 and 10 step print intervals.
  • Adds ~14% overhead in both Tinker 8.11.4 and Tinker 25.2 with a 1 step output interval.

Potential Documentation Text for Manual

SAVE-STRESS
Causes Tinker molecular dynamics calculations to save the values of the stress tensor components to an output file with the suffix ".str". This keyword is compatible with the velocity-verlet and beeman integrators.

STRESS-FREQ
Sets the number of MD steps between stress tensor prints. A default value of 10 steps is used for STRESS-FREQ in absence of the keyword.

Notes

Manuscript in preparation describing these modifications and a companion toolkit for viscosity calculations.

Modifications have also been implemented in version 8.11.4. Separate branches are maintained for version compatibility.

Support for these additions has been implemented in the CMake build system. I can extend this to the Makefile-based build system if desired. Happy to adjust anything to better align with project conventions. Thanks for your time and consideration.

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