コード例 #1
0
ファイル: rdf2cdf.py プロジェクト: harryhk/MD-tools
if __name__ == '__main__':
    
    inputP = parseInput(sys.argv[1:] ) 
    paraOpt = '-rdf -o -h   -d  '.split() 

    helpdoc = \
'''
Usage ./prog.py -rdf   ; rdf file 
                -o   ; output cdf ; if no present, sys.stdout 
                -d    ; dimension 
'''

    print_help( inputP, paraOpt, helpdoc ) 

    rdfdata = xvg( inputP['-rdf'] ) 

    r= rdfdata[:,0]
    g= rdfdata[:,1]


    if int( inputP['-d'] )  == 2 :
        cdf = scipy.integrate.cumtrapz( g * 2 * scipy.pi * r , r )
    elif int( inputP['-d'] == 3) :
        pass 
    else:
        print >> sys.stderr, "Dimension not supported"
        sys.exit(1) 
        
    
    if inputP.has_key('-o'):
コード例 #2
0
ファイル: chi_square.py プロジェクト: harryhk/MD-tools
import numpy as np 
from common.lnx_util import parseInput , print_help, xvg 

inputP = parseInput(sys.argv[1:])
paraOpt = ' -fexp  -fsim   '.split()

helpdoc=\
'''
Usage! ./prog.py
       -fexp  file1 ; input file for experimental form factor
       -fsim  file2 ; input file for simulation form factor 
'''

print_help(inputP, paraOpt, helpdoc)

fexp = xvg(inputP['-fexp'])
fsim = xvg(inputP['-fsim'])

chi = 0 
i=0
j=1
for q, fq, fqdelta in fexp:
    # use linear interpolation to find simulated value 
    while not ( fsim[i,0] < q and fsim[j,0] >= q ):
        i+=1
        j+=1

    #print q, fsim[i,0], fsim[j,0]
    fqsim = ((fsim[j,0]-q) * fsim[i,1]  + ( q-fsim[i,0]) * fsim[j,1] )/(fsim[j,0] - fsim[i,0])
    
    tmp = ( (np.abs(fq) - np.abs(fqsim) ) / fqdelta )** 2
コード例 #3
0
if __name__ == '__main__':
    
    inputP = parseInput( sys.argv[1:]  )  

    paraOpt = '-f  -area  -n  -mod -h'.split(' ')
    helpdoc =  'Usage ./prog.py -f box.xvg  ; box information from g_energy \n'\
               '-area 68.0    ;  find most close area per lipid to 68 a^2 \n'\
               '-n  64        ;  number of lipids per leaflet \n'\
               '-mod  10      ;  the frame should also be divided by 10 ps, since we are saving by every 10 ps\n'


    print_help(inputP, paraOpt, helpdoc)


    fin = xvg(inputP['-f']) 
    target = float(inputP['-area'])
    mod = int(inputP['-mod'])
    nlipids = int(inputP['-n'])

    apl = []
    for i in fin:
        apl.append( (i[0], abs(i[1]*i[2]/nlipids*100 - target  )  ) )

    
    apl.sort(key=lambda x:x[1]  ) 
    
    for i , data in enumerate(apl):
        if data[0] % mod == 0:
            print "%d ps, %f" %  (data[0] , data[1])
            break
コード例 #4
0
ファイル: surfTension.py プロジェクト: harryhk/MD-tools
import sys
from common.lnx_util import parseInput , print_help , xvg 

import numpy as np 


inputP = parseInput(sys.argv[1:])
paraOpt = "-f -col -n  -h ".split(' ')

helpdoc = 'Usage ./prog.py  -f file.xvg  ; input \n'\
          '                 -col px py pz lz ; col indx start from 0 \n'\
          '                 -n  2  ; number of surfaces \n'\

print_help(inputP , paraOpt , helpdoc )

data = xvg(inputP['-f'])

colpx, colpy, colpz , collz  = map( int, inputP['-col'] ) 

nsurfs = int( inputP['-n'] )

surfT =  ( data[:, colpz] - ( data[:, colpx] + data[:, colpy] ) / 2.0 ) * data[:, collz]

surfT = surfT / nsurfs ; 

for i in surfT : 
    print "%15.5f" % i