# fix ave/time

Hello all,

First of all excuse me if this question seems too trivial, I have done a good deal of reading and thinking and I have not found where I am failing, so perhaps my understanding of the fix ave/time is not as good as I thought. I want to get the stress in certain region of an atomic system. For that I am using this little fragment of LAMMPS code:

# Per atom stress. [(stress)(volume) per (atom)] = [barA3/atom]

compute strAS1 ASec stress/atom

# Per region stress. [Stress * volume)] = [bar*A3].

compute strAS2 ASec reduce sum c_strAS1[1] c_strAS1[2] c_strAS1[3] c_strAS1[4] c_strAS1[5] c_strAS1[6]

# Stress tensor [GPa]. Volume of the ASec was calculated before

variable Sxx equal (c_strAS2[1]/Volume/(-10000))
variable Syy equal (c_strAS2[2]/Volume/(-10000))
variable Szz equal (c_strAS2[3]/Volume/(-10000))
variable Sxy equal (c_strAS2[4]/Volume/(-10000))
variable Sxz equal (c_strAS2[5]/Volume/(-10000))
variable Syz equal (c_strAS2[6]/Volume/(-10000))

# Printing out results

fix strAS2 ASec ave/time 1 1 10000 c_strAS2[1] c_strAS2[2] c_strAS2[3] c_strAS2[4] c_strAS2[5] c_strAS2[6] title1 " Units: step [fs] - Stress*volume [bar*A^3]" title2 " TimeStep Sxx Syy Szz Sxy Sxz Syz" file strAS2.txt
fix strAS ASec ave/time 1 1 10000 v_Sxx v_Syy v_Szz v_Sxy v_Sxz v_Syz title1 " Units: step [fs] - Stress [GPa]" title2 " TimeStep Sxx Syy Szz Sxy Sxz Syz" file strAS.txt

There are four segments here:
i) a compute to calculate the stress per atom in the region. I understand that this command will generate a 6-element vector for each atom in the region

ii) a compute to add up the stress in the region. I understand that this command will reduce the N stress vectors (one per atom) to one 6-element vector (the stress tensor * volume of the region)

iii) fragment three simply divides by the volume of the region and convert the units

iv) It is intended to save the instantaneous values every 10’000 time steps. I want to create two files so I used two fix ave/time commands.

My problems are these:

1. I would like to have confirmation on my understanding of the compute command. I do not wish the results to mean what I think but I would like to be certain.

2. The fix ave/time commands does create the files I request but those files remain empty after the simulation has runs for 99’000 timesteps. It should write an output every 10’000 but it does not and I can’t see why.

3. The simulation runs until the timeteps is to change from 99’000 to 100’000 then this error message appears:
ERROR: Per-atom virial was not tallied on needed timestep (compute_stress_atom.cpp:98)
and the run stops taking the air out of me and leaving jaded. I know this error is associated with the fix ave/time commands because the runs continues without errors when I comment those two lines; but I don’t see where I am introducing the error.

I thank you a lot for taking time to help.

Regards,

I suggest the following. Change the fix ave/time commands
to "1 1 10" and run for 20 steps.

Verify that you get 2 lines of output in each fix ave/time output file.
Then run again and print the values you are using as inputs to fix ave/time
with your thermo output every step (for 20 steps). If you compare
those values to what is in the averaged output, you can verify
that fix ave/time did what you expect. And you can verify that the computes and
reduces are doing what you expect.

Once all of that works, there is no reason that a 100K step
run with 1 1 10000, should not work exactly the same.

Steve

Thanks Steve.

However one of my problems is that the fix ave/time command does create a file but does not write anything but the header in it. I have also tried writing a simple variable but it does not write its values.

Thanks a lot.

Did you do what I suggested? Namely run fix ave/time 1 1 10
and also print out the values with thermo output that
the fix is processing?

Steve

Steve,

Yes I tried that. However the issue I face is the fix ave/time does not write any results in the output file. Is there any other way to print out the results of a compute or a variable?

Thanks for all the help.

Steve,

Thanks for all your help. I was able to print all the results I needed using the thermo command in custom mode. Everything works well. However, I was not able to figure out why the fix ave/time does not save the result in a file.

Thanks again, and all the best!.

Can you post a simple script (with small data file if needed)
that runs for 20 steps and does not print to the fix ave/time file?

Steve