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: