I’ve one Sample that is moving with a specified velocity and my aim is to output a data file when it crosses special locations in the simulation box. I use the bound(Sample,xmin) variable to get the sample xmin dimension and the condition should be when xmin = some defined location.
The if statement does not check for the condition every N steps. It reads the first “xmin” only. So, I’m trying to find a way to make a conditional-every N step check.
as I suspected, the main issue is that you don’t understand the processing of the LAMMPS input script. Like a programming language it is evaluated line by line. So the if statement only applies immediately. all *_style commands as well as dump, compute, fix, region, group will create/replace internally a C++ class instance that will then be referred to or executed during a run or minimize or similar command. you have three options to have actions happening during a run: use the every option to the run command (which will break down the run into even sized chunks and run them individually) or use the fix python/invoke to regularly invoke python command or use the fix halt command to stop the run, do some commands and then continue using the “start and stop or upto options”. python function can issue LAMMPS commands through the python wrapper of the library interface, but commands are disallowed during a run since they often require operations that reinitialize the state of the system, which must not happen during a run.
The fix halt command would do it absolutely. However, I want to capture the whole process in a movie and using fix halt will exit the run and therefore the rendering.
that is not correct. a dump style will hold the file stream open until you issue an undump command or the simulation exits completely and all class instances are deleted.
Another concern is the second run command to continue the simulation, will it start from where the latest position of the sample ?
yes, it will continue as is. if you don’t do any “disruptive” changes, you can use the “pre no” option to run to avoid a full initialization and an additional force evaluation.
in combination with the “upto” and “start/stop” keywords, a run can continue without disruption. please study the details in the run command documentation.
Regards, Apologies if the explanation was not enough. I try to save words so I do not waste the time of the researchers trying to help
sorry, but that is not helping. quite the contrary. if you provide too much information or too many details, it is easy and fast to skip over them. having to speculate and trying to figure out what is going on with limited information and having to play 20 questions to find out the real reason and the motivation is about the most annoying thing when responding to mailing list e-mails. after many years, one can often guess what is going on, but never say with certainty.
in short, when posting to the list with questions about how to operate/use a command or a command not performing as expected also provide the following:
- which LAMMPS version is used (or even better the output of ./lmp -h from the top to the “List of individual style options included…” line.
- what platform/OS this is being run on and what the command line for running LAMMPS is
- a minimal input example that reproduces the issue quickly and without requiring many resources (best modifications made to an existing example of the LAMMPS distribution, so only the modified input file needs to be provided)
- parts the output of that example run where things don’t behave as documented or expected
a more comprehensive list of suggestions for posting to the mailing list is here: https://lammps.sandia.gov/guidelines.html