Modifying Pair Potentials

I want to modify eff to get a new potential style, and I don’t delete the original eff, I first change eff_cut to effmix, both .h and .cpp file, and I don’t change any other things.


when I put both of these files into /src,
1692609303088

and compile, it comes the error:

it says multiple definition of some functions, why, every pair style has some same functions.
pair_eff_cut.cpp (22.5 KB)
pair_eff_cut.h (2.1 KB)
pair_eff_inline.h (28.5 KB)
pair_effmix.cpp (22.5 KB)
pair_effmix.h (2.1 KB)

This is not LAMMPS question, but a C++ one. Without seeing actual files, I can only assume that you have two definitions of LAMMPS_NS::DE1 (and other variables mentioned in the error message): one is in pair_eff_inline.h, the second somewhere in your new code.

1 Like

Sorry to bother you. I’ve uploaded the files, could you please help me to debug.

As @mkanski said, that is really a C++ issue. You must not have the same symbol (i.e. function or global variable) defined in two places. This would happen, for example, if you define functions or variables outside the context of a class without declaring them static (so their scope is limited to their compilation unit). This would, as such, be considered a mistake in the original EFF code, but it didn’t show because there were no multiple pair styles.

Update: for what it is worth, I have updated the src/EFF/pair_eff_inline.h file as in this diff to make it compliant with the programming styles conventions generally applied in LAMMPS (EFF was added to LAMMPS a long time before those conventions were enforced).

2 Likes

Thanks for your help!