Modifying LAMMPS as a total beginner

Hello all,

I recently started working with LAMMPS for my Brownian Dynamics simulations and I already stumbled upon a limitation regarding the calculation of particle position autocorrelation. While searching for an answer I found this post: Autocorrelation function. There, it is suggested that a user can create his own compute routine by making small modifications to the already existing routines for velocity autocorrelation.

Since it is such a straightforward modification, I thought it would be nice to try to implement it as a first example of extending LAMMPS, and started gathering information on the source code structure in order to better understand how these modifications should be implemented. However, what I cannot seem to find anywhere is what should be done AFTER making these modifications. In the linked post, the answer suggests to “update the internal code”, which means nothing to me. Every tutorial on modifying and extending LAMMPS also seems to avoid describing this kind of “code renewal” procedure, probably assuming it to be very basic knowledge. At this point, I just need this small bit of information that is keeping me from actually modifying the code and checking out the results. Of course, any other suggestion for complete beginners with limited coding experience is more than welcome.

Thank you,

In the documents you have been checking, it is assumed that you already have some experience in C++ programming. It would be a very bad idea to start modifying the LAMMPS source code without any previous experience in C++ programming.

In general, what do you need to do if you have C++ source code and made modifications?

From my limited C++ experience in simple exercises, I understand that after modifying a file, the “make” process that was done during installation has to be done all over again. However, I feel like that is a bit counter-productive and there is a more straightforward way that I am missing.


My programming experience comes mostly from modern Fortran, where one can make changes to (or add new) modules and then just compile those specific modules and link them with the respective libraries. This way, there is no need to “reinstall” the whole source code every time a change is made.

In any case, I understand that I should avoid tampering with the source code. I can compute the position autocorrelation function during post-processing of the results using a different software. The main problem is that I will also have to implement custom potentials in the near future, and I can’t think of an alternative way to do so. I guess that your suggestion is to just start getting some experience with C++ and programming in general.

Edit: I just realized how Cmake works, so my first comment is irrelevant