05 September 2013

511. When nwchem PES scans fail to constrain -- autoz failure

Another update:
My jobs have run long enough now that I can confirm that using your own z matrix still does not constrain the bond lengths i.e. the link at the end of the post is useless.

Update:
I'm not sure using a zmatrix actually solved this -- for each step in the optimization it seems that nwchem attempts to generate a new zmatrix, and probably ignoring my input (and yes, I'm using noautoz). I'll let my calcs run for a little while to see whether the constraints are honoured or not.

But I'm getting really frustrated with nwchem right now, especially since gaussian isn't having any issues running these particular jobs (there are other issues with gaussian, such as the format of the output, etc.)

Original post:
I set up PES scans in nwchem as shown in this post: http://verahill.blogspot.de/2013/08/503-relaxed-pes-scanning-in-nwchem.html

I was noticing that while almost all of my potential energy surface scans were working out just fine, some of them would...not. What would happen is that there would be no error messages, but for some reason the e.g. atom-atom distance that was defined (and defined using constant) would not remain constant during the geometry optimization in each step.

I saw this when looking trying to move an anion (9 atoms) step-wise closer to a large, negatively charged metal oxide ion (25 atoms).

I took a while to chase this down. First I though that well maybe the distances weren't really set as immutable, but were just associated with a certain force constant -- and that the anion-anion repulsion somehow overcame this. That wasn't the case.

Instead it was something that I should've paid attention to: the zmatrix generation.
If you find that for some reason the PES scan is not constrained at all, look for something along the lines of the following in your output:
NWChem Input Module ------------------- molecules_def2_svp ---------------- Scaling coordinates for geometry "geometry" by 1.889725989 (inverse scale = 0.529177249) ------ auto-z ------ warning. autoz generated 10 bonds for atom 24 warning. autoz generated 10 bonds for atom 25 warning. autoz generated 10 bonds for atom 26 warning. autoz generated 10 bonds for atom 27 warning. autoz generated 10 bonds for atom 28 warning. autoz generated 10 bonds for atom 29 autoz: The atoms group into disjoint clusters cluster 1: 1 2 3 4 cluster 2: 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 Connecting clusters 1 2 via atoms 3 7 r = 3.71 autoz: regenerating connections with new bonds warning. autoz generated 10 bonds for atom 24 warning. autoz generated 10 bonds for atom 25 warning. autoz generated 10 bonds for atom 26 warning. autoz generated 10 bonds for atom 27 warning. autoz generated 10 bonds for atom 28 warning. autoz generated 10 bonds for atom 29 autoz: excessive number of variables 2066 81 AUTOZ failed to generate good internal coordinates. Cartesian coordinates will be used in optimizations.

If that happens, cartesian coordinates will be used, and your
python from nwgeom import * geom = ''' geometry adjust zcoord bond 1 14 %f bond constant end end '''

won't do anything.

The solution is to provide the coordinates as a zmatrix instead -- and that's the focus of my next post:
http://verahill.blogspot.com.au/2013/09/512-briefly-zmatrices-in-nwchem-methanol.html

Oh, and don't forget to include noautz

510. Kernel 3.11 on Debian

Here's another semi-recycled kernel building post -- the instructions are the same as for (almost) any previous version of the kernel.

There are several ways of building a kernel. The easiest (a purely subjective statement) is to use kernel-package i.e. make-kpkg. However, every now and again I see people writing that it's been deprecated.

I never spent much time with 3.10 as it caused (subjective) slow-downs on my SL410 laptop, and had issues -- at least in the early iterations -- when building the nvidia dkms module. I compiled this on a running 3.9.2-ck kernel.

So here's 3.11 -- note that this kernel too will not build the nvidia 304.88 dkms module, although it seems that 325.15 will build with a little bit of patching.

