first_step= int(sys.argv[1])
    print "Starting from step %i" % (first_step)
    if len(sys.argv) > 2:
        last_step = int(sys.argv[2])
        print "Ending at step %i" % (last_step)

# Read trajectory:
traj = read_trajectory(unwrap_pbcs = True, poscar_file = 'POSCAR')
traj.set_selection(first_step, last_step)

# Make plot
dp = DisplacementPlot(traj)
dp.add_plot( what = 'D', atom_no = 0, smoothen = True, linear_fit = False)

#dp.ax1.legend(('All atoms', 'P'), ncol = 1, loc = 'upper left', frameon = False)
D = dp.get_diffusion_coeff([0])[0]


td = np.zeros((D.shape[0],2))
td[:,0] = dp.trajs[0].time
td[:,1] = D
np.savetxt('out.csv',td, delimiter='\t')

Ds = D[-1]
Dm = np.mean(D[:])
dp.ax1.axhline(Dm, color='red')
dp.ax1.text(0.95,0.95,'$D_P$ = %.2e cm$^2$/s' % (Dm), horizontalalignment='right', verticalalignment='top', transform=dp.ax1.transAxes)
print "Diffusion coefficient:",Ds,"cm^2/s"
print "Mean diffusion coefficient:",Dm,"cm^2/s"

ymax = 0
from progressbar import ProgressBar, Percentage, Bar, ETA, FileTransferSpeed, \
     RotatingMarker, ReverseBar, SimpleProgress

from oppvasp.plotutils import DisplacementPlot

dp = DisplacementPlot()
dp.read_trajectory( dir = './' )

# Find the diffusivity of all atoms:
m = 65

D = np.zeros(m)
pbar = ProgressBar(widgets=['Henter diff koeff...',Percentage(),Bar()], maxval = m).start()    
for at in range(m):
    pbar.update(at)
    D[at] = dp.get_diffusion_coeff(at)[0]
pbar.finish()

# Find the 3 atoms with the highest diffusivity:
arg = np.argsort(D)
include_atoms = arg[:-4:-1] # return the last three values (not including -4)


#pbar = ProgressBar(widgets=['Smoothen trajectories...',Percentage(),Bar()], maxval = m).start()    
styles = [ { 'color' : c } for c in ['red','blue','black'] ]
i = 0
for at in include_atoms:
    #pbar.update(at)
    dp.add_plot( what = 'r2', atom_no = at, smoothen = True, style = styles[i] )
    i += 1
#pbar.finish()
示例#3
0
    first_step = int(sys.argv[1])
    print "Starting from step %i" % (first_step)
    if len(sys.argv) > 2:
        last_step = int(sys.argv[2])
        print "Ending at step %i" % (last_step)

# Read trajectory:
traj = read_trajectory(unwrap_pbcs=True, poscar_file='POSCAR')
traj.set_selection(first_step, last_step)

# Make plot
dp = DisplacementPlot(traj)
dp.add_plot(what='D', atom_no=0, smoothen=True, linear_fit=False)

#dp.ax1.legend(('All atoms', 'P'), ncol = 1, loc = 'upper left', frameon = False)
D = dp.get_diffusion_coeff([0])[0]

td = np.zeros((D.shape[0], 2))
td[:, 0] = dp.trajs[0].time
td[:, 1] = D
np.savetxt('out.csv', td, delimiter='\t')

Ds = D[-1]
Dm = np.mean(D[:])
dp.ax1.axhline(Dm, color='red')
dp.ax1.text(0.95,
            0.95,
            '$D_P$ = %.2e cm$^2$/s' % (Dm),
            horizontalalignment='right',
            verticalalignment='top',
            transform=dp.ax1.transAxes)