I wanted to ask for your help with a compilation issue. I downloaded the custom-made pair style files pair_type1.cpp and pair_type1.h (I know they do not contain errors because other users successfully use them). I inserted the files in lammps/src directory, added the line ‘#include “pair_type1.h”’ in the file style_pair.h and compiled everything with make clean-all and make mpi. Everything seems to work without errors at this point.
In the system.init file of my simulation directory, I added a line “pair_style type1” and started the simulation, however, log.lammps this immediately gives me an error:
ERROR: Unrecognized pair style ‘type1’ (…/force.cpp:271)
Last command: pair_style type1
Do you know why the error occurs? Did I compile something wrong (please tell me how I can check that if so), or is there some miscommunication between my simulation directory and the lammps source directory?
I am using an old version of lammps (I think 2003) and it was originally successfully compiled through src with “make mpi”
Sorry, but I don’t think anybody here wants to dig this deep and figure out issues with such an old LAMMPS version.
That is not guarantee of not having bugs, it only guarantees that there are no errors in the C++ syntax.
Impossible to know with such an abstract and vague description of the steps you did. Most likely, the compilation was not successful.
Again, impossible to say from remote without full disclosure.
We have a guide for updating sources for the current version, but that only reaches back to changes from 2014. So, as mentioned in the beginning, you are on your own.
Thank you for your reply. Unfortunately, I was not able to find a solution on my own. If I may then ask, what would you do if the lammps version that behaves in a way described above was released after 2014?
If it was me, I would port the pair style to the current version of LAMMPS. Comparing the interfaces and flags to current pair styles and change the code accordingly.
I’ve done this for a few old styles and turned them into plugins at: GitHub - lammps/lammps-plugins: Collection of LAMMPS plugins
These are not part of LAMMPS since they have not been verified and usually are lacking the required documentation. That said, for multiple of those pair styles and fix styles people later volunteered to provide the missing pieces and confirmed their functionality and then those were added to the LAMMPS distribution.
Thank you, I will try that. If I may, I would still like to ask another question.
In your first reply to the claim about other users successfully using the pair_style files, you said “That is not guarantee of not having bugs, it only guarantees that there are no errors in the C++ syntax.”. However, if I put the original .cpp and .h files in the src directory of lammps_2Aug2023 and then try to compile by making /lammps_2Aug2023/build and doing "cmake -D BUILD_MPI=yes -D LAMMPS_EXCEPTIONS=yes -D PKG_ALL=on …/cmake
" and “make -j 4” I am getting the following error:
////lammps_2Aug2023/src/pair_type1.cpp: In member function ‘virtual void LAMMPS_NS::Pairtype1::coeff(int, char**)’:
////lammps_2Aug2023/src/pair_type1.cpp:233:10: error: ‘class LAMMPS_NS::Force’ has no member named ‘bounds’; did you mean ‘bond’?
233 | force->bounds( FLERR, arg[0], atom->ntypes, ilo, ihi );
| ^~~~~~
| bond
////lammps_2Aug2023/src/pair_type1.cpp:234:10: error: ‘class LAMMPS_NS::Force’ has no member named ‘bounds’; did you mean ‘bond’?
234 | force->bounds( FLERR, arg[1], atom->ntypes, jlo, jhi );
| ^~~~~~
| bond
////lammps_2Aug2023/src/pair_type1.cpp:236:23: error: ‘class LAMMPS_NS::Force’ has no member named ‘numeric’
236 | double A = force->numeric( FLERR, arg[2] );
| ^~~~~~~
////lammps_2Aug2023/src/pair_type1.cpp:237:23: error: ‘class LAMMPS_NS::Force’ has no member named ‘numeric’
237 | double r0 = force->numeric( FLERR, arg[3] );
| ^~~~~~~
////lammps_2Aug2023/src/pair_type1.cpp:238:23: error: ‘class LAMMPS_NS::Force’ has no member named ‘numeric’
238 | double B = force->numeric( FLERR, arg[4] );
| ^~~~~~~
////lammps_2Aug2023/src/pair_type1.cpp:239:23: error: ‘class LAMMPS_NS::Force’ has no member named ‘numeric’
239 | double rc = force->numeric( FLERR, arg[5] );
| ^~~~~~~
make[2]: *** [CMakeFiles/lammps.dir/build.make:4489: CMakeFiles/lammps.dir////lammps_2Aug2023/src/pair_type1.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs…
make[1]: *** [CMakeFiles/Makefile2:1020: CMakeFiles/lammps.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
Is this a consequence of not oorting the file, or does this show that there indeed are errors in the code?
I am very sorry, but with my last question I was primarily trying to ask another thing.
My reasoning is: the new version throws an error, the old version does not. All the files that need to get updates in src of the old lammps (based on information online) get the needed updates upon installation. Is there maybe some file that I need to update manually (maybe you know it off the top of your head given your immense experience!) so that when I define “pair_style type1” in the simulation scripts the script can finally recognize the pair style. I really hope this issue is not as complicated as you pointed out.
To add to this, I am very sorry I am not a person with CS background and making your suggested plug-ins as well as being able to troubleshoot is difficult for me. Assuming that you would know the answer to the question in an instant given your expertise, I thought, I would be able to save days of work. If you would like me to pay you for your more thorough advice I would be happy to get that arranged because time is of substantial matter for me. I already asked 5 people (rather experienced users, I could say) before you and nobody was able to help with the issue (pretty sure nobody would know how to handle the plug-in because it is difficult to use, like I mentioned, for non-CS people). I have been trying my best.
I don’t know and I don’t care to figure out an issue with a 20+ year old software.
Please note that I, like almost everybody else responding to questions here, am
volunteering my time and mostly do this with the objective to help moving LAMMPS forward.
What you are asking about is the opposite.
Neither am I. I have been originally educated as a wet lab chemist in analytical organic chemistry. It is a common misconception that you have to be a computer scientist to write (scientific) software. I would claim that very few of the people contributing to LAMMPS have any formal training in C++ programming, but most are self-trained. In my case, I have collected substantial experience in programming long before I went to college and not at all in C++. I have trained myself in C++ and parallel when I was a graduate student to run my analysis of the simulations. The simulation software was written in Fortran and I had learned Fortran as part of my training in Theoretical Chemistry.
At the expense of me spending time on something that I don’t care about and taking time away from something I do care about.
First of all. If you want someone to modify your code to be ported to the current LAMMPS version, you just need somebody with basic C++ knowledge, a bit of common sense, and the available documentation that describes changes and about how pair styles are constructed. This is not really much to ask, so you probably didn’t ask the right people.
Second, you don’t need to create a plugin. I only mentioned the plugin package as this is a place where I forward ported code and I turned them into plugins so people can use them without compiling all of LAMMPS.
If that is the case, I can make a proposal. Please contact me on my personal email address.