Repeated steps for a double for loop

Hello,

I am having difficulty with a double for loop in my code. It functions, but every tenth line of output is repeated in the output file. I am running 10000 steps at a time and saving the results every 1000 steps, for a total of 400000 steps (or until the simulation completes). It appears as though each time it starts the next inner loop, it repeats the calculation for the last step of the previous loop. So steps 10000, 20000, 30000, etc, are calculated twice.

I have attempted to get around this problem, but I haven’t been successful so far. Unfortunately, I can’t share any attachments to show my code/output since I’m a new user, but if anyone has any tips, they would be greatly appreciated.

Thanks!

You can write your code in a comment here but make sure to format it well according to the guidelines, without seeing the code it is difficult to get help. But my guess is that you are repeating a step somewhere.

1 Like

Random_walk.in (1.7 KB)

Okay, I just got upgraded to the next level, so I can add my code now. I tried to make it as simple as possible while still able to run. I have also included an example output file, where you can see the repeated output line every tenth step.

1.output (2.1 KB)

Hope this helps, thank you!

It is missing the data file to actually reproduce what you are doing.

Nevertheless, try to change run 10000 in the inner loop to run 10000 pre no (you probably also want to use “post no” to reduce output).

1 Like