27 December 2013

539. Laptop not suspending on closing lid in Debian Jessie/Gnome 3.8.4 -- need to use systemd

Edit: I suspect that there are solutions out there that don't require systemd. It just happened that this was the path of least resistance, at least for my laptop which has a fairly simple set up. Not sure my work cluster would be so straight-forward...

Original post:
Closing the laptop lid doesn't have any effect. dmesg returns
[95643.717984] systemd-logind[2731]: Lid closed.
[95643.718173] systemd-logind[2731]: Suspending...
[95648.722146] systemd-logind[2731]: Delay lock is active but inhibitor timeout is reached.
[95648.735369] systemd-logind[2731]: Failed to send delayed message: Launch helper exited with unknown return code 1
(also, why are we suddenly requiring systemd? I thought debian was going to be free from that...that...abomination...but I suppose this will be fixed before jessie goes stable in a couple of years)

Anyway, the issue seems to be that systemd hasn't got PID 1:
Working suspend/resume requires systemd to be PID 1 [1]. Boot with init=/bin/systemd for that.
And in my case I had
init=/sbin/bootchartd
in my GRUB_CMDLINE_LINUX_DEFAULT which I changed to
init=/bin/bootchartd
. Note that my full line is
GRUB_CMDLINE_LINUX_DEFAULT="quiet drm_kms_helper.poll=N init=/bin/systemd initcall_debug printk.time=y resume=UUID=8adf424c-c375-4035-8d5d-181489b4461b resume_offset=7182336"
where the resume commands are related to this post about hibernation using a swap file, and the drm_kms_helper.poll is related to this issue.

Anyway, rebooting gives
ps aux|grep systemd
root         1  0.1  0.1  46104  4668 ?        Ss   07:31   0:00 /bin/systemd
root       202  0.0  0.4 144868 18416 ?        Ss   07:31   0:00 /lib/systemd/systemd-journald
root       221  0.0  0.0  38500  2292 ?        Ss   07:31   0:00 /lib/systemd/systemd-udevd
root       877  0.0  0.0  37024  1760 ?        Ss   07:31   0:00 /lib/systemd/systemd-logind
message+   887  0.1  0.0  29148  2520 ?        Ss   07:31   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

Closing (and opening) the lid gives

dmesg|grep PM
[..]
[  444.637761] PM: Syncing filesystems ... done.
[  444.668607] PM: Preparing system for mem sleep
[  444.784170] PM: Entering mem sleep
[  445.232203] PM: suspend of devices complete after 447.606 msecs
[  445.232862] PM: late suspend of devices complete after 0.650 msecs
[  445.277535] PM: noirq suspend of devices complete after 44.667 msecs
[  445.360219] PM: Saving platform NVS memory
[..]
[  445.509662] PM: noirq resume of devices complete after 100.525 msecs
[  445.510133] PM: early resume of devices complete after 0.295 msecs
[  447.065176] PM: resume of devices complete after 1555.037 msecs
[  447.151847] PM: Finishing wakeup.

i.e. it works.

So I'm now using systemd, I suppose. However, I have yet to explore whether I can still use my precious /etc/network/interfaces file. At least my network interfaces haven't been renamed using the systemd nomeclature which annoyed me so much back when I used Arch, and my /etc/udev/rules.d/70-persistent-net.rules are still respected.

25 December 2013

538. Briefly: Sort folders before files in nautilus 3.8

I'm running debian jessie (current testing) on my laptop and after having held off upgrading for a while since I had to take it to a conference and didn't want to risk ending up with a broken system, I finally took the leap. I notice that there are a lot of references to systemd in dmesg, but haven't had a look at what it actually means -- are we past init and fully switched to systemd now? Or how do I go about modifying my network configuration if I can't use /etc/network/interfaces?

Anyway, one annoying little thing is that in Nautilus the folder content by default is arranged in alphabetical order, regardless of whether it's a file or a directory. The old behaviour was to arrange folders in alphabetical order, then files.

Here's how to get it back to 'normal' behaviour:
 
