[gmx-developers] Adding external field to selected atoms

Bappa Ghosh ab54741 at gmail.com
Wed Dec 7 05:34:53 CET 2016

Dear users,
I am trying to add an external field which will add some extra force to my
simulation system for selected atoms.
For that, I was following the "patching mdrun" exercise in

There it tells to replace the function calc_f_el in
gmx/src/mdlib/sim_util.c as follows-

for(i=start; (i<start+homenr); i++) {
  if (x[i][ZZ] < box[ZZ][ZZ]/2) {
   Ext[ZZ] = FIELDFAC*Ex[ZZ].a[0]*2*x[i][ZZ]/box[ZZ][ZZ];
  else {
   Ext[ZZ] = FIELDFAC*Ex[ZZ].a[0]*(1- 2*x[i][ZZ]/box[ZZ][ZZ]);
  f[i][ZZ] += charge[i]*Ext[ZZ];

in order to add an external electric field along Z variable of the box.

My questions are-
1. What are the variables *"start" *and *"homenr" *mean ? I can understand
that they are choosen based on the residues, but not sure how they are
read/connected to my pdb file?
2. In order to add force by the external field to selected atoms, is there
any way to select atoms from the simulation system ( may be from the
index.ndx file ) which can be included here ?

Thank you in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.sys.kth.se/pipermail/gromacs.org_gmx-developers/attachments/20161207/f7c5dfa5/attachment.html>

More information about the gromacs.org_gmx-developers mailing list