[gmx-developers] mtop structure

Mark Abraham Mark.Abraham at anu.edu.au
Mon Feb 23 21:29:50 CET 2009

Alexander Malafeev wrote:
> Hello, please tell me how to read mtop structure?
>     int index=0;
>     for(j=0;j<mtop <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_mtop_t>->nmolblock;j++) ///enum all molecule types/
>     {
>      for(k=0;k<mtop <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_mtop_t>->molblock <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_molblock_t>[j].nmol;k++) ///enum all instances of each molecule type/
>      {
>        for(l=0;l<mtop <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_mtop_t>->moltype <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_moltype_t>[ mtop <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_mtop_t>->molblock <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_molblock_t>[j].type].atoms.nr <http://atoms.nr>;l++) ///enum atoms/
>        {
>          t_atom <http://wiki.gromacs.org/index.php/Gromacs_Intro#t_atom>* atom_info=&mtop <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_mtop_t>->moltype <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_moltype_t>[ mtop <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_mtop_t>->molblock <http://wiki.gromacs.org/index.php/Gromacs_Intro#gmx_molblock_t>[j].type].atoms.atom[l];
>          rvec* atom_position=&state <http://wiki.gromacs.org/index.php/Gromacs_Intro#t_state>->x <http://wiki.gromacs.org/index.php/Gromacs_Intro#X>[index];
>          index++;
>        }
>      }
>     }

That fragment strikes me as close to self-documenting :-P

This data structure corresponds to the [ molecules ] entry in your 
topology. There's an ordered list of molecule types (with numbers of 
each type; "molblock" is roughly synonymous with "molecule type"), and 
for each molecule type an ordered list of atoms. Structure members 
fitting the pattern "nxxx" have the "n" abbreviating "number" and tend 
to refer to the length of a corresponding ordered list - hence their use 
as the control variable in the for loops.

If you follow the links in the original fragment 
(http://wiki.gromacs.org/index.php/Gromacs_Intro#global_index) you'll 
get most of this information laid out.


More information about the gromacs.org_gmx-developers mailing list