I want to average the property (variable tau_xy_u_35) during the read-data phase of my simulation. Currently, I output the properties for every atom and every time step into a dump file and then use Python to read the file and calculate averages to generate a graph. However, writing the dump file is very time-consuming, so I want to perform the averaging directly in LAMMPS and output only the average of this property.
Specifically, I need to average the shear stresses in the xy direction for all atoms in a dynamic group every 200 steps, over a total of 10,000 steps (50 different time). At the end, I would like to output a single number where the average is computed over all atoms and time steps (i.e., if there are n1 atoms in the dynamic group at the moment1 and n2 atoms in the moment2 and so on to n50 atoms at the moment50, the I want the total average to be calculated over n1+n2+…+n50 data points).
Since my groups are dynamic, I am unsure which LAMMPS commands I should use to achieve this. Any guidance would be greatly appreciated.
Here is a part of my input code:
"
compute stressPerAtom_u_35 myBlockGroup_u_35 stress/atom NULL
compute voronoi_u_35 myBlockGroup_u_35 voronoi/atom
variable tau_xy_u_35 atom c_stressPerAtom_u_35[4]/c_voronoi_u_35[1]/10000
----- run -----
label myLoop
variable i loop 1 1000
print ‘# ----- ${i} started -----’
thermo 1000
fix fixU upHandleGroup move rotate 95 0 0 -1 0 0 {periodOfTorsion}
run {RunLoading}
unfix fixU
write_restart restart.torsion.{runSeries}.{runNumber}.*
fix fixU upHandleGroup move linear 0 0 0
run ${RunRelaxAfter}
write_restart restart.torsion.{runSeries}.{runNumber}.*
print ‘# ----- (${i}) read outputs from here -----’
thermo 100
dump myDumpLight${i} all xyz 1000 dumpL${i}.xyz
dump_modify myDumpLight${i} element Al
dump myDumpStress${i}u_test_35 myBlockGroup_u_35 custom 200 myDumpStress_u_35${i}.coord id v_tau_xy_u_35
run ${RunDataRead}
unfix fixU
write_restart restart.torsion.{runSeries}.{runNumber}.*
undump myDumpLight${i}
undump myDumpStress${i}_u_test_35
print ‘# ----- ${i} done -----’
next i
jump SELF myLoop
"
new 1.txt (1.2 KB)