Using Certain Values from files as input in Force Calculation of LAMMPS

Hello everyone,

I wished to calculate forces acting on a granular particle based on certain values that I have calculated and stored in a file (about 10 million values). I was going to calculate force on this particular particle by modifying fix viscous and I have been successful in doing so with constant values which I provide directly in the program(no reading from file). Now in order to read the value from files, I did the following :

  1. In the fix viscous, I read the file directly and read the values

  2. Wrote a python script and created a python variable to read the value. Then I created an atom type variable which could be accessed in fix viscous and force can be calculated.

However, the problem that I am facing in both cases is that only first value is read throughout the simulation and not all. This is due to the reason that the file pointer is reset to zero at every timestep for both the cases. Therefore, I created an atomtype variable that stored the no. of runs and the value was read from the file based on this no. of runs. However, this made the program extremely slow (4-5 times roughly).

Is there a way to access the values in a faster way or to prevent the file pointer from being reset to 0th byte of the file?

Sonu Kumar

3rd Year, Chemical Engineering B’Tech

IIT Guwahati

Hello everyone,

I wished to calculate forces acting on a granular particle based on
certain values that I have calculated and stored in a file (about 10
million values). I was going to calculate force on this particular particle
by modifying fix viscous and I have been successful in doing so with
constant values which I provide directly in the program(no reading from
file). Now in order to read the value from files, I did the following :

1. In the fix viscous, I read the file directly and read the values

2. Wrote a python script and created a python variable to read the value.
Then I created an atom type variable which could be accessed in fix viscous
and force can be calculated.

However, the problem that I am facing in both cases is that only first
value is read throughout the simulation and not all. This is due to the
reason that the file pointer is reset to zero at every timestep for both
the cases. Therefore, I created an atomtype variable that stored the no. of
runs and the value was read from the file based on this no. of runs.
However, this made the program extremely slow (4-5 times roughly).

​the atomfile variable type was created for purposes like this.

axel.​