Imposing a potential from discrete grid

Dear LAMMPS users and developers,

I am trying to apply forces to particles based on an external potential (some V(x,y,z)) that is defined on a discrete grid. Is this possible to read in a potential from a file or something like that? Or read in a force (again, defined on a discrete grid)?
I know that fix addforce can apply a force based on some analytical function of space and time, but I don’t have an analytical expression, just numerical data. Is this possible, and if so, how might I do this?

Thanks.

There is no direct way. There is neither a built-in mechanism to read such a grid, nor the functionality to perform an interpolation and apply the resulting forces.

Thus you need to implement this yourself. This could be done in Python using fix python/invoke command — LAMMPS documentation or with a custom fix implemented in C++: 4.7. Writing new styles — LAMMPS documentation, 3.8. Fix styles — LAMMPS documentation

Thanks for your response! I’ll give these a try.