Dump file in a loop

Hi all,

I have some problems while dumping file. I list the part of my input file:

label loop
variable a loop 1 100

variable dumpstep file dump_step.dat
variable dumpnum equal next(dumpstep)
dump 1 all custom 1 ${a}.dump id type xu yu zu
dump_modify 1 every v_dumpnum first yes

run 25000
unfix 1
undump 1

clear
next a
jump in.file loop

dump_step.dat is a list of integers used to specify the timestep for dumping data. When a=1 and the first loop operation is executed, this piece of code works well. I obtained 1.dump (through the command, dump 1 all custom 1 ${a}.dump id type xu yu zu), which is a trajectory containing 60 frames. However, in the subsequent loop operations, 2.dump, 3.dump, and so on, only contain the first initial frame each.

I suspect that the issue arises because when a=2 and the second loop operation is executed, the variable dumpstep is not re-reading values from the beginning of dump_step.dat. Instead, it starts from where a=1 ended and exceeds the total number of run steps.

Could you please take a look at how to fix this issue?

Thanks,
Jiang

You must delete the variable at the end of the loop body, so it will be recreated from scratch at the next iteration.

Thanks for your reply.
But why variable logfreq2 command works. I mean, without deleting the variable.

There is no such command in the input you quoted and without known the details, I cannot comment.

Please see the documentation of the variable command.

Another similar question, please.

My goal is: If I simulate a total of 10 ns and I want to dump data at intervals of 1 ps for the first 1 ns and intervals of 10 ps for the remaining 9 ns, I would need to dump the trajectories with different intervals into two separate files.

It seems that I should turn off unwanted output in the last 9 ns for the first dump (with a 1 ps interval). In other words, I need the opposite of the dump_modify delay command.

Alternatively, could you provide some suggestions to help me achieve my goal?

Thanks

The all-in-one solution would be to use “dump_modify every” with a variable.

The pragmatic solution would be to split your run command in two. That is, define the first dump command, using “run XXX post no” with exactly the number of steps for the first dump file (XXX). Then undump that dump and create a new dump with the different interval. Then use “run ZZZ upto pre no” with the original number of steps and LAMMPS will complete the simulation until step ZZZ is reached. See the documentation of the “run” command for details.

Thanks for your timely reply. Got it!