[gmx-users] Velocities from the .gro file

Eric Smoll ericsmoll at gmail.com
Wed Apr 15 00:26:11 CEST 2020


My knowledge is a bit old.

Tpr files are binary so you cannot read them without a special tool.  In gromacs 2018, there was a tool that would spit out the contents of a tpr file in a readable format.  Execute 
“gmx dump -h” to learn more.

Justin is correct.  There is no tool or file that will allow you to add a constant velocity in the z direction to a set of atoms.  I would suggest writing a program to build a custom gro file from the start that has everything you want.  If that is not possible for you, you could use gen-vel and attempt to export a gro with the resulting velocities at some point afterward (e.g., use gen-vel tpr for a 1 step simulation writing coordinates and velocities to the trr at every step and then extract gro with velocities from the trr).  Then go through the gro file and add a constant z-velocity to all the atoms that need it.  Then read the edited gro file in again and proceed.

-Eric

Sent from my iPhone

> On Apr 14, 2020, at 3:02 PM, Mohamed Abdelaal <m.b.abdelaal at gmail.com> wrote:
> 
> Many thanks Dr. Erik for your reply :)
> 
> 
>> On Tue, Apr 14, 2020 at 11:15 PM Eric Smoll <ericsmoll at gmail.com> wrote:
>> 
>> No problem.
>> 
>> Now it is clear what you are trying to do.  The previous description of
>> your goals did not make much physical sense.  The initial velocities are
>> such that all three dimensions are sampled from the same 3D velocity
>> distribution (gaussian with the same width).  The difference is that there
>> is a constant velocity added in the z-direction so there is net motion in
>> the z-direction.
> 
> 
> 
>> One way to do this is to use gen-vel as usual and just add the constant to
>> the z-coordinate.
>> 
> 
> *Can you please tell me more details how to add the constant to the
> z-coordinate ? If I will generate the velocity from the .mdp file, in which
> file should I add the constant to the z-coordinate ?  *
> 
>> 
> 
> The velocities were probably read in.  By default, the velocities may not
>> be printed in the gro.  What matters is that they were loaded in the tpr.
>> Try a simulation to see if the molecule is moving as expected.
>> 
> 
> I will complete the simulation to the end to check whether or not the
> velocity was added from my .gro file.
> 
> 
>> Alternatively, dump the contents of the tpr and make sure the velocities
>> you created were read in.
>> 
>> Do you mean that I should manually edit the .tpr file ? I have tried to
> open it with text editor but it can't be open.
> 
> 
>> -Eric
>> 
>> On Tue, Apr 14, 2020 at 1:56 PM Mohamed Abdelaal <m.b.abdelaal at gmail.com>
>> wrote:
>> 
>>> Sorry for writing again in the same topic but I couldn't solve
>>> the velocity problem.
>>> 
>>> I am trying to reproduce a paper written by: Claire Tonnel + , Martin
>>> Stroet + , Bertrand Caron, Andrew J. Clulow, Ravi C. R. Nagiri,
>> Alpeshkumar
>>> K. Malde, Paul L. Burn,* Ian R. Gentle, Alan E. Mark,* and Benjamin J.
>>> Powell
>>> Title: Elucidating the Spatial Arrangement of Emitter Molecules in
>> Organic
>>> Light-Emitting Diode Films
>>> 
>>> It was mentioned in the paper that " The molecule was inserted into the
>>> system such that the x and y coordinates of the centre of mass were
>> sampled
>>> from a uniform distribution covering the entire box while the z
>> coordinate
>>> of the centre of mass was set to 2.0 nm above the current surface. The
>>> initial orientation of the molecule was randomised. *The velocities of
>> each
>>> atom within the inserted molecule in x and y were sampled from a Gaussian
>>> distribution with a mean of 0.0 nm/ps and a standard deviation
>> appropriate
>>> for the temperature constant (σ = sqrt(kT/m), where k B is Botzmann’s , T
>>> is the temperature and m is the mass of the atom). The velocities in z
>> were
>>> sampled from the distribution with the same standard deviation as x and y
>>> but with a mean of 0.05 nmps -1 , negative z velocities (molecule moving
>> in
>>> the direction opposite to the surface) were rectified by taking the
>>> absolute value. This ensured all molecules moved toward the surface.*
>>> 
>>> I have read the section 3.4.1 of the manual version 5.1.2 as recommended
>>> above and I have also read all the velocity related topics in the manual
>>> and user guide.
>>> 
>>> (After Dr. Justin and Dr. Eric replies)  I added velocity in my .gro file
>>> and then I inserted the molecule in a box using insert-molecules, However
>>> after the insertion process is completed I opened the output .gro file
>> but
>>> the velocity was not read. This means that I can only generate the
>> velocity
>>> through the .mdp file.
>>> 
>>> If I am going to generate the velocity using my .mdp file, is it possible
>>> to change the standard deviation and the mean ? if yes, how can I modify
>>> them ? (I can't find any way to modify the parameters of the Maxwell
>>> distribution)
>>> 
>>> I want to have velocity distributions with means equal to 0,0,0.5 nmps in
>>> the x,y,z directions respectively.
>>> 
>>> You wrote in your last email that, "A 3D Maxwell Boltzmann velocity
>>> distribution corresponds to three identical gaussian speed distributions
>> in
>>> vx, vy, andvz centered at zero (mean should be zero for vx, vy, vz).
>> Just
>>> change the standard deviation of the velocity distribution sqrt(kT/m) for
>>> each velocity component if you want them to be different.  If you don't
>>> want the mean to be zero for whatever reason, add a constant."
>>> 
>>> If the velocity will not be read from the .gro file where should I add
>> the
>>> constant to change the mean?
>>> 
>>> Many thanks,
>>> Mohamed
>>> 
>>> 
>>> On Thu, Apr 9, 2020 at 5:00 AM Mohamed Abdelaal <m.b.abdelaal at gmail.com>
>>> wrote:
>>> 
>>>> Many thanks for your reply :)
>>>> 
>>>> All your language assumptions are true and that is exactly what I
>> wanted
>>>> to communicate, next time I will try to be more precise and sorry for
>> the
>>>> confusion 😊
>>>> 
>>>> I will read section 3.4.1 again carefully.
>>>> 
>>>> Thanks again and sorry for the inconvenience.
>>>> 
>>>> Mohamed
>>>> 
>>>>> On Thu, Apr 9, 2020 at 04:33 Eric Smoll <ericsmoll at gmail.com> wrote:
>>>>> 
>>>>> On Wed, Apr 8, 2020 at 4:41 PM Mohamed Abdelaal <
>> m.b.abdelaal at gmail.com
>>>> 
>>>>> wrote:
>>>>> 
>>>>>> Many thanks for your reply 😊
>>>>>> 
>>>>>> The limitation in the generate velocity using the .mdp file, is that
>>>>> while
>>>>>> I can generate the velocity from Maxwell distribution,  I will have
>>> the
>>>>>> same velocities in the x, y and z directions.
>>>>>> 
>>>>> 
>>>>> I think you mean "same velocity *distributions* in the x, y, and z
>>>>> directions."  The distributions will be approximately the same but
>> each
>>>>> atom will have a different velocity.
>>>>> 
>>>>>> 
>>>>>> On the other hand, generating the velocity from the .gro file will
>> let
>>>>> me
>>>>>> specify different velocities in the x,y and z directions but they
>> will
>>>>> be
>>>>>> the same velocities for all the atoms (will not be taken from a
>>> maxwell
>>>>>> distribution with variation in the atoms velocities).
>>>>>> 
>>>>> 
>>>>> I think you mean "specify different velocity *distributions* in the x,
>>> y,
>>>>> and z directions"
>>>>> 
>>>>>> 
>>>>>> Is it possible to generate different velocities in the x,y and z
>>>>> directions
>>>>>> 
>>>>> 
>>>>> I think you mean "generate different velocity *distributions* in the
>> x,
>>> y,
>>>>> and z directions."  If so, the answer is obviously yes. Because you
>> can
>>>>> type in each individual vxi, vyi, and vzi for every atom i, you can
>>>>> generate different velocity distributions in the x, y, and z
>> directions.
>>>>> 
>>>>> 
>>>>>> from a maxwell distribution ?
>>>>> 
>>>>> 
>>>>> I am not sure what this part of the sentence means.  If you do what
>> you
>>>>> are
>>>>> suggesting, you will not be working with a maxwell distribution
>> because
>>>>> all
>>>>> three directions should have identical distributions.  See comment
>>> below.
>>>>> If there is another misunderstanding, you need to spend more time
>>> crafting
>>>>> precise sentences to communicate what you are after.
>>>>> 
>>>>> 
>>>>>> (for example the velocities to be taken from
>>>>>> a maxwell distribution with a mean of 0.1 in the x direction and
>> with
>>> a
>>>>>> mean of 0.2 in the y direction and with mean of 0.3 in the z
>>> direction?)
>>>>>> 
>>>>> 
>>>>> In my last email I suggested reading section 3.4.1 of the manual
>> version
>>>>> 5.1.2.  It seems you did not.  A 3D Maxwell Boltzmann velocity
>>>>> distribution
>>>>> corresponds to three identical gaussian speed distributions in vx, vy,
>>> and
>>>>> vz centered at zero (mean should be zero for vx, vy, vz).  Just change
>>> the
>>>>> standard deviation of the velocity distribution sqrt(kT/m) for each
>>>>> velocity component if you want them to be different.  If you don't
>> want
>>>>> the
>>>>> mean to be zero for whatever reason, add a constant.  However, a
>>> non-zero
>>>>> mean for any of the velocity components will generate center of mass
>>>>> motion.  If you want center of mass motion, turn off center of mass
>>> motion
>>>>> removal in the mdp file.
>>>>> 
>>>>> 
>>>>>> Thanks for your help :)
>>>>>> Mohamed
>>>>>> 
>>>>>> On Wed, Apr 8, 2020 at 05:48 Eric Smoll <ericsmoll at gmail.com>
>> wrote:
>>>>>> 
>>>>>>> On Tue, Apr 7, 2020 at 3:38 PM Mohamed Abdelaal <
>>>>> m.b.abdelaal at gmail.com>
>>>>>>> wrote:
>>>>>>> 
>>>>>>>> No, I use the generate velocity option in the .mdp files.
>>>>>>>> 
>>>>>>>> However I want now to assign different velocities in the x,y,z
>>>>>>> directions.
>>>>>>>> Which I thought it could only be done through the .gro file,
>> but I
>>>>>> don't
>>>>>>>> know If I did that, should I change the value of the generate
>>>>> velocity
>>>>>> to
>>>>>>>> be = NO in the .mdp files ? (otherwise I would have generated
>> the
>>>>>>>> velocities twice).
>>>>>>>> 
>>>>>>> 
>>>>>>> That sounds logical.  Set it to no if you provide your own initial
>>>>>>> velocities.
>>>>>>> 
>>>>>>>> 
>>>>>>>> Moreover, if I added the velocities in the .gro file how can I
>>>>> generate
>>>>>>> the
>>>>>>>> velocities in the .gro file from a distribution (Maxwell) with a
>>>>>> specific
>>>>>>>> mean and standard deviation ?
>>>>>>>> 
>>>>>>>> I have tried to search in different sources (the user list,
>>> manual,
>>>>>> user
>>>>>>>> guide, research gate and other platforms) how to solve this
>>> velocity
>>>>>>>> problem but I didn't find a clear way to insert different
>>>>> velocities in
>>>>>>> the
>>>>>>>> x,y,z directions using distribution rater than constant
>>> velocities.
>>>>>>>> 
>>>>>>>> There is a good section on this in the manual.  For example,
>>> section
>>>>>>> 3.4.1
>>>>>>> in the Gromacs 5.1.2 manual.
>>>>>>> 
>>>>>>> Also, you know that the generate velocities option assigns
>>> velocities
>>>>> to
>>>>>>> atoms from an approximate MB distribution at whatever temperature
>>> you
>>>>>>> specify in the MDP file, right?  If I understand you correctly,
>> the
>>>>>>> generate velocities options should do exactly what you want.  With
>>> no
>>>>>> extra
>>>>>>> work.
>>>>>>> 
>>>>>>> 
>>>>>>>> Please guide me how to do it as I am a little bit confused in
>> the
>>>>>>> velocity
>>>>>>>> generation mechanisms.
>>>>>>>> 
>>>>>>>> Many thanks,
>>>>>>>> Mohamed
>>>>>>>> 
>>>>>>>> On Mon, Apr 6, 2020 at 6:19 PM Justin Lemkul <jalemkul at vt.edu>
>>>>> wrote:
>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>>> On 4/6/20 12:16 PM, Mohamed Abdelaal wrote:
>>>>>>>>>> Hello everybody :)
>>>>>>>>>> 
>>>>>>>>>> Can I use the gmx insert-molecules to insert molecules in my
>>> box
>>>>>> with
>>>>>>>>>> velocities by adding the velocities in t
>>>>> <
>>> 
>> https://www.google.com/maps/search/velocities+by+adding+the+velocities+in+t?entry=gmail&source=g
>>>> he
>>>>> .gro file and insert the
>>>>>>>>>> molecules from this .gro file ?
>>>>>>>>> 
>>>>>>>>> Have you tried it?
>>>>>>>>> 
>>>>>>>>> -Justin
>>>>>>>>> 
>>>>>>>>> --
>>>>>>>>> ==================================================
>>>>>>>>> 
>>>>>>>>> Justin A. Lemkul, Ph.D.
>>>>>>>>> Assistant Professor
>>>>>>>>> Office: 301 Fralin Hall
>>>>>>>>> Lab: 303 Engel Hall
>>>>>>>>> 
>>>>>>>>> Virginia Tech Department of Biochemistry
>>>>>>>>> 340 West Campus Dr.
>>>>>>>>> Blacksburg, VA 24061
>>>>>>>>> 
>>>>>>>>> jalemkul at vt.edu | (540) 231-3129
>>>>>>>>> http://www.thelemkullab.com
>>>>>>>>> 
>>>>>>>>> ==================================================
>>>>>>>>> 
>>>>>>>>> --
>>>>>>>>> Gromacs Users mailing list
>>>>>>>>> 
>>>>>>>>> * Please search the archive at
>>>>>>>>> http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List
>>>>> before
>>>>>>>>> posting!
>>>>>>>>> 
>>>>>>>>> * Can't post? Read
>> http://www.gromacs.org/Support/Mailing_Lists
>>>>>>>>> 
>>>>>>>>> * For (un)subscribe requests visit
>>>>>>>>> 
>>>>> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users
>>>>>> or
>>>>>>>>> send a mail to gmx-users-request at gromacs.org.
>>>>>>>>> 
>>>>>>>> --
>>>>>>>> Gromacs Users mailing list
>>>>>>>> 
>>>>>>>> * Please search the archive at
>>>>>>>> http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List
>>> before
>>>>>>>> posting!
>>>>>>>> 
>>>>>>>> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>>>>>>>> 
>>>>>>>> * For (un)subscribe requests visit
>>>>>>>> 
>>> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users
>>>>> or
>>>>>>>> send a mail to gmx-users-request at gromacs.org.
>>>>>>>> 
>>>>>>> --
>>>>>>> Gromacs Users mailing list
>>>>>>> 
>>>>>>> * Please search the archive at
>>>>>>> http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List
>> before
>>>>>>> posting!
>>>>>>> 
>>>>>>> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>>>>>>> 
>>>>>>> * For (un)subscribe requests visit
>>>>>>> 
>> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users
>>> or
>>>>>>> send a mail to gmx-users-request at gromacs.org.
>>>>>>> 
>>>>>> --
>>>>>> Gromacs Users mailing list
>>>>>> 
>>>>>> * Please search the archive at
>>>>>> http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before
>>>>>> posting!
>>>>>> 
>>>>>> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>>>>>> 
>>>>>> * For (un)subscribe requests visit
>>>>>> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users
>> or
>>>>>> send a mail to gmx-users-request at gromacs.org.
>>>>> --
>>>>> Gromacs Users mailing list
>>>>> 
>>>>> * Please search the archive at
>>>>> http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before
>>>>> posting!
>>>>> 
>>>>> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>>>>> 
>>>>> * For (un)subscribe requests visit
>>>>> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or
>>>>> send a mail to gmx-users-request at gromacs.org.
>>>> 
>>>> 
>>> --
>>> Gromacs Users mailing list
>>> 
>>> * Please search the archive at
>>> http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before
>>> posting!
>>> 
>>> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>>> 
>>> * For (un)subscribe requests visit
>>> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or
>>> send a mail to gmx-users-request at gromacs.org.
>> --
>> Gromacs Users mailing list
>> 
>> * Please search the archive at
>> http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before
>> posting!
>> 
>> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
>> 
>> * For (un)subscribe requests visit
>> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or
>> send a mail to gmx-users-request at gromacs.org.
> -- 
> Gromacs Users mailing list
> 
> * Please search the archive at http://www.gromacs.org/Support/Mailing_Lists/GMX-Users_List before posting!
> 
> * Can't post? Read http://www.gromacs.org/Support/Mailing_Lists
> 
> * For (un)subscribe requests visit
> https://maillist.sys.kth.se/mailman/listinfo/gromacs.org_gmx-users or send a mail to gmx-users-request at gromacs.org.


More information about the gromacs.org_gmx-users mailing list