Ecut conv.py
From EVOCD
This code plots the values found from the ecut convergence studies from Code: Quantum Espresso simulations.
This code is part of a group of five codes all used for post-processing data from Quantum Espresso simulations.
- The EvA EvV plot.py code generates plots for the energy vs volume and energy vs lattice parameter curves for any set of EvsA an EvsV files generated by the ev_curve.bash script.
- The Convergence plots.py code generates plots for the convergency study from the
SUMMARY
files. - The EOS plot.py code plots the difference in the energy values found from DFT and from the chosen EOS.
- The EOS comp plot.py code plots the energy vs lattice parameter curve from DFT and EOS fitting for multiple equations of state and compares the difference between each equation of state to values found directly from DFT.
- The Ecut conv.py code plots the values found from the ecut convergence studies.
# for ecut convergence study, should be ran from the file where all of the # output files for the ecut convergence study are # Name all output files #.out where # is the energy cutoff value # required imports import numpy as np import matplotlib.pyplot as plt import os # getting the path to the file were all of your ecut convergence studies are path = os.getcwd() ####################################################### ### User Settings ### ####################################################### # Print to screen/pdf or not write_to_screen = True print_to_pdf = True energy_offset = 2858.8298734 # Set by running simulation with very large lattice parameter #Color options for plots # Best source for colors = https://xkcd.com/color/rgb/ color1 = '#b66325' color2 = '#8b2e16' color3 = '#00035b' mk_size = 14 # Markersize for plots, larger is bigger ax_label_size = 24 # Font size for axis labels title_font_size = 30 # Font size for table title marker_type = 'o' # Type of marker used for plotting google matplotlib for more options #cutoff values, change these to match your convergence study cutoff = ['35','40','45','50','55','60','65','70'] ####################################################### ### End of User Settings ### ####################################################### all_lines = [] eng_values = [] tots = [] runs = [] for idx, val in enumerate(cutoff): out = open(os.path.join(path, cutoff[int(idx)]+'.out')) # runs.append(float(cutoff[idx])) eng_values = [] line = True while line: line = out.readline() lines = line.split() if lines != []: if lines[0] =="one-electron": eng_values.append(float(lines[3])) if lines[0] =="hartree": eng_values.append(float(lines[3])) if lines[0] =="xc": eng_values.append(float(lines[3])) if lines[0] =="ewald": eng_values.append(float(lines[3])) if lines[0] =="one-center": eng_values.append(float(lines[4])) if lines[0] =="smearing": eng_values.append(float(lines[4])) sums = sum(eng_values) tots.append(sums) out.close() total_values = np.array(tots) energy_cutoff = np.array(runs) total_values = total_values*13.6056980659 #converting to eV major_ticks = np.arange(-210.42, -210.414, .001) ecut_converge, ax = plt.subplots(figsize = (12,6)) ax.plot(energy_cutoff, total_values, marker_type, markersize = mk_size, color = color3) ax.ticklabel_format(axis='both', style='sci', useOffset=False) ax.set_xlabel('Energy Convergence Cutoff (Ry)', fontsize = ax_label_size) ax.set_ylabel('Total System Energy (eV)' , fontsize = 20) ax.set_yticks(major_ticks) ax.set_title('Energy Cutoff Convergence Study \n', fontsize = title_font_size) ax.grid(True, linestyle='-.') ax.tick_params(labelcolor='k', labelsize=15, width=3) # Printing plots to a .pdf file if print_to_pdf == True: ecut_converge.savefig("Converged_ecut.pdf", bbox_inches = 'tight') # Print to screen if write_to_screen == True: plt.show() |