The parameters for the ground-state calculations are the same as before in KS1.py. The parameters for the time-dependent calculations are new. They should be pretty much self- explanatory. The...

Show as much as possible and answer the questions as thoroughly as possible.


The parameters for the ground-state calculations are the same as before in KS1.py. The parameters for the time-dependent calculations are new. They should be pretty much self- explanatory. The parameter PC is a detail of the algorithm for solving the time-dependent Kohn-Sham equation. You can choose PC = 0, 1, 2, ... and it gets more and more accurate, but the calculation will take longer. PC = 1 is usually enough. 1. 2a. 2b. 2c. # This program solves the 1D Kohn-Sham equation for two electrons in a # harmonic-oscillator potential. # #-------------------------------------------------------------------------- NGRID = 81 # number of grid points (always an odd number) XMAX = 5. # the numerical grid goes from -XMAX < x="">< xmax="" kspring="1." #="" spring="" constant="" of="" the="" harmonic="" oscillator="" potential="" a="1." #="" coulomb="" softening="" parameter="" tol="1.e-10" #="" numerical="" tolerance="" (the="" convergence="" criterion)="" mix="0.95" #="" mixing="" parameter="" for="" the="" self-consistency="" iterations="" #--------------------------------------------------------------------------="" #="" dx="2.*XMAX/(NGRID-1)" #="" grid="" spacing="" pi="3.141592653589793" #="" define="" pi="" here="" #="" #="" define="" the="" numerical="" grid="" as="" an="" array="" #="" import="" numpy="" as="" np="" x="np.linspace(-XMAX,XMAX,NGRID)" #="" #="" initialize="" the="" density="" of="" the="" noninteracting="" 1d="" harmonic="" oscillator.="" #="" import="" math="" def="" h(i):="" return="" 2.*math.exp(-i**2)/math.sqrt(pi)="" #="" #="" initialize="" a="" bunch="" of="" arrays="" #="" n="np.zeros(NGRID)" n1="np.zeros(NGRID)" psi="np.zeros(NGRID)" di="np.zeros(NGRID)" vh="np.zeros(NGRID)" vx="np.zeros(NGRID)" vint="np.zeros(NGRID)" mat="np.zeros((NGRID,NGRID))" #="" for="" i="" in="" range(ngrid):="" n[i]="h(x[i])" n1[i]="n[i]" #="" from="" pylab="" import="" *="" plot(x,n)="" #="" #="" define="" the="" quadratic="" function="" of="" the="" spring="" #="" def="" g(i):="" return="" 0.5*kspring*i**2="" #="" #="" three-point="" formula:="" #="" #for="" i="" in="" range(ngrid):="" #="" diag[i]="g(x[i])" +="" 1./dx**2="" #for="" i="" in="" range(ngrid-1):="" #="" mat[i,i+1]="-0.5/DX**2" #="" mat[i+1,i]="-0.5/DX**2" #="" #="" seven-point="" formula:="" #="" for="" i="" in="" range(ngrid):="" di[i]="g(x[i])" +="" 490./(360.*dx**2)="" for="" i="" in="" range(ngrid-1):="" mat[i,i+1]="-270./(360.*DX**2)" mat[i+1,i]="-270./(360.*DX**2)" for="" i="" in="" range(ngrid-2):="" mat[i,i+2]="27./(360.*DX**2)" mat[i+2,i]="27./(360.*DX**2)" for="" i="" in="" range(ngrid-3):="" mat[i,i+3]="-2./(360.*DX**2)" mat[i+3,i]="-2./(360.*DX**2)" #="" #="" we="" will="" need="" numerical="" integration="" routines.="" #="" from="" scipy.integrate="" import="" simps="" #="" integration="" with="" simpson's="" rule="" from="" scipy.integrate="" import="" quad="" #="" integration="" with="" gaussian="" quadrature="" from="" scipy.special="" import="" kn="" #="" the="" modified="" bessel="" functions="" #------------------------------------------------------------------------="" #="" here="" is="" the="" start="" of="" the="" self-consistency="" loop.="" we="" initialize="" the="" #="" energy="" as="" that="" of="" two="" noninteacting="" electrons="" in="" a="" 1d="" harmonic="" potential="" #------------------------------------------------------------------------="" crit="1." eks_previous="math.sqrt(KSPRING)" counter="0" while="" crit=""> TOL: counter += 1 print(counter) # # mix with the density of the previous iteration # for i in range(NGRID): n[i] = MIX*n[i] + (1.-MIX)*n1[i] n1[i] = n[i] # # Calculate the Hartree potential VH: # for i in range(NGRID): for j in range(NGRID): vint[j]=n[j]/math.sqrt(A**2 + (x[i]-x[j])**2) result = simps(vint,x) VH[i] = result MAT[i,i] = di[i] + VH[i] # # Calculate the exchange potential VX: # for i in range(NGRID): upper = n[i]*PI*A def f(j): return kn(0,j) result, _ = quad(f,0.,upper) VX[i] = -result/(PI*A) MAT[i,i] = MAT[i,i] +VX[i] # # Now find the eigenvalues and eigenvectors of the matrix MAT, # and sort them to make sure we keep the lowest one only. # vals, vecs = np.linalg.eig(MAT) sorted = np.argsort(vals) lowest = sorted[0] EKS = vals[lowest] for i in range(NGRID): psi[i]=vecs[i,lowest] # # Now we need to normalize our solution. # norm = simps(psi**2,x) psi = psi/math.sqrt(norm) n = 2*psi**2 # # We define the convergence criterion (crit) as the difference between the # Kohn-Sham lowest energy eigenvalue in this iteration step to the one of # the previous step. The criterion needs to be < tol for the # iteration to end. # crit = abs(eks_previous - eks) eks_previous = eks # -------------------------------------------------------------------------- # end of the self-consistency loop # -------------------------------------------------------------------------- print('converged') plot(x,n) # # calculate the various contributions to the total energy: # vint = vh * n result = simps(vint,x) eh = -0.5*result # vint = vx * n result = simps(vint,x) evx = - result # for i in range(ngrid): upper = n[i]*pi*a def f(j): def g(l): return kn(0,l) result, _ = quad(g,0.,j) return result result, _ = quad(f,0.,upper) vint[i] = -result/(pi*a)**2 ex = simps(vint,x) # e = 2.*eks + eh + evx + ex # total ground-state energy # print('') print(' kohn-sham energy: eks =', 2*eks) print(' hartree energy:-eh =', eh) print(' vx energy: evx =', evx) print(' exchange energy: ex =', ex) print('--------------------------------------------') print('ground-state energy: e =', e) # # write the density to a file # f = open("nks.txt", "w") for i in range(ngrid): f.write(str(x[i]) + " " + str(n[i]) + '\n') f.close() # chapter 21 computational materials science: an overview computational materials science is the main area of application of electronic structure theory and, hence, of dft. the electronic structure problem of matter was formulated in section 4.1, and we can summarize it as follows: the goal of computational materials science is to predict the structure and properties of materials from first principles. ideally, all we need is a given stoichiometry (e.g., h2o, nacl, yba2cu3o7), and the computer predicts geometry, energy, spectral properties, etc. with the desired accuracy. from first principles (or ab initio) means that we use quantum mechanics, starting from an exact many-body hamiltonian. the n -particle schrödinger equation cannot be solved exactly, so we use instead dft. of course, dft needs approximations for the xc functional, but we only use functionals that are universal, such as the lda. but computational materials science is much more than just dft calculations: the bigger picture is illustrated in figs. 21.1 and 21.2, which give you an overview of the so-called multiscale modeling approach. the philosophy of this approach is that different length scales require different techniques: ˆ sub-nanometer scale. requires fully quantum mechanical treatment (with dft), to describe details of the electronic structure of atoms, molecules and solids. ˆ nanoscale. for system sizes up to a few hundred nanometers. atomic resolution is still required, but a fully quantum mechanical treatment is no longer possible, nor needed. uses molecular dynamics (md) with parametrized force fields. ˆ nano- to microscale. atomic resolution no longer needed. macromolecules, materi- als, and surfaces are described using coarse graining or continuum models. 139 figure 21.1: multiscale modeling spans many length and time scales. figure 21.2: overview of multiscale modeling in materials science. 140 so far, we have talked about length scales and multiscale modeling. in the context of electronic structure theory, you will often see another usage of the word “scaling”. namely, people use the word “scaling” to describe how the computational cost increases with the number of electrons n . standard dft calculations scale roughly as n2 to n3, depending on the implementation and on the xc functional used. thus, the computational effort increases more than quadratically with the number of electrons. this puts a limit to the system size that can be reasonably treated with present- day available computers. typically, with a desktop computer or workstation with several cpus, you can treat molecules with a few dozen atoms and a few hundred electrons, or solids with a few dozen electrons per unit cell. with present-day supercomputers, ab-initio methods based on dft can treat systems with a few thousand atoms; applications of systems with 105 to 106 atoms have begun to emerge. clearly, million-atom calculations are not yet mainstream, and require very large computers with hundreds or thousands of cpus. furthermore, such large system sizes can only be treated using so-called order-n or linear-scaling methods. these are very specialized algorithms to solve the kohn-sham equations, which make certain assumptions and approximations, often at the expense of accuracy. this chapter is entitled “dft in practice”. so far, we have discussed the formal framework of dft, but now we would like to know what is needed to actually solve the kohn-sham equations on a computer. clearly, a full discussion would be beyond the scope of this course, and so we will adopt a simplified point of view, and distinguish the usage of dft in (bio)chemistry and in condensed-matter physics. the difference between these two fields can be summarized as follows: condensed-matter physics ˆ typically deals with extended systems (periodic solids or surfaces). ˆ many electronic structure codes use plane-wave basis and pseudopotentials. (bio)chemistry ˆ typically deal with finite systems (molecules or complexes). ˆ most electronic structure codes use localized basis sets. in the following, we tol="" for="" the="" #="" iteration="" to="" end.="" #="" crit="abs(EKS_previous" -="" eks)="" eks_previous="EKS" #="" --------------------------------------------------------------------------="" #="" end="" of="" the="" self-consistency="" loop="" #="" --------------------------------------------------------------------------="" print('converged')="" plot(x,n)="" #="" #="" calculate="" the="" various="" contributions="" to="" the="" total="" energy:="" #="" vint="VH" *="" n="" result="simps(vint,x)" eh="-0.5*result" #="" vint="VX" *="" n="" result="simps(vint,x)" evx="-" result="" #="" for="" i="" in="" range(ngrid):="" upper="n[i]*PI*A" def="" f(j):="" def="" g(l):="" return="" kn(0,l)="" result,="" _="quad(g,0.,j)" return="" result="" result,="" _="quad(f,0.,upper)" vint[i]="-result/(PI*A)**2" ex="simps(vint,x)" #="" e="2.*EKS" +="" eh="" +="" evx="" +="" ex="" #="" total="" ground-state="" energy="" #="" print('')="" print('="" kohn-sham="" energy:="" eks=', 2*EKS) print(' hartree="" energy:-eh=', EH) print(' vx="" energy:="" evx=', EVX) print(' exchange="" energy:="" ex=', EX) print(' --------------------------------------------')="" print('ground-state="" energy:="" e=', E) # # Write the density to a file # f = open("nks.txt", "w") for i in range(NGRID): f.write(str(x[i]) + " " + str(n[i]) + ' \n')="" f.close()="" #="" chapter="" 21="" computational="" materials="" science:="" an="" overview="" computational="" materials="" science="" is="" the="" main="" area="" of="" application="" of="" electronic="" structure="" theory="" and,="" hence,="" of="" dft.="" the="" electronic="" structure="" problem="" of="" matter="" was="" formulated="" in="" section="" 4.1,="" and="" we="" can="" summarize="" it="" as="" follows:="" the="" goal="" of="" computational="" materials="" science="" is="" to="" predict="" the="" structure="" and="" properties="" of="" materials="" from="" first="" principles.="" ideally,="" all="" we="" need="" is="" a="" given="" stoichiometry="" (e.g.,="" h2o,="" nacl,="" yba2cu3o7),="" and="" the="" computer="" predicts="" geometry,="" energy,="" spectral="" properties,="" etc.="" with="" the="" desired="" accuracy.="" from="" first="" principles="" (or="" ab="" initio)="" means="" that="" we="" use="" quantum="" mechanics,="" starting="" from="" an="" exact="" many-body="" hamiltonian.="" the="" n="" -particle="" schrödinger="" equation="" cannot="" be="" solved="" exactly,="" so="" we="" use="" instead="" dft.="" of="" course,="" dft="" needs="" approximations="" for="" the="" xc="" functional,="" but="" we="" only="" use="" functionals="" that="" are="" universal,="" such="" as="" the="" lda.="" but="" computational="" materials="" science="" is="" much="" more="" than="" just="" dft="" calculations:="" the="" bigger="" picture="" is="" illustrated="" in="" figs.="" 21.1="" and="" 21.2,="" which="" give="" you="" an="" overview="" of="" the="" so-called="" multiscale="" modeling="" approach.="" the="" philosophy="" of="" this="" approach="" is="" that="" different="" length="" scales="" require="" different="" techniques:="" ˆ="" sub-nanometer="" scale.="" requires="" fully="" quantum="" mechanical="" treatment="" (with="" dft),="" to="" describe="" details="" of="" the="" electronic="" structure="" of="" atoms,="" molecules="" and="" solids.="" ˆ="" nanoscale.="" for="" system="" sizes="" up="" to="" a="" few="" hundred="" nanometers.="" atomic="" resolution="" is="" still="" required,="" but="" a="" fully="" quantum="" mechanical="" treatment="" is="" no="" longer="" possible,="" nor="" needed.="" uses="" molecular="" dynamics="" (md)="" with="" parametrized="" force="" fields.="" ˆ="" nano-="" to="" microscale.="" atomic="" resolution="" no="" longer="" needed.="" macromolecules,="" materi-="" als,="" and="" surfaces="" are="" described="" using="" coarse="" graining="" or="" continuum="" models.="" 139="" figure="" 21.1:="" multiscale="" modeling="" spans="" many="" length="" and="" time="" scales.="" figure="" 21.2:="" overview="" of="" multiscale="" modeling="" in="" materials="" science.="" 140="" so="" far,="" we="" have="" talked="" about="" length="" scales="" and="" multiscale="" modeling.="" in="" the="" context="" of="" electronic="" structure="" theory,="" you="" will="" often="" see="" another="" usage="" of="" the="" word="" “scaling”.="" namely,="" people="" use="" the="" word="" “scaling”="" to="" describe="" how="" the="" computational="" cost="" increases="" with="" the="" number="" of="" electrons="" n="" .="" standard="" dft="" calculations="" scale="" roughly="" as="" n2="" to="" n3,="" depending="" on="" the="" implementation="" and="" on="" the="" xc="" functional="" used.="" thus,="" the="" computational="" effort="" increases="" more="" than="" quadratically="" with="" the="" number="" of="" electrons.="" this="" puts="" a="" limit="" to="" the="" system="" size="" that="" can="" be="" reasonably="" treated="" with="" present-="" day="" available="" computers.="" typically,="" with="" a="" desktop="" computer="" or="" workstation="" with="" several="" cpus,="" you="" can="" treat="" molecules="" with="" a="" few="" dozen="" atoms="" and="" a="" few="" hundred="" electrons,="" or="" solids="" with="" a="" few="" dozen="" electrons="" per="" unit="" cell.="" with="" present-day="" supercomputers,="" ab-initio="" methods="" based="" on="" dft="" can="" treat="" systems="" with="" a="" few="" thousand="" atoms;="" applications="" of="" systems="" with="" 105="" to="" 106="" atoms="" have="" begun="" to="" emerge.="" clearly,="" million-atom="" calculations="" are="" not="" yet="" mainstream,="" and="" require="" very="" large="" computers="" with="" hundreds="" or="" thousands="" of="" cpus.="" furthermore,="" such="" large="" system="" sizes="" can="" only="" be="" treated="" using="" so-called="" order-n="" or="" linear-scaling="" methods.="" these="" are="" very="" specialized="" algorithms="" to="" solve="" the="" kohn-sham="" equations,="" which="" make="" certain="" assumptions="" and="" approximations,="" often="" at="" the="" expense="" of="" accuracy.="" this="" chapter="" is="" entitled="" “dft="" in="" practice”.="" so="" far,="" we="" have="" discussed="" the="" formal="" framework="" of="" dft,="" but="" now="" we="" would="" like="" to="" know="" what="" is="" needed="" to="" actually="" solve="" the="" kohn-sham="" equations="" on="" a="" computer.="" clearly,="" a="" full="" discussion="" would="" be="" beyond="" the="" scope="" of="" this="" course,="" and="" so="" we="" will="" adopt="" a="" simplified="" point="" of="" view,="" and="" distinguish="" the="" usage="" of="" dft="" in="" (bio)chemistry="" and="" in="" condensed-matter="" physics.="" the="" difference="" between="" these="" two="" fields="" can="" be="" summarized="" as="" follows:="" condensed-matter="" physics="" ˆ="" typically="" deals="" with="" extended="" systems="" (periodic="" solids="" or="" surfaces).="" ˆ="" many="" electronic="" structure="" codes="" use="" plane-wave="" basis="" and="" pseudopotentials.="" (bio)chemistry="" ˆ="" typically="" deal="" with="" finite="" systems="" (molecules="" or="" complexes).="" ˆ="" most="" electronic="" structure="" codes="" use="" localized="" basis="" sets.="" in="" the="" following,="">
May 07, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here