The gro file

The gro file contains the atomic coordinates and the size (and shape) of the unit cell. The file is fix format, so if you need to write a gro file using your home made script, here the right format:

C-format: "%5i%5s%5s%5i%8.3f%8.3f%8.3f%8.4f%8.4f%8.4f"

Fortran format: (i5,2a5,i5,3f8.3,3f8.4)

Here an example of gro file:

formic acid
    5
    1acf    H11    1   0.336   0.153   0.288
    1acf     C1    2   0.285   0.231   0.255
    1acf     OH    3   0.164   0.235   0.267
    1acf     OC    4   0.344   0.324   0.202
    1acf     HO    5   0.119   0.305   0.238
   0.50000   0.50000   0.50000

Atomic velocities, can also be specified, as in the last three columns in the example below:

solvent box formic acid
 2560
    1acf    H11    1   0.808   2.506   1.680 -1.8562  0.0962  1.7603
    1acf     C1    2   0.857   2.500   1.777  0.7837  0.0652  0.5314
    1acf     OH    3   0.899   2.377   1.818 -0.1020 -0.4160  0.0446
    1acf     OC    4   0.820   2.582   1.861 -0.4157  0.4329 -0.3214
    1acf     HO    5   0.893   2.368   1.912  0.5545 -0.8811  0.0491
    2acf    H11    6   1.574   0.506   3.142  0.8346  1.8403 -1.6980
    2acf     C1    7   1.621   0.562   3.222 -0.1796  0.6599 -0.2270
    2acf     OH    8   1.730   0.636   3.188  0.3051 -0.0070 -0.1210
    2acf     OC    9   1.569   0.577   3.333  0.0958  0.5822 -0.0860
    2acf     HO   10   1.751   0.700   3.254 -1.3288  0.6433 -0.1902
    3acf    H11   11   0.555   1.337   1.204  1.4714 -1.6282  0.6080
    3acf     C1   12   0.582   1.340   1.099 -0.4748  0.2153  0.0955
    3acf     OH   13   0.476   1.312   1.018 -0.3193  0.1403 -0.0844
    3acf     OC   14   0.658   1.425   1.054  0.0076 -0.3345 -0.1498
    3acf     HO   15   0.501   1.353   0.937 -0.2020  1.3255  0.5311
    4acf    H11   16   0.618   0.781   0.262  1.2376  0.3328  0.1194
    4acf     C1   17   0.598   0.787   0.155 -0.2749  0.2230  0.3708
    4acf     OH   18   0.492   0.865   0.118  0.1539  0.3384 -0.6465
    .....

With title etc., a gro file looks like this:

for (i=0; (i<natoms); i++)
         residuenr,residuename,atomname,atomnr,x,y,z,vx,vy,vz

box[X][X],box[Y][Y],box[Z][Z],box[X][Y],box[X][Z],box[Y][X],box[Y][Z],box[Z][X],box[Z][Y]

The unit cell

The unit cell is defined by the last line in the gro file:

box[X][X],box[Y][Y],box[Z][Z],box[X][Y],box[X][Z],box[Y][X],box[Y][Z],box[Z][X],box[Z][Y]

For orthorhombic unit cells, where all the angles are 90 degrees, is sufficient to specify the length (in nanometers) of the cell vectors. For non-orthorhombic unit cells all the nine parameters should be given. Here there is a good discussion on the meaning of box[X][X], box[Y][Y], box[Z][Z], box[X][Y], box[X][Z], box[Y][X], box[Y][Z], box[Z][X], box[Z][Y]. Also, in the discussion has been reported this python routine (by Tsjerk Wassenaar) to convert any unit cell into triclinic unit cell, given the length of the vectors and the angles between them:

def triclinic(L):
    B = [[0,0,0],[0,0,0],[0,0,0]]

    x, y, z, a, b, c = L[:6]

    B[0][0] = x
    if a == 90 and b == 90 and c == 90:
        B[1][1] = y
        B[2][2] = z
    else:
        a = a*pi/180
        b = b*pi/180
        c = c*pi/180
        B[1][0] = y*cos(c)
        B[1][1] = y*sin(c)
        B[2][0] = z*cos(b)
        B[2][1] = z*(cos(a)-cos(b)*cos(c))/sin(c)
        B[2][2] = sqrt(z*z-B[2][0]**2-B[2][1]**2)

    return B

The argument L is a tuple or list containing the lengths and angles.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License