Hi Berk,<div><br></div><div>I am mailing about the issue of setting up infinite potential well. </div><div><br></div><div>I now want to simplify the task of inversing the velocity and mirroring the particle by the following procedure. If a particle is found in z&lt;delta then i only change the z-component of the velocity v_z to mod(v_z) . This kind of mimic&#39;s a mirror at z=0 for the velocities. This way, i wont have to worry about the constraints because i never touch the co-ordinates of the particles. I also think that this would work fine with pbc = xyz . </div>
<div><br></div><div>Now i present the part (do_update_md)<span class="Apple-style-span" style="font-family: Monaco; font-size: 10px; "><span class="Apple-style-span" style="font-family: arial; font-size: small; "> of update.c that has to be changed. The bold lines are the ones that i included</span></span></div>
<div><br></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span style="color: #aa0d91">static</span> <span style="color: #aa0d91">void</span> do_update_md(<span style="color: #aa0d91">int</span> start,<span style="color: #aa0d91">int</span> homenr,<span style="color: #aa0d91">double</span> dt,</p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">                         t_grp_tcstat *tcstat,t_grp_acc *gstat,real nh_xi[],</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">                         rvec accel[],ivec nFreeze[],real invmass[],</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">                         <span style="color: #aa0d91">unsigned</span> <span style="color: #aa0d91">short</span> ptype[],<span style="color: #aa0d91">unsigned</span> <span style="color: #aa0d91">short</span> cFREEZE[],</p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">                         <span style="color: #aa0d91">unsigned</span> <span style="color: #aa0d91">short</span> cACC[],<span style="color: #aa0d91">unsigned</span> <span style="color: #aa0d91">short</span> cTC[],</p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">                         rvec x[],rvec xprime[],rvec v[],</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">                         rvec f[],matrix M,bool bExtended)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">  <span style="color: #aa0d91">double</span> imass,w_dt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">  <span style="color: #aa0d91">int</span>    gf=<span style="color: #1c00cf">0</span>,ga=<span style="color: #1c00cf">0</span>,gt=<span style="color: #1c00cf">0</span>;</p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">  rvec   vrel;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">  real   vn,vv,va,vb,vnrel;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">  real   lg,xi,u;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">  <span style="color: #aa0d91">int</span>    n,d;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">  <span style="color: #aa0d91">if</span>(bExtended) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"><span style="color: #000000">    </span>/* Update with coupling to extended ensembles, used for</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400">     * Nose-Hoover and Parrinello-Rahman coupling</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400">     * Nose-Hoover uses the reversible leap-frog integrator from</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400">     * Holian et al. Phys Rev E 52(3) : 2338, 1995</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400">     */</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">    <span style="color: #aa0d91">for</span>(n=start; n&lt;start+homenr; n++) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      imass = invmass[n];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      <span style="color: #aa0d91">if</span> (cFREEZE)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>gf   = cFREEZE[n];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      <span style="color: #aa0d91">if</span> (cACC)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>ga   = cACC[n];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      <span style="color: #aa0d91">if</span> (cTC)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>gt   = cTC[n];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      lg   = tcstat[gt].lambda;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      xi   = nh_xi[gt];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      rvec_sub(v[n],gstat[ga].u,vrel);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      <span style="color: #aa0d91">for</span>(d=<span style="color: #1c00cf">0</span>; d&lt;DIM; d++) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">        <span style="color: #aa0d91">if</span>((ptype[n] != eptVSite) &amp;&amp; (ptype[n] != eptShell) &amp;&amp; !nFreeze[gf][d]) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          vnrel = lg*(vrel[d] + dt*(imass*f[n][d] - <span style="color: #1c00cf">0.5</span>*xi*vrel[d]</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">                                </span>    - iprod(M[d],vrel)))/(<span style="color: #1c00cf">1</span> + <span style="color: #1c00cf">0.5</span>*xi*dt);  </p>

<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"><span style="color: #000000">          </span>/* do not scale the mean velocities u */</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          vn             = gstat[ga].u[d] + accel[ga][d]*dt + vnrel; </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          v[n][d]        = vn;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          xprime[n][d]   = x[n][d]+vn*dt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">        } <span style="color: #aa0d91">else</span> {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>  v[n][d]        = <span style="color: #1c00cf">0.0</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          xprime[n][d]   = x[n][d];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      }</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><b>if(xprime[n][2] &lt; delta) if(v[n][2] &lt; 0) v[n][2] = -v[n][2];</b> </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">    }</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">  } <span style="color: #aa0d91">else</span> {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"><span style="color: #000000">    </span>/* Classic version of update, used with berendsen coupling */</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">    <span style="color: #aa0d91">for</span>(n=start; n&lt;start+homenr; n++) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      w_dt = invmass[n]*dt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      <span style="color: #aa0d91">if</span> (cFREEZE)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>gf   = cFREEZE[n];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      <span style="color: #aa0d91">if</span> (cACC)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>ga   = cACC[n];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      <span style="color: #aa0d91">if</span> (cTC)</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><span class="Apple-tab-span" style="white-space:pre">        </span>gt   = cTC[n];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      lg   = tcstat[gt].lambda;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      <span style="color: #aa0d91">for</span>(d=<span style="color: #1c00cf">0</span>; d&lt;DIM; d++) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">        vn             = v[n][d];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">        <span style="color: #aa0d91">if</span>((ptype[n] != eptVSite) &amp;&amp; (ptype[n] != eptShell) &amp;&amp; !nFreeze[gf][d]) {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          vv             = lg*(vn + f[n][d]*w_dt);</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; color: #007400"><span style="color: #000000">          </span>/* do not scale the mean velocities u */</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          u              = gstat[ga].u[d];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          va             = vv + accel[ga][d]*dt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          vb             = va + (<span style="color: #1c00cf">1.0</span>-lg)*u;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          v[n][d]        = vb;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          xprime[n][d]   = x[n][d]+vb*dt;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">        } <span style="color: #aa0d91">else</span> {</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          v[n][d]        = <span style="color: #1c00cf">0.0</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">          xprime[n][d]   = x[n][d];</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">        }</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">      }</p><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco"><b>if(xprime[n][2] &lt; delta) if(v[n][2] &lt; 0) v[n][2] = -v[n][2];</b> </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">    }</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">  }</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco">}</p><div><font class="Apple-style-span" face="Monaco" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div></div><div><br>
</div><div>I assume that xprime[n][2] and v[n][2] refer to the z-components of position and velocity. xprime means the new co-ordinates. Do you think this change is enough to implement the stuff i was talking about? I must acknowledge that i have very little knowledge about the gromacs codes and my views might be very short sighted. So, please do let me know any of the shortcomings that you notice. </div>
<div><br></div><div>If everything is fine with the above, could you also suggest me how to recompile everything. </div><div><br></div><div>I cannot thank you all enough for helping me out.</div><div><br></div><div>Amit</div>
<div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br><div class="gmail_quote">On Fri, Oct 23, 2009 at 1:09 AM, Berk Hess <span dir="ltr">&lt;<a href="mailto:gmx3@hotmail.com">gmx3@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">



<div>
Hi,<br><br>If you have a wall potential, you can reweight the configurations<br>with weight 0 if one or more particles are beyond the wall<br>and exp(Vwall/kT) if no particles are beyond the wall.<br>This will only work efficiently if you choose the wall potential in a smart way.<br>
I managed to get an efficiency of 70%.<br><br>If you have constraints, an atom that goes beyond the wall is directly<br>coupled to the atoms it is constrained to. You will have to work out<br>the equations for such a situation. It might be as simple that you can<br>
just correct x and v for the atom that went beyond the wall and then<br>apply the constraints as normal.<br><br>Berk<br><br><hr>Date: Fri, 23 Oct 2009 00:26:08 -0700<br>Subject: Re: [gmx-users] Setting up an infinitely hard wall<div>
<div></div><div class="h5"><br>From: <a href="mailto:kgp.amit@gmail.com" target="_blank">kgp.amit@gmail.com</a><br>To: <a href="mailto:gmx-users@gromacs.org" target="_blank">gmx-users@gromacs.org</a><br><br>Hi Berk,<div><br>
</div><div>Thank you for the response.<br><br><div><blockquote style="border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div>I have obtained distributions with in infinite wall by simulating with an softer wall<br>

and unbiasing with configurations with the wall potential.<br></div></blockquote><div><br></div><div>Could you explain the above ? I am not sure if i get your point.</div><div> </div><blockquote style="border-left:1px solid rgb(204, 204, 204);padding-left:1ex">

<div>But if you need the dynamics, or you want less hassle during the simulation,<br>you will have to do a bit more effort in coding an infinitely hard wall.<br><br>You will not only have to inverse the velocity, but also mirror the position<br>

of the particle in the wall. </div></blockquote><div><br></div><div>That&#39;s true. I am sorry i didnt mention that.</div><div> </div><blockquote style="border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div>This should on require a few lines of code in do_update_md<br>in src/mdlib/update.c.<br></div></blockquote><div><br></div><div>Great, I will try this as soon as possible. </div><blockquote style="border-left:1px solid rgb(204, 204, 204);padding-left:1ex">

<div><br>Note that this will only work easily when you do not have constraints present.<br>With constraints things get much more complicated.<br></div></blockquote><div><br></div><div>I do have constraints present. Thank you for pointing this. I am working with SPC water and I should, in principle be able to figure out the co-ordinates of all atoms in the molecule if I am given one of the water&#39;s atom&#39;s co-ordinate. Does that sound ok?</div>

<div><br></div><div>Thanks for the input again,</div><div>Amit</div><div> </div><blockquote style="border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><br>Berk<br><br><hr>Date: Thu, 22 Oct 2009 14:34:06 -0700<br>

From: <a href="mailto:kgp.amit@gmail.com" target="_blank">kgp.amit@gmail.com</a><br>To: <a href="mailto:gmx-users@gromacs.org" target="_blank">gmx-users@gromacs.org</a><br>Subject: [gmx-users] Setting up an infinitely hard wall<div>

<div></div><div><br><br><div>Hi everyone,</div><div><br></div><div>I am sending this email again hoping for any quick input for my question.</div><div><br></div><div>
<br></div><div><div><br></div><div>I have been trying to set up an &quot;infinitely&quot; hard potential wall. </div><div><br></div><div>I tried to use the available wall options and could not really get it to do what i needed. I wanted a steep repulsive potential but when i created that, the system was blowing up, reason being that it requires smaller time step and i cant afford to have smaller time step. </div>



<div><br></div><div>My idea to overcome this issue is to just reverse the velocity of the particle whenever it hits the wall. I am not sure if there is any thing in GROMACS which does this but any suggestions will be very helpful.</div>



<div><br></div><div>If there is nothing set up for something like above, i would like to play around with the code to figure it out. If this is the case, could somebody direct me to a starting point.</div><div><br></div>


<div>
Thank you </div><div>Amit</div>
</div><br>                                               <br></div></div><hr>New Windows 7: Find the right PC for you. <a href="http://windows.microsoft.com/shop" target="_blank">Learn more.</a></div>
<br>_______________________________________________<br>
gmx-users mailing list    <a href="mailto:gmx-users@gromacs.org" target="_blank">gmx-users@gromacs.org</a><br>
<a href="http://lists.gromacs.org/mailman/listinfo/gmx-users" target="_blank">http://lists.gromacs.org/mailman/listinfo/gmx-users</a><br>
Please search the archive at <a href="http://www.gromacs.org/search" target="_blank">http://www.gromacs.org/search</a> before posting!<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-users-request@gromacs.org" target="_blank">gmx-users-request@gromacs.org</a>.<br>
Can&#39;t post? Read <a href="http://www.gromacs.org/mailing_lists/users.php" target="_blank">http://www.gromacs.org/mailing_lists/users.php</a><br></blockquote></div><br></div>                                               <br></div></div><div class="im">
<hr>Express yourself instantly with MSN Messenger! <a href="http://clk.atdmt.com/AVE/go/onm00200471ave/direct/01/" target="_blank">MSN Messenger</a></div></div>
<br>_______________________________________________<br>
gmx-users mailing list    <a href="mailto:gmx-users@gromacs.org">gmx-users@gromacs.org</a><br>
<a href="http://lists.gromacs.org/mailman/listinfo/gmx-users" target="_blank">http://lists.gromacs.org/mailman/listinfo/gmx-users</a><br>
Please search the archive at <a href="http://www.gromacs.org/search" target="_blank">http://www.gromacs.org/search</a> before posting!<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-users-request@gromacs.org">gmx-users-request@gromacs.org</a>.<br>
Can&#39;t post? Read <a href="http://www.gromacs.org/mailing_lists/users.php" target="_blank">http://www.gromacs.org/mailing_lists/users.php</a><br></blockquote></div><br></div>