EOS plot.py

From EVOCD
Jump to: navigation, search

This code plots the difference in the energy values found from DFT and from the chosen EOS using the Evfit routine on data 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.

# -*- coding: utf-8 -*-
# For Parsing Esv files and evfit files into images
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import os

# The values are stored in 2 Columns as:
# Lattice Parameter(angstrom)       energy(eV)
path = os.getcwd()



#######################################################
###                  User Settings                  ###
#######################################################

# Print to screen/pdf or not
write_to_screen = True
print_to_pdf    = True 

#Color options for plots
# Best source for colors = https://xkcd.com/color/rgb/
color1 = '#b66325'  
color2 = '#8b2e16'  
color3 = '#00035b'  

mk_size = 8  # Markersize for plots, larger is bigger
ax_label_size   = 36 # Font size for axis labels
title_font_size = 42 # Font size for table title
marker_type = 'o'  # Type of marker used for plotting google matplotlib for more options

pdf_name = "EOS_comp.pdf"

#Path to files.  the / is for linux. If you are on windows change them to \
EOS1 = open(path+'/1/evfit.1') #
EOS4 = open(path+'/2/evfit.4') #


#######################################################
###            End of  User Settings                ###
#######################################################




#Initializing arrays
A      = [] # array of Lattice Parameter in Angrstrom
E_run  = [] # array of Energy in eV
E_EOS  = [] 
err    = []




line = True
while line:  # looping over all of the lines in the file
    line  = EOS1.readline()
    lines = line.split()
    if lines != []:
        if lines[0] =="A0=":
            A_min1 = float(lines[1])
            K01    = float(lines[3])
            DK01   = float(lines[3])
            D2K01  = float(lines[3])
        if lines[0] =="Emin=":
            Emin1  = float(lines[1])
EOS1.close()


with open(path+'/1/evfit.1') as f:
    for line in f:
        lines = line.split()
        if lines != []:
            if (lines[0] != "A0=") and (lines[0] != "Equation") and (lines[0] != "Emin="):
                A.append((lines[0]))
                E_run.append((lines[1]))
                E_EOS.append((lines[2]))
                err.append((lines[3]))


Ang1     = np.array(A)
QE_soln1 = np.array(E_run)
EOS_soln1= np.array(E_EOS)
ERROR1   = np.array(err)




A      = [] # array of Lattice Parameter in Angrstrom
E_run  = [] # array of Energy in eV
E_EOS  = [] 
err    = []


line = True
while line:  # looping over all of the lines in the file
    line  = EOS4.readline()
    lines = line.split()
    if lines != []:
        if lines[0] =="A0=":
            A_min2 = float(lines[1])
            K02    = float(lines[3])
            DK02   = float(lines[3])
            D2K02  = float(lines[3])
        if lines[0] =="Emin=":
            Emin2  = float(lines[1])
EOS4.close()

with open(path+'/2/evfit.4') as f:
    for line in f:
        lines = line.split()
        if lines != []:
            if (lines[0] != "A0=") and (lines[0] != "Equation") and (lines[0] != "Emin="):
                A.append((lines[0]))
                E_run.append((lines[1]))
                E_EOS.append((lines[2]))
                err.append((lines[3]))

Ang4     = np.array(A)
QE_soln4 = np.array(E_run)
EOS_soln4= np.array(E_EOS)
ERROR4   = np.array(err)



params = {'legend.fontsize': 20,
          'legend.handlelength': 2}




ERR, ax = plt.subplots(figsize = (12,10))
EOS1, = ax.plot(Ang1, ERROR1, marker_type, markersize = mk_size, color = color1)
EOS1 = mpatches.Patch(color='#00035b', label='Birch $1^{st}$ order EOS')

EOS2, = ax.plot(Ang4, ERROR4, marker_type, markersize = mk_size, color = color2)
EOS2 = mpatches.Patch(color='#8b2e16', label='Murnaghan EOS')
plt.legend(handles=[EOS1,EOS2], fontsize = 18)


ax.axhline(linewidth=1, color='k')
ax.set_xlabel('Distance Values ($\AA$)', fontsize = ax_label_size)
ax.set_ylabel('Change in Energy Values ($eV$)' , fontsize = ax_label_size)
ax.set_title('Difference Between DFT and EOS Values', fontsize = title_font_size)
ax.grid(True, linestyle='-.')
ax.tick_params(labelcolor='k', labelsize='large', width=3)



# Printing plots to a .pdf file
if print_to_pdf == True:
    ERR.savefig(pdf_name, bbox_inches = 'tight')

if write_to_screen == True:
    plt.show()





Code: Quantum Espresso

Personal tools
Namespaces

Variants
Actions
home
Materials
Material Models
Design
Resources
Projects
Education
Toolbox