New fix to be called before integration step

Dear all,

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?

Best,
H.A

What does your input look like?

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.

sorry I thought you’re saying output, here’s my input:

units real
boundary f f f
atom_style molecular

log log-hist.log
read_data hist.txt

include interactions.in

timestep 1e7

neigh_modify delay 0 every 5 check yes

group parts id 1 2
group sites id 3 4

fix xwalls all wall/reflect xlo EDGE xhi EDGE
fix ywalls all wall/reflect ylo EDGE yhi EDGE
fix zwalls all wall/reflect zlo EDGE zhi EDGE

Production

fix 1 parts stochastic/rotation 0 0.15

fix 2 all brownian 300.0 8008 gamma_t 6870.1 rng uniform

thermo 10
dump mydump sites xyz 5 h3-h4.xyz

run 10

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 :grimacing:, 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.

can I message the new fix to you because it is a part of an unpublished work.

ok.

seems that I can’t message you.“Sorry, akohlmey is not accepting messages at the moment.”

How can I reach you out? any email of preference?

try [email protected]

thank you very much, email sent!

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.

yes indeed, totally forgot that, now it’s working as it should.

Thank you very much, really appreciate that.

H.A