#!/usr/bin/env python
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 
# vim:fenc=utf-8:et:sw=4:ts=4:sts=4:tw=0

import os, sys
import numpy as np
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'] ]
Esempio n. 2
0
parser.add_option('--poscar', dest = 'poscar_file', default = 'POSCAR', help = 'Input POSCAR')
parser.add_option('-f', '--firststep', metavar='STEP', dest = 'first_step', type='int', default = 1, help = 'First ion step to include')
parser.add_option('-l', '--laststep', metavar='STEP', dest = 'last_step', type='int', default = -1, help = 'Last ion step to include')
parser.add_option('-a', '--atom', metavar='ATOM', dest = 'atom_no', type='int', default = 0, help = 'Index of atom to watch (first index is 0)')
(options, args) = parser.parse_args()

print "Range: %i:%i. Atom: %i" % (options.first_step, options.last_step, options.atom_no)

############################## MAIN SCRIPT ######################################

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

# Make plot
dp = DisplacementPlot(traj)
dp.add_plot( what = 'r2', smoothen = True, style = { 'linestyle' : '--', 'dashes' : (3,1), 'color' : 'black' } ) # avg r^2 for all atoms
#dp.add_plot( what = 'x', atom_no = 0, smoothen = True, linear_fit = True)
dp.add_plot( what = 'r2', atom_no = 0, smoothen = True, linear_fit = False)
#dp.add_plot( what = 'r', atom_no = 0, smoothen = True, linear_fit = True)
#dp.add_plot( what = 'x', atom_no = 0, smoothen = False, style = { 'zorder' : -1, 'alpha': 0.4, 'color': 'gray' } )

ymax = 0
ymin = 0
for p in dp.plotdata:
    ymax_tmp = np.max(p['y'])
    if ymax_tmp > ymax:
        ymax = ymax_tmp
    ymin_tmp = np.min(p['y'])
    if ymin_tmp < ymin:
        ymin = ymin_tmp
Esempio n. 3
0
first_step = 0
last_step = -1
if len(sys.argv) > 1:
    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,
first_step = 0
last_step = -1
if len(sys.argv) > 1:
    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)
Esempio n. 5
0
                  help='Index of atom to watch (first index is 0)')
(options, args) = parser.parse_args()

print "Range: %i:%i. Atom: %i" % (options.first_step, options.last_step,
                                  options.atom_no)

############################## MAIN SCRIPT ######################################

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

# Make plot
dp = DisplacementPlot(traj)
dp.add_plot(what='r2',
            smoothen=True,
            style={
                'linestyle': '--',
                'dashes': (3, 1),
                'color': 'black'
            })  # avg r^2 for all atoms
#dp.add_plot( what = 'x', atom_no = 0, smoothen = True, linear_fit = True)
dp.add_plot(what='r2', atom_no=0, smoothen=True, linear_fit=False)
#dp.add_plot( what = 'r', atom_no = 0, smoothen = True, linear_fit = True)
#dp.add_plot( what = 'x', atom_no = 0, smoothen = False, style = { 'zorder' : -1, 'alpha': 0.4, 'color': 'gray' } )

ymax = 0
ymin = 0
for p in dp.plotdata: