Defining a variable from external data

Hi,

I’m trying to apply a force to a group of particles in my system. This force is dependent on the z-position of the particles. Right now, I have this:

# Apply external force to solute and solvent particles
variable addfx atom 0.1*z
fix addfxfrc upper addforce v_addfx 0.0 0.0

So the force increases linearly as a function of the z-coordinate of all particles in my group ‘upper’.

I’d like to apply a force that doesn’t have a functional form. I have a set of data points for applied force as a function of z. It’d be fine just to linearly interpolate to estimate values between points.

Is something like this possible? I.e. reading values into a variable from some external data file, and then interpolating between points, rather than defining a function? Or would this have to be implemented?

Thanks,
Nick

I am not aware that this kind of functionality exists anywhere in LAMMPS.

How complex is the shape of this data set? Perhaps it can be fit to a polynomial or some other approximation function like a Pade function, then you would have some analytic representation.

It’s not that complex. I could probably fit the dataset pretty easily with a polynomial. Just wanted to see if there was anything like this that exists.

Thanks Axel!