340 likes | 533 Views
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 CA mbridge S erial T otal E nergy P ackage. An introduction….
E N D
The Nuts and Bolts of First-Principles Simulation 4: The New CASTEP Durham, 6th-13th December 2001 CASTEP Developers’ Groupwith support from the ESF k Network
Lecture 4: NewCAmbridgeSerialTotalEnergyPackage 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 Serial • It’s doesn’t just calculate Total Energies • However, it is still a Package! Lecture 4: Introduction to New CASTEP
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 Lecture 4: Introduction to New CASTEP
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.) Lecture 4: Introduction to New CASTEP
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 Lecture 4: Introduction to New CASTEP
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. Lecture 4: Introduction to New CASTEP
New CASTEP Features • Parallel, portable code • Geometry Optimisation • BFGS • Damped MD • Molecular Dynamics • NVE • NVT • Linear Response for Phonon spectra Lecture 4: Introduction to New CASTEP
CASTEP Features Continued • Transition state search • LST/QST • Electronic properties • Optical Spectra • DOS • Population Analysis Lecture 4: Introduction to New CASTEP
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 Lecture 4: Introduction to New CASTEP
Technical Features Cont… • Metals treated by • Density mixing • Ensemble DFT • Exchange-Correlation Potentials • LDA • Perdew-Wang `91 GGA • PBE/RPBE GGA • Non-linear core corrections Lecture 4: Introduction to New CASTEP
How to Use the Code: The Cell File ! Example cell file for primitive SiC %block LATTICE_ABC 3.074500 3.074500 3.074500 60.0 60.0 60.0 %endblock LATTICE_ABC %block POSITIONS_FRAC Si 0.0000 0.0000 0.0000 C 0.2500 0.2500 0.2500 %endblock POSITIONS_FRAC Lecture 4: Introduction to New CASTEP
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 Lecture 4: Introduction to New CASTEP
Controlling the Calculation:The Parameter File Task : GeometryOptimization XC_functional PW91 Basis_precision Precise Electronic_minimiser CG Elec_energy_tol = 0.000001 eV Lecture 4: Introduction to New CASTEP
More Parameters… Geom_method BFGS Geom_force_tol : 0.01 hartree/bohr Fix_occupancies = TRUE Continuation = my_last_run.check Energy_unit = kcal/mol Lecture 4: Introduction to New CASTEP
Example Output [Summary of cell and parameters input] ----------------------------------------------------------------------- <-- SCF SCF loop Energy Energy gain Timer <-- SCF per atom (sec) <-- SCF ----------------------------------------------------------------------- <-- SCF Initial 6.99675047E+002 4.22 <-- SCF 1 -8.56371636E+002 1.94505835E+002 23.70 <-- SCF 2 -8.57260747E+002 1.11138925E-001 42.59 <-- SCF 3 -8.57286394E+002 3.20580434E-003 62.00 <-- SCF 4 -8.57286462E+002 8.55207285E-006 80.91 <-- SCF 5 -8.57286463E+002 3.12287085E-008 98.20 <-- SCF ----------------------------------------------------------------------- <-- SCF [Forces, stresses, Gemoetry optimisation, MD run…] Lecture 4: Introduction to New CASTEP
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 Lecture 4: Introduction to New CASTEP
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 Lecture 4: Introduction to New CASTEP
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 Lecture 4: Introduction to New CASTEP
Utility Modules Lecture 4: Introduction to New CASTEP
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 Lecture 4: Introduction to New CASTEP
Fundamental Modules Lecture 4: Introduction to New CASTEP
Example type: Wavefunction type, public :: wavefunction integer :: nbands ! Max no. bands integer :: nkpts ! No. of kpts integer :: nspins ! No. of spins represented complex(kind=dp), dimension(:,:,:,:), pointer :: coeffs logical :: paged ! Is the wavefn paged to disc? ! Iff paged:- integer :: page_unit ! the unit no. of the pagefile ... end type wavefunction N.B. This has been simplified for illustrative purposes! Lecture 4: Introduction to New CASTEP
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) Lecture 4: Introduction to New CASTEP
Functional Modules Lecture 4: Introduction to New CASTEP
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) Lecture 4: Introduction to New CASTEP
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 Lecture 4: Introduction to New CASTEP
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) Lecture 4: Introduction to New CASTEP
Timings for bad_trace Lecture 4: Introduction to New CASTEP
Timings for good_trace Lecture 4: Introduction to New CASTEP
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… Lecture 4: Introduction to New CASTEP
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! Lecture 4: Introduction to New CASTEP