Code Monkey home page Code Monkey logo

lammps_brownian's Introduction

🟢 Latest version of LAMMPS now contains official fix command for overdamped BD. See here.


This is the custom LAMMPS fix for overdamped Langevin dynamics(Brownian dynamics). LAMMPS has fix langevin for Langevin dynamics simulation. However, the algorithm LAMMPS use to integrate Langevin dynamics equation is Velocity-Verlet. This is not suitable for high friction(overdamped) simulation. Here are several files I modified from original fix_langevin.cpp and some other files to give LAMMPS a fix for overdamped Langevin dynamics simulation. This fix is only suitable for high friction case since velocity is overdamped. For more information and derivation of equation of motions, you can read this blog post as well https://www.guangshi.io/posts/simulating-brownian/

How to use

Build LAMMPS

  1. Put fix_bd.cpp/fix_bd_baoab.cpp and their header files into src folder of LAMMPS.
  2. Build LAMMPS.

Use it in input file

fix ID group-ID bd temperature damp seed
  • ID, group-ID
  • bd = style name of this fix command
  • temperature = desired temperature of run (temperature units)
  • damp = damping parameter (time units)
  • seed = random number seed to use for white noise (positive integer)

Examples

fix 1 all bd 1.00 0.01 324231

Remarks

  • For low friction, please use original fix langevin. As for what value is appropriate for high and low friction, one should do experiments themselves.

  • damp should be much smaller than one. This is to ensure the parameters are indeed for overdamped/high friction/low inertia regime. For instance (with LJ unit for simplicity), damp = 0.01 is sufficiently small for Brownian dynamics simulation. damp = 100 is too large to use this fix. Instead, just use fix langevin for a large value of damp constant.

  • Only fix bd and fix bd/baoab works. Do not use OMP versions.

Other Options

  • fix bd/baoab: BAOAB algorithm for Brownian Dynamics simulation (see https://arxiv.org/abs/1203.5428).
  • fix bd/srk: SRK algorithm for Brownian Dynamics simulation. (discarded)
  • fix bd/omp/fix bd/srk/omp/fix bd/baoab/omp: OMP version of Brownian Dynamics simulation. (discarded)

Reference

  • Leimkuhler, Benedict, and Charles Matthews. "Rational construction of stochastic numerical methods for molecular sampling." Applied Mathematics Research eXpress 2013.1 (2012): 34-56.

lammps_brownian's People

Contributors

anyuzx avatar aortiza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

lammps_brownian's Issues

Mass dependence

I have a question about BD. As long as I know, Brownian Dynamics should be mass-independent. But, when I went through your codes, I found it seems your implementation is mass-dependent (See line 103 of fix_bd.cpp

        randf = sqrt(rmass[i]) * gfactor;
        x[i][0] += dtv * dtfm * (f[i][0]+randf*random->gaussian());
        x[i][1] += dtv * dtfm * (f[i][1]+randf*random->gaussian());
        x[i][2] += dtv * dtfm * (f[i][2]+randf*random->gaussian());

or

line 112

        dtfm = dtf / mass[type[i]];
        randf = sqrt(mass[type[i]]) * gfactor;
        x[i][0] += dtv * dtfm * (f[i][0]+randf*random->gaussian());
        x[i][1] += dtv * dtfm * (f[i][1]+randf*random->gaussian());
        x[i][2] += dtv * dtfm * (f[i][2]+randf*random->gaussian());

).
Have you checked your program with masses other than 1.0? I am not sure if this will work.

Issue with command unfix for the fix bd baoab

I had some issue (segmentation fault) when trying to use the unfix command on the fix bd baoab.
It seems to come from the fact that the memory associated to the quantity rnum cannot be freed.

I managed to solve the issue by adding to the cpp:

FixBDBAOAB::~FixBDBAOAB()
{
  delete random;
  memory->destroy(rnum);
  atom->delete_callback(id,0);
}

In the header file I also changedvirtual ~FixBDBAOAB() {} to virtual ~FixBDBAOAB()

compatibility with enforce2d

have you tested this with enforce2d? I'm finding that my atoms are moving in the z direction with the bd fix, even when I've got enforce2d

fix_bd.o error

HI, I am trying to simulate a chromatin system in the overdamped regime using BD simulation. I have uploaded the fix_bd and fix_bd_baob.cpp and the corresponding header files in the src folder. While building Lammps I am getting the following error:
Can you help me where it goes wrong .It seems force -> numeric is the issue. How to fix this and didnt get much help in google for this

../fix_bd.cpp:45:21: error: ‘class LAMMPS_NS::Force’ has no member named ‘numeric’
t_target = force->numeric(FLERR,arg[3]); // set temperature
^~~~~~~
../fix_bd.cpp:46:21: error: ‘class LAMMPS_NS::Force’ has no member named ‘numeric’
t_period = force->numeric(FLERR,arg[4]); // same as t_period in fix_langevin_overdamp.cpp
^~~~~~~
../fix_bd.cpp:47:17: error: ‘class LAMMPS_NS::Force’ has no member named ‘inumeric’
seed = force->inumeric(FLERR,arg[5]); //seed for random number generator. integer
^~~~~~~~
Makefile:109: recipe for target 'fix_bd.o' failed
make[1]: *** [fix_bd.o] Error 1
make[1]: Leaving directory '/home/vanitha/Downloads/lammps-29oct20/src/Obj_serial'
Makefile:195: recipe for target 'serial' failed
make: *** [serial] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.