Computer Lab
From phys824
Contents
- 1 Unix Training
- 2 MATLAB Training
- 3 Python training
- 4 MATLAB Scripts
- 4.1 Matrix representation of single-particle Hamiltonians
- 4.2 Charge and spin densities in quantum dots via equilibrium density matrix
- 4.3 DOS of 1D disordered nanowire using eigenvalues + visualization of Anderson localization of eigenfunctions
- 4.4 Density of states using equilibrium Green functions
- 4.5 Subband structure of graphene nanoribbons using tight-binding models
- 4.6 Quantum transport in 1D nanowires using NEGF
- 4.7 Tunneling magnetoresistance in tight-binding models of magnetic tunnel junctions using NEGF
- 4.8 Quantum transport in graphene nanostructures via NEGF
- 5 MATLAB functions
- 6 Quantum transport simulations using KWANT package
- 7 Band structure calculations for tight-binding models using PythTB package
- 8 Density functional theory with GPAW package
- 9 First-principles quantum transport calculations using NEGF+DFT within GPAW package
- 10 Density functional theory with Quantum ESPRESSO
Unix Training
MATLAB Training
Hands-on tutorials by Instructor
- First steps with MATLAB
- Sparse matrices
- GPU accelerated computing with MATLAB
- How to run MATLAB in background on Unix:
nohup matlab -nojvm < your_script.m > output_messages &
Hands-on tutorials by MathWorks
- VIDEO: Getting Started
- VIDEO: Working with MATLAB Desktop
- Code Examples
- How to run code sections
- GPU computing in MATLAB
- GPU computing benchmarks with MATLAB
Books
- T. A. Driscoll, Learning MATLAB (SIAM, Philadelphia, 2009).
- C. Moler, Numerical Computing with MATLAB (SIAM, Philadelphia, 2004).
- C. Moler, Experiments with MATLAB (MathWorks, Natick, 2011).
Reference
- MATLAB Brief List of Commands
- Official MATLAB Documentation
- Common MATLAB programming pitfalls and how to avoid them
Python training
Hands-on tutorials by the Instructor (Dr. Marko D. Petrovic)
- Jupyter Notebook: First steps with Python
- Jupyter Notebook: Functions and Objects in Python
- Jupyter Notebook: Kwant Introduction
- PDF: Kwant Introduction
- Jupyter Notebook: Kwant Honeycomb Lattice
- PDF: Kwant Honeycomb Lattice
- Jupyter Notebook: Kwant Solvers
- PDF: Kwant Solvers
Other tutorials
- Scipy lecture notes
- J. M. Stewart, Python for Scientists (Cambridge University Press, Cambridge, 2014). (PDF from UD library)
- Timing Python script performance
- NumPy for Matlab users
Using Anaconda Python
- Installation of Anaconda Python
- Conda packages for KWANT
- in order to enable the Python environment on ulam provided by Anaconda you need to add the following to your
~/.bashrc
:
export PATH="/opt/anaconda/1.9.2/bin:$PATH"
- if you want to use the MKL and NumbaPro add-ons you'll need to request a free academic license from here and once you receive the license put it in the
~/.continuum
directory in your home directory - Speed-up using Anaconda Python + MKL over 1 to 8 cores on ulam
MATLAB Scripts
Matrix representation of single-particle Hamiltonians
- Discretization of 1D continuous Hamiltonian
- How to put magnetic field into discretized Hamiltonian
- How to construct tight-binding Hamiltonian for numerical calculations on graphene
Charge and spin densities in quantum dots via equilibrium density matrix
DOS of 1D disordered nanowire using eigenvalues + visualization of Anderson localization of eigenfunctions
Density of states using equilibrium Green functions
- dos_negf_closed.m computes DOS for finite 1D wire
- dos_negf_open.m computes DOS for finite 1D wire attached to one or two macroscopic reservoirs
- graphene_dos.m computes DOS for a supercell of graphene with periodic boundary conditions
Subband structure of graphene nanoribbons using tight-binding models
- 8zgnr.m (poor man's script follows literally the lecture slide, so it works only for 8-ZGNR)
Quantum transport in 1D nanowires using NEGF
- How to use NEGF matrix formulas: Step-by-step in pictures
- qt_1d.m (computes conductance, as well as total and local density of states for 1D nanowire modeled as tight-binding chain, with possible potential barriers or impurities, attached to two semi-infinite leads)
Tunneling magnetoresistance in tight-binding models of magnetic tunnel junctions using NEGF
- mtj_1d.m (computes TMR of F/I/F MTJs modeled using 1D tight-binding chain)
- mtj_3d.m (computes TMR of F/I/F MTJs modeled using mixed real space and k-space tight-binding model of 3D junctions
Quantum transport in graphene nanostructures via NEGF
Self.m, (code to compute the conductance of a finite graphene nanoribbon attached to two semi-infinite graphene electrodes)
MATLAB functions
- matrix_exp.m (Exponential, or any other function with small changed in the code, of a Hermitian matrix)
- visual_graphene_H.m (For a given tight-binding Hamiltonian on the honeycomb lattice, function plots position of carbon atoms and draws blue lines to represent hoppings between them; red circles to represent on-site potential between them; and cyan lines to represent the periodic boundary conditions; it can be used to test if the tight-binding Hamiltonian of graphene is set correctly); This function calls another three function which should be placed in the same directory (or in the path): atomCoord.m, atomPosition.m, and constrainView.m
- self_energy.m (Self-energy of the semi-infinite ideal metallic lead modeled on the square tight-binding lattice - the code shows how to convert analytical formulas of the lead surface Green function into a working program)
- transmission.m (Transmission function for 1D tight-binding chain with spin-dependent terms)
Quantum transport simulations using KWANT package
Tutorials
- VIDEO: Introduction to KWANT
- Learning KWANT through examples
- Interactive tutorials using Jupyter Notebooks
- Discretization of continuous Hamiltonians
- Conductance of graphene nanoribbons
- Conductance of topological insulators built from graphene nanoribbons
- Spin Hall effect in four terminal devices
- Topological Hall effect in four terminal devices
Manuals
Band structure calculations for tight-binding models using PythTB package
Density functional theory with GPAW package
How to run GPAW on ulam
GPAW has been installed on ulam with the OS installed python 2.6.
- in order to use the serial version of GPAW type:
python your_gpaw_program.py
- in order to use the parallel version of gpaw use the following syntax (replace 8 with the number of cores you want to use):
mpirun -np 8 gpaw-python_openmpi your_gpaw_program.py
Getting started with GPAW
- VIDEO Tutorial: Electronic structure calculations with GPAW
- VIDEO Tutorial: Overview of GPAW
- VIDEO Tutorial: CO molecule
- Plotting CO wavefunction
- relax.py used in VIDEO Tutorial:
from ase import Atoms from ase.io import write from ase.optimize import QuasiNewton from gpaw import GPAW d = 1.10 # Starting guess for the bond length atoms = Atoms('CO', positions=((0, 0, 0), (0, 0, d)), pbc=False) atoms.center(vacuum=4.0) write('CO.cif', atoms) calc = GPAW(h=0.20, xc='PBE', txt='CO_relax.txt') atoms.set_calculator(calc) relax = QuasiNewton(atoms, trajectory='CO.traj', logfile='qn.log') relax.run(fmax=0.05)
- ASE tutorials
- Basics of GPAW calculations
- Band structure of Ni plotted in three steps
- Lattice constant, DOS, and band structure of Si
- STM simulations
GPAW Exercises Related to Midterm Project
- Band structure of bulk graphene
- Subband structure of graphene nanoribbons
- Subband structure of carbon nanotubes
References
- Electronic structure calculations with GPAW: a real-space implementation of the projector augmented-wave method, J. Phys.: Condens. Matter 22, 253202 (2010). [PDF]
- Parameters selection in GPAW scripts
- LCAO basis set in GPAW
- Parameters selection in ASE to define atomic coordinates
- Density of States in GPAW
- About k-point sampling
First-principles quantum transport calculations using NEGF+DFT within GPAW package
Theory Background
- Crash course on NEGF+DFT codes
- NEGF+DFT within GPAW - see also J. Chen, K. S. Thygesen, and K. W. Jacobsen, Ab initio nonequilibrium quantum transport and forces with the real-space projector augmented wave method, Phys. Rev. B 85, 155140 (2012). [PDF]
- M. Strange, I. S. Kristensen, K. S. Thygesen, and K. W. Jacobsen, Benchmark density functional theory calculations for nanoscale conductance, J. Chem. Phys. 128, 114714 (2008). [PDF]
- D. A. Areshkin and B. K. Nikolić, Electron density and transport in top-gated graphene nanoribbon devices: First-principles Green function algorithms for systems containing a large number of atoms, Phys. Rev. B 81, 155450 (2010). [PDF]