Created
November 16, 2016 10:30
-
-
Save pastewka/a602b7e7c6cbae7f570822a179c89583 to your computer and use it in GitHub Desktop.
Compute virial from a trajectory file in a post-processing step
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| from __future__ import division, print_function | |
| import sys | |
| from ase.io import NetCDFTrajectory | |
| from atomistica import TabulatedAlloyEAM, KumagaiScr | |
| ### | |
| #calc = TabulatedAlloyEAM(fn='Au-Grochola-JCP05.eam.alloy') | |
| calc = KumagaiScr() | |
| ### | |
| traj = NetCDFTrajectory('traj.nc', types_to_numbers=[-1,14], mode='a') | |
| for frame, a in enumerate(traj): | |
| sys.stdout.write('=== {}/{} ==='.format(frame+1, len(traj))) | |
| a.set_calculator(calc) | |
| virial = a.get_stresses() | |
| a.set_array('virial', virial) | |
| # Dump virial array to NetCDF file. | |
| traj.write_arrays(a, frame, ['virial']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment