Obtaining single-temperature output from temper command

Hi
You can use the attached script for sorting parallel tempering
simulations, if the data is in multi-column text format. (I hesitate
to post. Of coarse, I think it is a good exercise for people/students
who are new to programming to learn to write this script themselves
instead of using mine. It's probably easier to write your own than it
is to read this wordy email.)

The attached python script was not written specifically for LAMMPS.
So you will have to adjust the format of the files which LAMMPS is
generating (see below). The program requires a shell and it uses the
following syntax:

./scramble_columns.py permutation.txt < in_multicolumn_file

The "scramble_columns.py" script does not sort trajectory data.
Instead you must calculate the (observable) quantity you are
interested in and store it in a multi-column text file (format
described below). Then "scramble_columns.py" will sort that file.
This is a very simple script (only a couple lines long after you
remove all the unnecessary docs and comments.)

  --- Input ---

If I understand correctly, when running parallel tempering the LAMMPS
log file contains an integer indicating which temperature the
corresponding replica was at at this moment in time. The
"permutation.txt" contains the columns from the this log file.
(...excluding the first row with T1 T2 T3, and excluding the first
column containing the time step. You have to edit out the first row
and column manually, or change the script to ignore them for you.)

(Permutations can use using 1-indexing or 0-indexing)

The "in_multicolumn_file" file in this example is text file,
containing an observable (measurement) of the system you simulated
measured over time, one line per time snapshot, the observed
measurement for each replica stored as a different number in the same
line (ordered by replica, not temperature).
Format of the in_multicolumn_file:

x_rep1_time1 x_rep2_time1 x_rep3_time1 ...
x_rep2_time2 x_rep2_time2 x_rep3_time2 ...
x_rep3_time3 x_rep2_time3 x_rep3_time3 ...
x_rep4_time4 x_rep2_time4 x_rep3_time4 ...
     :

..This means that the first line would typically contain that the
number you want to observe measured from replica1, then replica2, then
replica3, . (all at the same moment in time), regardless of what
temperatures these replicas were currently at. The next line contains
the same measurements at the next moment in time, sorted by replica,
etc...

example:

76.15 28.94 65.29 82.37 16.69 89.72 16.08 7.50 85.21 37.84 96.23
76.16 14.81 79.95 33.63 51.21 69.72 4.55 48.22 29.21 3.08 12.08
36.31 80.14 26.06 30.78 7.64 97.29 22.24 24.34 31.37 79.84 67.46
28.23 31.16 45.09 58.21 5.12 45.30 65.67 6.00 89.94 97.01 27.23
49.27 29.87 56.04 85.17 64.08 4.75 34.21 56.54 12.21 29.53 3.52

permutation file (example):

0 1 2 3 4 5 6 7 8 9 10
1 0 3 2 5 4 6 7 8 9 10
2 0 4 1 5 3 6 7 8 9 10
2 1 4 0 5 3 6 7 9 8 10
2 1 3 0 6 4 5 7 10 8 9

Be careful to remove blank lines, comments, and non-numeric lines from
both files.

This program sorts the entries in the second file by the integers in
the first file, for example:

76.15 28.94 65.29 82.37 16.69 89.72 16.08 7.50 85.21 37.84 96.23
14.81 76.16 33.63 79.95 69.72 51.21 4.55 48.22 29.21 3.08 12.08
26.06 36.31 7.64 80.14 97.29 30.78 22.24 24.34 31.37 79.84 67.46
45.09 31.16 5.12 28.23 45.30 58.21 65.67 6.00 97.01 89.94 27.23
56.04 29.87 85.17 49.27 34.21 64.08 4.75 56.54 3.52 12.21 29.53

The "unscramble_columns.py" script (also attached) performs the
permutation inverse. So if "unscramble_columns.py" is not doing what
you want, try "scramble_columns.py". You can see what this program
does by running it this way:

./unscramble_columns.py permutation.txt < permutation.txt

you should get:

0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10

Cheers
Andrew

docs_unscramble_columns.txt (834 Bytes)

unscramble_columns.py (3.3 KB)

in_multicolumn_file (322 Bytes)

permutation.txt (115 Bytes)

scramble_columns.py (2.51 KB)

docs_scramble_columns.txt (819 Bytes)