[lammps-users] Soft repulsive Gay-Berne potential in LAMMPS

Dear lammps developer,

The lammps version I am using is March 2020.

I am trying to add a potential to lammps. The potential is the Gay-Berne potential but without the part rho^(6) as defined in lammps documentation. In other words, I want to remove the attraction part and keep the repulsive part of the potential which is the term rho^(12). Of course, the other parameters are left as they are defined in LAMMPS.

I have checked the pair style table. I could understand that it can be used for pair interaction that is only a function of the separating distance between two particles. According to my current knowledge, the pair style table cannot be used for the interaction that depends on the distance and quaternions.

Therefore, I am going to download the source code of gay-berne potnetial and try to create my own code for the soft reoulsive gay-berne potential. I hope to succeed in that.

Could you please tell me if there might be any other way where I can use/create a soft repulsive gay-berene potential in lammps apart from modifying the source code ?

Best regards

no, I think you would have to modify the source code. E.g. create a new pair style derived from gayberne. Replace the compute method
with a copied version that turns off the terms you want.


Dear Lammps users,

As it is clear from the first message of the this conversation thread, I am trying to modify the lammps source code for the Gay-Berne potential. I want to make it purely soft repulsive potential by removing the attraction part of the potential which is the term rho^(6) as defined in lammps documentation.

I went to the files “pair_gayberne.h” and “pair_gayberne.cpp” and carried out the following replacements of some lines in both files. Then I rebuilt lammps with new modified gayberne files which have new names “pair_gayberne_rep.h” and “pair_gayberne_rep.cpp”. The replacements are :



I can reply to my email.

I think the data points that appear around r*=r/sigma = [4,6] are due to the periodic boundary condition. My simulation box length was almost equal to the cutoff distance of the potential. In this case, when the two particles get to the boundaries of the simulation box, they will see each other and experience the repulsion force from each other.

However, I would be grateful if someone could tell me whether the way I modified the source code of GayBerne potential makes sense or does not. It is explained in my last email in this thread.


It is near impossible to debug a software based on your say-so. Your descriptions are by necessity vague and since you are insecure about them, nobody else can be certain that you actually did exactly what you described.

In general, the steps and requirements for modifying LAMMPS are described in https://docs.lammps.org/Modify.html
Everything else is primarily a question of knowing C++ sufficiently well and careful debugging of your code (e.g. create multiple trivial inputs where you can compute the results by hand and compare to what LAMMPS computes for forces and torques).