Skip to content

Commit ad0047e

Browse files
committed
Merge branch '2021'
2 parents 4b93d53 + 936751a commit ad0047e

8 files changed

Lines changed: 100 additions & 189 deletions

File tree

install_tutorial.sh

Lines changed: 91 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
#!/bin/bash
22

3-
url=www.student.dtu.dk/~nicpa/sisl/workshop/20
3+
url=www.student.dtu.dk/~nicpa/sisl/workshop/21
4+
indir=$HOME/TBT-TS-sisl-workshop
45

56
function _help {
67
echo "This script may be used to install the dependencies for the"
7-
echo "tutorial such as Python, numpy, scipy matplotlib, jupyter and sisl."
8+
echo "tutorial such as Python, numpy, scipy matplotlib, jupyter, sisl and z2pack."
89
echo ""
910
echo "This script is a two-step script. Please read below."
1011
echo ""
11-
echo "If you do not have Python, numpy, scipy, jupyter, matplotlib or sisl installed"
12-
echo "you should probably run this script in installation mode:"
12+
echo "Running this script in installation mode will download and install conda"
13+
echo "conda provides both Siesta executables as well as the sisl and dependency packages"
14+
echo "so once installed all required infrastructure is available."
15+
echo "It does, however, require a disk space of approximately >4GB"
1316
echo ""
14-
echo " $0 install"
17+
echo "To use the conda framework, run this script in installation mode:"
1518
echo ""
16-
echo "If you have a working Python installation with pip3 you may only need"
17-
echo "to run"
19+
echo " $0 install"
1820
echo ""
19-
echo " pip3 install --upgrade numpy scipy matplotlib netCDF4 jupyter pyamg sisl z2pack"
21+
echo "If you can install Siesta 4.1.5 and sisl 0.11.0 and the rest of the dependencies"
22+
echo "manually then you won't be needing the above installation procedure."
23+
echo "However, we cannot assist installing the packages manually."
2024
echo ""
21-
echo "Once the above steps are fulfilled you should run the download part"
25+
echo "Once the above step is fulfilled you should run the download part"
2226
echo "of the script. It will download the required files for the tutorial:"
2327
echo ""
2428
echo " $0 download"
2529
echo ""
26-
echo "During the download part a new directory will be created:"
27-
echo " $HOME/TBT-TS-sisl-workshop"
28-
echo ""
2930
}
3031

3132
if [ $# -eq 0 ]; then
@@ -55,7 +56,7 @@ case "x$OSTYPE" in
5556
os=macos
5657
;;
5758
*)
58-
echo "Are you using MingGW or FreeBSD? Or a third?"
59+
echo "Are you using MingGW or FreeBSD? Or a ($(uname -s))?"
5960
echo "Either way this installation script does not work for your distribution..."
6061
exit 1
6162
;;
@@ -101,110 +102,66 @@ case $1 in
101102
esac
102103

103104

