Modify the DPD source code problem

Recently, l am modifying the source code of DPD in LAMMPS to calculate three forces in DPD, including conservative force, dissipative force and random force.l was imitating the format of force written in the code and represented the output of the three forces respectively.However, the resultant force calculated after modifying thecode was not equal to the sum of the three forces.After thinking for a long time, I did notunderstand how to solve this problem.

I have to agree with you. :wink:

Do you know how to solve it?

How could I know? I cannot read minds.

Do you also use the DPD models?

What has that to do with anything?

In your original post your stated that you made modifications to the source code and that after your modification the results did not add up and from that you concluded hat you didn’t understand what you were doing. That I agreed with.

However, since you are not sharing any specific details of what you did and how you determine that things don’t match and so on, how on earth shall anybody be able to explain to you what you did wrong or what you are not understanding.

Perhaps you should read through this writeup to get some idea of how to better communicate in an online forum to get answers to your problem.


I imitate its code to write the three forces and output them separately, but the result of the three component forces is not equal to the resultant force output of the source code, especially the conservative force Fc becomes very large. The result is correct at the beginning of the simulation, perhaps because the particles are not moving, but the next step when the particles are moving, the three components add up to be different from the resultant force.

This is just part of your modifications and doesn’t explain why you are seeing discrepancies. The sum of fpairc, fpaird, and fpairr is obviously fpair.

Most likely there is a mistake in the other parts, e.g. that you are not clearing the force arrays properly or not allocating or outputting them correctly. This is actually not very LAMMPS specific but a question of basic C++ programming skills.

Thank you !