A reader of gromacs tpr file
Project description
Description
TprParser is a convenient Python module for reading and setting simulation parameters in gromacs tpr file.
This module mainly aimed to modify atom property of tpr and create a new tpr file (named new.tpr) after use any one set_ method.
The module only supports get atoms coordinates, velocity and force if exist in tpr by module.get_xvf(...) function.
However, many properties can be set up by module, such as total simulation time nsteps, simulation integrator interval dt, output control parameters (nstxout, nstvout, etc.) and temperature/pressure coupling parameters.
Compatibility
GROMACS tpr version should between 4.0 to 2024, too old tpr can not be read by this module.
Install
-
Requirements
-
Python >= 3.8 -
Numpy -
C++ compiler(g++ for Linux, MSVC for Windows)
-
-
Install
The module is installed by
pipmethod:pip install TprParser -i https://pypi.org/simplePlease ALWAYS install Latest version.
Usage
Write your python program like this:
from TprParser.TprReader import TprReader # import this module
Get atom property
# get atom coords or velocity
reader = TprReader("your.tpr")
coords = reader.get_xvf('x')
velocity = reader.get_xvf('v')
# ...
Modify atom property
newcoords = np.array([[1,2,3], [4,5,6], [...]], dtype=np.float32) # shape= N*3
# The step will create new.tpr that used newcoords
reader.set_xvf('x', newcoords)
Modify system pressure
you can define a function do this work:
def Pressure(fname):
reader = TprReader(fname)
# 100 bar
ref_p = [
100, 0, 0,
0, 100, 0,
0, 0, 100
]
# compressibility 4.5E-5
compress = [
4.5E-5, 0, 0,
0, 4.5E-5, 0,
0, 0, 4.5E-5
]
assert len(ref_p) == 9
assert len(compress) == 9
# use ParrinelloRahman algorithm and Isotropic pressure coupling method
reader.set_pressure('ParrinelloRahman', 'Isotropic', 1.0, ref_p, compress)
Other
Please see TprReader module annotation
Cite
If TprParser is utilized in your work, please cite as follows in main text:
Yujie Liu, TprParser, Version xxx, https://pypi.org/project/TprParser/
TODO
- More parameters can be modified
- Get More essential parameters
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file TprParser-0.1.45.tar.gz.
File metadata
- Download URL: TprParser-0.1.45.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.28.2 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.65.0 importlib-metadata/6.8.0 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1deb036c08524d6361cd7d81db8b229de04c80752c73c5c374a9caeecfc7575
|
|
| MD5 |
b225df5fa703fca8547a72e6450dac9c
|
|
| BLAKE2b-256 |
2d9c87a57e36e94695b90cd60097c04fb72e8c4d5653b8940ca770b160223212
|