[lammps-users] Not able to access the output of "compute msd" by indices

Dear LAMMPS users,

My code is as follow:
compute 1 all msd
fix 1 ave/time 100 1 100 c_1[4] file msd.txt mode vector

ERROR: Fix ave/time compute does not calculate an array

I changed c_1[4] to c_1 deleting the index. The msd results can be
obtained in msd.txt. But the format is hard to be post-processed as
follow:

# Time-averaged data for fix 3
# TimeStep Number-of-rows
# Row c_1
100 4
1 0.76586
2 0.75768
3 0.778247
4 2.30179
200 4
1 1.49349
2 1.56584
3 1.45978
4 4.51911

What can we do something to rewrite the format of one row like: step
vector[1] vector[2] vector[3] vector[4]?

We read this from the "comput msd" section of the manual:
This compute calculates a global vector of length 4, which can be
accessed by indices 1-4 by any command that uses global vector values
from a compute as input.

Dear LAMMPS users,

My code is as follow:
compute 1 all msd
fix 1 ave/time 100 1 100 c_1[4] file msd.txt mode vector

ERROR: Fix ave/time compute does not calculate an array

I changed c_1[4] to c_1 deleting the index. The msd results can be
obtained in msd.txt. But the format is hard to be post-processed as

i disagree about the hard to process, you
just have to read it in the proper way. it is
a somewhat self-describing format.

follow:

# Time-averaged data for fix 3
# TimeStep Number-of-rows
# Row c_1
100 4
1 0.76586
2 0.75768
3 0.778247
4 2.30179
200 4
1 1.49349
2 1.56584
3 1.45978
4 4.51911

What can we do something to rewrite the format of one row like: step
vector[1] vector[2] vector[3] vector[4]?

this is trivial to do with a little bit of script programming.
here is a simple example in perl that took me 5mins to write.
it should be equally easy to write the equivalent in python
or matlab and then post-process further right away instead
of just writing it back in a different format.

#!/usr/bin/perl -w

while (<>) {
  next if (/^#/);
  next if (/^$/);
  ($step,$num) = split;
  foreach $i (1..num\) \{ &nbsp;&nbsp;&nbsp;&nbsp;_ = <>;
    ($idx,$val) = split;
    $data[$idx] = $val;
  }
  print "$step";
  foreach $i (1..$num) {
    print " $data[$i]";
  }
  print "\n";
}

save it to a file row2col.pl and then do:
perl row2col.pl msd.txt > msd-col.txt

cheers,
    axel.

Dear Dr. Kohlmeyer,

I really appreciate it.

Hongyi