Skip to content

Commit

Permalink
mnt: worked through basically all tutorials.
Browse files Browse the repository at this point in the history
All is good now.
  • Loading branch information
zerothi committed Apr 28, 2021
1 parent f891bb8 commit 93fcb71
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 24 deletions.
20 changes: 17 additions & 3 deletions A_05/run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,26 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Calculating projceted transmissions is verbose because multiple things is required to be defined. The following flags are required to be specified, careful read about each of them:\n",
"Calculating projected transmissions is verbose because multiple things is required to be defined. The following flags are required to be specified, careful read about each of them:\n",
"- TBT.Atoms.Device\n",
"- TBT.Projs (name the projection `C60`)\n",
"- TBT.Proj.<> (create a HOMO and a LUMO projection)\n",
"- TBT.Projs.T"
"- TBT.Projs.T\n",
"\n",
"After having completed the `tbtrans` calculation you will find the additional file `siesta.TBT.Proj.nc` file which contains the transmissions for the projected states.\n",
"\n",
"1. Read in the regular `siesta.TBT.nc` file and plot the transmission\n",
"2. Extend the transmission plot by adding the different projected transmissions (reading the documentation for the `tbtprojncSileTBtrans` is probably required).\n",
"3. Why do the total transmission not match the projected transmissions for the energies they represent? \n",
" *HINT*: degeneracy of HOMO and LUMO levels\n",
"4. Adapt the input to include more states in each HOMO, LUMO projection, rerun and check again.\n",
"5. **TIME**: Adapt the input to include every HOMO and LUMO state as a separate projection and run again. Compare each transmission."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
Expand All @@ -169,7 +183,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.8.5"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion S_01/run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.8.5"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions TB_04/run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
"collapsed": true
},
"source": [
"We may also plot the Green function density of states as well as the spectral density of states:"
"We may also plot the Green function density of states as well as the spectral density of states from each electrode:"
]
},
{
Expand All @@ -203,7 +203,7 @@
"metadata": {},
"source": [
"Can you from the above three quantities determine whether there are any localized states in the examined system? \n",
"_HINT_: What is the sum of the spectral density of states ($\\mathbf A$) compared to the Green function ($\\mathbf G$) density of states?"
"*HINT*: What is the sum of the spectral density of states ($\\mathbf A_i$) compared to the Green function ($\\mathbf G$) density of states?"
]
},
{
Expand All @@ -212,7 +212,7 @@
"source": [
"### Examining DOS on individual atoms\n",
"\n",
"The total DOS is a measure of the DOS spread out in the entire atomic region. However, TBtrans calculates, and stores all DOS related quantities in orbital resolution. I.e. we are able to post-process the DOS and examine the atom (orbital) resolved DOS. \n",
"The total DOS is a measure of the DOS spread out in the entire atomic region. However, TBtrans calculates, and stores all DOS related quantities in orbital resolution. I.e. we are able to post-process the DOS and examine the atom and/or orbital resolved DOS. \n",
"To do this the `.DOS` and `.ADOS` routines have two important keywords, 1) `atom` and 2) `orbital` which may be used to extract a subset of the DOS quantities. For details on extracting these subset quantities please read the documentation by executing the following line:\n",
"\n",
" help(tbt.DOS)\n",
Expand Down
10 changes: 6 additions & 4 deletions TB_05/run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
"As seen in [TB 4](../TB_04/run.ipynb) the transmission calculation takes a considerable amount of time. In this example we will redo the *same* calculation, but speed it up (no approximations made).\n",
"\n",
"A large computational effort is made on calculating the self-energies which basically is inverting, multiplying and adding matrices, roughly 10-20 times per $k$-point, per energy point, per electrode. \n",
"For some systems this is far more demanding than calculating the Green function for the system. \n",
"In systems where there is periodicity along the transverse semi-infinite direction (not along the transport direction) one can utilize Bloch's theorem to reduce the computational cost of calculating the self-energy. In ***ANY*** calculation if you have periodicity, please ***USE*** it. \n",
"For systems with large electrodes compared to the full device, this becomes more demanding than calculating the Green function for the system. \n",
"When there is periodicity in electrodes along the transverse semi-infinite direction (not along the transport direction) one can utilize Bloch's theorem to reduce the computational cost of calculating the self-energy.\n",
"\n",
"> In ***ANY*** calculation if you have periodicity, please ***USE*** it. \n",
"\n",
"In this example you should scour the tbtrans manual on how to enable Bloch's \n",
"theorem, and once enabled it should be roughly 3 - 4 times as fast, something that is non-negligeble for large systems."
Expand Down Expand Up @@ -116,7 +118,7 @@
" - The Green function DOS\n",
" - The spectral DOS\n",
" - The bulk DOS\n",
"5. Do the same calculation using only tiling. `H_elec.tile(25, axis=0).tile(15, axis=1)` instead of `repeat`/`tile`. Which of repeat or tile are faster?"
"5. **TIME**: Do the same calculation using only tiling. `H_elec.tile(25, axis=0).tile(15, axis=1)` instead of `repeat`/`tile`. Which of repeat or tile are faster?"
]
},
{
Expand Down Expand Up @@ -239,7 +241,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.8.5"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions TB_06/run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"source": [
"# Exercises\n",
"\n",
"In this example we have more than 1 transmission paths. Before you run the below code which plots all relevant transmissions ($T_{ij}$ for $j>i$), consider if there are any symmetries, and if so, determine how many different transmission spectra you should expect? Please plot the geometry using your favourite geometry viewer (`molden`, `Jmol`, ...). The answer is not so trivial."
"In this example we have more than 1 transmission path. Before you run the below code which plots all relevant transmissions ($T_{ij}$ for $j>i$), consider if there are any symmetries, and if so, determine how many different transmission spectra you should expect? Please plot the geometry using your favourite geometry viewer (`molden`, `Jmol`, ...). The answer is not so trivial."
]
},
{
Expand Down Expand Up @@ -313,7 +313,7 @@
"metadata": {},
"source": [
"Spectral density of states for all electrodes:\n",
"- As a final exercise you can explore the details of the density of states for single atoms. Take for instance atom 205 (204 in Python index) which is in *both* GNR at the crossing. \n",
"- As a final exercise you can explore the details of the density of states for single atoms. Take for instance atom 205 (204 in Python index) which is in *both* GNRs at the crossing. \n",
"Feel free to play around with different atoms, subset of atoms (pass a `list`) etc. "
]
},
Expand Down Expand Up @@ -376,7 +376,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.8.5"
}
},
"nbformat": 4,
Expand Down
7 changes: 3 additions & 4 deletions TB_07/run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"Now we have $\\mathbf H(0)$ with *no* phases due to magnetic fields. As the magnetic field is changing the Hamiltonian, and thus enters the bond-current calculations, we have to use the $\\delta\\mathbf H$ term (and *not* $\\delta\\boldsymbol\\Sigma$).\n",
"\n",
"The first thing we need to calculate is $\\delta x^- \\cdot\\delta y^+$.\n",
"Since we already have the Hamiltonian we can utilize the connections by looping the coupling elements (in a sparse matrix/graph this is called *edges*). This is *much* cheaper than trying to figure out which atoms are neighbouring."
"Since we already have the Hamiltonian we can utilize the connections by looping the coupling elements (in a sparse matrix/graph these are called *edges*). This is *much* cheaper than trying to figure out which atoms are neighbouring."
]
},
{
Expand Down Expand Up @@ -136,7 +136,7 @@
"metadata": {},
"source": [
"Now we have the coupling dependent phase factor, $\\delta x^-\\cdot\\delta y^+$, and all we need to calculate is $\\delta\\mathbf H$ that transforms $\\mathbf H(0) \\to \\mathbf H(\\Phi)$. \n",
"This is done easily as a `Hamiltonian` allows basic element wise operations, i.e. `+`, `-`, `*`, `/` and `**` (the power function). \n",
"This is easily done as the `Hamiltonian` allows basic element wise operations, i.e. `+`, `-`, `*`, `/` and `**` (the power function). \n",
"Your task is to insert the correct mathematical equation below, such that `dH` contains $\\delta \\mathbf H$ for $\\mathbf H(\\Phi) = \\mathbf H(0) + \\delta\\mathbf H$.\n",
"To help you I have inserted the exponential function. To finalize the equation, you need three terms: `H`, `xy` and `rec_phi`.\n",
"<!-- dH = np.exp(0.5j / rec_phi * xy) * H - H-->"
Expand Down Expand Up @@ -166,8 +166,7 @@
"- Calculate all physical quantities for all different applied magnetic fields. \n",
" Before running the calculations, search the manual on how to save the self-energies (*HINT* out-of-core). By default, TBtrans calculates the self-energies as they are needed. However, if one has the same electrodes, same $k$-grid and same $E$-points for several different runs (as in this case) one can with benefit calculate the self-energies *once*, and then reuse them in subsequent calculations.\n",
"\n",
" To ease the calculation of all magnetic fields \n",
" To help you a script `run.sh` is located in this directory. Carefully read it to infer which option specifies the $\\delta \\mathbf H$ term.\n",
" To ease the calculation of all magnetic fields a script (`run.sh`) is located in this directory which will loop over the different fields. Carefully read it to infer which option specifies the $\\delta \\mathbf H$ term.\n",
" \n",
" Since this example has 14 different setups, each with 51 energy points, it will take some time. Around 30 seconds for the first (includes self-energy calculation), and around 10 seconds for all subsequent setups. So be patient. :)\n",
"- Secondly, read in all output into the workbook in a list.\n",
Expand Down
27 changes: 21 additions & 6 deletions TB_08/run.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"In TBtrans and TranSiesta one is capable of performing real space transport calculations by using real space self-energies (see [here](https://doi.org/10.1103/PhysRevB.100.195417)). \n",
"Currently the real space self-energy calculation *has* to be performed in `sisl` since it is not implemented in TranSiesta.\n",
"\n",
"A real space self-energy is a $\\mathbf k$ averaged self-energy which can emulate *any* 2D or 3D electrode. I.e. for an STM junction a tip and a surface. In such a system the surface could be modelled using the real space self-energy to remove mirror effects of STM tips.\n",
"A real space self-energy is a $\\mathbf k$ averaged self-energy which can emulate *any* 2D or 3D electrode. I.e. for an STM junction a tip and a surface. In such a system the surface could be modelled using the real space self-energy to remove mirror effects of STM tips. This is important since the distance between periodic images disturbs the calculation due to long range potential effects.\n",
"\n",
"The basic principle for calculating the real space self-energy is the Brillouin zone integral:\n",
"\\begin{equation}\n",
Expand All @@ -32,6 +32,8 @@
"\n",
"---\n",
"\n",
"This example is rather complicated why basically everything is already done for you. Please try and understand each step.\n",
"\n",
"We start by creating the graphene tight-binding model."
]
},
Expand Down Expand Up @@ -61,7 +63,7 @@
"metadata": {},
"source": [
"Once the minimal graphene unit-cell (here orthogonal) is created we now turn to the calculation of the real space self-energy. \n",
"The construction of this object is somewhat complicated:\n",
"The construction of this object is somewhat complicated and has a set of required input options:\n",
"- `object`: the Hamiltonian\n",
"- `semi_axes`: which axes to use for the recursive self-energy\n",
"- `k_axis`: which axis to integrate in the Brillouin zone\n",
Expand All @@ -74,6 +76,11 @@
"metadata": {},
"outputs": [],
"source": [
"# object = H_minimal\n",
"# semi_axes = 0, x-axis uses recursive self-energy calculation\n",
"# k_axis = 1, y-axis uses a Brillouin zone integral\n",
"# unfold = (10, 10, 1), the full real-space green function is equivalent to the system\n",
"# H_minimal.tile(10, 0).tile(10, 1)\n",
"RSSE = sisl.RealSpaceSE(H_minimal, 0, 1, (10, 10, 1))"
]
},
Expand All @@ -82,16 +89,16 @@
"metadata": {},
"source": [
"Now we can create the real space self-energy. \n",
"However, in TBtrans (and TranSiesta) the electrode atomic indices *must* be in consecutive order.\n",
"This is a little troublesome since the natural order in a device would be an order according to $x$, $y$ or $z$. To create the correct order we extract the *real space coupling* matrix which is where the real space self-energy would like, the self-energy is calculated using:\n",
"In TBtrans (and TranSiesta) the electrode atomic indices *must* be in consecutive order.\n",
"This is a little troublesome since the natural order in a device would be an order according to $x$, $y$ or $z$. To create the correct order we extract the *real space coupling* matrix which is where the real space self-energy would live, the self-energy is calculated using:\n",
"\\begin{equation}\n",
" \\boldsymbol\\Sigma^{\\mathcal R} = E \\mathbf S - \\mathbf H - \\Big[\\int_{\\mathrm{BZ}} \\mathbf G\\Big]^{-1}.\n",
"\\end{equation}\n",
"Another way to calculate the self-energy would be to transfer the Green function from the infinite bulk into the region of interest:\n",
"\\begin{equation}\n",
" \\boldsymbol\\Sigma^{\\mathcal R} = \\mathbf V_{\\mathcal R\\infty}\\mathbf G_{\\infty\\setminus\\mathcal R}\\mathbf V_{\\infty\\mathcal R}.\n",
"\\end{equation}\n",
"From the 2nd equation it is obvious that the self-energy only lives on the boundary that $\\mathbf V_{\\infty\\mathcal R}$ couples to. Exactly this region is extracted using `real_space_coupling` as below. \n",
"From the 2nd equation it is obvious that the self-energy only lives on the boundary that $\\mathbf V_{\\infty\\mathcal R}$ couples to. Exactly this region is extracted using `real_space_coupling` as below. Take some time to draw a simple 2D lattice coupling and confirm the area that the real-space self energies couples to. \n",
"In this example we also retrieve the indices for the electrode atoms, those that connect *out to the infinite plane*."
]
},
Expand All @@ -105,6 +112,13 @@
"H_elec.write('GRAPHENE.nc')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The above yields the electrode region which contains the self-energies. Since the full device region is nothing but the `H_minimal` tiled $10\\times10$ times with an attached STM tip on top. Here we need to arange the electrode atoms first, then the final device region. The `real_space_parent` method returns the Hamiltonian that obeys the *unfolded* size. In this case $10\\times10$ times larger. One should always use this method to get the correct device order of atoms since the order of tiling is determined by the `semi_axes` and `k_axis` arguments."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -115,6 +129,7 @@
"# Create the true device by re-arranging the atoms\n",
"indices = np.arange(len(H))\n",
"indices = np.delete(indices, elec_indices)\n",
"# first electrodes, then rest of device\n",
"indices = np.concatenate([elec_indices, indices])\n",
"# Now re-arange matrix\n",
"H = H.sub(indices)"
Expand All @@ -124,7 +139,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Lastly, we need to add the STM tip. Here we simply add a gold atom and manually add the hoppings. "
"Lastly, we need to add the STM tip. Here we simply add a gold atom and manually add the hoppings. Since this is tight-binding we have full control over the self-energy and potential land-scape. Therefore we don't need to extend the electrode region to screen off the tip region. In DFT systems, a properly screened region is required."
]
},
{
Expand Down

0 comments on commit 93fcb71

Please sign in to comment.