<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>In fact I need forces and positions of all atoms. The code in groupcoord.c and edsam.c is as cryptic as in md.c for me, unfortunately... <br>My problem now is very simple in fact: I have to distribute global forces from master node (no need to update domain decompositions - just put them to corresponding local f's where they currently belong).<br><br>Regards,<br>Semen <br></div><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><br><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Carsten Kutzner &lt;ckutzne@gwdg.de&gt;<br><b><span style="font-weight: bold;">To:</span></b> Discussion list for GROMACS development
 &lt;gmx-developers@gromacs.org&gt;<br><b><span style="font-weight: bold;">Sent:</span></b> Thu, April 7, 2011 2:45:58 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [gmx-developers] Help needed with hacking mdrun<br></font><br>
Hi, <br><br>if you only need positions and forces of a part of the MD system,<br>you might want to take a look at the flooding code in edsam.c<br>and how it uses the routines in groupcoord.c which can do most<br>of the work for you. do_single_flood takes the node-local <br>positions x and forces f, assembles the positions x of a selected<br>group into a collective ('global') array, deduces forces from<br>it, and applies those to the local f[ ] array. do_edsam does a<br>similar thing, but operates on the positions x[ ].<br><br>Carsten<br><br><br>On Apr 7, 2011, at 11:11 AM, Semen Esilevsky wrote:<br><br>&gt; Dear All,<br>&gt; I need to hack mdrun in rather complex way and need some help from people, who <br>&gt; understand Gromacs internals really well.<br>&gt; My&nbsp; problem is the following. Each N MD steps I want to pass current&nbsp; <br>&gt; coordinates and forces to custom function, which transforms them in a&nbsp; certain <br>&gt; way (doesn't
 matter how at this point). Then I want to pass&nbsp; modified forces and <br>&gt; <br>&gt; coordinates back and continue simulation. Currently I&nbsp; got stuck with domain <br>&gt; decomposition stuff. I figured out how to collect&nbsp; data on master node and pass <br>&gt; it to my function. However,&nbsp; I have no&nbsp; idea how to distribute it back to all <br>&gt; nodes correctly after&nbsp; modification.<br>&gt; Here is my additional code in md.c&nbsp; so far:<br>&gt; <br>&gt; ...<br>&gt; /* ########&nbsp; END FIRST UPDATE STEP&nbsp; ############## */<br>&gt; /* ########&nbsp; If doing VV, we now have v(dt)&nbsp; ###### */<br>&gt; <br>&gt; /* ################## START TRAJECTORY OUTPUT ################# */<br>&gt; <br>&gt; /* Some preparations goes here */<br>&gt; ...<br>&gt; /* Collecting data*/<br>&gt; if (DOMAINDECOMP(cr))<br>&gt;&nbsp; &nbsp; {<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; /*We need to collect x and f only*/<br>&gt;&nbsp; &nbsp; &nbsp;
 &nbsp; dd_collect_vec(cr-&gt;dd,state_local,state_local-&gt;x,state_global-&gt;x);<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; dd_collect_vec(cr-&gt;dd,state_local,f_local,f_global);<br>&gt;&nbsp; &nbsp; }<br>&gt; <br>&gt; if (MASTER(cr))<br>&gt;&nbsp; &nbsp; {<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; printf("Collected %d atoms at step: %d\n",top_global-&gt;natoms,step);<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; /* Actually pass data */<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; pass_to(top_global-&gt;natoms, t, state_global-&gt;x, f_global);<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp;  ...<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; /* Processing data here */<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; ...<br>&gt;&nbsp; &nbsp; &nbsp;  /*&nbsp; Get data back */<br>&gt;&nbsp; &nbsp; &nbsp;  pass_from(state_global-&gt;x, f_global);<br>&gt;&nbsp; &nbsp; }<br>&gt; ...<br>&gt; if (DOMAINDECOMP(cr)){<br>&gt;&nbsp; &nbsp; /* Here I have to redistribute it back from state_global-&gt;x and I'm totally <br>&gt; stuck
 :(&nbsp; */<br>&gt; }<br>&gt; <br>&gt; The problem is that functions like dd_distribute_vector(...) are only used&nbsp; <br>&gt; deep inside domain decomposition code and they use some data structures, which <br>&gt; are not exposed in .h files. <br>&gt; <br>&gt; Is there any other more elegant way of plugging custom code to mdrun?<br>&gt; <br>&gt; Any hints are deeply appreciated!<br>&gt; <br>&gt; Regards,<br>&gt; Semen<br>&gt; -- <br>&gt; gmx-developers mailing list<br>&gt; <a ymailto="mailto:gmx-developers@gromacs.org" href="mailto:gmx-developers@gromacs.org">gmx-developers@gromacs.org</a><br><span>&gt; <a target="_blank" href="http://lists.gromacs.org/mailman/listinfo/gmx-developers">http://lists.gromacs.org/mailman/listinfo/gmx-developers</a></span><br>&gt; Please don't post (un)subscribe requests to the list. Use the <br>&gt; www interface or send it to <a ymailto="mailto:gmx-developers-request@gromacs.org"
 href="mailto:gmx-developers-request@gromacs.org">gmx-developers-request@gromacs.org</a>.<br><br><br>--<br>Dr. Carsten Kutzner<br>Max Planck Institute for Biophysical Chemistry<br>Theoretical and Computational Biophysics<br>Am Fassberg 11, 37077 Goettingen, Germany<br>Tel. +49-551-2012313, Fax: +49-551-2012302<br><span><a target="_blank" href="http://www.mpibpc.mpg.de/home/grubmueller/ihp/ckutzne">http://www.mpibpc.mpg.de/home/grubmueller/ihp/ckutzne</a></span><br><br><br><br><br>--<br>gmx-developers mailing list<br><a ymailto="mailto:gmx-developers@gromacs.org" 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't post (un)subscribe requests to the list. Use the<br>www interface or send it to <a ymailto="mailto:gmx-developers-request@gromacs.org"
 href="mailto:gmx-developers-request@gromacs.org">gmx-developers-request@gromacs.org</a>.<br></div></div>



</div></body></html>