# Computer Lab

## MATLAB Training

### Hands-on tutorials by Instructor

nohup matlab -nojvm < your_script.m > output_messages &


## Python training

### Using Anaconda Python

export PATH="/opt/anaconda/1.9.2/bin:\$PATH"


## MATLAB Scripts

### 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

### 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)

## 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)