Hi, I am a beginner to using LAMMPS & am trying to link LAMMPS for usage in the Unity Game Engine. So far I’ve been able to create dummy functions in C++ LAMMPS and access them in C# through a dll. I’m currently trying to create an instance of LAMMPS that I can use to calculate in real-time through the Unity game loop, but I’m not exactly sure how to do it. I might be misunderstanding the LAMMPS documentation, but I’m not really sure how the C++ api is supposed to be used in the first place, and I find it strange that there doesn’t appear to be much discussion about it online. For example, I see that in the example C++ instantiation code, the dev passes arguments into main – what are the arguments supposed to be in the first place? I’m just overall a bit lost on how to use this API, so I’d appreciate any help, advice, or warnings I could get.
The first thing to do is probably to not try to use C++ but rather use the C-library interface. It is easier to interface to, has a better defined interface for various steps and has a much more stable interface to begin with.
In general, the programming interface documentation is a work in progress and the best way to understand what the C++ API is doing is by looking at the C interface and how it is implemented (in the file library.cpp), but then again, with that you can just go ahead and use the C library interface. I am speaking from personal experience here, since I recently implemented a C++ application that combines LAMMPS with a customized text editor and I also used the C interface instead of the C++ classes, since it is far more straightforward to use.
Which specific example are you referring to? examples/simple/simple.cpp
? The explanations are in the comments. If those are not clear to you, you may have some bigger problems with LAMMPS.
In general, since there is only a partial formal programmer guide in the manual, people are supposed to figure out the details from the comments in the source code.
The basic understanding is that from the library interface (regardless of the language) you are effectively running a “remote controlled” LAMMPS simulation where you can intercept and manipulate data that goes into LAMMPS and comes out of it.
Thus my other recommendation is that before you start to write an interface to LAMMPS you first learn a bit about running LAMMPS on its own; what it can do, how to tell LAMMPS to do things and what the output looks like. If you don’t know these things, lots of comments and helpful advice will pass you by since you won’t understand what it is about.