コード例 #1
0
 def __init__(self, DMC_rcfile, NUC_csvfile):
     # read arguments from a file, see more in 'loadfile.py', default DMC_rcfile='DMC.rc'
     # NUC_csvfile is the file of nuclei coordinares ( recommend *.csv format)
     if( os.path.isfile(DMC_rcfile) ):
         self.myload = lf.Load(DMC_rcfile)
         # mass should move in array[0], if for different particles
         self.mass = self.myload.args['mass']
         self.dt = self.myload.args['dt']
         self.calctimes = int( self.myload.args['calctimes'] )
         self.alpha = self.myload.args['alpha']
         self.nelectrons = int( self.myload.args['nelectrons'] )
         self.nnuclei = int( self.myload.args['nnuclei'] )
         self.nwalkers_max = int( self.myload.args['nwalkers_max'] )
         self.nwalkers_initial = int( self.myload.args['nwalkers_initial'] )
         
         self.sigma = np.sqrt( self.dt/self.mass )
         self.nwalkers_current = self.nwalkers_initial
     else:
         print("error, %s doesn't exist"%DMC_rcfile)
         exit()
     
     # read the configuration of nuclei
     # 4-d array note as [mass, x, y, z]
     self.nuclei = np.zeros((self.nnuclei, 4))
     # simply initialze as:
     #   >   self.nuclei[0,:] = [1836, -0.699, 0.000, 0.000]
     #   >   self.nuclei[1,:] = [1836,  0.699, 0.000, 0.000]
     # or may read nuclei coordinates from (csv-like) data-file (for example, named as 'NUC.csv'):
     if( os.path.isfile(NUC_csvfile) ):
         self.nuclei = (pd.read_csv(NUC_csvfile,header=None)).values
     else:
         print("error, %s doesn't exist"%NUC_csvfile)
         exit()
     
     # creat walkers array
     # with array_like_structure:   [ number_of_walker,  number_of_e,  4-d coordinates ]
     self.walkers = np.zeros(( self.nwalkers_max, self.nelectrons, 4))
     # avoid electron too closed for each walker, so we give different electron different positioin 
     #       > alternative to read from an ELE_csvfile
     for i in range(self.nelectrons):
         self.walkers[:,i,0] = 1.000 # electron mass, you can revise for the miu meson-eletron mixture
         self.walkers[:,i,1] = 1.000 * np.cos( np.pi*i/(self.nelectrons) )
         self.walkers[:,i,2] = 1.000 * np.sin( np.pi*i/(self.nelectrons) )
         self.walkers[:,i,3] = 0.000
     
     # creat matrix recording potential
     self.potential = np.zeros((self.nwalkers_max))
     # creat time-potential series
     self.ERseries = np.zeros((self.calctimes))
コード例 #2
0
ファイル: IR.py プロジェクト: XShinHe/PIMDALF
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import sys
import os
import loadfile as lf

print('''
### < by Shin He > this procedure is mainly do with IR calculation of water
### each line should give a/or some statistic quantity at each step
### only one argument need
### make sure _put.in _plot.in here\n
''')
fflg = str(sys.argv[1])  #the filename to plot

myinfo = lf.Load('info.now')
myinfo.add('put.rc')

os.system('\nhead -n 1 %s' % fflg)

a = pd.read_csv(fflg, sep='\s+', header=None, low_memory=False)
if not setinfo.is_number(a.values[0, 0]):
    a = pd.read_csv(fflg, sep='\s+', low_memory=False)
fflg = (fflg.spilt('.', 1))[0]

mtx = a.values.T
x = mtx[0, ]
y = mtx[1:, ]

rangcct = 500000  # the max length for stat
u0ui = np.zeros((rangcct, len(y)))
コード例 #3
0
ファイル: plot.py プロジェクト: XShinHe/MapMD
#!/usr/bin/env python
# coding=utf-8

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import sys
import loadfile as lf

fflg = str(sys.argv[1])  # the filename to plot
clmn = int(sys.argv[2])  # the column to plot

myinfo = lf.Load('map.rc')

a = pd.read_csv(fflg, sep='\s+', header=None)
statname = 'null'
if not lf.is_number(a.values[0, 0]):
    a = pd.read_csv(fflg, sep='\s+')
    statname = str(a.columns.values[clmn])

xs = a.values[:, 0] * myinfo.args['mapdtime']
if (clmn == 0):
    ys = a.values[:, 1:]
else:
    ys = a.values[:, clmn]

if (clmn == 0):
    nclmn = len(ys[0, :])
    for i in range(nclmn):
        plt.plot(xs,
                 ys[:, i],
コード例 #4
0
#!/usr/bin/python3
# Filename: fft.py

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import loadfile as lf

myinfo = lf.Load('_plot.in')
myinfo.add('_put.in')

val=pd.read_csv('.irdat.tmp')
t=val.values.T[0]
cct=val.values.T[1]
t=np.arange(0,len(cct))
print(t,cct)

N=len(cct)
T=len(t)

cw = np.fft.fft(cct)
freq = np.fft.fftfreq(N,d=myinfo.args['dtime'])
print(len(freq),len(cw))
plt.plot(t,cct,'b--',label='cct plot')
#plt.plot(freq,np.abs(cw),'r-',label='fft plot')
plt.legend()
plt.show()
plt.savefig('IR.png')
#f=np.arange(N)/T
#tmp=(1-np.exp(-8*f[0:cut]))/(8*f[0:cut])*cw[0:cut]
#tmp[0]=cw[0]
コード例 #5
0
ファイル: Espec.py プロジェクト: XShinHe/MapMD
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import loadfile as lf

# load argument file
myload = lf.Load('map.rc')

# optimized arguments
timemax = int(1600 / myload.args['mapdtime'])
Ndivide = 1000
sigma = 600

a = pd.read_csv('pj2.dat', sep='\s+', header=None)
a = a.values.T
if (timemax > len(a[0])):
    timemax = len(a[0])

time = a[0, :timemax] * myload.args['mapdtime']
# and add Gauss smooth
real = a[1, :timemax] * np.exp(-time * time /
                               (2 * sigma**2))  # real part of <phi|U|Psi>
imag = a[2, :timemax] * np.exp(-time * time /
                               (2 * sigma**2))  # imaginary part of <phi|U|Psi>

E = np.linspace(-0.03, -0.01, Ndivide + 1)

Et = np.outer(E, time)
expiEt_r = np.cos(Et)
expiEt_i = np.sin(Et)
コード例 #6
0
ファイル: plot.py プロジェクト: XShinHe/PIMDALF
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import sys
import loadfile as lf
import os

# get arguments from terminal
narg = len(sys.argv) - 1
fflg = str(sys.argv[1])  # the filename to plot
clmn = int(sys.argv[2])  # the column to plot

# load the configuration file
if os.path.isfile('./put.rc'):
    myinfo = lf.Load('put.rc')
else:
    print('Warning: put.rc is need in current dir!')
    exit()
if os.path.isfile('./plot.rc'):
    myinfo.Add('plot.rc')
else:
    print('Warning: plot.rc is need in current dir!')
    exit()

# read the data file
a = pd.read_csv(fflg, sep='\s+', header=None)
name = 'Nan'
if not lf.is_number(a.values[0, 0]):
    a = pd.read_csv(fflg, sep='\s+')
    name = str(a.columns.values[clmn])