Implementation of LJ model driver (LJ__MD_414112407348_003)


I have a question about the implementation of the Lennard Jones model driver: LJ__MD_414112407348_003.
I am modifying the model driver and am stuck on a C++ feature that I do not understand (and therefore cannot extend). I would appreciate any insight on what the intended functionality is as well as what the C++ feature is.

My question focusses on the function LENNARD_JONES_PHI that is defined here using a macro. I have 2 questions

  1. The function is being called with and without passing an argument in the same file (the without case uses a semi-colon in lieu of a double). I am aware of the variadic macros feature in C++ but this doesnt appear to be that, what is the actual feature?
  2. In the equation inside the macro there appears to be no math operator preceding the variable exshift just a blank between the variable and the closing paranthesis, I understand that its the shift parameter so it needs to be added, but how is that being achieved?

Apologies for asking C++ questions in here, but I thought it might be more appropriate than lets say stackoverflow. Let me know if anything above seems unclear.

Appreciate your help!


It’s not a C++ feature, it’s a basic preprocessor behavior (used with a little trick). The preprocessor literally replaces the argument in the code, so here the mathematical arithmetic operator is provided as part of the argument (when the offset is present). When the offset is zero, instead of performing a null operation (adding zero) a semicolon is give as the argument to end the resulting expression.

1 Like

Oh, thats clever, I didnt think of the expression within the function itself being converted that way and forming into branches.
As always thanks for you the help Ryan! Much appreciated