<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
Hello everybody,
<div><br>
</div>
<div>This is my first time to post a message so feel free to comment accordingly. With that said however, let me get right to it.</div>
<div><br>
</div>
<div>i am performing md simulations (GROMACS 4.6.5)&nbsp;using the leap frog integrator. At this point i am not using LINCS but hope to be able to later. Lets just assume that at some point in the simulation i need to scale velocities such that the total energy
 after scaling is equal to some target value. I can do this easily so long as a single processor is used in the simulation. Unfortunately, if i attempt to use parallel processing (domain decomp) my equation for calculating the scaling factor seems to no longer
 work. This should not be the case and leads me to believe i may have misunderstood how gromacs is working.</div>
<div><br>
</div>
<div>I have tried two ways of doing this when domain decomp is used. the first uses dd_partition_system() and is as follows.</div>
<div><br>
</div>
<div>&nbsp;<span style="font-family: Menlo; font-size: 11px; color: rgb(206, 121, 36);">if</span><span style="font-family: Menlo; font-size: 11px;">(DOMAINDECOMP(cr))</span></div>
<div><span style="font-family: Menlo; font-size: 11px;">{</span></div>
<div><span style="font-family: Menlo; font-size: 11px;"><span class="Apple-tab-span" style="white-space:pre"></span></span><span style="font-family: Menlo; font-size: 11px;">dd_collect_state(cr-&gt;dd, state, state_global);</span></div>
<div><font face="Menlo"><span style="font-size: 11px;">}</span></font></div>
<div><font face="Menlo"><span style="font-size: 11px;"><br>
</span></font></div>
<div><font face="Menlo"><span style="font-size: 11px;">if(group_rank == 0)</span></font></div>
<div><font face="Menlo"><span style="font-size: 11px;">{</span></font></div>
<div><font face="Menlo"><span class="Apple-tab-span" style="font-size: 11px; white-space: pre;"></span><span style="font-size: 11px;">calc_scaling_factor(state_global, energy_data); //this function calculates&nbsp;the scaling factor. i believe it is correct.&nbsp;</span></font></div>
<div><font face="Menlo"><span style="font-size: 11px;">}</span></font></div>
<div><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span style="color: rgb(206, 121, 36);">for</span>(i=<span style="color: rgb(195, 55, 32);">0</span>; i&lt;nr_atoms; i&#43;&#43;)</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">{</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre"></span>state_global-&gt;v[i][<span style="color: rgb(195, 55, 32);">0</span>] = scaling_factor*state_global-&gt;v[i][<span style="color: rgb(195, 55, 32);">0</span>];</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre"></span>state_global-&gt;v[i][<font color="#c33720">1</font>] = scaling_factor*state_global-&gt;v[i][<font color="#c33720">1</font>];</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre"></span>state_global-&gt;v[i][<font color="#c33720">2</font>] = scaling_factor*state_global-&gt;v[i][<font color="#c33720">2</font>];</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">}</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">if(DOMAINDECOMP(cr))</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">{</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="Apple-tab-span" style="white-space:pre"></span>dd_partition_system(fplog, step, cr, TRUE,
<span style="color: rgb(195, 55, 32);">1</span>,</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; <span class="Apple-tab-span" style="white-space:pre">
</span>state_global, top_global, ir,</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state, &amp;f, mdatoms, top, fr,</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vsite, shellfc, constr,</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nrnb, wcycle, FALSE);<br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">}</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">I will admit i do not fully understand what all&nbsp;dd_partition_system()&nbsp;does and the parameters it takes in. Thus, i tried to avoid using it by simply having each node scale the velocities for its
 home atoms. Below is sample code from that attempt.</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">
<div style="font-family: Helvetica; font-size: 12px;">&nbsp;<span style="font-family: Menlo; font-size: 11px; color: rgb(206, 121, 36);">if</span><span style="font-family: Menlo; font-size: 11px;">(DOMAINDECOMP(cr))</span></div>
<div style="font-family: Helvetica; font-size: 12px;"><span style="font-family: Menlo; font-size: 11px;">{</span></div>
<div style="font-family: Helvetica; font-size: 12px;"><span style="font-family: Menlo; font-size: 11px;"><span class="Apple-tab-span" style="white-space: pre;"></span></span><span style="font-family: Menlo; font-size: 11px;">dd_collect_state(cr-&gt;dd, state,
 state_global);</span></div>
<div style="font-family: Helvetica; font-size: 12px;"><font face="Menlo"><span style="font-size: 11px;">}</span></font></div>
<div style="font-family: Helvetica; font-size: 12px;"><font face="Menlo"><span style="font-size: 11px;"><br>
</span></font></div>
<div style="font-family: Helvetica; font-size: 12px;"><font face="Menlo"><span style="font-size: 11px;">if(group_rank == 0)</span></font></div>
<div style="font-family: Helvetica; font-size: 12px;"><font face="Menlo"><span style="font-size: 11px;">{</span></font></div>
<div style="font-family: Helvetica; font-size: 12px;"><font face="Menlo"><span class="Apple-tab-span" style="font-size: 11px; white-space: pre;"></span><span style="font-size: 11px;">calc_scaling_factor(state_global, energy_data); //this function calculates&nbsp;the
 scaling factor. i believe it is correct.&nbsp;</span></font></div>
<div style="font-family: Helvetica; font-size: 12px;"><font face="Menlo"><span style="font-size: 11px;">}</span></font></div>
<div><font face="Menlo"><span style="font-size: 11px;"><br>
</span></font></div>
<div><font face="Menlo"><span style="font-size: 11px;">broadcast_scaling_factor(scaling_factor); //This sends the scaling factor to all nodes so they can scale their home atoms velocities accordingly.&nbsp;</span></font></div>
<div><font face="Menlo"><span style="font-size: 11px;"><br>
</span></font></div>
<div>
<div style="margin: 0px;">if(DOMAINDECOMP(cr))</div>
<div style="margin: 0px;">{</div>
</div>
<div style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre"></span><span style="color: rgb(206, 121, 36);">for</span>(i=<span style="color: rgb(195, 55, 32);">0</span>; i&lt;mdatoms[<span style="color: rgb(195, 55, 32);">0</span>].homenr; i&#43;&#43;)</div>
<div style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre"></span>{</div>
<div style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre"></span>state-&gt;v[i][<span style="color: rgb(195, 55, 32);">0</span>] = scaling_factor*state-&gt;v[i][<span style="color: rgb(195, 55, 32);">0</span>];</div>
<div style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre"></span>state-&gt;v[i][<font color="#c33720">1</font>] = scaling_factor*state-&gt;v[i][<font color="#c33720">1</font>];</div>
<div style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre"></span>state-&gt;v[i][<font color="#c33720">2</font>] = scaling_factor*state-&gt;v[i][<font color="#c33720">2</font>];</div>
<div style="margin: 0px;"><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div style="margin: 0px;">}</div>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">Neither of these methods have proved successful. In both cases the total energy after scaling is the same and off slightly from the target value by about 10kj/mol. In the second method I have tested
 that broadcasting of the scaling factor is successful. Since both methods require a global state to be collected and used for calculating the scaling factor i see no reason why the function that calculates this factor would work for the single processor case
 and not the domain decomp one. This leads me to believe that either the dd_collect_state() function is not doing exactly what i think it is, the dd_partition_system() may be working in ways i do not understand or that state-&gt;v[][] may not be the array I need
 to modify. Any help is appreciated.&nbsp;</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">Thanks</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;">Nathan Bernhardt</div>
<div style="margin: 0px; font-size: 11px; font-family: Menlo;"><br>
</div>
</body>
</html>