Assigning the value of a variable from a post-processed file

Hope you are doing well. I was wondering if it is possible to assign a value to a variable from a post-processed file?
For instance, I want to define an if command with the statement depending on the diffusion coefficient. The diffusion coefficient is calculated using the MSD results in the post-processing stage.

Thank you in advance,
Arman

Can you specify which kind of workflow you want to execute? It is possible to read the value from an external file, as explained in the documentation:

variable f file values.txt

In addition, you can have a decent value of the diffusion coefficient by computing the slope of the MSD directly in LAMMPS, so perhaps you don’t even need to post-process a simulation to decide how to move forwards.

1 Like

Thanks for the suggestions, should have done a better job reading the LAMMPS documentation!
A simplified case could be modeling a system of LJ particles in the NVT ensemble; I would like to adjust system’s temperature to reach a certain diffusion coefficient. Hence, I want to have an if command can take the diffusion coefficient every Nth timestep and if the diffusion coefficient is still not high enough, increase the system temperature for instance.

You can do simple loop constructs in the LAMMPS input, and for more complex situations you could consider using the LAMMPS python module and python scripting to drive your LAMMPS simulation.

Please note that diffusion coefficients require a sufficiently large sample of data and careful checking of convergence or the result. So basing an automated decision in a loop can be very risky and misleading, if that is not achieved.

1 Like

Thanks a bunch; appreciate the response and suggestions.
I completely agree with your note on the delicacy of calculations and precisely for the same reason, I am trying to perform a more thorough investigation of the MSD results and return the output back into the LAMMPS if statement.