diff --git a/install_tutorial.sh b/install_tutorial.sh index cd2f391..50e7287 100755 --- a/install_tutorial.sh +++ b/install_tutorial.sh @@ -1,31 +1,32 @@ #!/bin/bash -url=www.student.dtu.dk/~nicpa/sisl/workshop/20 +url=www.student.dtu.dk/~nicpa/sisl/workshop/21 +indir=$HOME/TBT-TS-sisl-workshop function _help { echo "This script may be used to install the dependencies for the" - echo "tutorial such as Python, numpy, scipy matplotlib, jupyter and sisl." + echo "tutorial such as Python, numpy, scipy matplotlib, jupyter, sisl and z2pack." echo "" echo "This script is a two-step script. Please read below." echo "" - echo "If you do not have Python, numpy, scipy, jupyter, matplotlib or sisl installed" - echo "you should probably run this script in installation mode:" + echo "Running this script in installation mode will download and install conda" + echo "conda provides both Siesta executables as well as the sisl and dependency packages" + echo "so once installed all required infrastructure is available." + echo "It does, however, require a disk space of approximately >4GB" echo "" - echo " $0 install" + echo "To use the conda framework, run this script in installation mode:" echo "" - echo "If you have a working Python installation with pip3 you may only need" - echo "to run" + echo " $0 install" echo "" - echo " pip3 install --upgrade numpy scipy matplotlib netCDF4 jupyter pyamg sisl z2pack" + echo "If you can install Siesta 4.1.5 and sisl 0.11.0 and the rest of the dependencies" + echo "manually then you won't be needing the above installation procedure." + echo "However, we cannot assist installing the packages manually." echo "" - echo "Once the above steps are fulfilled you should run the download part" + echo "Once the above step is fulfilled you should run the download part" echo "of the script. It will download the required files for the tutorial:" echo "" echo " $0 download" echo "" - echo "During the download part a new directory will be created:" - echo " $HOME/TBT-TS-sisl-workshop" - echo "" } if [ $# -eq 0 ]; then @@ -55,7 +56,7 @@ case "x$OSTYPE" in os=macos ;; *) - echo "Are you using MingGW or FreeBSD? Or a third?" + echo "Are you using MingGW or FreeBSD? Or a ($(uname -s))?" echo "Either way this installation script does not work for your distribution..." exit 1 ;; @@ -101,110 +102,66 @@ case $1 in esac -# Function for installation on Linux -function linux_install { +function dwn_file { + local rname=$1 + local outname=$1 + if [ $# -eq 2 ]; then + outname=$2 + fi + if [ ! -e $outname ]; then + wget -O $outname $url/$(basename $rname) + if [ $? -eq 0 ]; then + chmod u+x $outname + else + rm -f $outname + fi + fi +} - # Update lists - sudo apt-get update - # First ensure that the correct packages are installed - for p in gcc gfortran libhdf5-dev libnetcdf-dev libnetcdff-dev python3-dev python3-tk python3-pip libatlas3-base liblapack3 libfreetype6-dev libpng-dev - do - sudo apt-get install $p - done - - # Perform the Python installation - pip3 install --upgrade six numpy scipy matplotlib netCDF4 jupyter pyamg sisl z2pack - if [ $? -ne 0 ]; then - echo "pip3 failed to install the packages, will try to install" - echo "in your user directory, if this fails you will have to fix it" - pip3 install --user --upgrade six numpy scipy matplotlib netCDF4 jupyter pyamg sisl z2pack - if [ $? -ne 0 ]; then - echo "" - echo "pip3 failed to install the packages, in either the global or user domain." - echo "Please try and get pip3 to work and re-run the installation proceduce." - fi +function conda_install { + local exe=$1 ; shift + + [ ! -e $exe ] && wget -O $exe https://repo.anaconda.com/miniconda/$exe + + if [ -e $indir/miniconda3/etc/profile.d/conda.sh ]; then + # it should already be installed + source $indir/miniconda3/etc/profile.d/conda.sh + else + sh ./$exe -b -s -f -p $indir/miniconda3 + source $indir/miniconda3/etc/profile.d/conda.sh fi - # Figure out the local pip3 version - # Note that sometimes this may be wrong since Python should be `python3`. - local py_v=$(pip3 -V | awk '{print $NF}' | tr -d ')') + conda install -c conda-forge -y siesta=4.1.5 sisl=0.11.0 matplotlib jupyter pyamg + + # remove unused tarballs (no need for them to be around) + conda clean -t -y echo "" - echo "This script assumes you are using Python $py_v" + echo "Before you can run exercises etc. you should execute the following:" echo "" - - # You probably need to add to the path, this is a simplistic way of - # adding the default ubuntu installation directories - grep "/.local/bin" ~/.bashrc > /dev/null - if [ $? -eq 1 ]; then - echo "" >> ~/.bashrc - echo "export PATH=\$HOME/.local/bin:\$PATH" >> ~/.bashrc - echo "" - echo "PLEASE RESTART YOUR SHELL!" - fi - grep "/.local/lib/python$py_v" ~/.bashrc > /dev/null - if [ $? -eq 1 ]; then - echo "" >> ~/.bashrc - echo "export PYTHONPATH=\$HOME/.local/lib/python$py_v/site-packages:\$PYTHONPATH" >> ~/.bashrc - echo "" - echo "PLEASE RESTART YOUR SHELL!" - fi -} + echo " source $indir/setup.sh" + echo "" + { + echo "#!/bin/bash" + echo "source $indir/miniconda3/etc/profile.d/conda.sh" + echo "conda activate" + } > $indir/setup.sh + source $indir/setup.sh -# Function for installation on Linux -function my_brew { - brew $@ - if [ $? -ne 0 ]; then - echo "Running:" - echo " brew $@" - echo "failed." - echo "If this requests you should do a link brew:" - echo " brew link ..." - echo "then most probably your write access to this folder is prohibited:" - echo " /usr/local/include/Frameworks" - echo "If the folder does not exist, create it." - exit 1 - fi + # now install packages not part of conda-forge + pip install z2pack } - -function macos_install { - # Check that brew is installed? - which brew 2>/dev/null - if [ $? -ne 0 ]; then - echo "You have not installed brew, this script requires that you have brew installed" - exit 1 - fi - - # First we need to install xcode-select - xcode-select --install - - # Now try and install gcc (it should also include gfortran) - my_brew install gcc - # Ensure wget is installed - my_brew install wget --with-libressl - - # Add the science tap (it HAS been deprecated, so probably not needed - #my_brew tap homebrew/science +# Function for installation on Linux +function linux_install { + conda_install Miniconda3-latest-Linux-x86_64.sh +} - my_brew install szip hdf5 - my_brew install netcdf --with-fortran - my_brew install python3 - sudo easy_install pip3 - pip3 install --upgrade six numpy scipy matplotlib netCDF4 jupyter pyamg sisl z2pack - if [ $? -ne 0 ]; then - echo "pip3 failed to install the packages, will try to install" - echo "in your user directory, if this fails you will have to fix it" - pip3 install --user --upgrade six numpy scipy matplotlib netCDF4 jupyter pyamg sisl z2pack - if [ $? -ne 0 ]; then - echo "" - echo "pip3 failed to install the packages, in either the global or user domain." - echo "Please try and get pip3 to work and re-run the installation proceduce." - fi - fi +function macos_install { + conda_install Miniconda3-latest-MacOSX-x86_64.sh } function install_warning { @@ -215,70 +172,54 @@ function install_warning { echo "" echo " CTRL+^C" echo "" + echo "Please ensure you have more than 5 GB of disk space available!" + echo "" sleep 3 } +# Now create a common folder in the top-home directory + +function download_warning { + echo "" + echo "This script will create a folder in your $HOME directory:" + echo " $HOME/TBT-TS-sisl-workshop" + echo "where all the tutorials and executable files will be downloaded." + echo "" +} + function install_test_sisl { echo "" echo " Will try and run sisl" - echo " import sisl ; print(sisl.geom.graphene())" - python3 -c "import sisl ; print(sisl.geom.graphene())" + echo " import sisl ; print(sisl.__version__, sisl.__file__)" + python -c "import sisl ; print(sisl.__version__, sisl.__file__)" if [ $? -ne 0 ]; then echo "Failed running sisl, please mail the organizer with the error message (unless some of the installations failed)" fi } +# create installation directory +mkdir -p $indir +pushd $indir + if [ $action == install ]; then # os will be download + download_warning + install_warning case $os in linux) - install_warning linux_install ;; macos) - install_warning macos_install ;; esac install_test_sisl exit 0 +else + download_warning fi -# Now create a common folder in the top-home directory - -function download_warning { - echo "" - echo "This script will create a folder in your $HOME directory:" - echo " $HOME/TBT-TS-sisl-workshop" - echo "where all the tutorials and executable files will be downloaded." - echo "" -} - -function dwn_file { - local rname=$1 - local outname=$1 - if [ $# -eq 2 ]; then - outname=$2 - fi - if [ ! -e $outname ]; then - wget -O $outname $url/$(basename $rname) - if [ $? -eq 0 ]; then - chmod u+x $outname - else - rm -f $outname - fi - fi -} - -download_warning - -indir=$HOME/TBT-TS-sisl-workshop -mkdir -p $indir -pushd $indir - -# Now download the executables -mkdir -p bin # Download latest tutorial files if [ -e sisl-TBT-TS.tar.gz ]; then @@ -286,46 +227,16 @@ if [ -e sisl-TBT-TS.tar.gz ]; then fi dwn_file sisl-TBT-TS.tar.gz -# Determine the optimization level for the current architecture -_suffix= -case $os in - linux) - # Figure out if the user has AVX - if $(grep "avx2" /proc/cpuinfo > /dev/null) ; then - _suffix=_avx2 - elif $(grep "avx" /proc/cpuinfo > /dev/null) ; then - _suffix=_avx - elif $(grep "sse2" /proc/cpuinfo > /dev/null) ; then - _suffix=_sse - fi - ;; -esac - -case $os in - linux) - dwn_file bin/siesta$_suffix bin/siesta - dwn_file bin/tbtrans$_suffix bin/tbtrans - ;; - macos) - dwn_file bin/siesta_mac bin/siesta - dwn_file bin/tbtrans_mac bin/tbtrans - ;; -esac - -# We will simply add it if it does not exist -# We also assume the SHELL is BASH -if ! `grep $indir ~/.bashrc` ; then - echo "" >> ~/.bashrc - echo "# Variable for the TBT-TS-sisl workshop" >> ~/.bashrc - echo "export PATH=$indir/bin:\$PATH" >> ~/.bashrc - echo "" >> ~/.bashrc -fi - echo "" echo "In folder" echo " $indir" -echo "you will find everything needed for the tutorial" -echo "If you use BASH (most likely) you should have siesta and tbtrans in your path." +echo "you will find everything needed for the tutorial." +echo "If you are using the conda installation provided by this script" +echo "please always start your sessions by executing:" +echo "" +echo " source $indir/setup.sh" +echo "" +echo "which will correctly setup the environment for you." echo "Run (after you have restarted your shell):" echo " which tbtrans" -echo "and check it returns $indir/bin/tbtrans" +echo "and check it returns $indir/miniconda3/bin/tbtrans" diff --git a/presentations/01/electrodes.tex b/presentations/01/electrodes.tex index 7d405ed..33d49c6 100644 --- a/presentations/01/electrodes.tex +++ b/presentations/01/electrodes.tex @@ -413,10 +413,10 @@ \subsection{Electrodes} } \uncover<3->{ \fill (.5,0) circle (\mysize) node[above right] {1}; - \fill (1.5,0) circle (\mysize) node[above right] {2}; - \fill (2.5,0) circle (\mysize) node[above right] {3}; - \fill (.5,1) circle (\mysize) node[above right] {4}; - \fill (1.5,1) circle (\mysize) node[above right] {5}; + \fill (1.5,0) circle (\mysize) node[above right] {3}; + \fill (2.5,0) circle (\mysize) node[above right] {5}; + \fill (.5,1) circle (\mysize) node[above right] {2}; + \fill (1.5,1) circle (\mysize) node[above right] {4}; \fill (2.5,1) circle (\mysize) node[above right] {6}; } \foreach \x in {-2.5,-1.5,-.5,3.5,4.5,5.5} { diff --git a/presentations/01/negf.tex b/presentations/01/negf.tex index 9bd4f56..8ac1724 100644 --- a/presentations/01/negf.tex +++ b/presentations/01/negf.tex @@ -150,8 +150,8 @@ \subsection{Transmission} The sum of bond-currents crossing \emph{any} device cross-section is equal to the current between the leads. Without the prefactor $e/h$ this also applies for the - bond-transmissions\footnote{TBtrans calculates bond-\emph{transmissions}, although - they are named \emph{currents}.}. + bond-transmissions\footnote{TBtrans calculates bond-\emph{transmissions} (without the + prefactor $e/h$), although they are named \emph{currents}.}. The bond-currents obey Kirchoff's laws. diff --git a/presentations/01/se.tex b/presentations/01/se.tex index 878615f..3384012 100644 --- a/presentations/01/se.tex +++ b/presentations/01/se.tex @@ -46,7 +46,7 @@ \subsection{Semi-infinity} Describes interaction of a system to a semi-infinite region \item% - Self-energy calculations \emph{require} no more than nearest neighbour interactions between unit-cells! + Self-energy calculations \emph{require} no more than nearest neighbour interactions between unit-cells \begin{align*} \SE_{\mrc 11}(E) &= \VV^\dagger\big[E+\im\eta-\HH\big]^{-1}\VV diff --git a/presentations/02/sisl.tex b/presentations/02/sisl.tex index 13defcf..99f1d4d 100644 --- a/presentations/02/sisl.tex +++ b/presentations/02/sisl.tex @@ -101,7 +101,7 @@ \subsection{Calculating DOS} \begin{verbatim} H = sisl.Hamiltonian.read('RUN.fdf') - mp = sisl.MonkhorstPack(H, [nx, ny, nz]).asaverage() + mp = sisl.MonkhorstPack(H, [nx, ny, nz]).apply.average E = np.linspace(-4, 4, 1000) DOS = mp.DOS(E) \end{verbatim} diff --git a/presentations/04/hartree.tex b/presentations/04/hartree.tex index 0affa43..075ca1a 100644 --- a/presentations/04/hartree.tex +++ b/presentations/04/hartree.tex @@ -73,7 +73,7 @@ \subsection{Boundary conditions} \begin{block}<+->{Boundary conditions} - The electrode Hartree potential are the boundary conditions. + The electrode Hartree potential is the boundary condition. In TranSiesta this is accomplished by fixing the electrostatic potential at one of the electrode planes. diff --git a/siesta.pdf b/siesta.pdf index d2c3642..4abae9d 100644 Binary files a/siesta.pdf and b/siesta.pdf differ diff --git a/tbtrans.pdf b/tbtrans.pdf index 114d994..5deea32 100644 Binary files a/tbtrans.pdf and b/tbtrans.pdf differ