The new behaviour
Click on the 'Files' menu on the top desktop bar, select preferences:
Check 'Sort folders before files' to get back the normal behaviour
Check sort folders before files to make Nautilus behave well again

18 December 2013

537. Building ECCE 7.0 on CentOS 6.4

Following a report that there were issues building ECCE 7 on Centos 6.4 I decided to investigate.

1. Download 
Download the centos 6.4 iso: At ftp://mirror.stanford.edu/pub/mirrors/centos/6.4/isos/x86_64/ I downloaded ftp://mirror.stanford.edu/pub/mirrors/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso

wget ftp://mirror.stanford.edu/pub/mirrors/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso

2. Install centos in virtualbox
Not much to say other than that I gave the VM 12 gb disk and 1024 mb ram.
During installation I selected Install or Upgrade an existing system (option 1).  I went with all the defaults during installation.

3. Basic setup
Following the installation I rebooted.

First I activated eth by editing /etc/sysconfig/network-scripts/ifcfg-eth0 and changing onboot from no to yes. I rebooted and installed Gnome

Then install X and gnome.
yum groupinstall -y 'X Window System'
yum groupinstall -y 'Desktop'
useradd verahill
passwd verahill

Edit /etc/inittab and change
id:3:initdefault:
to
id:5:initdefault:

Reboot.

Install openGL libraries. The way to do that depends on what graphics chip your have, e.g. libgl1-nvidia-glx for nvidia. In my virtualbox example I didn't have to do anything.  

4. ECCE
Launch gnome-terminal
Become root and install packages, then exit:
su
yum install vim csh gcc gcc-c++ gcc-gfortran java-1.7.0-openjdk-devel python-devel ant gtk2-devel libjpeg-turbo-devel libtool ImageMagick libXt-devel xterm mesa-libGLU-devel kernel-devel perl-Digest-Perl-MD5 perl-Digest-MD5
yum install 
exit
mkdir ~/tmp
cd ~/tmp
Download ecce from http://ecce.pnl.gov/using/download.shtml into ~/tmp
tar xvf ecce-v7.0-src.tar.bz2
cd ecce-v7.0/
export ECCE_HOME=`pwd`
cd build/
./build_ecce
./build_ecce
./build_ecce
./build_ecce
./build_ecce
./build_ecce
./build_ecce

Everything builds just fine.

You can then install the ecce_install.v7.0.csh file created in the parent directory by following e.g. this post: http://verahill.blogspot.com.au/2013/08/487-version-70-of-ecce-out-now.html

17 December 2013

536. Briefly: Getting ECCE to work with Gaussian 09 (G09) part 1: frequency calcs

I'm slowly looking at improving the support for G09 in ECCE. One of the things that haven't worked in the past is visualising frequency calcs.

Since I'm not using G03 I've been content with editing the g03 files so that they work with G09. My changes will be submitted upstreams at a later point.

Anyway, turns out this was a very simple one.

How ECCE works:
data is extracted from the output through the use of perl parser scripts. These are located in apps/scripts/parsers, and are fairly clearly named.

The script that deals with Gaussian vibrational analyses is called gaussian-03.vib

To use it manually with a gaussian 'log' file (here called g03.output), do
./gaussian-03.vib < g03.output

So far so easy. However, if you use it on a g09 output file you'll end up with a single message: 'Zero atoms'.

Turns out that the reason is that the script looks for instances of 'Atom AN', with a single white space between m and N. In G09, however, there are two white spaces: 'Atom AN'.

