# About Brownian dynamics simulation

**URL:** <https://gromacs.bioexcel.eu/t/about-brownian-dynamics-simulation/4128>\
**Category:** User discussions\
**Created:** [May 7, 2022, 2:19pm UTC](https://gromacs.bioexcel.eu/t/about-brownian-dynamics-simulation/4128 "2022-05-07T14:19:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![palash](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@palash](https://gromacs.bioexcel.eu/u/palash)\
**Post date:** [May 7, 2022, 2:19pm UTC](https://gromacs.bioexcel.eu/t/about-brownian-dynamics-simulation/4128/1 "2022-05-07T14:19:14Z")

</div>

GROMACS version:5.0.6  
GROMACS modification: No  
How does gromacs fix the temperature of the system in Brownian dynamics simulations? In the .mdp file, I have not provided any thermostats. From the source-code velocity should be in the order of 1/dt. So if I calculate temperature by using 0.5_m_v^2 = (3/2)_kB_T, then the temperature is not being maintained. Please help me to figure out this.

static void do\_update\_bd\_Tconsts(double dt, real friction\_coefficient,  
int ngtc, const real ref\_t[],  
real _rf)  
{  
/_ This is separated from the update below, because it is single threaded \*/  
int gt;

```
if (friction_coefficient != 0)
{
    for (gt = 0; gt < ngtc; gt++)
    {
        rf[gt] = sqrt(2.0*BOLTZ*ref_t[gt]/(friction_coefficient*dt));
    }
}
else
{
    for (gt = 0; gt < ngtc; gt++)
    {
        rf[gt] = sqrt(2.0*BOLTZ*ref_t[gt]);
    }
}

```

}

static void do\_update\_bd(int start, int nrend, double dt,  
ivec nFreeze[],  
real invmass[], unsigned short ptype[],  
unsigned short cFREEZE[], unsigned short cTC[],  
rvec x[], rvec xprime[], rvec v[],  
rvec f[], real friction\_coefficient,  
real _rf, gmx\_int64\_t step, int seed,  
int_ gatindex)  
{  
/\* note – these appear to be full step velocities . . . \*/  
int gf = 0, gt = 0;  
real vn;  
real invfr = 0;  
int n, d;

```
if (friction_coefficient != 0)
{
    invfr = 1.0/friction_coefficient;
}

for (n = start; (n < nrend); n++)
{
    real rnd[3];
    int ng = gatindex ? gatindex[n] : n;

    if (cFREEZE)
    {
        gf = cFREEZE[n];
    }
    if (cTC)
    {
        gt = cTC[n];
    }
    gmx_rng_cycle_3gaussian_table(step, ng, seed, RND_SEED_UPDATE, rnd);
    for (d = 0; (d < DIM); d++)
    {
        if ((ptype[n] != eptVSite) && (ptype[n] != eptShell) && !nFreeze[gf][d])
        {
            if (friction_coefficient != 0)
            {
                vn = invfr*f[n][d] + rf[gt]*rnd[d];
            }
            else
            {
                /* NOTE: invmass = 2/(mass*friction_constant*dt) */
                vn = 0.5*invmass[n]*f[n][d]*dt
                    + sqrt(0.5*invmass[n])*rf[gt]*rnd[d];
            }

            v[n][d] = vn;
            xprime[n][d] = x[n][d]+vn*dt;
        }
        else
        {
            v[n][d] = 0.0;
            xprime[n][d] = x[n][d];
        }
    }
}

```

}

---

<div class="post-metadata">

**Author:** ![hess](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hess/32/416_2.png) [@hess](https://gromacs.bioexcel.eu/u/hess)\
**Post date:** [May 11, 2022, 8:08am UTC](https://gromacs.bioexcel.eu/t/about-brownian-dynamics-simulation/4128/2 "2022-05-11T08:08:55Z")

</div>

There is no velocity in Brownian dynamics.  
The temperature is not maintained, but directly affect the magnitude of the random displacement.  
GROMACS defines a “velocity” in BD as displacement/dt, but this is not really a velocity.

---

<div class="post-metadata">

**Author:** ![palash](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@palash](https://gromacs.bioexcel.eu/u/palash)\
**Post date:** [May 11, 2022, 8:52am UTC](https://gromacs.bioexcel.eu/t/about-brownian-dynamics-simulation/4128/3 "2022-05-11T08:52:41Z")

</div>

> [@palash](#):
>
> `;`

Thanks for the reply.  
Can you kindly help me figure out how the temperature of the system reported in the log file is being calculated?

---

<div class="post-metadata">

**Author:** ![hess](https://dub1.discourse-cdn.com/flex017/user_avatar/gromacs.bioexcel.eu/hess/32/416_2.png) [@hess](https://gromacs.bioexcel.eu/u/hess)\
**Post date:** [May 11, 2022, 9:19am UTC](https://gromacs.bioexcel.eu/t/about-brownian-dynamics-simulation/4128/4 "2022-05-11T09:19:04Z")

</div>

The 'kinetic energy" is computed as: 0.5 sum 0.5 gamma displacement^2 / dt.  
This is not a real kinetic energy, as there are no velocities. But if the integrations is accurate, the computed temperature should be close to the requested temperature.

We should document this in the reference manual.

---

<div class="post-metadata">

**Author:** ![palash](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@palash](https://gromacs.bioexcel.eu/u/palash)\
**Post date:** [May 11, 2022, 11:04am UTC](https://gromacs.bioexcel.eu/t/about-brownian-dynamics-simulation/4128/5 "2022-05-11T11:04:59Z")

</div>

Thank you so much. It’s working perfectly.
