I’m trying to write a new fix to be run ahead of fix_brownin.cpp. Following the doc, I added “initial_integrate” into the setmask() function:
int FixStochasticRotation::setmask() {
int mask = 0;
mask |= FixConst::INITIAL_INTEGRATE;
return mask;
}
then wrote the initial_integrate function like this:
void FixStochasticRotation::initial_integrate() {
std::cout << " ***** got into rotation code *****\n";
Atom *atom = lmp->atom;
double **x = atom->x; // Positions
int *mask = atom->mask;
int nlocal = atom->nlocal;
… the rest
to do some rotations but the simulation doesn’t get into the initial_integrate function? I tried adding print statements in all functions and it’s just the initial_integrate function that doesn’t print out.
Now if I add “end_of_step” function instead of “initial_integrate” it works just fine. I also tried “pre_force” as an alternative to initial_integrate but didn’t make a difference. Also the brownian code uses “initial_integrate” as well, not sure though if it does affect my code or not. Also, in the input file I put the brownian fix does after my fix.
Could you let me know what I might be missing here?
the input looks file but the print statement that I put in the “FixStochasticRotation::initial_integrate()” doesn’t print out. I used iostream library not LAMMPS’s built-in printing function. But I’m running with single CPU so I think it should print out, but for some reason it doesn’t.
I also put a print statement in the brownian code to check the ordering (like which one goes first) but it only shows the print statement in the brownian code, not my fix.
Please see the guidelines post to learn how to correctly quote in the forum.
Next questions to ask would be which version of LAMMPS you are using and how you are building it.
The most common situation explaining what you are seeing would be that there is an error either compiling or linking that you didn’t notice and thus you are still using an older executable without the output.
There’s no attachment , but I’ll try to find it in the forum, thanks for reminding.
It’s 3 Aug 2023 version, I use cmake for building it. Well, I don’t see any warning or error, but not sure if they are suppressed. But I do see these lines at the end of compiling:
…
[ 8%] Built target gitversion
[ 9%] Building CXX object CMakeFiles/lammps.dir/home/hacr6/packages/lammps/src/fix_stochastic_rotation.cpp.o
[ 9%] Linking CXX static library liblammps.a
[100%] Built target lammps
[100%] Linking CXX executable lmp
[100%] Built target lmp
and when doing “ll lmp” in build directory it shows it recently modified.
Then there is nothing else that can be done to help you from remote short of you providing access to the exact files for the new fix you are trying to compile and use.
Please have a look at: 4.3. Code design — LAMMPS documentation
and compare your header with that of other time integration fixes (e.g. fix nve) and have a look at the function prototypes in fix.h as well.
Fix classes are polymorphic and the corresponding member functions must not have overloads, but that is your problem. You have:
int setmask();
void initial_integrate();
but fix nve has:
int setmask() override;
void initial_integrate(int) override;
So in your code the function Fix::initial_integrate(int) is called and not the one in your code.
If you include the “override” property (as required for polymorphic member function in derived classes where the base function is flagged as virtual), then you will get an error during compilation.