Hi,<div>I am doing on hacking gromacs and, since gromacs code is very complicated, </div><div>in my opinion it is better avoiding to touch so deeply the code.<div><br></div><div>You can do simply writing your own function and executing it after (or before, it depends by the details of your modification)</div>
<div>do_force (in md.c) simply modifying the f vector and printing the output after print_ebin (the function that actually prints results). </div><div>Of course this approach is right just if your modification can be developed as an independent module.</div>
<div><br></div><div>Regarding coordinates, because of domain decomposition, each node can access only to local atom data.</div><div><br></div><div>To obtain the local index starting from the global index,  you need to execute the following code (tested on gromacs 4.5.5):</div>
<div><br></div><div>#include &quot;gmx_ga2la.h&quot;</div><div><br></div><div>int global_index,local_index,cell_id;</div><div>t_commrec *cr;</div><div><br></div><div><div>for(global_index=0;global_index&lt;atom_count; global_index++)</div>
<div>       {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>   cell_id            = cr-&gt;dd-&gt;ga2la-&gt;laa[global_index].cell;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>   local_index   = cr-&gt;dd-&gt;ga2la-&gt;laa[global_index].la;</div>
</div><div><div>          </div><div>          if(cell_id == 0)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>    {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>      //atom global_index is on this node</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>   }</div></div><div>         else</div><div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>    {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>      //atom global_index is NOT on this node</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>   }</div></div></div><div>       }</div><div><br></div><div>you can get the atom_count (total number of atoms) in md.c using:</div><div>state_global-&gt;natoms </div>
<div><br></div><div>I hope I&#39;ve helped you :)</div><div><br></div><div>Francesco</div><div><br></div><div><br></div><div><div class="gmail_quote">2012/8/31 alex.bjorling <span dir="ltr">&lt;<a href="mailto:alex.bjorling@gmail.com" target="_blank">alex.bjorling@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I&#39;m now in the exact same position as Radhakrishna describes here. After<br>
posting the following, I did some more research and now have ways to get<br>
both energy and force from a complicated operation over all coordinates.<br>
<br>
<a href="http://gromacs.5086.n6.nabble.com/Adding-an-artificial-energy-term-for-structure-refinement-tp5000240.html" target="_blank">http://gromacs.5086.n6.nabble.com/Adding-an-artificial-energy-term-for-structure-refinement-tp5000240.html</a><br>

<br>
Has anyone been successful in making these modifications?<br>
<br>
Best,<br>
Alex<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://gromacs.5086.n6.nabble.com/Editing-the-GROMACS-energy-function-tp4669473p5000716.html" target="_blank">http://gromacs.5086.n6.nabble.com/Editing-the-GROMACS-energy-function-tp4669473p5000716.html</a><br>

Sent from the GROMACS Developers Forum mailing list archive at Nabble.com.<br>
<span class="HOEnZb"><font color="#888888">--<br>
gmx-developers mailing list<br>
<a href="mailto:gmx-developers@gromacs.org">gmx-developers@gromacs.org</a><br>
<a href="http://lists.gromacs.org/mailman/listinfo/gmx-developers" target="_blank">http://lists.gromacs.org/mailman/listinfo/gmx-developers</a><br>
Please don&#39;t post (un)subscribe requests to the list. Use the<br>
www interface or send it to <a href="mailto:gmx-developers-request@gromacs.org">gmx-developers-request@gromacs.org</a>.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Cordiali saluti, Dr.Oteri Francesco<br>
</div></div>