atom

Contents

Version

2.11

Introduction to the atom struct

The atom struct variable (as in Atomistic Topology Operations in Matlab) is an indexed Matlab struct variable that stores molecule attributes like atomtype names, moleculeID's, atomID's, coordinates and more as indexed fields in the atom struct. A brief list of the atom struct fields are listed below. Normally all strings are cell strings and all numeric variables are double-precision floating-points. Unassigned values are set to 'NaN' or 0 . atom is the default variable name for the atom struct, however any string name (not starting with a numeric value) would also work, like DNA, Ions or Water etc.

Furthermore, different atom structs for instance representing a DNA molecule, a set of counter-ions and solvating waters, can easy be concatenated/appended to each other by issuing:

FullSystem = [DNA Ions Water]; % Caveat: all fields must be the same

However, if one wants to update all the moleculeID's and atomID's, it is recommended to use the update_atom function like this:

FullSystem = update_atom({DNA Ions Water}); % Updating the molid and index fields

If invoking other functions like the bond_angle_atom or similar functions it can also hold other optional fields carrying the bonding and angle info to the nearest neighbours etc, or the mass, charge, bond valence and so on. Since the atom struct is indexed, atom(n) holds the attributes of the n:th particle in the atom struct. Because of indexing, the particles in the atom struct can easily be filtered and manipulated - based on a selection of specific or a range of attributes, like atomtype names, coordinates and so on. A few examples are shown below... see the List_all_functions for all functions that operate on the atom struct. Note that many of these functions also need the often accompaning Box_dim variable.

Default fields

  1. molid (molecule/residue ID number)
  2. resname (molecule/residue name)
  3. type (atomname/type)
  4. fftype (secondary atomname/type)
  5. index number (atomID number)
  6. neigh (holds different subfields)
  7. bond (holds different subfields)
  8. angle (holds different subfields)
  9. x (X-coordinate in Ångström)
  10. y (Y-coordinate in Ångström)
  11. z (Z-coordinate in Ångström)
  12. vx (X-velocity in Ångström/ps)
  13. vy (Y-velocity in Ångström/ps)
  14. vz (Z-velocity in Ångström/ps)

Non default fields that can be set after invoking other functions

atom struct examples

Import some molecule from an .pdb or .gro file with atom=import_atom(filename), then try this some of these or similar commands relevant for your molecule

To find certain atomtypes... can you spot the differences between the different commands?

  1. index=ismember([atom.type],[{'Al' 'Alt' 'Mgo'}]) % gives a binary (1/0) logical array
  2. index=find(ismember([atom.type],[{'Al' 'Alt' 'Mgo'}])) % finds the values of matching indexes
  3. index=strcmp([atom.type],'Al') % try also strncmp or strncmpi?
  4. index=find(strncmpi([atom.type],'al',2) % Will find the indexes of 'Al' 'Alt'

Now create a new atom struct with the selected atomtypes

  1. new_atom=atom(index) % This creates a new_atom struct with the filtered/selected atomtypes

To select atoms/particles/sites based on their coordinates

  1. positive_z_atom = atom([atom.z]>0) % finds all atoms with a positve z-coordinate
  2. inbetween10n20_atom = atom([atom.z]>10&[atom.z]<20) % finds all atoms with a positve z-coordinate
  3. first100_atom = atom(1:100) % finds the first 100 atoms in the atom struct
  4. first100_atom = atom([atom.index]<101) % also finds the first 100 atoms in the atom struct

Replace some atomtype's or resname's

  1. [atom(index).type]=deal({'Mg'})
  2. [atom(index).resname]=deal({'MIN'})

Try this:

atom=import_atom('Ethanol.pdb') % Will also output the Box_dim variable and some other stuff, see the variable explorer
atom=center_atom(atom,Box_dim) % Center the coordinates, i.e. [atom.x|.y|.z]
show_atom(atom,Box_dim,.1,1) % Plot the atom with the Box_dim