avatarBenjamin Obi Tayo Ph.D.

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2542

Abstract

">Band Structure Analysis Using Pylab</h1><p id="d737"><b>Import Necessary Libraries</b></p><div id="cf4d"><pre><span class="hljs-keyword">import</span> pylab <span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd</pre></div><p id="ef44"><b>Import Conduction Band Data</b></p><div id="1efc"><pre><span class="hljs-comment">#import conduction band data: x = crystal momentum; y = energy</span></pre></div><div id="6ea8"><pre><span class="hljs-class"><span class="hljs-keyword">data</span>=pd.read_csv('<span class="hljs-title">c_band</span>.<span class="hljs-title">csv'</span>)</span></pre></div><div id="33f2"><pre><span class="hljs-class"><span class="hljs-keyword">data</span>.head(<span class="hljs-title">n</span>=10)</span></pre></div><figure id="b686"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*j0k3723sYY2Xg4Qqs-K_TA.png"><figcaption><b>Table 1: Conduction band dataset.</b></figcaption></figure><p id="0642"><b>Select x Values in the Vicinity of the Conduction Band Minimum</b></p><div id="bf29"><pre><span class="hljs-class"><span class="hljs-keyword">data</span>=<span class="hljs-keyword">data</span>[(<span class="hljs-title">data</span>.<span class="hljs-title">x</span> >0.82) & (<span class="hljs-title">data</span>.<span class="hljs-title">x</span><1.0)]</span></pre></div><p id="d7b0"><b>Perform Polynomial fit using Pylab</b></p><div id="15ff"><pre><span class="hljs-attribute">Xvals</span><span class="hljs-operator">=</span>data.x</pre></div><div id="cfce"><pre><span class="hljs-attribute">Yvals</span><span class="hljs-operator">=</span>data.y</pre></div><div id="e698"><pre><span class="hljs-attribute">degree</span> <span class="hljs-operator">=</span> <span class="hljs-number">2</span></pre></div><div id="7d97"><pre><span class="hljs-attr">model</span>=pylab.polyfit(Xvals,Yvals,degree)</pre></div><div id="f781"><pre><span class="hljs-attr">estY</span>=pylab.polyval(model,Xvals)</pre></div><p id="5311"><b>Calculate R-squared Value</b></p><div id="be65"><pre>R<span class="hljs-number">2</span> = <span class="hljs-number">1</span> - <span class="hljs-comment">((Yvals-estY)</span><span class="hljs-number">2</span>).sum<span class="hljs-comment">()</span>/<span class="hljs-comment">((Yvals-Yvals.mean()</span>)<span class="hljs-number">2</span>).sum<span class="hljs-comment">()</span></pre></div><p id="11c5"><b>Visualization of Observed and Modeled Data</b></p><div id="8448"><pre><span class="hljs-attribute">pylab</span>.figure(figsize=

Options

(<span class="hljs-number">10</span>,<span class="hljs-number">7</span>))</pre></div><div id="9928"><pre>pylab.scatter(Xvals,Yvals, <span class="hljs-attribute">c</span>=<span class="hljs-string">'b'</span>, <span class="hljs-attribute">label</span>=<span class="hljs-string">'observed'</span>)</pre></div><div id="ad8f"><pre>pylab.plot(Xvals,estY, <span class="hljs-attribute">c</span>=<span class="hljs-string">'r'</span>, <span class="hljs-attribute">label</span>=<span class="hljs-string">'predicted:'</span> + <span class="hljs-string">' R2'</span> <span class="hljs-string">'='</span>+ <span class="hljs-string">' '</span> + str(round(R2,4)))</pre></div><div id="4656"><pre>pylab<span class="hljs-selector-class">.xlabel</span>(<span class="hljs-string">'k (2pi/a)'</span>)</pre></div><div id="e58f"><pre>pylab<span class="hljs-selector-class">.ylabel</span>(<span class="hljs-string">'E (eV)'</span>)</pre></div><div id="600b"><pre><span class="hljs-attribute">pylab</span>.xticks(pylab.arange(<span class="hljs-number">0</span>.<span class="hljs-number">8</span>, <span class="hljs-number">1</span>.<span class="hljs-number">05</span>, <span class="hljs-number">0</span>.<span class="hljs-number">05</span>))</pre></div><div id="d1b8"><pre>pylab.legend(<span class="hljs-attribute">loc</span>=10)</pre></div><div id="ac24"><pre>pylab.<span class="hljs-keyword">show</span>()</pre></div><figure id="7f53"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*l1FCw97vBfAxYtZ6yrurgg.png"><figcaption><b>Figure 2: Parabolic fit of the conduction band of MoS2 crystal.</b></figcaption></figure><p id="8082">In summary, we’ve discussed how linear regression can be used in materials sciences to analyze data generated from computational studies. We’ve seen that the primary factor in determining a good fit to any given data is the validity of the functional form to which you’re fitting. Certainly, theoretical or analytic information about the physical problem should be incorporated into the model whenever it’s available. In this example, a quadratic model was used to fit the data based on our understanding of the nearly-free electron dispersion relationship close to the conduction band minimum. This ensures that the problem of bias-variance trade-off is taken into consideration.</p><p id="d86f">The data set and code for this article can be downloaded from this repository: <a href="https://github.com/bot13956/regression_band_structure">https://github.com/bot13956/regression_band_structure</a>.</p></article></body>

