Step function not recognised for lepton bond

Hello everyone,

I’m currently using LAMMPS stable version August 2nd 2023 and LEPTON package for my research project. I’m specifically trying to implement a bond with style lepton in the form “k*(step(r-l)); k=2; l=2”, but this gives me the following error “ERROR: getVariableReference: Unknown variable ‘r’ (src/LEPTON/bond_lepton.cpp:187)”.

Other potentials of the same form (e.g. “k*(exp(r-l)); k=2; l=2”) work perfectly fine, and I can’t really find the problem in the source code for lepton bonds. Do you have any idea on what could cause this error?

Thank you and please let me know if any clarification is need,

The derivative of the step function is 0 and thus the Lepton library optimizes the reference to “r” away when creating the expression for the force from the potential and throws an exception when you try to reference it. Hence the error you see. So either there is an error in your input (are you sure your potential is not something like k*r*step(r-l)), or you could just omit this potential and use bond style zero instead. This will affect only the potential energy.

This exception is caught properly in the 7 Feb 2024 release of LAMMPS together with some additional improvements to the LEPTON package. Since this is more a new feature than a bugfix it has not been backported to the stable release.

Thanks for your answer

I checked the potential and seems that every form that includes the step function (even step()) raises the same error.

Seems that in the 7 Feb 2024 release this issue is solved. I’ll probably keep using the newer version from now on.

Thanks for the help