The Nuts and Bolts of First
Download
Report
Transcript The Nuts and Bolts of First
The Nuts and Bolts of
First-Principles Simulation
4: The New CASTEP
Durham, 6th-13th December 2001
CASTEP Developers’ Group
with support from the ESF k Network
Lecture 4:
New CAmbridge
Serial
Total
Energy
Package
An introduction…
The Nuts and Bolts of
First-Principles Simulation
Durham,
6th-13th December 2001
What New CASTEP is not
It’s not just CAmbridge
It’s not just
It’s doesn’t just calculate Total Energies
However, it is still a Package!
Nuts and Bolts 2001
Serial
Lecture 4: Introduction to New CASTEP
3
So, What is it Then?
Introduction to the CASTEP Developer’s
Group
The goals of the New CASTEP project
A brief history of New CASTEP
The features of the package
How to use the code (command line)
Philosophy and design of the code
The future of New CASTEP
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
4
The CASTEP Developers
Group
Mike Payne (Cambridge)
Matt Probert (York)
Chris Pickard (Cambridge)
Stewart Clark (Durham)
Phil Hasnip (Cambridge)
Phil Lindan (Kent at Canterbury)
Matt Segall (Cambridge, Camitro UK Ltd.)
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
5
The Goals of New CASTEP
Ease of maintenance
Ease of future development
Portability
Efficiency
These goals are sometimes conflicting,
therefore a compromise must be found
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
6
A Brief History of New
CASTEP
July ‘99: A meeting of interested parties. Is there a
need for a new PW pseudopotential code?
July ’99 -> Jan. ’00: Informal specification group
outlines the spec. of a new code.
Feb. ’00: Implementation of new code begins. CDG
formed.
May ’01: Agreement reached with MSI (Now
Accelrys) to commercialise New CASTEP.
Dec. ’01: Code freeze on first version of New
CASTEP.
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
7
New CASTEP Features
Parallel, portable code
Geometry Optimisation
Molecular Dynamics
BFGS
Damped MD
NVE
NVT
Linear Response for Phonon spectra
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
8
CASTEP Features Continued
Transition state search
LST/QST
Electronic properties
Optical Spectra
DOS
Population Analysis
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
9
CASTEP Technical Features
Ultrasoft/Norm-conserving pseudopotentials
Pseudopotential generation on-the-fly
Double grid technique for charge/potential
grid
Multiple electronic minimisers
All-bands CG
RMM/DIIS
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
10
Technical Features Cont…
Metals treated by
Exchange-Correlation Potentials
Density mixing
Ensemble DFT
LDA
Perdew-Wang `91 GGA
PBE/RPBE GGA
Non-linear core corrections
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
11
How to Use the Code:
The Cell File
! Example cell file for primitive SiC
%block LATTICE_ABC
3.074500
3.074500
60.0
60.0
%endblock LATTICE_ABC
3.074500
60.0
%block POSITIONS_FRAC
Si 0.0000
0.0000
0.0000
C 0.2500
0.2500
0.2500
%endblock POSITIONS_FRAC
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
12
More Cell File Keywords
KPOINTS_MP_GRID 4 4 4
%block SYMMETRY_OPS
…
%endblock SYMMETRY_OPS
%block SPECIES_POT
C my_C_pot.usp
%endblock SPECIES_POT
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
13
Controlling the Calculation:
The Parameter File
Task : GeometryOptimization
XC_functional PW91
Basis_precision Precise
Electronic_minimiser CG
Elec_energy_tol = 0.000001 eV
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
14
More Parameters…
Geom_method BFGS
Geom_force_tol : 0.01 hartree/bohr
Fix_occupancies = TRUE
Continuation = my_last_run.check
Energy_unit = kcal/mol
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
15
Example Output
[Summary of cell and parameters input]
----------------------------------------------------------------------SCF loop
Energy
Energy gain
Timer
per atom
(sec)
----------------------------------------------------------------------Initial 6.99675047E+002
4.22
1 -8.56371636E+002
1.94505835E+002
23.70
2 -8.57260747E+002
1.11138925E-001
42.59
3 -8.57286394E+002
3.20580434E-003
62.00
4 -8.57286462E+002
8.55207285E-006
80.91
5 -8.57286463E+002
3.12287085E-008
98.20
-----------------------------------------------------------------------
<-<-<-<-<-<-<-<-<-<-<--
SCF
SCF
SCF
SCF
SCF
SCF
SCF
SCF
SCF
SCF
SCF
[Forces, stresses, Gemoetry optimisation, MD run…]
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
16
Design Philosophy of
New CASTEP
Written specification, prior to coding!
Implemented in FORTRAN90
Modular approach (F90 not truly object
oriented)
Data abstraction using derived data types
Overloading for simple, clear subroutine
names
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
17
Why FORTRAN90?
A language for numerical codes
‘Designed’ with optimisation in mind good
numerical efficiency
‘Modern’ high level language
Modules (classes)
Interfaces (prototypes)
Memory allocation
Derived types
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
18
Code Structure (Overview)
Functional Modules
•The ‘Physics’
•High-level
Fundamental Modules
•The building blocks
•Define types and operations
Utility Modules
•Machine-dependant
•Low-level algorithms
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
19
Utility Modules
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
20
Utility modules provide:
Fundamental constants
API for parallel execution
I/O
Basic operations, e.g. opening and closing files
Freeform file I/O
Generic algorithms
FFTs
Matrix inversion
Random numbers
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
21
Fundamental Modules
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
22
Example type: Wavefunction
type, public :: wavefunction
integer :: nbands
integer :: nkpts
integer :: nspins
! Max no. bands
! No. of kpts
! No. of spins represented
complex(kind=dp), dimension(:,:,:,:), pointer :: coeffs
logical :: paged
integer :: page_unit
! Is the wavefn paged to disc?
! Iff paged:! the unit no. of the pagefile
...
end type wavefunction
N.B. This has been simplified for illustrative purposes!
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
23
Example Operations:
wavefunction_allocate(wvfn)
wavefunction_deallocate(wvfn)
wavefunction_initialise(wvfn,method)
wavefunction_copy(wvfn1,wvfn2)
wavefunction_add(wvfn2,wvfn2,wvfn_out)
wavefunction_dot(wvfn1,wvfn2,products)
wavefunction_orthogonalise(wvfn)
wavefunction_recip_to_real(wvfn,nb,nk,ns,real_bnd)
Overloading:
wavefunction_add(wvfn1,wvfn2,wvfn_out,c1,c2)
wavefunction_add(bnd,wvfn,nb,nk,ns)
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
24
Functional Modules
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
25
Use of Fundamental Building
Blocks (e.g. Calculating H)
! Apply kinetic energy operator to wvfn
call wave_kinetic_energy(wvfn,ek,H_wvfn)
! Calculate the charge density
call density_calculate(wvfn,occ,dens)
! Calculate the local potential
call locpot_calculate(dens,local_pot)
! Apply the local potential to the wavefunction
call pot_apply(local_pot,wvfn,wvfn_temp)
! Add Vloc|psi> to kinetic energy contribution
call wave_add(wvfn_temp,H_wvfn)
! Apply the non-local potential to the wavefunction
call nlpot_apply(wvfn,…,wvfn_temp)
! Add Vnl|psi> to get final H|psi>
call wave_add(wvfn_temp,H_wvfn)
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
26
Coding Style
Clear code
Meaningful variable and subroutine names
Lots of comments
Good structure
Care with performance issues
Some features of FORTRAN90 sub-optimal
Use BLAS/LAPACK where applicable
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
27
Example problem with F90
! Finding the trace of a sub-array
real, dimension(N,N) :: A
! Pass a sub-array of A of
dimension m
tr = bad_trace(A(1:m,1:m),m)
!Pass the whole array with
dimension of sub-array
tr = good_trace(A,m,N)
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
28
Timings for bad_trace
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
29
Timings for good_trace
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
30
The Future of New CASTEP
NPT Molecular Dynamics
Free-energy integration for reaction barriers
New non-local XC functionals
NMR chemical shifts
EELS
Raman spectroscopy
Self-consistent pseudopotentials
Etc…
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
31
Summary
New CASTEP code designed and
implemented by an academic group
Sound software design
Modern implementation
State-of-the-art features
Good performance
The future is bright!
Nuts and Bolts 2001
Lecture 4: Introduction to New CASTEP
32