Analyzing the band structure of MoS2 crystal using Pylab | Towards AI

Linear Regression Analysis in Materials Sciences

Analyzing the band structure of MoS2 crystal using Pylab

Parabolic fit of the conduction band of MoS2 crystal.

This code performs linear regression on simulated band structure data for MoS2 crystal. The band structure of MoS2 was calculated in a previous article: Tutorial on Density Functional Theory using quantum espresso.

Figure 1: Band structure of MoS2 crystal using density function theory.

Linear regression analysis can be used to fit a parabola (degree = 2) to the conduction and valence band data in the vicinity of the K point, as shown in Figure 1. This analysis will yield important information about the electron and hole effective masses, which are key transport properties for any semiconducting material. For simplicity, we shall only focus on the conduction band.

For electron effective mass calculations, we use a quadratic (parabolic) fit (degree = 2) for our conduction band data:

where

This is an example where knowledge of the behavior of the dispersion relation in the vicinity of the conduction band minimum (at K point in Figure 1) guides us to choose a quadratic fit. Even though a higher degree polynomial fit, e.g. degree = 4 produces a better accuracy (higher R-squared value), it leads to over fitting of the model, that is a model with no physical interpretation.

The data set and code for this article can be downloaded from this repository: https://github.com/bot13956/regression_band_structure.

Band Structure Analysis Using Pylab

Import Necessary Libraries

import pylab
import pandas as pd

Import Conduction Band Data

#import conduction band data: x = crystal momentum; y = energy
data=pd.read_csv('c_band.csv')
data.head(n=10)
Table 1: Conduction band dataset.

Select x Values in the Vicinity of the Conduction Band Minimum

data=data[(data.x >0.82) & (data.x<1.0)]

Perform Polynomial fit using Pylab

Xvals=data.x
Yvals=data.y
degree = 2
model=pylab.polyfit(Xvals,Yvals,degree)
estY=pylab.polyval(model,Xvals)

Calculate R-squared Value

R2 = 1 - ((Yvals-estY)**2).sum()/((Yvals-Yvals.mean())**2).sum()

Visualization of Observed and Modeled Data

pylab.figure(figsize=(10,7))
pylab.scatter(Xvals,Yvals, c='b', label='observed')
pylab.plot(Xvals,estY, c='r', label='predicted:' + ' R2' '='+ ' ' + str(round(R2,4)))
pylab.xlabel('k (2pi/a)')
pylab.ylabel('E (eV)')
pylab.xticks(pylab.arange(0.8, 1.05, 0.05))
pylab.legend(loc=10)
pylab.show()
Figure 2: Parabolic fit of the conduction band of MoS2 crystal.

In summary, we’ve discussed how linear regression can be used in materials sciences to analyze data generated from computational studies. We’ve seen that the primary factor in determining a good fit to any given data is the validity of the functional form to which you’re fitting. Certainly, theoretical or analytic information about the physical problem should be incorporated into the model whenever it’s available. In this example, a quadratic model was used to fit the data based on our understanding of the nearly-free electron dispersion relationship close to the conduction band minimum. This ensures that the problem of bias-variance trade-off is taken into consideration.

The data set and code for this article can be downloaded from this repository: https://github.com/bot13956/regression_band_structure.

Machine Learning
Linear Regression
Materials Science
Python
Data Analysis
Recommended from ReadMedium