Either way, start by doing
sudo apt-get install fakeroot build-essential ncurses-dev kernel-package
mkdir ~/tmp
cd ~/tmp
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.11.tar.xz
tar xvf linux-3.11.tar.xz
cd linux-3.11/
cat /boot/config-`uname -r`>.config
make oldconfig
Compile also drivers which will not load (COMPILE_TEST) [N/y/?] (NEW) N Kernel compression mode > 1. Gzip (KERNEL_GZIP) 2. Bzip2 (KERNEL_BZIP2) 3. LZMA (KERNEL_LZMA) 4. XZ (KERNEL_XZ) 5. LZO (KERNEL_LZO) 6. LZ4 (KERNEL_LZ4) (NEW) choice[1-6?]: 1 Timer tick handling 1. Periodic timer ticks (constant rate, no dynticks) (HZ_PERIODIC) (NEW) > 2. Idle dynticks system (tickless idle) (NO_HZ_IDLE) (NEW) 3. Full dynticks system (tickless) (NO_HZ_FULL) (NEW) choice[1-3]: 2 Memory placement aware NUMA scheduler (NUMA_BALANCING) [N/y/?] (NEW) N Simple CPU accounting cgroup subsystem (CGROUP_CPUACCT) [N/y/?] (NEW) Group CPU scheduler (CGROUP_SCHED) [N/y/?] (NEW) Automatic process group scheduling (SCHED_AUTOGROUP) [N/y/?] (NEW) Choose SLAB allocator 1. SLAB (SLAB) (NEW) > 2. SLUB (Unqueued Allocator) (SLUB) choice[1-2?]: SLUB per cpu partial cache (SLUB_CPU_PARTIAL) [Y/n/?] (NEW) AIX basic partition table support (AIX_PARTITION) [N/y/?] (NEW) Linux guest support (HYPERVISOR_GUEST) [N/y/?] (NEW) N Timer frequency 1. 100 HZ (HZ_100) 2. 250 HZ (HZ_250) (NEW) 3. 300 HZ (HZ_300) > 4. 1000 HZ (HZ_1000) choice[1-4?]: Enable workqueue power-efficient mode by default (WQ_POWER_EFFICIENT_DEFAULT) [N/y/?] (NEW) Memory Hotplug (ACPI_HOTPLUG_MEMORY) [N/y/?] (NEW) AMD frequency sensitivity feedback powersave bias (X86_AMD_FREQ_SENSITIVITY) [N/m/?] (NEW) Support for PCI Hotplug (HOTPLUG_PCI) [N/y/?] (NEW) Kernel support for scripts starting with #! (BINFMT_SCRIPT) [Y/n/m/?] (NEW) InfiniBand media type support (TIPC_MEDIA_IB) [N/y/?] (NEW) Network Coding (BATMAN_ADV_NC) [N/y/?] (NEW) NETLINK: mmaped IO (NETLINK_MMAP) [N/y/?] (NEW) NETLINK: socket monitoring interface (NETLINK_DIAG) [N/m/y/?] (NEW) MPLS: GSO support (NET_MPLS_GSO) [N/m/y/?] (NEW) NCI over SPI protocol support (NFC_NCI_SPI) [N/y/?] (NEW) NFC hardware simulator driver (NFC_SIM) [N/m/?] (NEW) Dummy IRQ handler (DUMMY_IRQ) [N/m/y/?] (NEW) Generic on-chip SRAM driver (SRAM) [N/y/?] (NEW) ME Enabled Intel Chipsets (INTEL_MEI_ME) [N/m/y/?] (NEW) FlashPoint support (SCSI_FLASHPOINT) [N/y/?] (NEW) Renesas R-Car SATA support (SATA_RCAR) [N/m/?] (NEW) Block device as cache (BCACHE) [N/m/y/?] (NEW) Switch target support (EXPERIMENTAL) (DM_SWITCH) [N/m/?] (NEW) Virtual netlink monitoring device (NLMON) [N/m/y/?] (NEW) ARC devices (NET_VENDOR_ARC) [Y/n/?] (NEW) Qualcomm Atheros AR816x/AR817x support (ALX) [N/m/y/?] (NEW) QLOGIC QLCNIC 83XX family SR-IOV Support (QLCNIC_SRIOV) [Y/n/?] (NEW) Renesas SuperH Ethernet support (SH_ETH) [N/m/y/?] (NEW) SMSC LAN911x/LAN921x families embedded ethernet support (SMSC911X) [N/m/y/?] (NEW) Realtek RTL8152 Based USB 2.0 Ethernet Adapters (USB_RTL8152) [N/m/?] (NEW) m Atheros ath9k rate control (ATH9K_LEGACY_RATE_CONTROL) [N/y/?] (NEW) Atheros 802.11ac wireless cards support (ATH10K) [N/m/?] (NEW) m Atheros ath10k PCI support (ATH10K_PCI) [N/m/?] (NEW) m Atheros ath10k debugging (ATH10K_DEBUG) [N/y/?] (NEW) Atheros ath10k debugfs support (ATH10K_DEBUGFS) [N/y/?] (NEW) Atheros ath10k tracing support (ATH10K_TRACING) [N/y/?] (NEW) rt2800usb - Include support for rt55xx devices (EXPERIMENTAL) (RT2800USB_RT55XX) [N/y/?] (NEW) y Realtek rtlwifi family of devices (RTL_CARDS) [M/n/?] (NEW) Realtek RTL8188EE Wireless Network Adapter (RTL8188EE) [N/m/?] (NEW) m CW1200 WLAN support (CW1200) [N/m/?] (NEW) Cypress TrueTouch Gen4 Touchscreen Driver (TOUCHSCREEN_CYTTSP4_CORE) [N/m/y/?] (NEW) IMS Passenger Control Unit driver (INPUT_IMS_PCU) [N/m/?] (NEW) Freescale lpuart serial port support (SERIAL_FSL_LPUART) [N/m/y/?] (NEW) Analog Devices ADT7310/ADT7320 (SENSORS_ADT7310) [N/m/y/?] (NEW) GMT G762 and G763 (SENSORS_G762) [N/m/?] (NEW) National Semiconductor LM95234 (SENSORS_LM95234) [N/m/?] (NEW) Nuvoton NCT6775F and compatibles (SENSORS_NCT6775) [N/m/y/?] (NEW) generic cpu cooling support (CPU_THERMAL) [N/y/?] (NEW) X86 package temperature thermal driver (X86_PKG_TEMP_THERMAL) [M/n/?] (NEW) MEN A21 VME CPU Carrier Board Watchdog Timer (MEN_A21_WDT) [N/m/y/?] (NEW) ChromeOS Embedded Controller (MFD_CROS_EC) [N/m/y/?] (NEW) Kontron module PLD device (MFD_KEMPLD) [N/m/y/?] (NEW) Silicon Laboratories 4761/64/68 AM/FM radio. (MFD_SI476X_CORE) [N/m/?] (NEW) System Controller Register R/W Based on Regmap (MFD_SYSCON) [N/y/?] (NEW) TI TPS65912 Power Management chip (MFD_TPS65912) [N/y/?] (NEW) USBTV007 video capture support (VIDEO_USBTV) [N/m/?] (NEW) Conexant cx25821 support (VIDEO_CX25821) [N/m/?] (NEW) Cypress firmware helper routines (CYPRESS_FIRMWARE) [N/m] (NEW) QXL virtual GPU (DRM_QXL) [N/m/?] (NEW) Max number of sound cards (SND_MAX_CARDS) [32] (NEW) Build Display HD-audio controller/codec power well support for i915 cards (SND_HDA_I915) [N/y/?] (NEW) y M2Tech hiFace USB-SPDIF driver (SND_USB_HIFACE) [N/m/?] (NEW) Apple infrared receiver (HID_APPLEIR) [N/m/?] (NEW) ELO USB 4000/4500 touchscreen (HID_ELO) [N/m/?] (NEW) Huion tablets (HID_HUION) [N/m/?] (NEW) Enable USB persist by default (USB_DEFAULT_PERSIST) [Y/n/?] (NEW) Y FUSBH200 HCD support (USB_FUSBH200_HCD) [N/m/?] (NEW) OHCI support for PCI-bus USB controllers (USB_OHCI_HCD_PCI) [M/n/?] (NEW) USB-Wishbone adapter interface driver (USB_SERIAL_WISHBONE) [N/m/?] (NEW) Infineon Modem Flashloader USB interface driver (USB_SERIAL_FLASHLOADER) [N/m/?] (NEW) USB Suunto ANT+ driver (USB_SERIAL_SUUNTO) [N/m/?] (NEW) USB Physical Layer drivers (USB_PHY) [N/y/?] (NEW) Faraday FOTG210 USB Peripheral Controller (USB_FOTG210_UDC) [N/m/?] (NEW) PXA 27x (USB_PXA27X) [N/m/?] (NEW) MARVELL PXA2128 USB 3.0 controller (USB_MV_U3D) [N/m/?] (NEW) USB functions configurable through configfs (USB_CONFIGFS) [N/m/?] (NEW) LED Support for TI LP5562 LED driver chip (LEDS_LP5562) [N/m/?] (NEW) LED Camera Flash/Torch Trigger (LEDS_TRIGGER_CAMERA) [N/m/y/?] (NEW) QIB DCA support (INFINIBAND_QIB_DCA) [Y/n/?] (NEW) Mellanox Connect-IB HCA support (MLX5_INFINIBAND) [N/m/?] (NEW) iSCSI Extentions for RDMA (iSER) target support (INFINIBAND_ISERT) [N/m/?] (NEW) Set system time from RTC on startup and resume (RTC_HCTOSYS) [Y/n/?] (NEW) Set the RTC time based on NTP synchronization (RTC_SYSTOHC) [Y/n/?] (NEW) RTC used to set the system time (RTC_HCTOSYS_DEVICE) [rtc0] (NEW) NXP PCF2127 (RTC_DRV_PCF2127) [N/m/?] (NEW) Synopsys DesignWare AHB DMA support (DW_DMAC_CORE) [N/m/y] (NEW) Synopsys DesignWare AHB DMA PCI driver (DW_DMAC_PCI) [N/m/y/?] (NEW) WIS GO7007 MPEG encoder support (VIDEO_GO7007) [N/m/?] (NEW) DesignWare USB2 DRD Core Support (USB_DWC2) [N/m/?] (NEW) Mediatek Bluetooth support (USB_BTMTK) [N/m/?] (NEW) Intel Rapid Start Technology Driver (INTEL_RST) [N/m/y/?] (NEW) Intel Smart Connect disabling driver (INTEL_SMARTCONNECT) [N/m/y/?] (NEW) pvpanic device support (PVPANIC) [N/m/y/?] (NEW) Reset Controller Support (RESET_CONTROLLER) [N/y/?] (NEW) FMC support (FMC) [N/m/y/?] (NEW) XFS Verbose Warnings (XFS_WARN) [N/y/?] (NEW) Btrfs will run sanity tests upon loading (BTRFS_FS_RUN_SANITY_TESTS) [N/y/?] (NEW) Btrfs debugging support (BTRFS_DEBUG) [N/y/?] (NEW) EFI Variable filesystem (EFIVAR_FS) [N/m/y/?] (NEW) NFS client support for NFSv4.2 (NFS_V4_2) [N/y/?] (NEW) Provide Security Label support for NFSv4 server (NFSD_V4_SECURITY_LABEL) [N/y/?] (NEW) 9P Security Labels (9P_FS_SECURITY) [N/y/?] (NEW) Wait/wound mutex debugging: Slowpath testing (DEBUG_WW_MUTEX_SLOWPATH) [N/y/?] (NEW) torture tests for RCU (RCU_TORTURE_TEST) [N/m/y/?] (NEW) Ring buffer startup self test (RING_BUFFER_STARTUP_TEST) [N/y/?] (NEW) Test functions located in the string_helpers module at runtime (TEST_STRING_HELPERS) [N/m/y] (NEW) Debug alternatives (X86_DEBUG_STATIC_CPU_HAS) [N/y/?] (NEW) CMAC support (CRYPTO_CMAC) [M/y/?] (NEW) SHA256 digest algorithm (SSSE3/AVX/AVX2) (CRYPTO_SHA256_SSSE3) [N/m/y/?] (NEW) SHA512 digest algorithm (SSSE3/AVX/AVX2) (CRYPTO_SHA512_SSSE3) [N/m/y/?] (NEW) Camellia cipher algorithm (x86_64/AES-NI/AVX2) (CRYPTO_CAMELLIA_AESNI_AVX2_X86_64) [N/m/y/?] (NEW) Serpent cipher algorithm (x86_64/AVX2) (CRYPTO_SERPENT_AVX2_X86_64) [N/m/y/?] (NEW) LZ4 compression algorithm (CRYPTO_LZ4) [N/m/y/?] (NEW) LZ4HC compression algorithm (CRYPTO_LZ4HC) [N/m/y/?] (NEW) KVM legacy PCI device assignment support (KVM_DEVICE_ASSIGNMENT) [Y/n/?] (NEW) VHOST_SCSI TCM fabric driver (VHOST_SCSI) [N/m/?] (NEW)
make menuconfig

