10 July 2012

205. Debian, TeXLive and style files: making lecture slides

Because I keep forgetting...(my blog serves as a public notebook). I don't make any presumptions about this being terribly new or relevant to a lot of people.

This post expanded into something quite different from what was indicated by the title:

Here's the short version:
kpsewhich -var-value=TEXMFHOME
$HOME/texmf
ls $HOME/texmf
ls: cannot access /home/me/texmf: No such file or directory
mkdir ~/texmf/tex/latex -p

Copy your style files e.g.
cp lecturestyles/ -R ~/texmf/tex/latex

(sudo) texhash

And here goes the long version:

I hate powerpoint presentations --- even if they are made with latex (time to make it a generic trademark?) but the university I'm working at considers blackboards too old-fashioned. Apparently the maths and physics departments are still fighting the good fight, but my department has rolled over. Why do we let people who don't teach decide how we do things? Anyway...

For my lecturs, slides, seminar talks etc. I'm using a fairly heavily edited version of this
http://robjhyndman.com/researchtips/latex-templates-for-monash/
for making slides. It's served me well for giving seminar talks etc. I'm currently putting together a new course* and it's now becoming more important than ever to make sure I organise my material already from the outset.

So, a few things to do:
1. Organise everything neatly in folders:
main.tex

/lectures/silicon.tex
/lectures/aluminium.tex

images/aluminium/
images/algorithms/opa

etc.

Beware: when you include images in silicon.tex but call silicon.tex via main.tex, the paths are relative to main.tex, i.e. it's not ../images/aluminium/ore.eps but images/aluminium/ore.eps.

2. Finally move the style files from the local folder (i.e. where the tex file is) to the destination indicated by TEXMFHOME variable:


kpsewhich -var-value=TEXMFHOME
/home/me/texmf
ls $HOME/texmf
ls: cannot access /home/me/texmf: No such file or directory
mkdir ~/texmf/tex/latex -p

Copy your style files e.g.
cp lecturestyles/ -R ~/texmf/tex/latex/

(sudo) texhash 

3. Make liberal use of \include{} in latex
Basically -- you have a document with the preamble

\documentclass[14pt]{beamer}
\usepackage[version=3]{mhchem}
\usepackage{array}
\usepackage{color}
\usetheme{styles/Hytex}
 \def\biz{\begin{itemize}[<+-| alert@+>]}
 \def\eiz{\end{itemize}}
 \def\ben{\begin{enumerate}[<+-| alert@+>]}
 \def\een{\end{enumerate}}

\title{Chemistry 3456}
\author{Verahill}
\date{}

\begin{document}
\include{lectures/introduction}
\include{lectures/silicon}
\include{lectures/phosphorous}
\include{lectures/aluminium}
\end{document}

And then you create individual files for each lecture or topic e.g. silicon.tex:

\title{Silicon: spines, shells and minerals}
\begin{frame}
 \titlepage
 \centerline{Department of Chemistry}
 \centerline{\includegraphics[width=8cm]{styles/myunilogo}}
 \centerline{\small\color[rgb]{0.01,0.33,0.58}}
\end{frame}

\section{Silicon}
\begin{frame}
Today's lecture will cover:
biz
\item Bouncy balls
\item Froth reductors
eiz
\end{frame}

without preambles or anything of that sort.

It's still a bit annoying that you can't set the location of the aux, nav, log etc. files in each .tex document since the clutter offends my eyes. But hey, there's a limit even to my grumpiness.

4. \usepackage{}
Try looking for chemistry related packages which are installed on your system
find /usr/share/texlive/texmf-dist/tex/latex/ -name "*.sty"|grep [cC]hem

The ones which show up on my system are:
achemso, mychemistry, chemstyle, chemcompounds, mhchem, chemmacros, chemarrow and chemfig

