def plot_bonds(listabifile, listidtset): pp = PdfPages("bonds.pdf") plt.ioff() if not listidtset: allbonds = get_all_bonds(listabifile) else: allbonds = get_all_bonds(listabifile, listidtset) plt.figure(figsize=(32, 20), dpi=100) plt.subplots_adjust(left=0.05, bottom=0.05, right=0.95, top=0.95, wspace=None, hspace=None) abivar = InputVariables(listabifile[0].get_input_filename()) nbond = len(allbonds[0]) n = 0 for ibond in allbonds: if len(ibond) != nbond: print('ERROR: Number of bonds changed') if not listidtset: print( (listabifile[n].basedir, 'contains', len(ibond), 'bonds')) else: print( (listabifile[n].filename + ':' + listidtset[n], 'contains', len(ibond), 'bonds')) n += 1 iplot = 1 for ibond in range(nbond): plt.subplot(5, 4, iplot) y = [bohr_angstrom * seti[ibond][2] for seti in allbonds] label = abivar.atom_name(seti[ibond][0]) + ' ' + abivar.atom_name( seti[ibond][1]) plt.plot(y, label=label) plt.plot(y, 'ro') iplot += 1 plt.legend() pp.savefig() plt.clf() for ibond in range(nbond): y = [bohr_angstrom * seti[ibond][2] for seti in allbonds] label = abivar.atom_name(seti[ibond][0]) + ' ' + abivar.atom_name( seti[ibond][1]) plt.plot(y, label=label) plt.plot(y, 'ro') plt.text(0.09, y[0] + 0.001, label, size='small') iplot += 1 plt.legend() pp.savefig() pp.close()
def plot_history(abinitfile, dataset=""): history = get_history(abinitfile, dataset) av = InputVariables(abinitfile.get_input_filename()) if dataset == "": filep = abinitfile.basedir + "/" + abinitfile.files['tmpout'] + ".pdf" else: filep = abinitfile.basedir + "/" + abinitfile.files['tmpout'] + "_DS" + str(dataset) + ".pdf" xcart = history.variables['xcart'][:] fcart = history.variables['fcart'][:] # rprimd = history.variables['rprimd'][:] etotal = history.variables['etotal'][:] if 'ekin' in history.variables: ekin = history.variables['ekin'][:] if max(history.variables['ekin'][:]) == 0.0: ekin = None else: ekin = None # Getting Labels of atoms labels = [av.atom_name(i) for i in range(av.get_value('natom', dataset))] znucl = av.get_value('znucl', idtset=dataset) typat = av.get_value('typat', idtset=dataset) bonds = compute_bonds(typat, xcart, znucl) # natom = len(xcart[0]) # ComputeAngles(bonds,natom) plot_history_energy(etotal, ekin, fcart, labels, bonds, filep)
def plot_history(abinitfile, dataset=""): history = get_history(abinitfile, dataset) av = InputVariables(abinitfile.get_input_filename()) if dataset == "": filep = abinitfile.basedir + "/" + abinitfile.files['tmpout'] + ".pdf" else: filep = abinitfile.basedir + "/" + abinitfile.files[ 'tmpout'] + "_DS" + str(dataset) + ".pdf" xcart = history.variables['xcart'][:] fcart = history.variables['fcart'][:] # rprimd = history.variables['rprimd'][:] etotal = history.variables['etotal'][:] if 'ekin' in history.variables: ekin = history.variables['ekin'][:] if max(history.variables['ekin'][:]) == 0.0: ekin = None else: ekin = None # Getting Labels of atoms labels = [av.atom_name(i) for i in range(av.get_value('natom', dataset))] znucl = av.get_value('znucl', idtset=dataset) typat = av.get_value('typat', idtset=dataset) bonds = compute_bonds(typat, xcart, znucl) # natom = len(xcart[0]) # ComputeAngles(bonds,natom) plot_history_energy(etotal, ekin, fcart, labels, bonds, filep)