Computer Lab: Difference between revisions

From phys824
Jump to navigationJump to search
 
(333 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Unix Training==
==Installing Python and course related packages==
*[[Media:gs_linux.pdf|Getting Started With Linux]]
*Install [https://www.anaconda.com/products/individual Anaconda]
*[http://www.doc.ic.ac.uk/~wjk/UnixIntro/ UNIX Tutorial]
*Install [https://kwant-project.org/install KWANT package]:
<pre>
conda install -c conda-forge kwant
</pre>
*Install [http://www.physics.rutgers.edu/pythtb/ PythTB package]:
<pre>
pip install pythtb --upgrade
</pre>
*Install and test [https://wiki.fysik.dtu.dk/ase/ ASE package]:
<pre>
pip install --upgrade --user ase
python -m ase test
</pre>
*[https://wiki.fysik.dtu.dk/gpaw/ GPAW] package can be easily installed using Anaconda on [https://anaconda.org/conda-forge/gpaw Linux] or    [https://wiki.fysik.dtu.dk/gpaw/platforms/MacOSX/anaconda.html#anaconda MacOS]
*If you want to add [https://rise.readthedocs.io/en/stable/ RISE] package for Jupyter notebooks, execute:
<pre>
conda install -c conda-forge rise
</pre>


== MATLAB Training ==
==JUPYTER notebooks for hands-on practice==
* [[Media:Getting_started_python.ipynb|Getting started with Python]]
* [[Media:Getting_started_numpy_scipy.ipynb.txt|Getting started with NumPy and SciPy]]
* [[Media:Getting_started_matplotlib.ipynb.txt|Getting started with Matplotlib]]
* [[Media:Equilibrium_nanophysics_python.ipynb|Nanostructures in equilibrium with Python]]
* [[Media:Nanostructures_out_of_equilibrium_with_python.ipynb.txt|Nanostructures out of equilibrium with Python]]
* [[Media:getting_started_pythtb.ipynb.txt|Nanostructures in equilibrium with PythTB]]
* [[Media:Nanostructures_in_equilibrium_with_kwant.ipynb.txt|Nanostructures in equilibrium with KWANT]]
* [[Media:Nanostructures_out_of_equilibrium_with_kwant.ipynb.txt|Nanostructures out of equilibrium with KWANT]]


=== Hands-on tutorials by Instructor ===
==Python references==
* [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/matlab_tutorial_phys824.m MATLAB: Getting Started]
* [http://www.scipy-lectures.org/ Scipy lecture notes]
* [http://www.physics.udel.edu/~bnikolic/teaching/phys660/Matlab/sparse_matrices.m MATLAB: Sparse Matrices]
* [https://numpy.org/doc/1.19/user/absolute_beginners.html NumPy: Absolute Beginners Tutorial]
* [https://numpy.org/doc/1.19/user/quickstart.html NumPy: Quickstart tutorial]
* [https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html NumPy for Matlab users]
* [http://www.huyng.com/posts/python-performance-analysis/ Timing Python script performance]
* J. M. Stewart, ''Python for Scientists'' (Cambridge University Press, Cambridge, 2014). [https://delcat.worldcat.org/title/python-for-scientists/oclc/885338129&referer=brief_results [PDF]]


=== Hands-on Lab tutorials by MathWorks ===
==KWANT references==
* [http://www.mathworks.com/academia/student_center/tutorials/launchpad.html MATLAB Student Center]
*[https://kwant-project.org/doc/1/ KWANT documentation]
*[http://www.mathworks.com/support/2007a/matlab/7.4/demos/RapidCodeIterationUsingCells_viewlet_swf.html Rapid code iteration using cells in the Editor]
*[http://kwant-project.org/doc/kwant-screencast-2014 VIDEO: Introduction to KWANT]
*[https://kwant-project.org/doc/1/tutorial/ Learning KWANT through examples]
*[https://kwant-project.org/doc/1/reference/kwant.solvers Selecting matrix solvers in KWANT]
*[https://github.com/jbweston/kwant_tools KWANT tools]


=== Reference ===
== Density functional theory with GPAW package==
*[[MATLAB Brief List of Commands]]
*[http://www.mathworks.com/access/helpdesk/help/helpdesk.html MATLAB Documentation]
* [[Media:matlab_pitfals.pdf | Some Common MATLAB Programming Pitfalls and How to Avoid Them]]


=== Books and notes ===
=== How to run GPAW on ulam===
[https://wiki.fysik.dtu.dk/gpaw 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


* C. Moler: ''Numerical Computing with MATLAB'' (SIAM, Philadelphia, 2004). [http://www.mathworks.com/moler/chapters.html [PDF]
=== Getting started with GPAW ===
* [http://www.physics.udel.edu/%7Ebnikolic/teaching/phys660/PDF/ud_crash_course_matlab.pdf UD Crash Course on Matlab]
* [https://www.youtube.com/watch?v=4P7ukme5f84 VIDEO Tutorial: Electronic structure calculations with GPAW]
* [http://www.youtube.com/watch?v=guXoS3Ojd8Q VIDEO Tutorial: Short overview of GPAW]
* [https://youtu.be/-z2M3g-o_sA VIDEO Longer overview of GPAW]
* [http://www.youtube.com/watch?v=hUVu7Kcs7Tc VIDEO Tutorial: CO molecule]
** [https://wiki.fysik.dtu.dk/gpaw/tutorials/plotting/plot_wave_functions.html Plotting CO wavefunction]
** relax.py used in VIDEO Tutorial:
<pre>
from ase import Atoms
from ase.io import write
from ase.optimize import QuasiNewton
from gpaw import GPAW


=== Implementation Tools ===
= 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)


*[http://www.math.umbc.edu/%7Egobbert/matlab.html Running MATLAB m-files in the background under Linux]
relax = QuasiNewton(atoms, trajectory='CO.traj', logfile='qn.log')
*[http://www.physics.udel.edu/%7Ebnikolic/teaching/phys660/PDF/mlab_bench.pdf Multithreaded MATLAB performance on multicores]
relax.run(fmax=0.05)
</pre>
* [https://wiki.fysik.dtu.dk/ase/tutorials/tutorials.html ASE tutorials]
* [https://wiki.fysik.dtu.dk/gpaw/exercises/water/water.html Basics of GPAW calculations]
* [[Band structure of Ni]] plotted in three steps
* [[Lattice constant, DOS, and band structure of Si]]
* [https://wiki.fysik.dtu.dk/gpaw/tutorials/stm/stm.html STM simulations]


== MATLAB Scripts ==
===GPAW Exercises Related to Midterm Project===


===Electron density in nanowires using equilibrium density matrix===
* [[Band structure of bulk graphene]]
*[http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/electron_density.m electron_density.m]
* [[Subband structure of graphene nanoribbons]]
*[[Discretization of 1D Hamiltonian]]
* [[Subband structure of carbon nanotubes]]
 
===DOS of disordered nanowire using eigenvalues and Anderson localization of eigenfunctions===
*[http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/disordered_nanowire.m disordered_nanowire.m]
 
===Density of states using equilibrium retarded Green function===
*[[Media:dos_negf_closed.m|dos_negf_closed.m]] computes DOS for finite 1D wire
*[[Media:dos_negf_open.m|dos_negf_open.m]] computes DOS for finite 1D wire attached to a single reservoir
*[http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/graphene_dos.m graphene_dos.m] computes DOS for a supercell of graphene with periodic boundary conditions
 
===Subband structure of graphene nanoribbons using tight-binding models===
*[http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/8zgnr.m 8zgnr.m] (pedestrian code for 8-ZGNR only)
 
===Quantum transport in 1D nanowires using NEGF===
*[http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/qt_1d.m qt_1d.m] (code to compute the conductance and total and local density of states of a 1D nanowire, with possible potential barriers or impurities, attached to two semi-infinite electrodes)
 
===Tunneling magnetoresistance in 1D models===
* tmr_1d.m (code to compute conductance of F/I/F junction as a function of angle between magnetizations using 1D tight-binding Hamiltonian)
 
===Spin-transfer torque in 1D models===
* stt_1d.m (code to compute in-plan torque component in F/I/F junction using 1D tight-binding Hamiltonian)
 
===Quantum transport in graphene nanostructures using NEGF===
 
*[http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/gnr_cond_recursive.m gnr_cond_recursive.m],[http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/bstruct.m bstruct.m], [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/blocktosparse.m blocktosparse.m], [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/sparsetoblock.m sparsetoblock.m], [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/h_zigzag.m h_zigzag.m], [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/invnn.m invnn.m], [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/Self.m Self.m], (code to compute the conductance of a finite graphene nanoribbon attached to two semi-infinite graphene electrodes)


* M.-H. Liu and K. Richter, ''Efficient quantum transport simulation for bulk graphene heterojunctions'', [http://arxiv.org/abs/1206.0266  arXiv:1206.0266].
===References===
 
* ''Electronic structure calculations with GPAW: a real-space implementation of the projector augmented-wave method'', J. Phys.: Condens. Matter '''22''', 253202 (2010). [http://iopscience.iop.org/0953-8984/22/25/253202 [PDF]]
== MATLAB functions ==
* [https://wiki.fysik.dtu.dk/gpaw/documentation/manual.html Parameters selection in GPAW scripts]
* [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/matrix_exp.m matrix_exp.m] (Exponential, or any other function with small changed in the code, of a Hermitian  matrix)
* [https://wiki.fysik.dtu.dk/gpaw/documentation/lcao/lcao.html LCAO basis set in GPAW]
* [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/visual_graphene_H.m 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): [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/atomCoord.m atomCoord.m], [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/atomPosition.m atomPosition.m], and [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/constrainView.m constrainView.m]
* [https://wiki.fysik.dtu.dk/ase/ase/atoms.html Parameters selection in ASE to define atomic coordinates]
* [http://www.physics.udel.edu/~bnikolic/teaching/phys824/MATLAB/self_energy.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)
* [https://wiki.fysik.dtu.dk/gpaw/documentation/pdos/pdos.html Density of States in GPAW]
 
* [[About k-point sampling]]
== First-principles calculations using GPAW==
* [https://wiki.fysik.dtu.dk/gpaw/exercises/gettingstarted/gettingstarted.html Getting started with GPAW] (structure and binding energies of simple molecules)
* [https://wiki.fysik.dtu.dk/gpaw/exercises/water/water.html Basics of GPAW calculations]
* [https://wiki.fysik.dtu.dk/gpaw/exercises/iron/iron.html Band structure of Fe]
* [https://wiki.fysik.dtu.dk/gpaw/exercises/dos/dos.html DOS of Fe]
* [[Band structure of graphene]]
* [[Subband structure of graphene nanoribbons]]


== NEGF-DFT using GPAW==
== First-principles quantum transport calculations using NEGF+DFT within GPAW package==


===Zero-bias transmission function of single-molecule nanojunctions===
===Theory Background===
* [https://wiki.fysik.dtu.dk/gpaw/exercises/transport/transport.html Pt-<math> \mathrm{H}_2 </math>-Pt junction]  
* [[Media:negf_dft_slide.pdf|Crash course on NEGF+DFT codes]]
* [https://wiki.fysik.dtu.dk/gpaw/documentation/transport/negftransport.html 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). [http://link.aps.org/doi/10.1103/PhysRevB.85.155140 [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). [http://dx.doi.org/10.1063/1.2839275 [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). [https://wiki.physics.udel.edu/wiki_qttg/images/d/dc/Negf_dft_gnr.pdf [PDF]]


===I-V curve of magnetically ordered zigzag GNR===
===GPAW Exercises===
* D. A. Areshkin and B. K. Nikolić, ''I-V curve signatures of nonequilibrium-driven band gap collapse in magnetically ordered zigzag graphene nanoribbon two-terminal devices'', Phys. Rev. B '''79''', 205430 (2009). [https://wiki.physics.udel.edu/wiki_qttg/images/f/fa/Noneq_spin_zgnr.pdf [PDF]]
* [[PtH2Pt nanojunction|Pt-<math> \mathrm{H}_2 </math>-Pt nanojunction]].
* J. Chen, K. S. Thygesen, and K. W. Jacobsen, Phys. Rev. B '''85''', 155140 (2012). [http://link.aps.org/doi/10.1103/PhysRevB.85.155140 [PDF]]
* [[Annulene molecule between two graphene nanoribbon electrodes nanojunction]]

Latest revision as of 13:14, 7 September 2022

Installing Python and course related packages

conda install -c conda-forge kwant
pip install pythtb --upgrade
pip install --upgrade --user ase
python -m ase test
  • GPAW package can be easily installed using Anaconda on Linux or MacOS
  • If you want to add RISE package for Jupyter notebooks, execute:
conda install -c conda-forge rise

JUPYTER notebooks for hands-on practice

Python references

KWANT references

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

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)

GPAW Exercises Related to Midterm Project

References

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]

GPAW Exercises