The fix:
So, edit line 277:
276     while ()  {
277       if (/Atom AN/) {
278         last;

and change it to
276     while ()  {
277       if (/Atom\s*AN/) {
278         last;

Do the same thing with line 315:
314     while ()  {
315       if (/Atom\s*AN/) {
316         last;

Done!

535. Briefly: ACS journal latex template -- achemso

There's no outright template for the preparation of tex files for ACS journals. However, there are two files provided: a bibtex styles file, achemso.bst, and a macro file, achemso.cls. Both are available in the texlive-latex-extra package on debian.

Luckily there's a lot of information online, including a demo file: ftp://ftp.dante.de/tex-archive/biblio/bibtex/contrib/achemso/

Anyway, here's a simple file that can act as a template. Have a look at the demo file at ftp.dante.de for a much more exhaustive example, including how to use schemes and insert references.

You can figure out the journal abbreviations from their URLs. Otherwise, page 4 in this pdf has a list: http://www.tug.org/texlive/Contents/live/texmf-dist/doc/latex/achemso/achemso.pdf

Anyway:

\documentclass[journal=inoraj, layout=twocolumn]{achemso}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\author{Vera Hill}
\affiliation{Department of Chemistry, This University, This Country}
\email{my@email}
\author{I. Lindqvist}
\affiliation{Department of Chemistry, Another University, That Country}
\title{A quick, non-exhaustive tex template}

\begin{document}
\maketitle

%\begin{tocentry} %graphical TOC
%\includegraphics{example.eps}
%TOC text goes here
%\end{tocentry}

\begin{abstract}
The ACS should provide a simple template. They don't, so I do.
\end{abstract}

\section{Introduction}
\section{Results and Discussion}

%\begin{figure}
% \includegraphics{graphic}
% \caption{A figure}
% \label{fig:example}
%\end{figure}


\subsection{References}
\section{Experimental}
\begin{acknowledgement}
VH thanks the internet. IL thanks the electron.
\end{acknowledgement}

\begin{suppinfo}
See supporting information for additional experimental details.
\end{suppinfo}

\end{document}

Example:

05 December 2013

534. Adding new options to ECCE -- adding solvation models for G03 (G09)

To minimize the amount of manual editing of my input files I've started to modify the menus in ECCE. One thing that was missing before was the option of selecting a solvation model for Gaussian jobs. I've added that now.

I will eventually submit my changes upstreams, but for now I'll just post a clunky list of changes that I've made:
There are two files to edit:

apps/scripts/codereg/ged03theory.py.

Add the following right after the DFT options section and before the MP options section (ca line number 273 in my case)
#Theory options solvation -CAO sovSizer = EcceBoxSizer(self, label = "Solvation", cols = 2) sovLeftSizer = EcceVBoxSizer() sovRightSizer = EcceVBoxSizer() #Use solvation self.useSCRF = EcceCheckBox(self, #useCosmo label = " Use SCRF" name = "ES.Theory.SCF.UseSCRF", default = False) sovLeftSizer.AddWidget(self.useSCRF, border = EcceGlobals.BorderDefault) #SCRF type scrfChoice = ["PCM", "CPCM", "IPCM", "SCIPCM", "SMD", "Dipole"] self.scrf = EcceComboBox(self, choices = scrfChoice, name = "ES.Theory.SCF.SCRF", label = "SCRF type:", default = 0) sovRightSizer.AddWidget(self.scrf, border = EcceGlobals.BorderDefault) #Solvent type solventChoice = ["Water", "Acetonitrile", "Methanol", "Ethanol", "Manual", "Benzene", "Chloroform", "Diethylether", "Dichloromethane", "Dichloroethane", "Carbontetrachloride", "Toluene", "Chlorobenzene", "Nitromethane", "Heptane", "Aniline", "Acetone", "Tetrahydrofuran", "Dimethylsulfoxide", "Argon", "Krypton", "Xenon", "n-Octanol", "1-Butanol" "Cyclohexane", "Isoquinoline", "Quinoline", ] self.solvent = EcceComboBox(self, choices = solventChoice, name = "ES.Theory.SCF.Solvent", label = "Solvent:", default = 0) sovRightSizer.AddWidget(self.solvent, border = EcceGlobals.BorderDefault) self.scrfDielec = EcceFloatInput(self, default = 78.4, name = "ES.Theory.SCF.Dielectric", label = "Dielectric Constant:", hardRange = "(0..)", unit = "Debye") sovRightSizer.AddWidget(self.scrfDielec, border = EcceGlobals.BorderDefault) sovSizer.AddWidget(sovLeftSizer, flag = wx.ALL) sovSizer.AddWidget(sovRightSizer, flag = wx.ALL) self.panelSizer.Add(sovSizer) #End theory options solvation -CAO

Also add the following to the def CheckDependency(self) block, right before the "if (EcceGlobals.Category == "MP" or" line:
# SCRF solvation -- CAO if EcceGlobals.Category == "DFT" or EcceGlobals.Category == "SCF": self.solvent.Enable(self.useSCRF.GetValue()) self.scrf.Enable(self.useSCRF.GetValue()) self.scrfDielec.Enable(self.useSCRF.GetValue() and self.solvent.GetValue() == "Manual") # end SCRF

Edit apps/scripts/parsers/ai.gauss03 and put the following somewhere in the file.
############################################################################## # # Description: # SCRF options field -CAO # ############################################################################## sub SCRFOptions { my($options,$result); $result = ""; $options = ""; #scrf type if ($AbiDict{"ES.Theory.SCF.UseSCRF"}) { if ($AbiDict{"ES.Theory.SCF.SCRF"} eq "" ) { $options .= "PCM,"; } else {$options .= ($AbiDict{"ES.Theory.SCF.SCRF"}).","}; # solvent/dielectric if ($AbiDict{"ES.Theory.SCF.Solvent"} eq "Manual") { if (defined($AbiDict{"ES.Theory.SCF.Dielectric"})) { $options .= "Dielectric=".$AbiDict{"ES.Theory.SCF.Dielectric"}.""; } } elsif ($AbiDict{"ES.Theory.SCF.Solvent"} eq "") { $options .= "Solvent=water"; } else { $options .= "Solvent=".$AbiDict{"ES.Theory.SCF.Solvent"}; } if ($options ne "") { $result = "SCRF=("; $result .= $options; $result .= ") "; } return $result; } }
Also add the following right below the "$route .= &SCFOptions;" line:
$route .= &SCRFOptions;

And you're done:

03 December 2013

533. Adding a new Exchange/Correlation functional to ECCE. M06 for G03 (G09)

Nothing fancy here. I'd just like to be able to select the M06 functional, which is available in G09, using the ECCE interface.

At some point in the future I might set up separate files for G09, but for now I run G09 using the G03 files in ECCE.

See here and here for how to add basis sets to ECCE.

You'll need to edit 2-3 files. I did this in ECCE v7.0.

Edit apps/scripts/codereg/ged03theory.py
185 xcFuncChoice = ["None", 186 "M06 (hybrid)", 187 "SVWN 5 (local)", 188 "SVWN 1/RPA (local)", 189 "BLYP (nonlocal)",
Edit apps/scripts/parsers/ai.gauss03
635 if ($xcFun eq "SVWN 1/RPA (local)") {# convert our terminology to Gaussian's 636 $result = "SVWN"; 637 } elsif ($xcFun eq "SVWN 5 (local)") { 638 $result = "SVWN5"; 639 } elsif ($xcFun eq "M06 (hybrid)") { 640 $result = "M06"; 641 } elsif ($xcFun eq "BLYP (nonlocal)") {

Editing apps/scripts/parsers/Gaussian-03.expt isn't necessary to get this to work, but I did it anyway. Not sure if it 'does' anything:
557 if ($method =~ /b.*3lyp/ || 558 $method =~ /m06/ || 559 $method =~ /bhandh/ || 560 $method =~ /vscx/ || 561 $method =~ /hcth407/ || 562 $method =~ /hcth147/ ||

You should now be able to select M06 in the Theory Details dialogue:


02 December 2013

532. TEMPer temperature monitoring USB stick on Debian Wheezy

Because the air conditioning in my office has a habit of turning itself off, and since I'm running my beowulf cluster in there, and since it's Australia, I've become interested in monitoring the temperature in my office.

The USB stick itself looks nothing special, so here's the card from the box it came in.


A colleague of mine got a TEMPer thermometer USB (0c45:7401 Microdia) back when he didn't have any air conditioning at all in his office and wanted to prove to the university that the temperature got so high that it was impossible for him to do any work on some days. He's now got air conditioning.

Anyway, plugging in the USB stick got me the following:
* /dev/hidraw5 and /dev/hidraw6 get created

* DMESG shows
[441126.932728] usb 2-4.2: new low-speed USB device number 11 using ehci-pci [441127.025790] usb 2-4.2: New USB device found, idVendor=0c45, idProduct=7401 [441127.025803] usb 2-4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [441127.025811] usb 2-4.2: Product: TEMPerV1.2 [441127.025818] usb 2-4.2: Manufacturer: RDing [441127.030229] input: RDing TEMPerV1.2 as /devices/pci0000:00/0000:00:02.1/usb2/2-4/2-4.2/2-4.2:1.0/input/input24 [441127.030516] hid-generic 0003:0C45:7401.000F: input,hidraw5: USB HID v1.10 Keyboard [RDing TEMPerV1.2] on usb-0000:00:02.1-4.2/input0 [441127.033234] hid-generic 0003:0C45:7401.0010: hiddev0,hidraw6: USB HID v1.10 Device [RDing TEMPerV1.2] on usb-0000:00:02.1-4.2/input1
* lsusb shows
Bus 002 Device 011: ID 0c45:7401 Microdia

Searching online for 0c45:7401 brought up this cheesily title post: http://www.linuxjournal.com/content/temper-pi

From that post:
 If instead dmesg says this:
[snip]
and lsusb says:
$ lsusb
Bus 001 Device 005: ID 0c45:7401 Microdia
then congratulations, you have the new TEMPer probe and will have to use completely different software. 
While that sounds as if you'll have continue searching for a new how-to, in fact the entire post is about that particular version. So, I followed the instructions at Linux Journal -- I'll just offer my step by step version of it here with some added detail:

sudo apt-get install python-usb python-setuptools snmpd git
sudo easy_install snmp-passpersist
mkdir ~/tmp
cd ~/tmp
git clone git://github.com/padelt/temper-python.git
cd temper-python/
sudo python setup.py install

At this point I could get a temperature reading by doing:
$ sudo temper-poll 
Found 1 devices Device #0: 24.4°C 75.9°F
But running stuff as root is unsatisfying, so I created a UDEV rule:
$ sudo vim /etc/udev/rules.d/80-temper.rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401", GROUP="users", MODE="0666"
I then unplugged the USB stick, did
sudo service udev restart

and plugged it back in.
$ temper-poll 
Found 1 devices
Device #0: 25.8°C 78.3°F

Sweet.
Finally, I set up a cronjob that would check the temperature, update a plot and put it in my Dropbox:
$ crontab -e
*/2 * * * * sh /home/me/temper.sh
where temper.sh looks like this:
temp=`/usr/local/bin/temper-poll |grep Device|gawk '{print $3}'|sed 's/°C//'` when=`date +%s` thetime=`date +%D' '%T` if [ -n "$temp" ]; then echo $when $temp $thetime>> /home/me/temper.dat fi gnuplot /home/andy/temper.gplt cp /home/me/temper.eps /home/me/Dropbox
The temper.gplt script looks like this:
set term postscript eps enhanced colour set output 'temper.eps' unset key set ylabel 'Temperature (Celsius)' set border 3 set xtics nomirror set ytics nomirror unset xlabel set xdata time set multiplot set size 0.5,0.45 set origin 0,0.05 set timefmt "%H:%M:%S" set title 'Daily' set xtics 30000 plot 'temper.dat' u 4:2 w points pt 1 ps 0.15 set origin 0.5,0.05 set title 'By Day' set timefmt "%m/%d/%y" set xtics 100000#0 plot 'temper.dat' u 3:2 w points pt 2 ps 0.5 set size 1.0,0.5 set origin 0.0,0.5 set timefmt "%m/%d/%y %H:%M:%S" set xtics 30000 set title 'Log' plot 'temper.dat' u 3:2 w lines
and the plot looks like this:
Temperature in a lab at a leading Australian research institute. In five years they have not been able to fix the air conditioning.  On 01/04 someone pushed a cardboard box against the sensor which lead to a slower change in temperature.