#!/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'] ]
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,