Esempio n. 1
0
############################## 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
ymax = (ymax)*1.1
ymin = (ymin)*1.1
dp.ax1.set_ylim(ymin,ymax)

dp.save_plot(options.pdf_file)

# 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()

#dp.add_plot( what = 'r2', atom_no = 1, smoothen = True, style = { 'color': 'black' } )

dp.ax1.legend(['%d' % (at) for at in include_atoms], loc='upper right', ncol=1, frameon = False)
dp.ax1.set_ylabel(u'$r^2$ [Å]')


#dp.ax1.legend(('All atoms', 'P' % (p1[0],p1[1])), ncol = 2, loc = 'upper left', frameon = False)
#D = dp.get_diffusion_coeff()[0]
#dp.ax1.text(0.95,0.05,'$D$ = %.1f cm$^2$/s' % (D), horizontalalignment='right', verticalalignment='bottom', transform=ax1.transAxes)
#print "Diffusion coefficient:",D,"cm^2/s"


filename = os.path.splitext(os.path.basename(sys.argv[0]))[0] + '.pdf'
dp.save_plot(filename)


Esempio n. 3
0
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
ymax = (ymax) * 1.1
ymin = (ymin) * 1.1
dp.ax1.set_ylim(ymin, ymax)

dp.save_plot(options.pdf_file)