Download presentation
Presentation is loading. Please wait.
Published byΦθα Ζαφειρόπουλος Modified over 5 years ago
1
物質科学のための計算数理 II Numerical Analysis for Material Science II
9th: Density Functional Theory (2) Dec. 7 (Fri) Lecturer: Mitsuaki Kawamura (河村光晶)
2
Schedule (This semester W1, W2)
Sep. 28 (Fri) Guidance Y Oct (Fri) Monte Carlo method O Oct. 12 (Fri) Monte Carlo method O Oct. 19 (Fri) Monte Carlo method O Oct. 26 (Fri) Exact diagonalization Y Nov (Fri) Exact diagonalization Y Nov (Fri) Molecular dynamics O (1st report problem will be announced.) Nov. 30 (Fri) Standard DFT code K Dec (Fri) Density functional theory K Dec. 14 (Fri) Density functional theory K Dec. 21 (Fri) Density functional theory K Dec. 25 (Tue) (2nd)Report problem K (遠隔講義室) Jan (Fri) Density functional theory K ※ Lecturers: Y … Yamaji, K … Kawamura, O… Ohgoe
3
Schedule in this section (DFT)
Nov. 30 (Fri) Standard DFT code First-principles calculation and Density functional theory (Lecture) One-body Schrödinger eq. for periodic system and Bloch theorem (L) Numerical solution of Kohn-Sham (one-body Schrödinger) eq. (L) Hands-on DFT code (Tutorial) Version control system : Git (T) Dec (Fri) Kohn-Sham eq. Plane-wave basis and Pseudopotentials (L) Iterative eigenvalue solution method (L & T) Dec. 14 (Fri) Self-Consistent loop Hartree potential (Poisson eq.) Brillouin-zone integral (Tetrahedron method) Visualization (T) Dec. 21 (Fri) Total Energy Coulomb potential for periodic point charge (Ewald sum) Dec. 25 (Tue) (2nd)Report problem K (遠隔講義室) Jan (Fri) Density functional theory K
4
Today’s Schedule Kohn-Sham eq. in periodic system
Plane-wave representation Iterative diagonalization Matrix-vector product Kinetic energy term Potential term Visualize
5
Kohn-Sham method last week 𝐸 𝜌 = 𝑑 3 𝑟𝜌 𝒓 𝑣 𝒓 + 𝐸 𝑢𝑛𝑖𝑣 𝜌
𝐸 𝜌 = 𝑑 3 𝑟𝜌 𝒓 𝑣 𝒓 + 𝐸 𝑢𝑛𝑖𝑣 𝜌 𝑣 𝒓 ≡ 𝐼=1 𝑁 atom 𝑍 𝐼 𝒓− 𝑹 𝐼 𝐸 𝑢𝑛𝑖𝑣 𝜌 = 𝑇 𝐾𝑆 𝜌 𝑑 3 𝑟 𝑑 3 𝑟 ′ 𝜌(𝒓)𝜌( 𝒓 ′ ) 𝒓− 𝒓 ′ + 𝐸 𝑋𝐶 𝜌 Kinetic energy of non-interacting system whose charge density is 𝜌(𝒓) − 𝛁 𝑣 𝐾𝑆 [𝜌] 𝒓 𝜑 𝑛 𝒓 = 𝜀 𝑛 𝜑 𝑛 𝒓 𝜌 𝒓 =2 𝑛=1 𝑁/2 𝜑 𝑛 𝒓 2 𝑣 𝐾𝑆 [𝜌] 𝒓 =𝑣 𝒓 + 𝑑 3 𝑟 ′ 𝜌 𝒓 ′ 𝒓− 𝒓 ′ + 𝑣 𝑋𝐶 𝜌 𝒓 𝑣 𝑋𝐶 𝜌 𝒓 ≡ 𝛿 𝐸 𝑋𝐶 𝜌 𝛿𝜌 𝒓 Self-consistent field (SCF)
6
Kohn-Sham eq. for periodic system (1)
last week 𝑣 𝐾𝑆 𝒓 is periodic, i.e., 𝑣 𝐾𝑆 𝒓+ 𝑛 1 𝒂 1 + 𝑛 2 𝒂 2 + 𝑛 3 𝒂 3 = 𝑣 𝐾𝑆 𝒓 − 𝛁 𝑣 𝐾𝑆 𝒓 𝜑 𝒓 =𝜀𝜑 𝒓 Unit lattice vectors (Not unique) 𝜌 𝒓 = 𝑛=1 𝑁× 𝑁 𝑐 𝜑 𝑛 𝒓 2 𝑁 electrons per unit cell 𝑁 𝑐 cells → ∞ Equation to solve in the whole region of bulk crystal 𝒂 1 𝒂 1 𝒂 2 Unit cell
7
Kohn-Sham eq. for periodic system (2)
last week 𝜑 𝒓 = 1 𝑁 𝐶 𝑒 𝑖𝒌⋅𝒓 𝑢 𝑛𝒌 (𝒓) 𝜑(𝒓) can be written as Bloch’s theorem 𝑈.𝐶. 𝑑 3 𝑟𝜌 𝑟 =𝑁 − 𝛁+𝒌 𝑉 𝐾𝑆 𝒓 𝑢 𝑛𝒌 𝒓 =𝜀 𝑢 𝑛𝒌 𝒓 𝜌 𝒓 =2 1 𝑉 𝐵𝑍 𝐵𝑍 𝑑 3 𝑘 𝑛=1 ∞ 𝑢 𝑛𝒌 𝒓 2 𝜃( 𝜀 F − 𝜀 𝑛𝑘 ) Equation to solve only in the unit cell 𝜀 𝑛𝑘 Band structure 𝒂 1 𝒂 2 𝒂 𝒃 1 , 𝒃 2 , 𝒃 3 =2𝜋 𝐼 Unit reciprocal lattice vectors 𝜀 𝑛𝑘 and 𝑢 𝑛𝒌 𝒓 is periodic with 𝒃 𝛼 in the k space. 𝒌 𝒃 1
8
How to solve Kohn-Sham eq. : Basis
last week − 𝛁+𝑖𝒌 𝑣 𝐾𝑆 𝒓 𝑢 𝑛𝒌 𝒓 = 𝜀 𝑛𝑘 𝑢 𝑛𝒌 𝒓 𝑢 𝑛𝒌 𝒓 = 𝐺 𝑢 𝑛𝒌 𝑮 𝑒 𝑖𝑮⋅𝒓 𝑉 𝑢𝑐 𝑮 ′ 𝑮+𝒌 𝛿 𝑮 𝑮 ′ + 𝑣 𝐾𝑆 (𝑮− 𝑮 ′ ) 𝑢 𝑛𝒌 𝑮 ′ = 𝜀 𝑛𝑘 𝑢 𝑛𝒌 𝑮 𝑣 𝐾𝑆 𝑮 = 𝑢𝑐 𝑑 3 𝑟 𝑒 −𝑖𝑮⋅𝒓 𝑉 𝑢𝑐 𝑣 𝐾𝑆 (𝒓)
9
Unit in this lecture Input and output : Length : Angstrom
Energy : Electron volt Useful to read by VESTA Inside program code: Length : Atomic unit (Bohr radius). 1 [Bohr] = [Å] Energy : Atomic unit (Hartree). 1 [Eh] = [eV] [Bohr-1] 𝑮 ′ 𝑮+𝒌 𝛿 𝑮 𝑮 ′ + 𝑣 𝐾𝑆 (𝑮− 𝑮 ′ ) 𝑢 𝑛𝒌 𝑮 = 𝜀 𝑛𝑘 𝑢 𝑛𝒌 𝑮 [Eh] [Eh]
10
Fourier Transformation
𝑣 𝐾𝑆 𝑮 = 𝑢𝑐 𝑑 3 𝑟 𝑒 −𝑖𝑮⋅𝒓 𝑉 𝑢𝑐 𝑣 𝐾𝑆 (𝒓) Discretize (considering one dimension) 𝑣 2𝜋 𝐿 𝑚 = 𝑛=1 𝑁 𝑃𝑊 1 𝑁 𝑃𝑊 𝑒 −𝑖 2𝜋 𝐿 𝑚×𝐿 𝑛 𝑁 𝑃𝑊 𝑣 𝐿 𝑛 𝑁 𝑃𝑊 𝑁 𝑃𝑊 → ∞ : Exact 𝑚=− 𝑁 𝑃𝑊 2 ,⋯,−1,0,1,⋯, 𝑁 𝑃𝑊 2 𝑁 𝑃𝑊 × 𝑁 𝑃𝑊 𝑉 𝑂 𝑁 𝑃𝑊 2 numerical cost Fast Fourier Transformation (FFT) : 𝑂 𝑁 𝑃𝑊 ln 𝑁 𝑃𝑊 numerical cost We do not detail in this lecture. We just use FFT numerical library.
11
Cutoff frequency 𝑢 𝑛𝒌 𝒓 = 𝑮 𝑮 2 2 < 𝐸 𝑐𝑢𝑡 𝑢 𝑛𝒌 𝑮 𝑒 𝑖𝑮⋅𝒓 𝑉 𝑢𝑐
𝑢 𝑛𝒌 𝒓 = 𝑮 𝑮 < 𝐸 𝑐𝑢𝑡 𝑢 𝑛𝒌 𝑮 𝑒 𝑖𝑮⋅𝒓 𝑉 𝑢𝑐 𝑢 2𝜋 𝐿 𝑁 𝑃𝑊 −𝑚 = 𝑛=1 𝑁 𝑃𝑊 1 𝑁 𝑃𝑊 𝑒 −𝑖2𝜋 𝑛 𝑁 𝑃𝑊 −𝑚 𝑁 𝑃𝑊 𝑉 𝐿 𝑛 𝑁 𝑃𝑊 = 𝑉 − 2𝜋 𝐿 𝑚
12
Very simple plane-wave DFT program
$ cd ~ $ git clone git://git.osdn.net/gitroot/educational-pwdft/pwdft.git $ cd pwdft $ cp make.inc.mac make.inc $ make $ cd sample/Al/ $ ../../src/pwdft.x < direct.in &CONTROL calculation = 'direct' / &SYSTEM nbnd = 10 nat = 1 ntyp = 1 ecutwfc = ecutrho = &ELECTRONS CELL_PARAMETERS ATOMIC_SPECIES Al al.lda.lps ATOMIC_POSITIONS Al K_POINTS 1 Aluminum Face centered cubic (fcc) Metal Almost free electron keep "ecutrho" ≧ 4*ecutwfc Only perform first SCF step 𝜌 𝑟 = 𝑁 𝑉 𝑢𝑐 Initial density is uniform
13
lwork = -1 allocate(work(1)) call zheev('V', 'U', npw, ham, npw, eval_full, work, lwork, rwork, info) lwork = nint(dble(work(1))) deallocate(work) allocate(work(lwork)) Workspace (memory size) query : Do not need to care. Diagonalize Hamiltonian matrix "ham" Computational cost : 𝑂 𝑁 𝑃𝑊 3 Memory size : 𝑂( 𝑁 𝑃𝑊 3 ) keep ecutrho ≧ 4*ecutwfc Changing "ecutrho" and "ecutwfc" and see "Kohn-Sham Time" in Standard output Large numerical cost for large 𝑁 𝑃𝑊 We only need lower energy (occupied) band.
14
Locally Optimal Block Preconditioned Conjugate Gradient (LOBPCG) method
One of the iterative eigen solution methods A. V. Knyazev, SIAM J. Sci. Compute. 23, 517 (2001). 山田進 他, 日本計算工学会論文集, (2006). For computing 𝑁 𝑏 eigenvector, at each step Construct subspace Hamiltonian (3 𝑁 𝑏 dim.) Approx. eigenvector 𝒙 1 , 𝒙 2 ,⋯ 𝒙 𝑁 𝑏 𝒙 𝑖 † 𝒘 𝑖 † 𝒑 𝑖 † 𝐻 ( 𝒙 𝑖 , 𝒘 𝑖 ,{ 𝒑 𝑖 }) Residual vector 𝒘 𝑖 = 𝐻 𝒙 𝑖 − 𝜀 𝑖 𝒙 𝑖 CG vector 𝒑 1 , 𝒑 2 ,⋯ 𝒑 𝑁 𝑏 Diagonalize with direct method Take lowest 𝑁 𝑏 vectors as approximate eigenvectors at next step Loop until all 𝑟 𝑖 become smaller than the threshold Computational cost : 𝑂 𝛼 𝑁 𝑏 3 +𝛽 𝑁 𝑏 𝑁 𝑃𝑊 ln 𝑁 𝑃𝑊 +𝛾 𝑁 𝑏 2 𝑁 𝑃𝑊 Memory : 𝑂 𝑁 𝑏 𝑁 𝑃𝑊
15
Algorithm of LOBPCG method lobpcg_main@lobpcg.F90
Initial guess 𝒙 𝑖 (Random or atomic) 𝒑 𝑖 =𝟎 𝑷 𝑖 =𝟎 𝑿 𝑖 = 𝐻 𝒙 𝑖 𝜀 𝑖 = 𝑿 𝑖 † 𝒙 𝑖 do iteration 𝒘 𝑖 = 𝑿 𝑖 − 𝜀 𝑖 𝒙 𝑖 All 𝒘 𝑖 are small enough ? → Exit 𝒘 𝑖 = 𝑃 𝒘 𝑖 𝒘 𝑖 = 𝒘 𝑖 / 𝒘 𝑖 𝑾 𝑖 = 𝐻 𝒘 𝑖 𝐻 𝑠𝑢𝑏 = 𝑾 𝑖 , 𝑿 𝑖 , 𝑷 𝑖 † 𝒘 𝑖 , 𝒙 𝑖 , 𝒑 𝑖 𝑂 𝑠𝑢𝑏 = 𝒘 𝑖 , 𝒙 𝑖 , 𝒑 𝑖 † 𝒘 𝑖 , 𝒙 𝑖 , 𝒑 𝑖 Solve 𝐻 𝑠𝑢𝑏 𝑥 𝑖,𝑠𝑢𝑏 = 𝜀 𝑖,𝑠𝑢𝑏 𝑥 𝑖,𝑠𝑢𝑏 Take lowest 𝑁 𝑏 : 𝑥 𝑖,𝑠𝑢𝑏 𝑙𝑜𝑤 𝒙 𝑖 = 𝒘 𝑖 , 𝒙 𝑖 , 𝒑 𝑖 𝑥 𝑖,𝑠𝑢𝑏 𝑙𝑜𝑤 𝒑 𝑖 = 𝒘 𝑖 , 𝟎 , 𝒑 𝑖 𝑥 𝑖,𝑠𝑢𝑏 𝑙𝑜𝑤 𝑿 𝑖 = 𝑾 𝑖 , 𝑿 𝑖 , 𝑷 𝑖 𝑥 𝑖,𝑠𝑢𝑏 𝑙𝑜𝑤 𝑷 𝑖 = 𝑾 𝑖 , 𝟎 , 𝑷 𝑖 𝑥 𝑖,𝑠𝑢𝑏 𝑙𝑜𝑤 𝒙 𝑖 = 𝒙 𝑖 / 𝒙 𝑖 𝑿 𝑖 = 𝑿 𝑖 / 𝑿 𝑖 𝒑 𝑖 = 𝒑 𝑖 / 𝒑 𝑖 𝑷 𝑖 = 𝑷 𝑖 / 𝑷 𝑖 end do iteration
16
Hamiltonian vector product h_psi@hamiltonian.F90
𝑾 𝑖 = 𝐻 𝒘 𝑖 H 𝑢 𝑮 = − 𝑮+𝒌 𝑣 𝐾𝑆 𝑢 𝑮 𝑣 𝐾𝑆 𝑢 𝑮 = 𝑢𝑐 𝑑 3 𝑟 𝑒 −𝑖𝑮⋅𝒓 𝑉 𝑢𝑐 𝑣 𝐾𝑆 𝒓 𝑢 𝒓 ≈ 𝒓 𝑉 𝑢𝑐 𝑁 𝒓 𝑒 −𝑖𝑮⋅𝒓 𝑣 𝐾𝑆 𝒓 𝑢 𝒓 𝑢 𝑛𝒌 𝒓 = 𝑮 𝑢 𝑛𝒌 𝑮 𝑒 𝑖𝑮⋅𝒓 𝑉 𝑢𝑐 Done in subroutine hpsi in hamiltonian.F90
17
Running iterative method
$ cd ~/pwdft/sample/Al/ $ ../../src/pwdft.x < iterative.in &CONTROL calculation = 'iterative' / &SYSTEM nbnd = 10 nat = 1 ntyp = 1 ecutwfc = ecutrho = &ELECTRONS CELL_PARAMETERS ATOMIC_SPECIES Al al.lda.lps ATOMIC_POSITIONS Al K_POINTS 1 See "Kohn-Sham Time" in Standard output keep ecutrho ≧ 4*ecutwfc
18
Report problem 1 (1) Compare the computational time of direct method and LOBPCG method by changing ecutrho and ecutwfc. keep ecutrho ≧ 4*ecutwfc Time [sec] ecutwfc [Ry] (2) Plot the cutoff-energy dependence of Kohn-Sham energy 𝜀 𝑛𝑘 for 𝑘=(0,0,0) and 𝑛=1, 2 (they are outputted to a file band.dat).
19
What is the command "git" Backup code Port program in any system
$ git clone Backup code Port program in any system Merge modifications Compare diff Log each modification with comment Etc.
20
Considered case 1 ・ Where is the latest source code ?
System C PC cluster Laptop PC Labo PC System B Home PC ・ Where is the latest source code ? ・ We need to update source code easily.
21
Considered case 2 ・ We need to trace when was it broken.
Program System A System B Speed up with symmetry Program System A OpenMP Program System A OpenMP+MPI System A System B Program ・ We need to trace when was it broken. ・ We need to be available to return the stable (no error) code.
22
Version control $ git pull update modification $ git commit $ git pull
Logging : Who When What modified Program (commit 1) Program (commit 2) Repository server Program (commit 3) ⋮ Program (commit 10) Latest $ git pull update modification Program (commit 11) $ git commit $ git push $ git pull Update latest version local repository local repository Modify
23
When modified simultaneously
Program (commit 1) Program (commit 2) Repository server Program(commit 3) $ git push ⋮ Program (commit 10) Program (commit 11) Latest Program (commit 12) $ git pull commit 10+ commit 11+ local repo local repo $ git push commit
24
Tutorial $ cd ~/pwdft/ $ git branch -a
$ git config --global user.name "user-name" $ git config --global user. $ git checkout -b user-name $ echo "Hello, I am user-name." > user-name.txt $ git add user-name.txt $ git commit (vi is used) $ git push --set-upstream origin user-name
25
Example of branches V0.2 V1.0 V0.1 Master Hotfix (Bug fix) Release
Develop Feature (new features) "A successful branch in git"
26
Today's summary Plane-wave representation of Kohn-Sham eq.
Direct method and LOBPCG method Hamiltonian-vector product with FFT Git
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.