git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14947 f3b2605a-c512-4ea7-a41b-209d697bcdaa
BIN
doc/Manual.pdf
|
@ -1,89 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
function:
|
||||
parse the block of thermo data in a lammps logfile and perform auto- and
|
||||
cross correlation of the specified column data. The total sum of the
|
||||
correlation is also computed which can be converted to an integral by
|
||||
multiplying by the timestep.
|
||||
output:
|
||||
standard output contains column data for the auto- & cross correlations
|
||||
plus the total sum of each. Note, only the upper triangle of the
|
||||
correlation matrix is computed.
|
||||
usage:
|
||||
correlate.py [-c col] <-c col2> <-s max_correlation_time> [logfile]
|
||||
"""
|
||||
import sys
|
||||
import re
|
||||
import array
|
||||
|
||||
# parse command line
|
||||
|
||||
maxCorrelationTime = 0
|
||||
cols = array.array("I")
|
||||
nCols = 0
|
||||
args = sys.argv[1:]
|
||||
index = 0
|
||||
while index < len(args):
|
||||
arg = args[index]
|
||||
index += 1
|
||||
if (arg == "-c"):
|
||||
cols.append(int(args[index])-1)
|
||||
nCols += 1
|
||||
index += 1
|
||||
elif (arg == "-s"):
|
||||
maxCorrelationTime = int(args[index])
|
||||
index += 1
|
||||
else :
|
||||
filename = arg
|
||||
if (nCols < 1): raise RuntimeError, 'no data columns requested'
|
||||
data = [array.array("d")]
|
||||
for s in range(1,nCols) : data.append( array.array("d") )
|
||||
|
||||
# read data block from log file
|
||||
|
||||
start = False
|
||||
input = open(filename)
|
||||
nSamples = 0
|
||||
pattern = re.compile('\d')
|
||||
line = input.readline()
|
||||
while line :
|
||||
columns = line.split()
|
||||
if (columns and pattern.match(columns[0])) :
|
||||
for i in range(nCols):
|
||||
data[i].append( float(columns[cols[i]]) )
|
||||
nSamples += 1
|
||||
start = True
|
||||
else :
|
||||
if (start) : break
|
||||
line = input.readline()
|
||||
print "# read :",nSamples," samples of ", nCols," data"
|
||||
if( maxCorrelationTime < 1): maxCorrelationTime = int(nSamples/2);
|
||||
|
||||
# correlate and integrate
|
||||
|
||||
correlationPairs = []
|
||||
for i in range(0,nCols):
|
||||
for j in range(i,nCols): # note only upper triangle of the correlation matrix
|
||||
correlationPairs.append([i,j])
|
||||
header = "# "
|
||||
for k in range(len(correlationPairs)):
|
||||
i = str(correlationPairs[k][0]+1)
|
||||
j = str(correlationPairs[k][1]+1)
|
||||
header += " C"+i+j+" sum_C"+i+j
|
||||
print header
|
||||
nCorrelationPairs = len(correlationPairs)
|
||||
sum = [0.0] * nCorrelationPairs
|
||||
for s in range(maxCorrelationTime) :
|
||||
correlation = [0.0] * nCorrelationPairs
|
||||
nt = nSamples-s
|
||||
for t in range(0,nt) :
|
||||
for p in range(nCorrelationPairs):
|
||||
i = correlationPairs[p][0]
|
||||
j = correlationPairs[p][1]
|
||||
correlation[p] += data[i][t]*data[j][s+t]
|
||||
output = ""
|
||||
for p in range(0,nCorrelationPairs):
|
||||
correlation[p] /= nt
|
||||
sum[p] += correlation[p]
|
||||
output += str(correlation[p]) + " " + str(sum[p]) + " "
|
||||
print output
|
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 594 KiB |
Before Width: | Height: | Size: 168 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 14 KiB |