# [CP2K-user] How to plot RDFs for NPT simulations?

Travis polla... at gmail.com
Wed Oct 23 20:22:14 UTC 2019

```Hi,

Just some minor modifications then,
for ((i=0; i<310; i++)); do a=`echo "30 + \$RANDOM/30" | bc`; b=`echo "30 +
\$RANDOM/30" | bc`; c=`echo "30 + \$RANDOM/30" | bc`; vol=`echo "\$a*\$b*\$c" |
bc`; echo "\$i \$i \$a 0 0 0 \$b 0 0 0 \$c \$vol"; done > foo-1.cell

Just swap out the cell specification by angles with the 9 component one,

#!/usr/bin/env python3

'''
usage: python3 xyzcell2gro.py

Reads XMOL format file, adds lattice parameters, dumps Gromos file that can
'''

import glob
import os
import sys
import numpy as np

import ase

dir = os.getcwd()

# trajectory is XMOL format
# cell       is step time ax ay az bx by bz cx cy cz vol
for file in glob.glob('%s/*-pos-*.xyz' % dir):
filename, fileext = os.path.splitext(file)
fileroot, filescrap = filename.split('-pos')
trj = read('%s%s' % (filename, fileext) , format='xyz', index=':')
cel = np.loadtxt('%s-1.cell' % (fileroot), usecols=range(2,11),
dtype=np.double)
nframes = len(trj)
for frame in range(nframes):
trj[frame].set_cell([(cel[frame][0], cel[frame][1], cel[frame][2]),
(cel[frame][3], cel[frame][4], cel[frame][5]),
(cel[frame][6], cel[frame][7], cel[frame][8])])
trj[frame].set_pbc([True, True, True])
write('%s.g96' % (fileroot), trj[frame], format='gromos', append=True)

-T

On Wednesday, October 23, 2019 at 4:52:29 PM UTC-3, Ant wrote:
>
> Thank you very much, Travis!
>
> Here are the first few lines of a .cell file directly from CP2K (below).
> My cells are all cubic (90 degree angles, equal dimensions), so I can
> change these to three columns; e.g., Ax, By, Cz.
>
> Step   Time [fs]       Ax [Angstrom]       Ay [Angstrom]       Az
> [Angstrom]       Bx [Angstrom]       By [Angstrom]       Bz [Angstrom]
>   Cx [Angstrom]       Cy [Angstrom]       Cz [Angstrom]      Volume
> [Angstrom^3]
>
>        0       0.000       13.6105000000        0.0000000000
> 0.0000000000        0.0000000000       13.6105000000        0.0000000000
>     0.0000000000        0.0000000000       13.6105000000
> 2521.2867393576
>
>        1       0.500       13.6102685896        0.0000000000
> 0.0000000000        0.0000000000       13.6102685896        0.0000000000
>     0.0000000000        0.0000000000       13.6102685896
> 2521.1581382194
>
>        2       1.000       13.6101388560        0.0000000000
> 0.0000000000        0.0000000000       13.6101388560        0.0000000000
>     0.0000000000        0.0000000000       13.6101388560
> 2521.0860435793
>
>        3       1.500       13.6101072636        0.0000000000
> 0.0000000000        0.0000000000       13.6101072636        0.0000000000
>     0.0000000000        0.0000000000       13.6101072636
> 2521.0684874332
>
> This is finally making sense.  Now I understand why I have a problem.  My
> simple XYZ trajectories don't contain my cell dimensions.  Your code adds
> the cell dimensions and then I can read that new file right into the GUI
> where I would usually read in my simple XYZ file.  It's great to finally
> understand what is going on.  Thank you very much.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cp2k.org/archives/cp2k-user/attachments/20191023/dbdbac31/attachment.htm>
```