[lammps-users] Feeding a file containing discrete time vs position data to LAMMPS


I am contacting with the hope of finding a way to feed in a time vs position text file to dictate the position of an atom. The file will have the following structure:

time(s) position(m)
0 0
0.1 0.003
0.2 0.004

I stumbled upon an old answer in the mail list which made use of a variable with file format to achieve this. The solution in that thread was the following:

I am trying to make sense of this when comparing it with documentation. So does the first line assign ‘time’ to variable ‘alphaFile’ and the second line assigns ‘position’ to alpha or am I misunderstanding?

My next concern is that this solution mentions that it must be specified at everytime timestep. Since I’m running millions of timesteps it doesn’t make sense for me to store such a large data file. Is there a method to interpolate between data points?

The previous solution I am referencing is:
https://sourceforge.net/p/lammps/mailman/lammps-users/thread/[email protected]/

Thank you for your time!


this kind of topic has come up in multiple variants on multiple occasions.

detailed information about the file format and the processing of file style variables are in the documentation for the variable command.

if you don’t want to provide a file with an entry for each item, you would have to have some kind of interpolation algorithm. LAMMPS has a few simple ones that are available to equal style variables.
but in all generality and based on some arbitrary tabulated data it could be implemented with a python style variable, that can be used like an equal style variable and you can pass it arguments like the current simulation time or timestep and what specific property or atom you are interested and then you would process this with a custom python script and return the result (which has to be a single number). python style variables can be used everywhere, where you can use equal style variables.

another option would be to use fix python/move