104-
# Function for installation on Linux
105-
function linux_install {
105+
function dwn_file {
106+
local rname=$1
107+
local outname=$1
108+
if [ $# -eq 2 ]; then
109+
outname=$2
110+
fi
111+
if [ ! -e $outname ]; then
112+
wget -O $outname $url/$(basename $rname)
113+
if [ $? -eq 0 ]; then
114+
chmod u+x $outname
115+
else
116+
rm -f $outname
117+
fi
118+
fi
119+
}
106120

107-
# Update lists
108-
sudo apt-get update
109121

110-
# First ensure that the correct packages are installed
111-
for p in gcc gfortran libhdf5-dev libnetcdf-dev libnetcdff-dev python3-dev python3-tk python3-pip libatlas3-base liblapack3 libfreetype6-dev libpng-dev
112-
do
113-
sudo apt-get install $p
114-
done
115-
116-
# Perform the Python installation
117-
pip3 install --upgrade six numpy scipy matplotlib netCDF4 jupyter pyamg sisl z2pack
118-
if [ $? -ne 0 ]; then
119-
echo "pip3 failed to install the packages, will try to install"
120-
echo "in your user directory, if this fails you will have to fix it"
121-
pip3 install --user --upgrade six numpy scipy matplotlib netCDF4 jupyter pyamg sisl z2pack
122-
if [ $? -ne 0 ]; then
123-
echo ""
124-
echo "pip3 failed to install the packages, in either the global or user domain."
125-
echo "Please try and get pip3 to work and re-run the installation proceduce."
126-
fi
122+
function conda_install {
123+
local exe=$1 ; shift
124+
125+
[ ! -e $exe ] && wget -O $exe https://repo.anaconda.com/miniconda/$exe
126+
127+
if [ -e $indir/miniconda3/etc/profile.d/conda.sh ]; then
128+
# it should already be installed
129+
source $indir/miniconda3/etc/profile.d/conda.sh
130+
else
131+
sh ./$exe -b -s -f -p $indir/miniconda3
132+
source $indir/miniconda3/etc/profile.d/conda.sh
127133
fi
128134

129-
# Figure out the local pip3 version
130-
# Note that sometimes this may be wrong since Python should be `python3`.
131-
local py_v=$(pip3 -V | awk '{print $NF}' | tr -d ')')
135+
conda install -c conda-forge -y siesta=4.1.5 sisl=0.11.0 matplotlib jupyter pyamg
136+
137+
# remove unused tarballs (no need for them to be around)
138+
conda clean -t -y
132139

133140
echo ""
134-
echo "This script assumes you are using Python $py_v"
141+
echo "Before you can run exercises etc. you should execute the following:"
135142
echo ""
136-
137-
# You probably need to add to the path, this is a simplistic way of
138-
# adding the default ubuntu installation directories
139-
grep "/.local/bin" ~/.bashrc > /dev/null
140-
if [ $? -eq 1 ]; then
141-
echo "" >> ~/.bashrc
142-
echo "export PATH=\$HOME/.local/bin:\$PATH" >> ~/.bashrc
143-
echo ""
144-
echo "PLEASE RESTART YOUR SHELL!"
145-
fi
146-
grep "/.local/lib/python$py_v" ~/.bashrc > /dev/null
147-
if [ $? -eq 1 ]; then
148-
echo "" >> ~/.bashrc
149-
echo "export PYTHONPATH=\$HOME/.local/lib/python$py_v/site-packages:\$PYTHONPATH" >> ~/.bashrc
150-
echo ""
151-
echo "PLEASE RESTART YOUR SHELL!"
152-
fi
153-
}
143+
echo " source $indir/setup.sh"
144+
echo ""
145+
{
146+
echo "#!/bin/bash"
147+
echo "source $indir/miniconda3/etc/profile.d/conda.sh"
148+
echo "conda activate"
149+
} > $indir/setup.sh
154150

151+
source $indir/setup.sh
155152

156-
# Function for installation on Linux
157-
function my_brew {
158-
brew $@
159-
if [ $? -ne 0 ]; then
160-
echo "Running:"
161-
echo " brew $@"
162-
echo "failed."
163-
echo "If this requests you should do a link brew:"
164-
echo " brew link ..."
165-
echo "then most probably your write access to this folder is prohibited:"
166-
echo " /usr/local/include/Frameworks"
167-
echo "If the folder does not exist, create it."
168-
exit 1
169-
fi
153+
# now install packages not part of conda-forge
154+
pip install z2pack
170155
}
171-
172-
function macos_install {
173156

174-
# Check that brew is installed?
175-
which brew 2>/dev/null
176-
if [ $? -ne 0 ]; then
177-
echo "You have not installed brew, this script requires that you have brew installed"
178-
exit 1
179-
fi
180-
181-
# First we need to install xcode-select
182-
xcode-select --install
183-
184-
# Now try and install gcc (it should also include gfortran)
185-
my_brew install gcc
186-
# Ensure wget is installed
187-
my_brew install wget --with-libressl
188-
189-
# Add the science tap (it HAS been deprecated, so probably not needed
190-
#my_brew tap homebrew/science
157+
# Function for installation on Linux
158+
function linux_install {
159+
conda_install Miniconda3-latest-Linux-x86_64.sh
160+
}
191161

192-
my_brew install szip hdf5
193-
my_brew install netcdf --with-fortran
194-
my_brew install python3
195-
sudo easy_install pip3
196162

197-
pip3 install --upgrade six numpy scipy matplotlib netCDF4 jupyter pyamg sisl z2pack
198-
if [ $? -ne 0 ]; then
199-
echo "pip3 failed to install the packages, will try to install"
200-
echo "in your user directory, if this fails you will have to fix it"
201-
pip3 install --user --upgrade six numpy scipy matplotlib netCDF4 jupyter pyamg sisl z2pack
202-
if [ $? -ne 0 ]; then
203-
echo ""
204-
echo "pip3 failed to install the packages, in either the global or user domain."
205-
echo "Please try and get pip3 to work and re-run the installation proceduce."
206-
fi
207-
fi
163+
function macos_install {
164+
conda_install Miniconda3-latest-MacOSX-x86_64.sh
208165
}
209166

210167
function install_warning {
@@ -215,117 +172,71 @@ function install_warning {
215172
echo ""
216173
echo " CTRL+^C"
217174
echo ""
175+
echo "Please ensure you have more than 5 GB of disk space available!"
176+
echo ""
218177
sleep 3
219178
}
220179

180+
# Now create a common folder in the top-home directory
181+
182+
function download_warning {
183+
echo ""
184+
echo "This script will create a folder in your $HOME directory:"
185+
echo " $HOME/TBT-TS-sisl-workshop"
186+
echo "where all the tutorials and executable files will be downloaded."
187+
echo ""
188+
}
189+
221190
function install_test_sisl {
222191
echo ""
223192
echo " Will try and run sisl"
224-
echo " import sisl ; print(sisl.geom.graphene())"
225-
python3 -c "import sisl ; print(sisl.geom.graphene())"
193+
echo " import sisl ; print(sisl.__version__, sisl.__file__)"
194+
python -c "import sisl ; print(sisl.__version__, sisl.__file__)"
226195
if [ $? -ne 0 ]; then
227196
echo "Failed running sisl, please mail the organizer with the error message (unless some of the installations failed)"
228197
fi
229198
}
230199

200+
# create installation directory
201+
mkdir -p $indir
202+
pushd $indir
203+
231204
if [ $action == install ]; then
232205
# os will be download
206+
download_warning
207+
install_warning
233208
case $os in
234209
linux)
235-
install_warning
236210
linux_install
237211
;;
238212
macos)
239-
install_warning
240213
macos_install
241214
;;
242215
esac
243216
install_test_sisl
244217

245218
exit 0
219+
else
220+
download_warning
246221
fi
247222

248-
# Now create a common folder in the top-home directory
249-
250-
function download_warning {
251-
echo ""
252-
echo "This script will create a folder in your $HOME directory:"
253-
echo " $HOME/TBT-TS-sisl-workshop"
254-
echo "where all the tutorials and executable files will be downloaded."
255-
echo ""
256-
}
257-
258-
function dwn_file {
259-
local rname=$1
260-
local outname=$1
261-
if [ $# -eq 2 ]; then
262-
outname=$2
263-
fi
264-
if [ ! -e $outname ]; then
265-
wget -O $outname $url/$(basename $rname)
266-
if [ $? -eq 0 ]; then
267-
chmod u+x $outname
268-
else
269-
rm -f $outname
270-
fi
271-
fi
272-
}
273-
274-
download_warning
275-
276-
indir=$HOME/TBT-TS-sisl-workshop
277-
mkdir -p $indir
278-
pushd $indir
279-
280-
# Now download the executables
281-
mkdir -p bin
282223

283224
# Download latest tutorial files
284225
if [ -e sisl-TBT-TS.tar.gz ]; then
285226
rm sisl-TBT-TS.tar.gz
286227
fi
287228
dwn_file sisl-TBT-TS.tar.gz
288229

289-
# Determine the optimization level for the current architecture
290-
_suffix=
291-
case $os in
292-
linux)
293-
# Figure out if the user has AVX
294-
if $(grep "avx2" /proc/cpuinfo > /dev/null) ; then
295-
_suffix=_avx2
296-
elif $(grep "avx" /proc/cpuinfo > /dev/null) ; then
297-
_suffix=_avx
298-
elif $(grep "sse2" /proc/cpuinfo > /dev/null) ; then
299-
_suffix=_sse
300-
fi
301-
;;
302-
esac
303-
304-
case $os in
305-
linux)
306-
dwn_file bin/siesta$_suffix bin/siesta
307-
dwn_file bin/tbtrans$_suffix bin/tbtrans
308-
;;
309-
macos)
310-
dwn_file bin/siesta_mac bin/siesta
311-
dwn_file bin/tbtrans_mac bin/tbtrans
312-
;;
313-
esac
314-
315-
# We will simply add it if it does not exist
316-
# We also assume the SHELL is BASH
317-
if ! `grep $indir ~/.bashrc` ; then
318-
echo "" >> ~/.bashrc
319-
echo "# Variable for the TBT-TS-sisl workshop" >> ~/.bashrc
320-
echo "export PATH=$indir/bin:\$PATH" >> ~/.bashrc
321-
echo "" >> ~/.bashrc
322-
fi
323-
324230
echo ""
325231
echo "In folder"
326232
echo " $indir"
327-
echo "you will find everything needed for the tutorial"
328-
echo "If you use BASH (most likely) you should have siesta and tbtrans in your path."
233+
echo "you will find everything needed for the tutorial."
234+
echo "If you are using the conda installation provided by this script"
235+
echo "please always start your sessions by executing:"
236+
echo ""
237+
echo " source $indir/setup.sh"
238+
echo ""
239+
echo "which will correctly setup the environment for you."
329240
echo "Run (after you have restarted your shell):"
330241
echo " which tbtrans"
331-
echo "and check it returns $indir/bin/tbtrans"
242+
echo "and check it returns $indir/miniconda3/bin/tbtrans"