mhchem is most likely the most useful one:
\usepackage[version=3]{mhchem}
You can either do
\ce{OH-}+\ce{[B(OH)3} $\rightarrow$ \ce{[B(OH)4-}or more elegantly:\begin{reaction}
OH- + B(OH)3 -> B(OH)4-
\end{reaction}
SIunits are good too:
\usepackage{SIunits}
The bond length is 1.1 \angstrom{} at 298\kelvin{} (25 \celsius{})
Chemfig looks very promising for a 2D chemistry drawing package and uses tikz, but it has a fairly steep learning curve (in the sense that you need to familiarise yourself with most use cases before you can do anything - it doesn't necessarily take very long):

\chemfig{C(-[2]H)(-[4]H)(-[6]H)-C(-[2]H)(-[6]H)-H}
draws ethane. The 2, 4, 6 are angles in multiples of 45 degrees. So, there are H at 90, 180 and 360  relative to the first carbon. 0 degrees is parallel to the horizontal, and angles increase as in a normal coordinate system (i.e. counter-clockwise).
In addition, you can do Lewis dot structures:
\chemfig{B(-[3]\lewis{420,Cl})(-[5]\lewis{460,Cl})-\lewis{260,Cl}
The 420 means bar to the left (0), top (2) and left (4). 260 means bar left, bottom and top. There's a lot to learn though...

Lastly, e.g.
\chemfig{*6(-=-=-=)}
draws benzene. The 6 indicates a hexagon and the -=-= the sequence of bonds.


5. Dia for flowcharts and cycles
I tried using tikz to make pretty, native flowcharts and cycling diagrammes, but it was too much work and too hard for lecture slides (I might revisit it for articles)
Instead, the dia package in debian make it easy to quickly make up .eps flowcharts

6. Use inkscape to turn png into eps
A lot of programmes can create eps files from raster formatted image files. However, most of them do a very poor job.

Instead I like using inkscape and have a .sh file for it:
inkscape --verb FileSave --verb FileClose --export-eps=$1.eps $1.png

7. BKChem for more difficult schemes
8. GDIS/povray for nice 3D structures.

9. MOdiagram for MO diagrams. Awesome BUT enabling labels leads to catastrophic failure:
"! Font LGR/cmss/m/n/12=gsmn1200 at 12.0pt not loadable: Metric (TFM) file not found."

You need to install cbfonts which is supposed to be included in texlive (I think). But it seems that some files are missing. Download cbfonts.zip from http://www.ctan.org/tex-archive/fonts/greek/cbfonts. Assuming you downloaded in ~/Downloads.
mv ~/Downloads/cbfonts.zip ~/tmp
cd ~/tmp
unzip cbfonts.zip
cd cbfonts/
sudo cp fonts/* -R /usr/share/texmf/fonts/ 

sudo update-updmap

sudo texhash && sudo updmap-sys
*to all my former lecturers: I am so, so, so truly sorry for not appreciating more how 1) much effort is involved in putting together a course (even a badly prepared one) and 2) as an undergraduate I didn't acknowledge that teaching isn't your main job.

204. GNOME 3: prevent shotwell from taking over storage devices with photos

I occasionally move pictures off my phone and the CF card of my camera. It annoys me a little bit that shotwell  gets to open and import my photos uninvited.

It also annoys me that a 5 seconds search through the preferences of nautilus and shotwell doesn't offer a solution, but I suppose when we really think about it is a GNOME issue.

Well, it's easy to sort it out: start the gnome system settings, go to details, and select Removable Media.

Post-script:
A lot of functionality is disabled, shifted around or removed completely in the core gnome apps because select devs consider it 'confusing', not obvious or difficult to locate (fixing the sentence to make it grammatically coherent would make it unreadable and clunky -- you know what I mean). Yet somehow the System Settings/Details as a dumping ground for some rather odd stuff has survived since Gnome 3.0.

Again, I like gnome. But gnome will probably do a whole lot better taking criticism from it's loyal users than catering to imaginary mobile device users, hypothetical ex-windows/osx users or basing design decisions on classroom-appropriated theory.

09 July 2012

203. Gimme a desktop I can use and love...the OTHER reason why I use the terminal

* The first, obvious reason for using the terminal is that it's the most efficient way of processing data -- the DE is good for presenting data but is awful at handling data input, the terminal is great at input but is often found wanting at presentation. 

[this is a fairly meandering post without any real purpose -- originally it was meant to show how to set up a quick E17 DE which wouldn't feel too foreign for a GNOME refugee, but that was not to be]

I like gnome. It works. It's pretty. I know how to use it and I can be productive with GNOME. Also, I do think GNOME 3 make GNOME 2.3X look dated. Functionality-wise, once I've installed enough extensions, GNOME 3 works as well or better than GNOME 2.3. Almost... 

 The problem is: it often feels like my trust has been betrayed and I constantly dread the what features the next update are going to remove. The problem lies very much with the applications that combine to make up what we know as gnome:

+ Evolution is constantly breaking. In particular, whether you'll be able to use google calendar or not is always a gamble. Actually, almost EVERYTHING to do with the calendar functionality of evolution tends to be problematic: at the moment I can't see the names of my calendars, I can't select a default view (e.g. day/week/month) of calendars and more...

+ A direct insult was what recently happened to gnome-screenshot. Screw that.

And yes: this probably means that I can stick with gnome but look for other pieces of software instead e.g. use thunderbird instead of evolution etc. In fact, I already do...

At any rate, not trusting the GNOME project anymore, instead of waiting for the disaster to strike, like many of us I'm constantly exploring alternative desktops.

First of all familiarise yourself with: 
sudo update-alternatives --config x-session-manager 
sudo update-alternatives --config x-window-manager 

The first command changes what starts (in the absence of a ~/.xinitrc) when you do startx. The second command select the window manager. 

Anyway.

Xmonad always seems like the logical destination for me since I spend most of my time working in the terminal. The whole idea of having a completely keyboard driven DE is awesome -- yes, it makes the learning curve steeper, but ponder this: you should never ever select a tool because it's easy to learn how to use, you should select a tool that is easy to USE (for your intended purpose etc. etc.). After all, you may spend a week learning a new skill, but you'll be spending the next 10 years using that skill.

In spite of everything about xmonad that sounds so, so right, somehow I just can't warm to it.

XFCE and LXDE are ok, but I'm feeling a bit lukewarm about XFCE in particular -- remember that my issues with GNOME aren't really about their focus on eye-candy, but about the removal of features: essentially treating the users like something verging on idiots. 

Be a bit careful about what you're doing windows manager wise -- e.g. openbox and metacity will create two completely different LXDE experiences out of the box. Metacity is what underpinned gnome 2.3. Openbox doesn't seems to be associate with a default menu bar or anything along those line.

I won't comment much on KDE. That's for some other day. Suffice to say that for you should make sure to do
sudo update-alternatives --config x-window-manager 
and make sure to select kwin, or you will not be able to switch between virtual desktops in KDE. KDE is pretty, but it's different enough that you should devote a reasonable fair amount of time to learning the proper workflow before making your mind up.

Enlightment: I've had a look at it over the years, and it's looked fast, and responsive. Checking it out again today on two different desktops., it proceeded to eat up all my ram, then all my swap (8+16 GB) and then die an undignified death. Of course it might just be a temporary bug, but it does make me think twice. And here, since I tired it out on two very different systems, I think the problem lies squarely with E17.

So after my little safari I'm back in the familiar gnome shell. Maybe we'll switch tomorrow instead...

05 July 2012

202. Reproducing the paper: computing organic reduction potentials

This post is not altogether finished yet -- will be updated with additional results as they come in

This isn't as much as a straight reproduction as a test of the authors' thesis that the SCFE+solvation energies can be used vs the results from using a classic adiabatic thermodynamic cycle.

The paper by Speelman and Gillmore can be found here:
http://pubs.acs.org/doi/abs/10.1021/jp800782e

Again, I'm doing this in large part to deepen my understanding of the practical aspects of computational chemistry. It's not a critical evaluation of the authors' approach -- I don't possess that kind of expertise.

0. Exploring solvation
Because NWChem implements one implicit solvation model (COSMO) and Gaussian implements three, it may be worth quickly exploring what they yield in terms of predicting solvation energies. In particular for processes like reduction or oxidation, solvation is highly important.

Benzene:
The structure of benzene was optimised at 3-21G in vacuo in both software packages. 3-21G was used throughout since it's a matter of making a crude comparison. The solvent was set to be water for all calcs. Note that benzene is neutral, so the solvation energy will be much smaller than for e.g. a cation.

Programme   Solvation model Energy (hartree)    Relative energy to gas phase
NWChem     none                      -230.9757626747    0
NWChem     COSMO               -230.9820692591    3.96 kcal/mol
G09               none                     -230.97576997        0
G09               PCM                    -230.9795649          2.38 kcal/mol
G09               cPCM                  -230.9796073          2.41 kcal/mol
G09               iPCM                   -230.9810728          3.33 kcal/mol

Basically, the gas phase energies are very similar for both G09 and NWChem. The differences lie in the solvation model energies, which iPCM and COSMO yielding the values closest to each other. Ultimately, the energy of solvation spans a fairly small region.

What about frequency calculations?
Well, without PCM I get an enthalpy correction of 0.106934 and with PCM I get 0.106976, a difference of .026355126 hartree. We're talking about a precision beyond that of the method itself. The entropy varies similarly: 68.754 w/o PCM, 68.764 cal/MolK with or ca 0.003 kcal/mol at 298.15 K.

1. Thermodynamic cycle of compound 5 (1,2,4,5-tetracyano-benzene)

A. G09 was used to optimise the structure first using b3lyp/3-21G, then using b3lyp/6-31+G* while applying a solvation model using PCM (water). The optimised structure was then used with IPCM. Also, the frequencies were calculated in vacuo.

(species:   gas phase E/IPCM E/Free Energy corr)
Neutral:   -601.2211700670/-601.2223222/0.057097
Reduced: -601.3655493120/-601.3680354/0.054093

Absolute potential: 
[(-601.3680354+0.054093)-(-601.2223222+0.057097)]*27.2107 eV/hartree= -4.0469 eV
The paper we're following gives 4.12 as the SCE absolute potential.
4.0469-4.12=-0.0731 V

Not close at all...one obvious problems is the reference potential though -- is this really applicable to acetonitrile? Our ideal reference potential should be somewhere around  4.05+0.7=4.75 eV in order to give the desired value of -0.7 V.

IUPAC gives SHE in acetonitrile as 4.60 eV (as mentioned here by Davis and Fry). Also, Pavlishchuck and Addison discuss different reference electrodes in acetonitrile in Inorg. Chim. Acta 200, 298, 97-102 and recommend subtracting 244 mV from SHE to yield the SCE potential. This still leaves us with 4.60-0.24=4.36 V. That in turn gives 4.05-4.36=-0.31 V as the potential. An improvement, certainly, but still 360 mV off.

If we use the old trick of optimising in one level, but using single-point and solvation energies from another level of theory (see section 3 for the origin of the values):

cpcm: [(-601.513973+0.054093)-(-601.3684665+0.057097)]*27.2107= -4.0411/(-1 e)
ipcm: [(-601.5166797+0.054093)-(-601.3698362+0.057097)]*27.2107=-4.0775/(-1 e)

It hardly changes it at all. Also, it quite clear that solvation effectsdominate over thermochemical correction terms here.

B. NWChem was used to optimise the structure at b3lyp/6-31+G* (gas phase) starting with the b3lyp/3-21G structure obtained from G09. 

(species:   gas phase opt/COSMO E/Enthalpy corr/Entropy Corr)
Neutral:    -601.1996294139/-601.2262889216/66.800 kcal/105.187 cal (times/2 cores: 15 min + 4 min +2h 10 min)
Reduced:  -601.2988217652/-601.373759558/65.498 kcal/105.799 cal (times/2 cores: 15 min + 4 min + 2h 30 min)

Absolute potential:
((-601.373759558+(65.498-298.15*105.799/1000)/627.503)-(-601.2262889216+(66.8-298.15*105.187/1000)/627.503))*27.2107=-4.077 eV

Basically the same as we saw with gaussian (ipcm).

2. The proposed method using 6-311++G**
Instead of using MIDI! I optimised the structures with ub3lyp/6-31+G*/PCM.

(species:  cpcm/ipcm energies in hartree)
Neutral:   -601.3684665/-601.3698362
Reduced: -601.513973/-601.5166797
EQM: -3.959 eV /-3.99571
PotCPCM: (-3.959+4.6067)/(-1.0886)    = -0.5949 eV; reported (comp.) -0.604 V
PotIPCM: (-3.99571+4.6291)/(-1.0508) = -0.603 eV

3. Reality
-0.74 V vs SCE in acetonitrile.

4. Summary
From the computational chemist's point of view anions are difficult. Metals are difficult. Radicals are difficult. What I didn't appreciate is quite how difficult anions really are. There should be no appreciable difference between the computation of an oxidation potential and a reduction potential since they are each other's conjugate-- the difference in these particular examples is only in the nature of the product when starting with a neutral parent species.
Empirically we've been getting excellent results in the lab calculating the oxidation potential of neutral organic compounds, and awful results for the reduction potential. This can't really be blamed on the reference potentials used either since they should be the same for both processes. Instead the challenge must be more fundamental.

04 July 2012

201. ...not like linux or anything...

The linux community is even more marginalised in Australia than in the US

In
http://www.theage.com.au/technology/technology-news/taxtime-mac-attack-gains-momentum-20120703-21enx.html

there's this little gem:
"..it isn't as if we're asking for  Linux or anything like that, Mac OS is a major operating system."

25 June 2012

200. How long will your nwchem frequency calc take?

Update 19/12/12: Having done a lot more frequency calculations since I posted this I sincerely doubt that this approach works.

Original post
Because I'm stuck waiting for the results of frequency calcs on some large transition metal clusters, I've become interested in understanding the output of frequency calculations in progress. After all, why wait 15 days for a results if there are early signs that the calculation has gone haywire?

Also, it might just be me, but frequency calculations are not that easy to restart, so you want to make sure that you give them enough wall time to finish if you use a queue manager.

I'm sure most of this could be appreciated by RTFM, but who has time for that?

So this is what the calc does:
After the usual boredom of reading in the geometry and doing an energy calculation, followed by an MO analysis, the computational fun starts.

Each cycle contains the following reports:


  1. Total Density - Mulliken Population Analysis
  2. Spin Density - Mulliken Population Analysis
  3. Total Density - Lowdin Population Analysis
  4. Spin Density - Lowdin Population Analysis
  5. Expectation value of S2:  
  6. NWChem DFT Module
  7.   Caching 1-el integrals 
  8.       Total Density - Mulliken Population Analysis
  9.       Spin Density - Mulliken Population Analysis
with the exception of the first cycle, which also look at the alpha-beta orbital overlaps, the centre of mass, moments of inertia and does a multipole analysis of density and save an initial hessian.





Each cycle ends with a report of the energy for that vibration:


         Total DFT energy =    -3297.032399945703
      One electron energy =   -26618.764098759657
           Coulomb energy =    12938.745973154924
    Exchange-Corr. energy =     -382.742230868704
 Nuclear repulsion energy =    10765.727956527733

 Numeric. integr. density =      441.999974968347

     Total iterative time =   7947.4s

If you do cat nwch.nwout|egrep "Total iterative time|Total DFT energy" you can see the progress:
        Total DFT energy =    -3297.032416366805
     Total iterative time =  12146.0s
         Total DFT energy =    -3297.032399945703
     Total iterative time =   7947.4s
         Total DFT energy =    -3297.032399544749
     Total iterative time =   7946.0s
         Total DFT energy =    -3297.032406934719
     Total iterative time =   7945.8s
         Total DFT energy =    -3297.032405026814

You now have an idea of how long each step takes. But how many steps in total? I think it's 3N steps, where N is the number of atoms.

For my 50 atoms POM using the values above it'd be roughly 8000 s * 150 = 13 days 22 hours.

Which seems about right...

cat nwch.nwout|grep 'Total DFT'|gawk 'END {print NR}'
66
so I've got another 8 days before I can get my hand on some juicy thermochemical data...

Time to start preparing lectures...




22 June 2012

199. NeCTAR -Virtualisation of Australian compute resources -- first steps

So they are seeing whether they can make more efficient use of the compute resources at different institutions in Australia by creating a cloud to pool their resources. One of the potential solutions is called NeCTAR.


Getting started
Go to http://dashboard.rc.nectar.org.au/auth/login/?next=/dash/
Log in using your institutions username and password

You now have two options to deal with the key issue:

Method 1 -- generate online
Once you're in, create a keypair under Manage Compute/Access & Security and give it an easy-to-remember name

This is your private key, so protect it: don't lose it and don't expose it. You can't download it again. You delete it, it's gone.

On your computer
mv ~/Downloads/nectar.pem ~/.ssh
chmod og-rwx ~/.ssh/nectar.pem
cp nectar.pem nectar
ssh-keygen -e -f nectar >nectar.pub

 ls nectar* -lah
-rw------- 1 me me 887 Jun 22 11:31 nectar
-rw------- 1 me me 887 Jun 22 11:28 nectar.pem
-rw-r--r-- 1 me me 335 Jun 22 11:31 nectar.pub
To use the key do
ssh -i nectar user@server

Method 2 -- BYOK
You're using linux -- you probably have your own key already.
Go to the Manage Compute/Access & Security, Import Keypair

Paste your ~/.ssh/id_rsa.pub (or id_dsa.pub) key.


And that's the extent of the setup.

Test run
Go to Manage Compute/Images & Snapshot and select a Real Linux image (i.e. Debian)
Select image
Hit Launch.
Set up -- don't forget to check SSH to be able to log on. If you want to be able to ping, check icmp as well.
Set up the image -- the defaults are ok, but make sure to check icmp (to be able to ping) and ssh (to be able to log in).
Loading
Generating and loading the image takes about 10-20 seconds -- about the duration of a Victorian earthquake.
Running
Now your image is up an running. To check that all is well

ping -c 3 115.146.92.154
PING 115.146.92.154 (115.146.92.154) 56(84) bytes of data.
64 bytes from 115.146.92.154: icmp_req=1 ttl=54 time=1.70 ms
64 bytes from 115.146.92.154: icmp_req=2 ttl=54 time=1.66 ms
64 bytes from 115.146.92.154: icmp_req=3 ttl=54 time=1.73 ms

--- 115.146.92.154 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 1.660/1.698/1.733/0.029 ms

To be able to log in via ssh you need to know what username to use -- it's (probably) image specific.

To find out, click on the image name (here: testing4)
Click me
Hit the 'Log' tab
Select 'log'
 And look for the username which is created in addition to root
Look for the username -- here it's debian


ssh -v -i ~/.ssh/tmp/nectar debian@115.146.92.154
The authenticity of host '115.146.92.154 (115.146.92.154)' can't be established.
RSA key fingerprint is 81:a8:a7:0f:a9:68:a0:08:f1:60:45:e3:57:2e:4c:4c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '115.146.92.154' (RSA) to the list of known hosts.


Once you're in you'll be greeted by:

Linux unnamed-virtual-machine 2.6.32-5-amd64 #1 SMP Thu Mar 22 17:26:33 UTC 2012 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
debian@i-00001637:~$ 
debian@i-00001637:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/vda1             9.9G  768M  8.6G   9% /
tmpfs                 2.0G     0  2.0G   0% /lib/init/rw
udev                  2.0G  112K  2.0G   1% /dev
tmpfs                 2.0G     0  2.0G   0% /dev/shm
debian@i-00001637:~$ uname -a
Linux i-00001637 2.6.32-5-amd64 #1 SMP Thu Mar 22 17:26:33 UTC 2012 x86_64 GNU/Linux
debian@i-00001637:~$ groups
debian cdrom floppy audio dip video plugdev
debian@i-00001637:~$ cat /etc/group|grep debian
cdrom:x:24:debian
floppy:x:25:debian
audio:x:29:debian
dip:x:30:debian
video:x:44:debian
plugdev:x:46:debian
debian:x:1000:

When you're done, don't forget to log out and terminate your image. If you leave it running it will count towards your resource allocations.
Terminating


Notes:

1. you'll run into trouble with the key fingerprints eventually as the IP addresses and key fingerprints won't be matching. Either you'll be doing a lot of editing of you ~/.ssh/known_hosts file or you have to relax your security setttings.

2. Yes, you can log in as root as well. The default user does not have sudo powers. 

3. It takes about 60 seconds after the launch of the image before the openssh server is up and accepting connections. Think more desktop speeds than laptop+SSD speeds.

4. For actual production stuff you can crank up the image requirements:
16 cores and 65 GB? Why, thank you!
5. Also, I think the real value of using virtual machine is that you can load a vanilla setup and customize it, then saving it by making a snapshot:
Snapshot saves
A first couple of actions might be to add a new user, and edit /etc/sudoers.

Troubleshooting ssh:
If you're having problems logging in using your key, use the ssh -v switch as shown above and parse the output



Unsuccessful:
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/me/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/me/.ssh/id_dsa
debug1: Trying private key: /home/me/.ssh/id_ecdsa
debug1: Next authentication method: password

A successful authentication should contain
debug1: Offering RSA public key: /home/me/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).


If you are sure that you're using the right key (e.g. using -i), then make sure that you're using the right username -- to find out how to find it, look above.


21 June 2012

198. Nwchem -- freeze core and tddft on benzene

UPDATE: it's taken a while, but I've tested this on a large polyoxometalate cluster (>10 group 5/6 atoms and >30 oxygens) -- with a total of ca 700 alpha and beta orbitals, respectively, I froze 200 core orbs and used 3-21G/3-21G* w/ ub3lyp. The frozen core calculation took 44% of the time the full calculation took. The spectra look identical to within 3 nm (18 roots -- only 2 intermediate transitions have been shifted. All other transitions are identical). The full calc took 7 days and 4 hours, while the frozen calc took 3 days and 4 hours. 

Original post:
Benzene has 21 occupied α and 21 occupied β orbitals.

How many core orbitals can we freeze when looking at electronic transitions, how does freezing core orbitals affect the energies, and what are the performance gains, if any?

I used the following relevant statements
tddft
    cis
    freeze core X
    nroots 24
end
task tddft energy
Also, xc b3lyp and 6-31++g**.

Freeze core 10 means freeze 10 α and freeze 10 β orbitals.

Results:

Frozen Runtime    Transitions with f>0
0          1111 s     6.7835, 6.8038, 6.8042, 7.3479, 7.3496
5          1107 s     6.7835, 6.8038, 6.8042, 7.3480, 7.3498
10        1063 s     6.7838, 6.8040, 6.8045, 7.3761, 7.3862
15        1063 s     6.5878, 6.7840, 6.8042, 6.8046
20          719 s     6.8038, 6.8355, 7.1692, 7.5334, 8.1866

Evaluation:
We're not really looking at what's right or wrong -- the main goal is to understand how the results are affected (we might accidentally get 'right' answer doing something stupid). Freezing more than 10 α/β orbitals leads to significant differences in predicted transitions.

Taking oscillation strength into account and plotting it, we see that we really don't want to overdo it with the number of frozen cores -- 15 and 20 frozen cores yield results that are about as predictable as a coin toss. We also don't see any overwhelming performance gains, but that may well be due to the size and computational cost (or lack thereof) of the system.



Octave code:
spec1=load('bz631gppdd_cosmo.dat');
spec2=load('bz631gppdd_cosmo_f5.dat');
spec3=load('bz631gppdd_cosmo_f10.dat');
spec4=load('bz631gppdd_cosmo_f15.dat');
spec5=load('bz631gppdd_cosmo_f20.dat');

gau= @(x,c,w,i) i*(1/(w*sqrt(2*pi))).*exp(-0.5.*((x-c)./w).^2);
x=linspace(160,200,200);
y1=cumsum(gau(x,1241.25./spec1(:,2),4,spec1(:,3)));
y2=cumsum(gau(x,1241.25./spec2(:,2),4,spec2(:,3)));
y3=cumsum(gau(x,1241.25./spec3(:,2),4,spec3(:,3)));
y4=cumsum(gau(x,1241.25./spec4(:,2),4,spec4(:,3)));
y5=cumsum(gau(x,1241.25./spec5(:,2),4,spec5(:,3)));


subplot(3,2,1)
 plot(x,y1(rows(y1),:))
 axis([160 200 0 0.2]);
 title('0 frozen');
 subplot(3,2,3)
 plot(x,y2(rows(y2),:))
 axis([160 200 0 0.2]);
 title('5 frozen');
 subplot(3,2,5)
 plot(x,y3(rows(y3),:))
 axis([160 200 0 0.2]);
 title('10 frozen');
 subplot(3,2,2)
 plot(x,y4(rows(y4),:))
 axis([160 200 0 0.2]);
 title('15 frozen');
 subplot(3,2,4)
 plot(x,y5(rows(y5),:))
 axis([160 200 0 0.2]);
 title('20 frozen');
 subplot(3,2,6)
  plot(x,y1(rows(y1),:),x,y2(rows(y2),:), x, y3(rows(y3),:), x,y4(rows(y4),:),x,y5(rows(y5),:))
  axis([160 200 0 0.2]);
 title('');

197. Post-mortem of the Moe Quake

The news keep on reporting about a single injured person who was unlucky enough to be standing on a ladder close to the epicentre, but beyond that it seems like no-one else suffered any injuries serious enough to warrant medical attention.

Property damages are a different story though, but the news are having a field day with it, so no point in me repeating what they are saying. My only comment is that the Gippsland/La Trobe Valley area has been hit hard lately, first by floods, storms and now an earthquake -- in addition to recent job losses and uncertainties.

Anyway, science.

www.ga.gov.au has a nice page with technical information about the earthquake:
http://www.ga.gov.au/earthquakes/getQuakeDetails.do?quakeId=3226344

There are several seismograms available from different stations around the country (am I the only chemist who looks at them wanting to apply a FFT?)

Victoria


ACT

Northern QLD

The shape varies with the distance from the earthquake, which I guess tallies with different types of waves travelling at different speeds.

For those of us who are reasonably new to this area, the USGS has a historical earthquake map over Melbourne and the Gippsland/La Trobe valley area.

Here's seismicity in Australia as a whole, and it shows that SE Victoria is no stranger to phenomenon:

http://www.quakes.uq.edu.au/html/quake_info/OZ_QLD_info.html#6

Big earthquakes are a different matter though: http://earthquake.usgs.gov/earthquakes/world/australia/seismicity.php

Only a handful of earthquakes show up on this map, and they are  in WA and NT.

Here's a map with the number of large earthquakes per year (5 and above) -- and Melbourne is by no means the worst hit by the Top 5 cities in Australia
http://earthquake.usgs.gov/earthquakes/world/australia/density.php

Finally, here's a map with the 'earthquake hazard' estimates for different regions of Australia:
http://earthquake.usgs.gov/earthquakes/world/australia/gshap.php

It seems like SE Tassie is the safest, inhabited area. SW WA is the least safe one, but is still nothing compared to PNG and Indonesia and other countries on plate boundaries.

Here's a full paper on seismic hazards in Australia, which contains a nice map with past earthquakes indicated on it: http://www.sciencedirect.com/science/article/pii/S0040195104002185
I'm loading the picture from the publisher's website which is probably the lesser of two evils.

19 June 2012

196. M 5.5 Earthquake near Moe, Victoria. Felt in Melbourne, Australia, 19 June 2012

[20th of July 2012 earthquake here: http://verahill.blogspot.com.au/2012/07/another-earthquake-felt-in-melbourne.html ]

Just (ca 20:50/8.50 pm) experienced my first earthquake (South-eastern suburbs)  -- or rather earth tremor. Rattling doors, a bit of noise, a bit of shaking. Felt like about 10-15 s. More exciting than scary, although I would NOT have wanted to be any closer to the epicentre than we already were (100 km).

Funny it should happen in Australia after five years in California without the slightest tremor.

I like the possum comment below -- was my first thought too! The second one was wind.

If you felt it, you can report it here http://earthquake.usgs.gov/earthquakes/eventpage/usb000ajek#dyfi
There is a point in reporting your experience, since earthquakes aren't just reported in terms of the energy released, but also in terms of damage (or perception).

Update 22:02: http://www.seis.com.au/ is slowly coming back online, but there's no obvious information up yet.

http://www.seis.com.au/ and http://www.ga.gov.au/earthquakes/ went down immediately, and the ga.gov.au site is still down. www.seis.com.au is operating slowly.

Update 21:52. ABC 24 is covering it right now. Quake happened 7 minutes to 9 with the epicentre over by Trafalgar near Moe. No serious injuries. Upgraded to M 5.5.

Update 21:30
The news sites are catching up:
http://www.abc.net.au/news/2012-06-19/magnitude-52-quake-shakes-southern-vic/4080446

http://news.smh.com.au/breaking-news-national/melbourne-hit-by-earthquake-20120619-20m8d.html

http://www.heraldsun.com.au/news/more-news/strong-tremors-rock-victoria/story-fn7x8me2-1226401623358

http://www.theage.com.au/victoria/quake-shakes-melbourne-20120619-20m88.html

Update 21.27: ABC 24 just confirmed it. M 5.2. Moe was the epicentre.

Update 21.10: It's on the USGS website: http://earthquake.usgs.gov/earthquakes/eventpage/usb000ajek#summary




Apparently it was a Magnitude 5.2 centerd somewhere out in Gippsland. Best guess at time is 20:53:29.
The magnitude will likely be adjusted once local data is available.

Postscript:
I posted since the seismology sites were down and there was nothing on the news. Apparently I wasn't the only one who was looking for information:

195. Frequency calcs in NWChem

It's no secret that I'm a computational 'noob'. As such as I'm learning both by reading and by doing.

The doing part consists of checking 1) what the time penalty for different methods is and 2) what the accuracy/differences between different methods are.

Again, these are short calculations for simple molecules. Longer calculations with more exciting features (unpaired electrons, closely spaced MOs, highly negative charges etc.) may well behave completely different.

Today's focus is vibrational calcs.

Test Molecule: CHClF(OH) (chloro-fluoro-methanol)
  1 Title "Freq_test"
  2 
  3 Start  Freq_test
  4 
  5 echo
  6 
  7 charge 0
  8 
  9 geometry noautosym units angstrom
 10  C     0.0416942     -0.501783     0.399137
 11  H     0.0442651     -0.499048     1.48122
 12  O     1.21393     -1.00985     -0.0746688
 13  H     1.25125     -0.957351     -1.06923
 14  F     -1.08480     -1.08768     -0.134571
 15  Cl     -0.120345     1.41214     -0.0717951
 16 end
 17 
 18 ecce_print ecce.out
 19 
 20 basis "ao basis" cartesian print
 21   H library "3-21G"
 22   F library "3-21G"
 23   Cl library "3-21G"
 24   O library "3-21G"
 25   C library "3-21G"
 26 END
 27 
 28 dft
 29   mult 1
 30   odft
 31   mulliken
 32 end
 33 
 34 task dft energy
 35 task dft freq

All geometries were optimised in the gas phase using 3-21G.

0. Some useful statements:
hessian      print "hess_follow"
                 profile
end
1. Basis set (geometry optimised in 3-21g)
(time/enthalpy/entropy/scfe)
3-21G:              81s    24.984 kcal/mol    69.235 cal/mol-K   -671.17956992206 Hartree
6-31G:            105s    21.885 kcal/mol    68.793 cal/mol-K   -674.478768966106
6-31++G**:    399s   21.734 kcal/mol     68.818 cal/mol-K   -674.573524091623
cc-pVDZ:        325s    21.682 kcal/mol    68.819 cal/mol-K   -674.594059146606
aug-cc-pVDZ:  901s   21.605 kcal/mol    68.840 cal/mol-K   -674.623145113155

LANL2DZ(C)/6-+G* 262s  24.923 kcal/mol 68.981 cal/mol-K  -674.539040349134
UHF/aug-cc-pVDZ   373 s 26.196  kcal/mol 68.228 cal/mol-K -672.85402652170

Cation:
3-21G:               ---     21.164 kcal/mol     74.407 cal/mol-K    -670.763278724519 Hartree
6-31G:              142s   21.153 kcal/mol     74.645 cal/mol-K    -674.089132280731
6-31++G**:      637s   21.192 kcal/mol    73.768 cal/mol-K    -674.178146586266
cc-pVDZ:          399s   21.153 kcal/mol    73.736 cal/mol-K    -674.210312017948
aug-cc-pVDZ:   1776s 21.089 kcal/mol     73.774 cal/mol-K   -674.228204222891

LANL2DZ(C)/6-+G* 454s 24.795 kcal/mol  74.293 cal/mol-K -674.140922359750
UHF/aug-cc-pVDZ  741s 26.002 kcal/mol  72.462 cal/mol-K  -672.518095855130

2. Thermochemistry (ΔG of oxidation; gas phase)
3-21G:            -5.3620 kcal/mol +  261.22 kcal/mol =  6.814 V*
6-31G:            -2.4768 kcal/mol +  244.50 kcal/mol =  6.214 
6-31++G**:    -2.0178 kcal/mol+  248.10 kcal/mol =  6.390 
cc-pVDZ:        -1.9950 kcal/mol + 240.80 kcal/mol =  6.075 
aug-cc-pVDZ: -1.9871 kcal/mol + 247.83 kcal/mol =  6.380

LANL2DZ(C)/6-+G* -1.7118 kcal/mol + 249.82 kcal/mol 6.478
UHF/aug-cc-pVDZ -1.4564 kcal/mol +210.80 kcal/mol = 4.797

* vs SHE=4.281 eV

3. Solvation (cosmo/water/scfe)
neutral
3-21g:                66s    22.097 kcal/mol    68.875 cal/mol-K   -671.1936338426 Hartree
6-31g:                82s    22.277 kcal/mol    68.609 cal/mol-K   -674.4934780299
6-31++g**:       277s   21.493 kcal/mol    69.353 cal/mol-K  -674.586704959695
cc-pVDZ:          266s   21.869 kcal/mol    68.808 cal/mol-K  -674.605608009070
aug-cc-pVDZ:    712s  22.116 kcal/mol    69.596 cal/mol-K   -674.635237990779

LANL2DZ(C)/6-31+G* 180s  25.022 kcal/mol   69.073 cal/mol-K -674.552417717602
UHF/aug-cc-pVDZ 412s  24.083 kcal/mol 70.519 cal/mol-K  -672.868085966222

cation (solvation energy)**

3-21G:               --- /26s        21.164 kcal/mol     74.407 cal/mol-K     -670.881469242560 Hartree
6-31G:              142s/51s      21.153 kcal/mol     74.645 cal/mol-K     -674.175491218588
6-31++G**:      637s/111s   21.192 kcal/mol    73.768 cal/mol-K      -674.267298880087
cc-pVDZ:          399s/129s   21.153 kcal/mol    73.736 cal/mol-K      -674.294609415029
aug-cc-pVDZ:   1776s/311s 21.089 kcal/mol     73.774 cal/mol-K     -674.316552324118

LANL2DZ(C)/6-31+G* 454s 24.795 kcal/mol  74.293 cal/mol-K -674.232656980139
UHF/aug-cc-pVDZ   741s 26.002 kcal/mol  72.462 cal/mol-K -672.451040948823
** UHF can't be used with COSMO according to nwchem. Instead we use the cation thermo calcs in the gas phase and use the scfe from a cosmo calc.

Thermochemistry*** (using gas phase freq for both cation and neutral species with scfe w/ cosmo given in parentheses):

3-21G:            -2.5824+195.88=  4.101 V (3.981 V)
6-31G:            -2.9236+199.54=  4.245 V (4.265 V)
6-31++G**:   -1.6173+200.43=  4.341 V (4.324 V)
cc-pVDZ:       -2.1853+195.15=  4.087 V (4.095 V)
aug-cc-pVDZ: -2.2727+199.98= 4.293 V (4.305 V)

LANL2DZ(C)/6-31+G*  -0.41322+200.65= 4.402
UHF/aug-cc-pVDZ 1.3397+261.7 (!)= 7.126
* vs SHE=4.281 eV

*** using freq calc of neutral species with cosmo, vs freq calc of cation in gas phase and energy w/ cosmo

4. Spectra
We'll use octave for this. First, using cat and gawk, I put the x/y coordinates in a file.

gauss= @(x,f,i,sigma)  i.*1./(sigma.*sqrt(2*pi)).*exp(-0.5.*((x-f)./sigma).**2)
subplot(3,2,1); axis([0 4000 0 2])
spc=load('321g.spc');sf=spc(:,1); si=spc(:,2);x=linspace(0,4000,800);spec=cumsum(gauss(x,sf,si,75)); 
title("321g"); plot(x,spec(18,:))
subplot(3,2,2)
spc=load('ccpvdz.spc');sf=spc(:,1); si=spc(:,2);x=linspace(0,4000,800);spec=cumsum(gauss(x,sf,si,75));
title("ccPVDZ");plot(x,spec(18,:))
subplot(3,2,3)
spc=load('631g.spc');sf=spc(:,1); si=spc(:,2);x=linspace(0,4000,800);spec=cumsum(gauss(x,sf,si,75));
title("631g"); plot(x,spec(18,:))
subplot(3,2,4)
spc=load('augccpvdz.spc');sf=spc(:,1); si=spc(:,2);x=linspace(0,4000,800);spec=cumsum(gauss(x,sf,si,75));
title("aug-ccPVDZ");plot(x,spec(18,:))
subplot(3,2,5)
spc=load('631gppdd.spc');sf=spc(:,1); si=spc(:,2);x=linspace(0,4000,800);spec=cumsum(gauss(x,sf,si,75));
title("631++g**"); plot(x,spec(18,:))

From top to bottom: Left: 3-21G, 6-31G, 6-31++G**. Right: cc-pVDZ, aug-cc-pVDZ
5. Conclusions
It may seem weird that as a test case I picked a species I don't have any reference potential for. However, the goal here was to understand how the basis set affects the results, without being distracted by such things as Real Life.

The observed spectra can be divided into two group: 3-21G/6-31G vs 6-31++G**/cc-pVDZ/aug-cc-pVDZ. Polarization (and diffuse functions) seem to play a large role.

In terms of thermochemistry, not surprisingly aug-cc-pVDZ and 6-31++G** give very similar results since they both implement pol/diff functions. The computational cost is, however, significantly higher for aug-cc-pVDZ than 6-31++G**, at least in nwchem.

There is also little difference between doing freq calculations in gas phase vs using cosmo when it comes to the calculated redox potential for the more extensive basis sets.

3-21G gives very varying results, with it giving the highest potential in the gas phase but the second lowest potential with cosmo. cc-pVDZ consistently gives the lowest potential.

UHF/ROHF/HF are fast, but wildly inaccurate. LANL2DZ/6-31+G* looks ok, results-wise, but the thermodynamic corrections are actually much smaller in conjunction with COSMO than the other methods, which is suspicious.

If given the time I may post a more detailed analysis of polarisation vs diffuse functions later.

17 June 2012

194. Wine 1.4.1 and Wine 1.5.6 on Debian Wheezy

UPDATE 16 May 2013: See here for Wine 1.5.30: http://verahill.blogspot.com.au/2013/05/416-wine-1530-in-chroot.html

There's great appetite for anything wine-related in Debian, as I can see from visitor numbers, so  here's how to build  Wine 1.4.1 and Wine 1.5.6 in Debian Testing/Wheezy. Enough talking -- let's get compilin'!

The builds take a little while, so be warned. Not all features are enabled in this particular build either -- see the configure output.

If you're interested in the missing development files seen below, this post might help: http://verahill.blogspot.com.au/2012/03/cross-compiling-eg-32-bit-binaries-on.html. Instinctively, I am suspicious as to whether that would work. I haven't explored it though, and my chief motivation is to make build instructions which anyone can easily follow and reproduce.

UPDATE (10th Jan 2013): See here for Wine 1.5.21 using the multiarch approach: http://verahill.blogspot.com.au/2013/01/308-compiling-wine-1521-on-debian.html


For both
sudo apt-get install bison flex gcc libc6-dev libfontconfig-dev libfreetype6-dev libglu-dev libgsm1-dev libice-dev libjpeg-dev libldap-dev libmpg123-dev libncurses5-dev libopenal-dev libpng-dev libsm-dev libssl-dev libusb-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxml2-dev libxrandr-dev libxrender-dev libxslt-dev libxt-dev libxxf86vm-dev make libcapi20-dev liblcms-dev libsane-dev libhal-dev libdbus-1-dev valgrind prelink libcups2-dev opencl-dev lib32opencl1 oss4-dev gettext lib32v4l-dev lib32ncurses5-dev lib32asound2-dev lib32z-dev ia32-libs-dev


Version 1.4.1
wget http://prdownloads.sourceforge.net/wine/wine-1.4.1.tar.bz2

tar xvf wine-1.4.1.tar.bz2
cd wine-1.4.1/
./configure
configure: OpenCL 32-bit development files not found, OpenCL won't be supported.
configure: gstreamer-0.10 base plugins 32-bit development files not found, gstreamer support disabled
configure: libgsm 32-bit development files not found, gsm 06.10 codec won't be supported.
configure: libtiff 32-bit development files not found, TIFF won't be supported.
configure: WARNING: libjpeg 32-bit development files not found, JPEG won't be supported.
configure: Finished.  Do 'make' to compile Wine.
make
sudo checkinstall --install=yes

Note: To just make a .deb package, do ---install=no.

Version 1.5.6
wget http://prdownloads.sourceforge.net/wine/wine-1.5.6.tar.bz2
tar xvf wine-1.5.6.tar.bz2
cd wine-1.5.6/
./configure

configure: OpenCL 32-bit development files not found, OpenCL won't be supported.
configure: libsane 32-bit development files not found, scanners won't be supported.
configure: gstreamer-0.10 base plugins 32-bit development files not found, gstreamer support disabled
configure: libgsm 32-bit development files not found, gsm 06.10 codec won't be supported.
configure: libtiff 32-bit development files not found, TIFF won't be supported.
configure: WARNING: libjpeg 32-bit development files not found, JPEG won't be supported.
configure: Finished.  Do 'make' to compile Wine.
make
sudo checkinstall --install=yes

Note: To just make a .deb package, do ---install=no.

15 June 2012

193. Notes on UV/VIS - TD DFT in nwchem

I've been interested in looking at using NWChem to predict UV/VIS spectra. This post doesn't show how to do it but is rather just a look at what affects the positions of absorbances.
(although it more or less just involves
tddft
       cis
       nroots 24
end
task tddft energy)
I chose benzene and water as test cases. 

Here's water:
water

Reference spectrum in gas phase: http://www.lsbu.ac.uk/water/vibrat.html (166.5 nm) which tallies very well with 3-21g and 6-31g, but not at all with 6-31++g** or 3-21++g*.

Here's benzene:

Reference spectrum: http://www3.wooster.edu/chemistry/is/brubaker/uv/uv_spectrum.html
The reference spectrum, while a bit diffuse, shows the main absorbance at ca 178 nm. Presumably that's in benzene, not water.

More basis sets:


(cat Benzene_631g/Outputs/nwch.nwout |egrep "Root|sci"|gawk '{print $4,$6}'>bz631g.dat)

192. Skype on Debian STABLE (updated for Skype 4.x)

Update 15/6/12: New Skype (4) out this morning. Screengrabs etc posted at the end.

This post came about from a question posted on the Debian forums.

Before you read, be aware of this:
* I don't have debian 6.05 installed on any physical system. They all run debian wheezy
* This guide was done in a virtualbox installation. For sound, I used a headset and USB-passthrough. 

Having said that, there's no reason this shouldn't work.

As my system, I used the same one I used here (i.e. a very slim install):

The advantage is that it's likely to a lot more barebones than a regular desktop debian install.
The disadvantage is that I don't know what's pulled in by default by debian 6.05.

Anyway, here's what I did:

1. Download and install  skype from skype.com
I selected the Debian 5 64 bit package which is gives you the skype-debian_2.2.0.35-1_amd64.deb file.

Install:
sudo dpkg -i skype-debian_2.2.0.35-1_amd64.deb 

Selecting previously deselected package skype.
(Reading database ... 53724 files and directories currently installed.)
Unpacking skype (from skype-debian_2.2.0.35-1_amd64.deb) ...
dpkg: dependency problems prevent configuration of skype:
 skype depends on lib32stdc++6 (>= 4.1.1-21); however:
  Package lib32stdc++6 is not installed.
 skype depends on lib32asound2 (>> 1.0.14); however:
  Package lib32asound2 is not installed.
 skype depends on ia32-libs; however:
  Package ia32-libs is not installed.
 skype depends on lib32gcc1 (>= 1:4.1.1-21+ia32.libs.1.19); however:
  Package lib32gcc1 is not installed.
 skype depends on ia32-libs-gtk; however:
  Package ia32-libs-gtk is not installed.
dpkg: error processing skype (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 skype
That's fine. Now fix the dependencies:
sudo apt-get install -f
Reading package lists... Done
Building dependency tree    
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  ia32-libs ia32-libs-gtk lib32asound2 lib32bz2-1.0 lib32gcc1 lib32ncurses5
  lib32stdc++6 lib32v4l-0 lib32z1 libv4l-0
Suggested packages:
  lib32asound2-plugins
The following NEW packages will be installed:
  ia32-libs ia32-libs-gtk lib32asound2 lib32bz2-1.0 lib32gcc1 lib32ncurses5
  lib32stdc++6 lib32v4l-0 lib32z1 libv4l-0
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 50.1 MB of archives.
After this operation, 123 MB of additional disk space will be used.
Do you want to continue [Y/n]? 

2. Get sounds organised
aptitude search pulseaudio|grep ^i
i A libpulse0                       - PulseAudio client libraries 
Not enough. Need. More. Packages.

sudo apt-get install pulseaudio pulseaudio-esound-compat pulseaudio-module-gconf
sudo apt-get install gnome-core

Obviously, if you have gnome installed, skip the second line.

Sort out your ~/.asoundrc file
echo "pcm.!default.type pulse">>~/.asoundrc
echo "ctl.!default.type pulse">>~/.asoundrc

At this point I rebooted for good luck.

3. Putting it all together

First open your volume control to see that it 'looks right'

Start Skype
Go to options (click on the S at the bottom left).  Make sure it says pulseaudio.

Make a test sound. Make a test call. Make sure to select the correct outputs and inputs in the gnome volume control

This worked perfectly for me and took all in all ca 25 minutes with screenshots and all.

Update 15/6/2012:
Skype 4 came out today -- I downloaded and installed it and tested it in the virtual machine above. Everything works perfectly.






Links to this post:
http://crunchbang.org/forums/viewtopic.php?id=27451