You can now enable any additional modules by navigating the menu structure. Note that most likely you don't have to enable anything in this step, but it can come in handy if there's a major transition (e.g. the way multimedia was handled changed between kernel 3.5 and 3.6) or if you want to enable a previously disabled option.

If you only want to compile modules that are currently in use (not a good idea if you want to use the same kernel on a range of computers, or have USB devices that aren't currently plugged in) you can do that by using make localmodconfig instead of make oldconfig. I wouldn't recommend it -- in most cases it won't make a faster kernel, and space and memory tends not to be much of in the way of issues these days.

Below, change -j2 to -jX, where X is the number of cores in your CPU (not cores+1 or anything funny like that. See other posts on this blog for compilation performance tests)


make-kpkg clean
time fakeroot make-kpkg -j2 --initrd kernel_image kernel_headers
sudo dpkg -i ../linux-image-3.11.0_3.11.0-10.00.Custom_amd64.deb ../linux-headers-3.11.0_3.11.0-10.00.Custom_amd64.deb


And that's it.

04 September 2013

509. Very briefly: Send remote commands via the dropbox folder

This is probably fairly obvious to most people.

I've got a reverse ssh tunnel set up so that I can access my work computer from home. However, for the past few days I've had the connection get stuffed up on a regular basis (it doesn't get dropped, but the connection gets refused), and it frustrates me a little bit.

While a proper ssh connection is unbeatable, I would at least be able to copy files back and forth via dropbox if I only had a way of sending commands to my work computer.

And an obvious way of doing that would be to use a cronjob and a tiny bit of bash scripting. So here we go:
While we don't have to (we could just have an empty script file instead) I like the idea of testing for the presence of a specific file in the Dropbox folder, and if it exists, execute it.

Let's call the file that tests for it runremote.sh, and put it in our home folder (~/). I personally suspect that making sure that execution output and error messages get properly logged is a good thing if you're going to fly blind like this, hence the 1> and 2>

runremote.sh
if [ -e ~/Dropbox/runme.sh ]; then sh ~/Dropbox/runme.sh 1>> ~/Dropbox/runme.log 2>> ~/Dropbox/runme.error & fi

Then when you want something executed, put a file called runme.sh in ~/Dropbox:
pwd echo 'Is it working?' cp ~/testfile.text ~/Dropbox date
Note that any command in runme.sh is going to be run in the ~/ folder -- not in ~/Dropbox.

And set the runremote.sh file to be executed e.g. every five minutes through cron:

crontab -e
*/5 * * * * sh ~/runremote.sh

Again, you don't need to have it test for the presence of a file, but I just instinctively like the idea.

Anyway, any command you put in ~/Dropbox/runme.sh should be executed and logged within five minutes from being synced.

You CAN use sudo (echo mypassword| sudo -S ls /root )as well by providing your password in the script file, but this is obviously not terribly safe.

02 September 2013

508. Very, very briefly: why apt-get purge exists (anecdote)

Sometimes my brain and I fall out, and we refuse to communicate. Yesterday was a day like that.

Having put my TV computer back together again (see post), I realised that I hadn't installed conky or guake on it. So I did. Having edited my default conky.conf (a bit like the one in this post) to change eth0 to eth1, I was wondering why my wireless card wasn't showing up in the ifconfig -a output. lspci showed that I had a broadcom chip, so I installed broadcom-sta-dkms. Nothing much happened, so I rebooted. And...no network card whatsoever recognised (including the ethernet one).

Face palm. I don't have a wireless pci/pci-e card on that computer. I should know -- I had just rebuilt it...

Oh well. apt-get autoremove broadcom-sta-dkms. Nothing. Reboot. Still no eth card -- also, the eth card was obviously the broadcom one (broadcom 4401). But why wasn't it working? I had uninstalled the broadcom package after all.

A bit of googling suggested loading b44 so modprobe b44 it was. Still nothing. Then a thought hit me -- ls /etc/modprobe.d/*blacklist*

And yes -- the broadcom package had installed a broadcom-wl-blacklist.conf file in /etc/modprobe.d -- and b44 was blacklisted. At this point I could either edited the file and comment out b44, delete the file entirely or purge the package and everything would be back to normal. So I did.

So remember: just because you uninstall a package (apt-get autoremovedoesn't mean that you've restore your system to the state it was before you installed the package. To at least have a chance of restoring it you need to purge your package so that settings files are removed too (apt-get purge).



01 September 2013

507. (re)assembling a Dell C521 -- pictures

I finally got around to getting a new (well, refurbished) power supply for my old Dell C521. While the PSU worked fine, on trying to shut down the computer before it booted linux I managed to get the power button stuck. As it turns out, it's not that easy to access things on the front panel on this particular model...

So I took everything apart. EVERYTHING. Except for removing the front panel, ironically. If this post has a lesson for anyone else it's that you shouldn't be afraid to attack (gently) your desktop with a screwdriver. Computers ain't magic.

Anyway, here are some pictures from me reassembling it. For most people it will probably be more useful to look at these pictures in reverse.
Empty case. The arrow indicates where the screws for the panel go. I forget to attach them the first time I reassembled the case...

The plastic bits go to the lights on the front panel

The arrow indicates the front button thingy which I had to attack (gently) with a screw driver to get the power button to release.

The power button. Not sure why I took a picture of it, but there you go.

Front panel screws.

The (very dusty) fan swings out in the direction shown by the arrow. Because of this, you must remove the mobo before removing the fan, which you need to remove in order to remove the front panel. Not a very good design.

The mobo gets stuck in the fabric, so you might need to poke it with a narrow plastic pen or something like that in order to get it to release when removing it. Lift up this side and then slide out the mobo when dismantling.

Another odd design feature -- the heatsink must (more or less) be removed in order to reach the front panel. Also, the CPU is in dire need of a clean and some thermal paste.

The heatsink is now attached -- the plastic bit funnels the airflow from the fan at the front across the heat sink.
The PSU is now in place, but not connected

The P1 main power connector

ATX12V (labelled p2 here) in place

The HDD in place

The CD/DVD ROM in place

PCI and PCI-E in place (and nvidia graphics card and a DTV 1000S tv card)

And it's back in one piece.


30 August 2013

506. Extracting optimized structures from a potential energy scan in nwchem

Another update:
It now dumps the energies in a file, energies.dat, as well.

Update:
some programmes, like ecce, are more picky about the xyz format than others (e.g. jmol, vmd). I've updated the code to output xyz files that ecce too can read.

Original post:
When you use scan_input() in nwchem to do a PES scan (see e.g. here: http://verahill.blogspot.com.au/2013/08/503-relaxed-pes-scanning-in-nwchem.html) you get the energies and the gradients for the optimized structures returned as the results. However, for a casual user the atomic actual coordinates is more informative.

Here's a very simple parser written in python (2.7) which extracts the optimized structures from the output file:

#!/usr/bin/python
import sys

def getrawdata(infile):
        f=open(infile,'r')
        opt=0
        geo=0
        energy=[]
        energies=[]
        struct=[]
        structure=[]
        for line in f:
                if "Total DFT" in line:
                        line=filter(None,line.rstrip('\n').split(' '))
                        energy=float(line[4])
                if 'Optimization converged' in line:
                        opt=1
                if opt==1 and 'Geometry' in line:
                        geo=1
                if      'Atomic Mass' in line and (opt==1 and geo==1):
                        opt=0
                        geo=0
                        struct+=[structure]
                        energies+=[energy]
                        structure=[]
                if opt==1 and geo==1:
                        structure+=[line.rstrip()]
        return struct,energies

def genxyzstring(coords,element):
        x_str='%10.5f'% coords[0]
        y_str='%10.5f'% coords[1]
        z_str='%10.5f'% coords[2]
 
        xyz_string=element+(3-len(element))*' '+10*' '+\
        (8-len(x_str))*' '+x_str+10*' '+(8-len(y_str))*' '+y_str+10*' '+(8-len(z_str))*' '+z_str+'\n'
 
        return xyz_string

def getstructures(rawdata):
        
        n=0
        for structure in rawdata:
                
                n=n+1
                num="%03d" % (n,)
                g=open('structure_'+num+'.xyz','w')
                itson=False
                cartesian=[]
                        
                for item in structure:
                        
                        if itson and not(item==""):
                                coords=filter(None,item.split(' '))
                                coordinates=[float(coords[3]),float(coords[4]),float(coords[5])]
                                element=coords[1]
                                cartesian+=[genxyzstring(coordinates,element)]
                                #cartesian+=[coords[1]+'\t'+coords[3]+'\t'+coords[4]+'\t'+coords[5]+'\n']
                
                        if "---" in item:
                                itson=True
                        if item=="" and itson==True:
                                itson=False
                                if not(len(cartesian)==0):
                                        g.write(str(len(cartesian))+'\n')
                                        g.write('Structure '+str(n)+'\n')
                                        for line in cartesian:
                                                g.write(line)
                                        g.close()
                                cartesian=[]
        return 0
        
if __name__ == "__main__":
        infile=sys.argv[1]
        rawdata,energies=getrawdata(infile)
        structures=getstructures(rawdata)

        g=open('energies.dat','w')
        for n in range(0,len(energies)):
                g.write(str(n)+'\t'+str(energies[n])+'\n')
        g.close()


Presuming that you've saved it as pes_parse.py you can then generate a series of xyz files with the structures, catenate them into a trajectory file, and open it in e.g. jmol. I'm using the output from example 1 in http://verahill.blogspot.com.au/2013/08/503-relaxed-pes-scanning-in-nwchem.html as the example:

chmod +x pes_parse.py
./pes_parse.py nwch.nwout
ls
nwch.nwout structure_001.xyz structure_003.xyz structure_005.xyz structure_007.xyz structure_009.xyz structure_011.xyz structure_013.xyz structure_015.xyz structure_017.xyz structure_019.xyz pes_parse.py structure_002.xyz structure_004.xyz structure_006.xyz structure_008.xyz structure_010.xyz structure_012.xyz structure_014.xyz structure_016.xyz structure_018.xyz
cat structure_*.xyz >> trajectory.xyz jmol trajectory.xyz

You can go through the structures by clicking on the arrows indicated by the white arrow:

Finally, using VMD it's easy to make videos -- note that they for some reason look awful here (seems like a lot of frames are removed, in particular from the beginning of the run):

And here's the SN2 reaction from post 503:


29 August 2013

505. Testing KDE on Debian (if you're a gnome user) -- getting set up

Every now and again I get ticked off with something to do with planned 'features' in gnome 3. I'm still not happy about gnome-screenshot, but I patched and compiled my own version, so I'm doing alright. I don't really like the transition of menus from the, well, menu bar of applications to the top bar of the gnome desktop, but it's not a great issue.

Oh, and I don't really use vanilla gnome 3 anyway -- I've got a desktop set up with a top panel, and bottom panel, static desktops etc. The latest 'feature' which is making me want to move to a different desktop is the planned change in the use of the middle-button so that it no longer can be used to paste text.

(of course there's a bit of inconsistency here: KDE turns out to have a remapped middle-click, the screenshot application needs a few more clicks than the old gnome-screenshot etc.)

I've toyed with the idea of changing desktops in the past, and for a while was running nothing but KDE on my laptop (I'd rather switch on my 'casual' computer first, before making the transition on my work computer), but for some reason I switched back. I actually can't remember why, but something really annoyed me about KDE.

Before I forget: a good reason to try another desktop is simply to reassure yourself that you do have alternatives if your chose DE suddenly turns into something you can't work with.

Anyway, time to give it another go. But what desktop? I like the idea of going for KDE since it's 'the other desktop' -- it's been around longer than gnome, whereas lxde and xcfe are mere babies in comparison. Alternatively, one could always piece together a custom desktop using e.g. fluxbox. Or switch to something completely different, like xmonad. Or something a little bit different, like Enlightenment. I think I should probably be going for LXDE (I instinctively don't like XFCE), but let's go for KDE first.

Finally, the main danger is switching desktops and expecting the new one to act exactly like the old one (minus the bad parts, obviously). Which is pretty much how windows users (myself included once upon a time) behave when trying out linux for the first time.

Anyway, time for a week in KDE (4.10.5).

Here's my gnome desktop at the time of switching:

In addition, I'm using Guake, and my network manager is wicd.

So let's see what KDE will look like at the end -- whether I'll be able to use KDE as KDE, instead of as an ersatz gnome.

Step 1. Install KDE
sudo apt-get install kde-full wicd-kde kdesudo yakuake

I selected kdm.

Step 2. First boot
Reboot and make sure to click the little sun icon to select the desktop you want to use, in my case KDE/plasma.

2.1 Switching workspaces
I next set up proper workspace switching so that it behaves like in...gnome (falling into the old trap of making the new desktop just like the old one)...i.e. ctrl+alt right/left arrow.

Go to System Settings/WorksSpace behaviour, Virtual Desktops -- I incrased the number of desktops to 6 (1 row), then clicked on the Switching tab -- I set shortcuts for Switch One Desktop to the Left and Switch One Desktop to the Right to ctrl+alt+left and ctrl+at+right.

2.2 Disable nepomuk
At this point I noticed that I was using 100% of the CPU. virtuoso-t was chewing up a lot, as was nepomukservices. I had a look at this post: https://forum.kde.org/viewtopic.php?f=66&t=98892



I first went to Search and Indexing (in the menu), unchecked Monitor file and directory changes, Enable when running on battery, Only when computer is not being used.  You can also go to System Settings/Desktop Search and uncheck Enable Nepomuk Semantic Desktop.

2.3 konqueror crashing
I also had repeated issues with konqueror crashing when clicking on links, but it seems to have resolved itself after disabling nepomuk.

2.4 guake/yakuake
Guake worked from the beginning -- I didn't have to set it up at all. However, I still ended up changing to yakuake since I figure it's a bit more KDE like.To get yakuake to remember changed settings (e.g. height, width) you'll need to close it manually. Restarting it will use the new settings. Not sure how I got yakuake to autostart -- I think it just happened.


2.5 The bottom panel
I had a difficult time figuring out how to add shortcuts to the panel, and once I had accidentally figured it out, I promptly screwed up the entire bottom panel, then managed to fix it again.

2.6 Keyboard shortcuts
I then had to figure out how to bind shortcuts to opening applications -- right-click on the menu ('kicker'), click Edit Applications, select your application, advanced, Advanced, Current Shortcut Key.
A more general approach to creating shortcuts was shown to me by an anonymous commentator (see below this post) -- I've posted the screenshot provided to me below:
shortcuts, gestures and whatnots


2.7 Update notification
I promptly removed the Update Notification widget -- it was driving me crazy and reminds me too much of windows. I first tried simply disabling the update notifier:



I then did apt-get autoremove update-notifier-kde. The problem -- even after a reboot I still get notifications about updates! I then did System Settings/Software Management, and click on the tiny, tiny button on the far right (level with the search field), and then click on settings and set Check for updates to never.  This finally seems to have done it.

2.8 Theme
I also changed from the default 'air' theme to 'oxygen'.


2.9 Gnome/GTK programs in KDE
To make gnome (well, gtk) programs look acceptable under KDE, install gtk2-engines-oxygen and gtk3-engines-oxygen and reboot.

2.10 Tap-to-click with synaptics
I can't get synaptics tap to click to work. Based on the odd post I tried gpointing-device-settings, but while there's a checkbox to disable tap to click, it won't enable it. I then installed kde-config-touchpad and was happy again. Funnily enough this made me discover that middle-click is mapped in KDE -- the one reason I wanted to explore something other than gnome...oh well.


2.11 Conky
To get conky to work properly I only had to make some minimal changes. /etc/conky/conky.conf:
background no own_window yes own_window_type normal own_window_argb_visual true own_window_transparent yes own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager double_buffer yes alignment top_right background yes border_width 1 cpu_avg_samples 2 default_color white default_outline_color white default_shade_color white default_graph_size 20 200 draw_borders no draw_graph_borders yes draw_outline no draw_shades no use_xft yes xftfont DejaVu Sans Mono:size=12 gap_x 20 gap_y 60 minimum_size 5 5 net_avg_samples 2 no_buffers yes out_to_console no out_to_stderr no extra_newline no own_window_class Conky own_window_transparent yes stippled_borders 0 update_interval 1.0 uppercase no use_spacer none show_graph_scale no show_graph_range no TEXT ${exec lsb_release -ds} ${execi 5 acpi|gawk '{print $3,$4}'} ${addr eth0}/${addr wlan0} $hr ${color grey}Uptime:$color $uptime CPU:$alignc $cpu% $alignc$color ${cpugraph 10,200 ffff00 ff0000 -t} RAM:$alignc $mem/$memmax $alignc$color ${memgraph 10,200 ffff00 ff0000 -t} I/O:$alignc $diskio_read/$diskio_write $alignc$color ${diskiograph 10,200 ffff00 ff0000 -t} ${color grey}Frequency (in GHz):$color ${freq_g 1}, ${freq_g freq_g2} ${color grey}Temperature: $color CPU: ${acpitemp}°C $hr ${color grey}File systems:$alignr $color/ ${fs_used /}/${fs_size /} $alignr /home $color${fs_used /home}/${fs_size /home} ${color grey}Networking: ${color grey}eth0 ${color red} ${upspeed eth0}/${color green} ${downspeed eth0} ${color grey} ${color grey} ${upspeedgraph eth0 10,100 ffff00 ff0000 -t} ${color grey} ${downspeedgraph eth0 10,100 0000ff 00ff00 -t} ${color grey} ${color grey}wlan0 ${color red} ${upspeed wlan0}/${color green} ${downspeed wlan0} ${color grey} ${color grey} ${upspeedgraph wlan0 10,100 ffff00 ff0000 } ${color grey} ${downspeedgraph wlan0 10,100 0000ff 00ff00 } ${color grey} $hr ${color grey}Name CPU% MEM% ${color} ${top name 1} ${top cpu 1} ${top mem 1} ${color} ${top name 2} ${top cpu 2} ${top mem 2} ${color} ${top name 3} ${top cpu 3} ${top mem 3} $hr ${color}City Ping $alignr Time $font${color}San Francisco ${execi 60 ping -c 1 sfgate.com -n|grep icmp_seq|sed 's/=/\t/g'|gawk '{print $10,$11}'} $alignr${tztime America/Los_Angeles %a %H:%M} $font${color}Copenhagen $alignr${tztime Europe/Copenhagen %a %H:%M} $font${color}Shanghai $alignr${tztime Asia/Shanghai %a %H:%M} $font${color}Melbourne $alignr${tztime Australia/Melbourne %a %H:%M


And I've discovered that I really like the hot corner (top left) in gnome. There is a hot corner in kde too, but it does slightly different things.

KDE is pretty but it still gives me the occasional feeling that I'm using windows due to the bottom panel, the menu on the left and the task tray on the right, but these are things I'll hopefully grow out of. But yes, KDE is pretty -- very pretty. And it's pretty fast too.
My old gnome desktop (same as at the beginning of this post)

and my new KDE desktop
And one just to show how versatile KDE is -- you can even make it look (almost) like gnome 3

So...now it just remains to see how I feel after a week or so. The baby duck syndrome is pretty powerful...and I'm already well on my way to turning KDE into GNOME. But then, isn't the versatility of KDE the real selling point?

Postscript:
I ended up re-enabling nepomuk and spent some time struggling with akonadi to get kmail working -- the key to getting akonadi to work was to install the same server as the backend. In my case I did:
sudo apt-get install akonadi-backend-mysql mysql-server

28 August 2013

504. Swap file and hibernation on debian

I've got an SSD and 4 gb ram on my laptop, and have no desire to use to actual swap during normal use. However, I'd like to be able to let my laptop go into hibernation -- even suspend seems to be draining my battery pretty fast (at maybe a quarter of the rate of keeping the laptop on).

Does it make sense hibernating a laptop with SSD i.e. one which boots in ten seconds flat? Probably not. But we humans are greedy by nature.

So I need to set up a swap file, disable swapping, and see if I can use it for hibernation.

As usual, the best source of information is the archlinux wiki.
https://wiki.archlinux.org/index.php/Swap#Swap_file
https://wiki.archlinux.org/index.php/Pm-utils#Using_Swap_file_instead_of_regular_swap_partition

Anyway, having made it work and tried it out I would say this is really not worth the hassle IF you have an SSD. 


1. The swap file
This is my file system layout:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        39G   20G   18G  53% /
udev             10M     0   10M   0% /dev
tmpfs           380M  816K  380M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           760M  1.1M  759M   1% /run/shm
/dev/sda2       109G   71G   33G  69% /home

In my case I'd say that / has enough space to handle a swap file. My RAM is '4 gb' (really 3.71 Gb) -- according to this and this my swap should equal my RAM, which makes intuitive sense.

Since 4,000,000,000 byte is 3.76 gb, and 4000*1024*1024 (i.e. 4000M) is 3.91 Gb, I think 4000M should be ok:

su -
fallocate -l 4000M /swapfile
chmod 600 /swapfile
mkswap /swapfile
Setting up swapspace version 1, size = 4095996 KiB no label, UUID=2a8de3d1-14f6-473f-b40f-31618fd81169
echo 'vm.swappiness=1' >> /etc/sysctl.d/50-local.conf echo '/swapfile none swap defaults 0' >> /etc/fstab



2. "PM: Swap header not found"

To try it out without rebooting:
sudo sysctl -w vm.swappiness=1
sudo swapon /swapfile
pm-is-supported --hibernate 
echo $?
0
If you got 0, then you're good to go.
sudo pm-hibernate

Trying it out the first time I got "PM: swap header not found" and some weird behaviour. This has been mentioned e.g. here. A step-by-step guide is here: https://ubuntuforums.org/showthread.php?t=1042946

Get the UUID of the partition on which the swapfile is located:
mount | grep " / "
/dev/disk/by-uuid/8adf424c-c375-4035-8d5d-181489b4461b on / type ext4 (rw,noatime,nodiratime,discard,errors=remount-ro,data=ordered)
sudo filefrag -v /swapfile | grep "First block:"

The latter command gave nothing, so I then did:
sudo filefrag -v /swapfile|less
Filesystem type is: ef53 File size of /swapfile is 4194304000 (1024000 blocks of 4096 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 0: 7182336.. 7182336: 1: 1: 1.. 6143: 7182337.. 7188479: 6143: unwritten 2: 6144.. 8191: 7190528.. 7192575: 2048: 7188480: unwritten
So now we have the UUID (8adf424c-c375-4035-8d5d-181489b4461b) and the offset (7182336).
su -
echo "resume=UUID=8adf424c-c375-4035-8d5d-181489b4461b resume_offset=7182336" | sudo tee /etc/initramfs-tools/conf.d/resume
exit

Edit /etc/default/grub and add the same line to GRUB_CMDLINE_LINUX_DEFAULT:
GRUB_CMDLINE_LINUX_DEFAULT="quiet resume=UUID=8adf424c-c375-4035-8d5d-181489b4461b resume_offset=7182336"
Run
sudo update-grub
sudo update-initramfs -u

Reboot.

3. Hibernating.
sudo pm-hibernate

On my lenovo sl410 what I see is the screen go blank save for a blinking "-", and the little crescent light at the front of the laptop starting to blink (next to the battery light).

After 5-10 seconds the laptop turns off.

Hitting the power button starts up the laptop -- you get the bios screen, then the grub menu, and at this point you're thinking that the whole exercise has failed -- but it ends up booting into the same situation as you had when you did pm-hibernate i.e. it worked. I mean, this is how hibernation works -- but I had honestly never used anything other than suspend before, so...well..there's a first time for everything.

Overall, on a laptop with an SSD, resuming from hibernation is about as slow as a cold start -- with entering hibernation taking longer than a shutdown. On a laptop with a spinning disk this could presumably be worth it.

503. (relaxed) PES scanning in Nwchem revisited.

Update 2: The coordinates are actually gradients, and so aren't terribly informative to a casual user like myself. See this post for how to extract the geometries properly: http://verahill.blogspot.com.au/2013/08/506-extracting-optimized-structures.html


Update:
Please note that the coordinates in square brackets ([]) in the python output are not raw coordinates for the atoms in the molecule -- I haven't quite figured out how they scale, but it's not a simple matter of just multiplying. The energies are good though, and you can always extract the coordinates the slow and painful way by manually going through the output.

Another issue which should be stressed is that scan_input(geom,[1.398],[3.398],19,'dft',task_optimize) does not do the end points -- i.e. you won't get the energy for a bond length of 1.398, and you won't get the energy for a bond length of 3.398. Instead you'll get 19 data points in between these. It's a bit...awkward.

Original post:
A long time ago I made a post on doing potential energy surface (PES) scans in nwchem using python.

This is a post giving PES another look. The impetus for the post is that I'm tired of Gaussian failing and being opaque about the whole procedure.

The following page was of great help: http://www.fqt.izt.uam.mx/html/software_fqt/user/node34.html

NOTE: you'll need to compile nwchem with python support. See e.g. http://verahill.blogspot.com.au/2013/06/449-nwchem-63-updated-sources-compiling.html (the post is a bit messy, but persevere -- it's not that difficult)

On Debian the key is to change
    EXTRA_LIBS +=    -lnwcutil  -lpthread -lutil -ldl
to
    EXTRA_LIBS +=    -lnwcutil  -lpthread -lutil -ldl -lssl -lz

in config/makefile.h before compiling. It's not necessary on RHEL clones.

Below I'll show three examples:
* a simple bond dissociation reaction. I also discuss the use of 'constant', and task_energy vs task_optimize.
* an SN2 reaction (CH3Br + I-)
* a 2D/parallel PES scan of ethane ( C-C bond length, H-C-C angle). I also show constant vs free variables.


Example 1.
Breaking the C-O bond in methanol

I set this up in ecce (see e.g. next example), but you don't have to. The input file I used was the following:
scratch_dir /scratch Title "meoh_pes" Start meoh_pes echo charge 0 geometry autosym units angstrom C 0.0351714 0.00548884 0.0351714 H -0.617781 -0.634073 0.667983 H 0.667983 -0.634073 -0.617781 H -0.605139 0.646470 -0.605139 O 0.839603 0.818768 0.839603 H 1.38912 0.201564 1.38912 end ecce_print ecce.out basis "ao basis" cartesian print H library "3-21G" O library "3-21G" C library "3-21G" END dft mult 1 direct XC b3lyp grid fine iterations 99 mulliken end driver default maxiter 888 end python from nwgeom import * geom = ''' geometry adjust zcoord bond 1 5 %f cccc constant end end ''' results=scan_input(geom,[1.398],[3.398],19,'dft',task_optimize) for i in range(0,len(results)): print results[i][0][0],results[i][1] end task python
The PES bit is highlighted in blue. Note the 'constant' keyword -- if you omit that the bond length will initially be set to whatever you define it to in your scan, but it can relax back to the optimum length. If you DO set 'constant' everything BUT that bond will be relaxed. Most likely this is what you will want to do.

Also note that a constrained (i.e. not relaxed) PES scan can be done by doing task_energy instead of task_optimize.

ECCE can't quite handle the textual output (alt+O) since there are lines that are too long. The output is properly written though -- you'll just have to look in the Output folder of the job. The ecce.out file works fine though.

The job takes 90-100 seconds on an old 3-core node (AMD Athlon II X3).


The very end of the output file has all the results, but in a non-obvious way:
1.498 (-115.07289914310056, [-0.00130778291169336, 0.01798903956433226, 0.0, -4.009155466250247e-05, 1.693340302064139e-05, -6.637550254401381e-06, -4.009155466250247e-05, 1.693340302064139e-05, 6.637550254401381e-06, 2. 4514244186701895e-05, -1.5885649893555842e-05, 0.0, 0.0012636893525275195, -0.018041103298149008, 0.0, 9.97624242821682e-05, 3.4082577691996185e-05, 0.0]) (-114.8737952986994, [-4.7287277448850376e-05, 0.030029200359777717, 0.0, -1.3711175166353229e-06, -8.452926738775068e-08, 9.941241931599176e-07, -1.3711175166353229e-06, -8.452926738775068e-08, -9.941241931599176e-07, 8. 167348279908282e-07, -2.5820569179275075e-06, 0.0, 4.871429991895604e-05, -0.030027845123621805, 0.0, 4.984777179639632e-07, 1.3958792967685985e-06, 0.0]) 1.498 (-115.07289914310056, [-0.00130778291169336, 0.01798903956433226, 0.0, -4.009155466250247e-05, 1.693340302064139e-05, -6.637550254401381e-06, -4.009155466250247e-05, 1.693340302064139e-05, 6.637550254401381e-06, 2. 4514244186701895e-05, -1.5885649893555842e-05, 0.0, 0.0012636893525275195, -0.018041103298149008, 0.0, [..] 3.198 (-114.87977711993531, [-0.00018979360652668711, 0.033296276783081655, 0.0, -2.3787379704320877e-06, 1.7510009376556918e-06, 1.3530564600128248e-06, -2.3787379704320877e-06, 1.7510009376556918e-06, -1.3530564600128248e-06, 8. 24207064487048e-06, -8.055936327900498e-07, 0.0, 0.00018027576986845428, -0.03329589479259992, 0.0, 6.033241931824307e-06, -3.0783987173960137e-06, 0.0]) 3.298 (-114.8737952986994, [-4.7287277448850376e-05, 0.030029200359777717, 0.0, -1.3711175166353229e-06, -8.452926738775068e-08, 9.941241931599176e-07, -1.3711175166353229e-06, -8.452926738775068e-08, -9.941241931599176e-07, 8. 167348279908282e-07, -2.5820569179275075e-06, 0.0, 4.871429991895604e-05, -0.030027845123621805, 0.0, 4.984777179639632e-07, 1.3958792967685985e-06, 0.0])
All in all, there are 58 lines for 19 steps. I think that there are three things happening -- firstly, the line in blue is the output from the 19th step, and that somehow gets mixed in with the output from all the calculations. Secondly, the structure and energy of each step is reported twice at a time. Thirdly, the optimised structures/energies are reported one more time by injecting them into the output, like this:
A
S
A
B
B
C
C
D
D
A
E
E
B

where A is the first step, S is the 19th step etc. This way you get 19x3+1=58 lines. This is clearly idiotic.

Instead, you can look through the output and search for 'Scanning NWChem input - results from step' to see all the output for the optimised structures one by one:
Scanning NWChem input - results from step 2 (-115.06618436935011, [-0.0038228970733096973, 0.050051062094932305, 0.0, 2.9196769046224702e-05, -6.928661348853948e-06, 4.746536668570611e-06, 2.9196769046224702e-05, -6.928661348853948e-06, -4.746536668570611e-06, -1.0103262985700079e-05, 1.6491089715894858e-05, 0.0, 0.003767244388907326, -0.05005618579508188, 0.0, 7.362409274846993e-06, 2.489933151654522e-06, 0.0])
In this particular case I can grep my way through by doing
cat nwch.nwout |grep '^(-'|cat -n
1 (-115.07289914310056, [-0.00130778291169336, 0.01798903956433226, 0.0, -4.009155466250247e-05, 1.693340302064139e-05, -6.637550254401381e-06, -4.009155466250247e-05, 1.693340302064139e-05, 6.637550254401381e-06, 2.4514244186701895e-05, -1.5885649893555842e-05, 0.0, 0.0012636893525275195, -0.018041103298149008, 0.0, 9.97624242821682e-05, 3.4082577691996185e-05, 0.0]) 2 (-115.06618436935011, [-0.0038228970733096973, 0.050051062094932305, 0.0, 2.9196769046224702e-05, -6.928661348853948e-06, 4.746536668570611e-06, 2.9196769046224702e-05, -6.928661348853948e-06, -4.746536668570611e-06, -1.0103262985700079e-05, 1.6491089715894858e-05, 0.0, 0.003767244388907326, -0.05005618579508188, 0.0, 7.362409274846993e-06, 2.489933151654522e-06, 0.0]) 3 (-115.05478103866017, [-0.005033784212299788, 0.06848598587431667, 0.0, -1.3396548676491982e-06, -2.5875637174599397e-08, -5.261746410523127e-07, -1.3396548676491982e-06, -2.5875637174599397e-08, 5.261746410523127e-07, 1.4459720645843e-07, -2.8328952926398587e-06, 0.0, 0.005034455335082233, -0.0684825786855032, 0.0, 1.8635897582608418e-06, -5.225422206114883e-07, 0.0]) 4 (-115.04079235517, [-0.005485543277166251, 0.07798880362126945, 0.0, 4.745460307237215e-06, -5.597510268573469e-06, 5.645418744981701e-07, 4.745460307237215e-06, -5.597510268573469e-06, -5.645418744981701e-07, -6.651712157745848e-07, 6.750842351778419e-06, 0.0, 0.00548062073181968, -0.07798086728839469, 0.0, -3.903204054994669e-06, -3.4921546817404114e-06, 0.0]) 5 (-115.02560006674966, [-0.0054233976595857575, 0.08166232318137269, 0.0, -1.659239761503395e-06, -4.376603580866223e-07, 4.4580035316599265e-06, -1.659239761503395e-06, -4.376603580866223e-07, -4.4580035316599265e-06, 3.034808945895362e-06, -6.726118036586015e-06, 0.0, 0.005436665955901393, -0.08164730868562775, 0.0, -1.2984625724410392e-05, -7.4130570159938736e-06, 0.0]) [..] 16 (-114.89364787840326, [-0.0005591249462735259, 0.04018795560035916, 0.0, -5.34666220519675e-07, 1.1370871814235517e-06, 4.809133242467123e-07, -5.34666220519675e-07, 1.1370871814235517e-06, -4.809133242467123e-07, -6.9140095421138525e-06, -3.095664552260277e-06, 0.0, 0.0005695756951453745, -0.040185884820554796, 0.0, -2.467406898132296e-06, -1.2492896190128416e-06, 0.0]) 17 (-114.8863872514371, [-0.00036666056940981573, 0.03667976502852128, 0.0, 2.9101399354747315e-06, -2.094045026924257e-06, -4.933288234976185e-06, 2.9101399354747315e-06, -2.094045026924257e-06, 4.933288234976185e-06, 1.6531622304416516e-07, 1.511517903679191e-07, 0.0, 0.00036162347288279384, -0.03668602744257765, 0.0, -9.484995716624312e-07, 1.0299352320775057e-05, 0.0]) 18 (-114.87977711993531, [-0.00018979360652668711, 0.033296276783081655, 0.0, -2.3787379704320877e-06, 1.7510009376556918e-06, 1.3530564600128248e-06, -2.3787379704320877e-06, 1.7510009376556918e-06, -1.3530564600128248e-06, 8.24207064487048e-06, -8.055936327900498e-07, 0.0, 0.00018027576986845428, -0.03329589479259992, 0.0, 6.033241931824307e-06, -3.0783987173960137e-06, 0.0]) 19 (-114.8737952986994, [-4.7287277448850376e-05, 0.030029200359777717, 0.0, -1.3711175166353229e-06, -8.452926738775068e-08, 9.941241931599176e-07, -1.3711175166353229e-06, -8.452926738775068e-08, -9.941241931599176e-07, 8.167348279908282e-07, -2.5820569179275075e-06, 0.0, 4.871429991895604e-05, -0.030027845123621805, 0.0, 4.984777179639632e-07, 1.3958792967685985e-06, 0.0])
Not pretty, but manageable.
cat nwch.nwout |grep '^(-'|sed 's/\,/\t/g;s/(\([^)]*\))/\1/g'|cat -n|gawk '{print $1,$2}' > profile.dat

and then plot it:


Example 2.
SN2 reaction between iodide and bromomethane

You can set up your calc however you want, but ECCE is easier than anything else.

Draw bromomethane, then throw in an iodine atom. Adjust the angle across Br-C-I to 180 degrees, and set the C to I distance to 3 Ã….


Set up the calculation -- in this case I used b3lyp/def2-svp
Edit the input and add
python from nwgeom import * geom = ''' geometry adjust zcoord bond 1 6 %f cccc constant end end ''' results=scan_input(geom,[3.00],[1.5],20,'dft',task_optimize) for i in range(0,len(results)): print results[i][0][0],results[i][1] end task python

(Delete 'task dft optimize')

You'll now have the following input file:
scratch_dir /scratch
Title "sn2_br"

Start  sn2_br

echo

charge -1

geometry noautosym units angstrom
 C     0.00000     0.00000     0.00000
 H     -0.675500     -0.675500     0.675500
 H     0.675500     -0.675500     -0.675500
 H     -0.675500     0.675500     -0.675500
 Br     1.10274     1.10274     1.10274
 I     -1.73205     -1.73205     -1.73205
end

ecce_print ecce.out

basis "ao basis" spherical print
  H library "def2-svpd"
  Br library "def2-svpd"
  C library "def2-svpd"
  I library "def2-svpd"
END
ECP
  I library "def2-ecp"
END

dft
  mult 1
  direct
  XC b3lyp
  grid fine
  iterations 99
  mulliken
end

driver
  default
  maxiter 99
end


python
from nwgeom import *
geom = '''
    geometry adjust
        zcoord
            bond 1 6 %f cccc constant
        end
    end
'''
results=scan_input(geom,[3.00],[1.5],20,'dft',task_optimize)
for i in range(0,len(results)):
    print results[i][0][0],results[i][1]
end


task python
Launch it and wait...eventually (2h 30 min on a slow three-core node) you'll get an output like the one below. Note that I didn't pre-optimise the bromomethane, so there's a bit of a drop in energy at the beginning. Likewise, I let the C-I distance get so short that the energy is rising rapidly at the end
Structure at the beginning

Transition-state-ish structure

Product


Example 3:
Two-dimensional PES scan

I'll keep this brief. First we do a scan where we use 'constant' for the angle, but not the bond length:
scratch_dir //scratch Title "2d_pes-1" Start 2d_pes-1 echo charge 0 geometry noautosym units angstrom C -2.51242e-66 1.67495e-66 -0.767732 H -0.722530 0.722530 -1.16548 H -0.264464 -0.986995 -1.16548 H 0.986995 0.264464 -1.16548 C 2.51242e-66 -2.51242e-66 0.767732 H 0.264464 0.986995 1.16548 H -0.986995 -0.264464 1.16548 H 0.722530 -0.722530 1.16548 end ecce_print ecce.out basis "ao basis" cartesian print H library "6-31G" C library "6-31G" END dft mult 1 direct XC b3lyp grid fine iterations 99 mulliken end driver default end python from pes_scan import pes_scan geom = ''' geometry noprint adjust zcoord bond 1 5 %f cc angle 2 1 5 %f hcc constant end end ''' results = pes_scan(geom, \ [1.535, 111.269], [1.800, 90], 5, 'dft', task_optimize) end task python

And the output:
What's happening is that the bond length ends up being the same no matter what we initially set it to

If we instead set constant for the bond as well:
python from pes_scan import pes_scan geom = ''' geometry noprint adjust zcoord bond 1 5 %f cc constant angle 2 1 5 %f hcc constant end end ''' results = pes_scan(geom, \ [1.535, 111.269], [1.800, 90], 5, 'dft', task_optimize) end task python

And we get:

27 August 2013

502. Spell checking in WPS office on linux -- changing language by replacing the default files

To my great shame I am using a piece of non-FOSS to deal with MS Office files -- namely, WPS. As a junior faculty member it'd be professional suicide to try to force other people to deal with the mis-rendered libreoffice files in MS Office, and for some reason no-one uses PDF anymore when sending out forms...

Anyway, in spite of not being open source and not supporting any open formats, WPS can read and save .doc and .docx files in a way that works together with MS Office, and since it runs natively on linux it's a practical solution until the day libre/openoffice become viable alternatives.

There doesn't seem to be any simple way of changing language beyond replacing the default dictionary files. It ain't pretty, but it works.

In my case I wanted Australian English, so I first installed the myspell dictionary:
sudo apt-get install myspell-en-au
mkdir ~/.dictionaries
sudo mv /opt/kingsoft/wps-office/office6/dicts/main.aff /opt/kingsoft/wps-office/office6/dicts/en_us.aff
sudo mv /opt/kingsoft/wps-office/office6/dicts/main.dic /opt/kingsoft/wps-office/office6/dicts/en_us.dic
sudo cp /usr/share/hunspell/en_AU.dic /opt/kingsoft/wps-office/office6/dicts/main.dic
sudo cp /usr/share/hunspell/en_AU.aff /opt/kingsoft/wps-office/office6/dicts/main.aff

Start WPS and it should now speak 'Strine.

24 August 2013

501. Briefly: Adding a new node to SGE

I've done this a couple of times by now, and I always forget one step or another. Most of the information is on http://verahill.blogspot.com.au/2012/06/setting-up-sun-grid-engine-with-three.html but here it is in a briefer form:

In the example I've used krypton as the node name, and 192.168.1.180 as the IP.
My front node is called beryllium and has an IP of 192.168.1.1.

0. On the front node
Add the new node name to the front node/queue master

Add execution host
qconf -ae 

which opens a text file in vim

Edited hostname (krypton) but nothing else. Saving returns
added host krypton to exec host list
Add krypton as a submit host
qconf -as krypton
krypton added to submit host list
Doing this before touching the node makes life a little bit easier.

1. Edit /etc/hosts on the node
Leave
127.0.0.1 localhost
but remove
127.0.1.1 krypton
and make sure that it says
192.168.1.180 krypton
instead.

Throw in
192.168.1.1 beryllium
as well.

2. Install SGE on node
sudo apt-get install gridengine-exec gridengine-client

You'll be asked about
Configure automatically: yes Cell name: rupert Master hostname: beryllium
3. Add node to queue and group
I maintain separate queues and groups depending on how many cores each node has. See e.g. http://verahill.blogspot.com.au/2012/06/setting-up-sun-grid-engine-with-three.html for how to create queues and groups.

If they already exits, just do

qconf -aattr hostgroup hostlist krypton @fourcores
qconf -aattr queue slots "[krypton=4]" fourcores.q

to add the new node.

4. Add pe to queue if necessary
Since I have different queues depending on the number of cores of a node, I tend to have to fiddle with this.

See e.g. http://verahill.blogspot.com.au/2012/06/setting-up-sun-grid-engine-with-three.html for how to create pe:s.

If the pe you need is already created, you can do
qconf -mq fourcores.q

and edit pe_list

5. Check
On the front node, do
qhost
HOSTNAME ARCH NCPU LOAD MEMTOT MEMUSE SWAPTO SWAPUS ------------------------------------------------------------------------------- global - - - - - - - beryllium lx26-amd64 3 0.16 7.8G 5.3G 14.9G 398.2M boron lx26-amd64 6 6.02 7.6G 1.6G 14.9G 0.0 helium lx26-amd64 2 - 2.0G - 1.9G - lithium lx26-amd64 3 - 3.9G - 0.0 - neon lx26-amd64 8 8.01 31.4G 1.3G 59.6G 0.0 krypton lx26-amd64 4 4.01 15.6G 2.8G 14.9G 0.0