presentations/01/electrodes.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,10 @@ \subsection{Electrodes}
413413
}
414414
\uncover<3->{
415415
\fill (.5,0) circle (\mysize) node[above right] {1};
416-
\fill (1.5,0) circle (\mysize) node[above right] {2};
417-
\fill (2.5,0) circle (\mysize) node[above right] {3};
418-
\fill (.5,1) circle (\mysize) node[above right] {4};
419-
\fill (1.5,1) circle (\mysize) node[above right] {5};
416+
\fill (1.5,0) circle (\mysize) node[above right] {3};
417+
\fill (2.5,0) circle (\mysize) node[above right] {5};
418+
\fill (.5,1) circle (\mysize) node[above right] {2};
419+
\fill (1.5,1) circle (\mysize) node[above right] {4};
420420
\fill (2.5,1) circle (\mysize) node[above right] {6};
421421
}
422422
\foreach \x in {-2.5,-1.5,-.5,3.5,4.5,5.5} {

presentations/01/negf.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ \subsection{Transmission}
150150

151151
The sum of bond-currents crossing \emph{any} device cross-section is equal to the
152152
current between the leads. Without the prefactor $e/h$ this also applies for the
153-
bond-transmissions\footnote{TBtrans calculates bond-\emph{transmissions}, although
154-
they are named \emph{currents}.}.
153+
bond-transmissions\footnote{TBtrans calculates bond-\emph{transmissions} (without the
154+
prefactor $e/h$), although they are named \emph{currents}.}.
155155

156156
The bond-currents obey Kirchoff's laws.
157157

presentations/01/se.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ \subsection{Semi-infinity}
4646
Describes interaction of a system to a semi-infinite region
4747

4848
\item%
49-
Self-energy calculations \emph{require} no more than nearest neighbour interactions between unit-cells!
49+
Self-energy calculations \emph{require} no more than nearest neighbour interactions between unit-cells
5050

5151
\begin{align*}
5252
\SE_{\mrc 11}(E) &= \VV^\dagger\big[E+\im\eta-\HH\big]^{-1}\VV

0 commit comments

Comments
 (0)