01 October 2020

666. Zoom -- multiple booking for a course

Problem:

Recurring bookings are easy enough to make in zoom, but what do you do if your lectures are given at different times each day?

Solution: 

make a recurring booking e.g. at 8 am, 2 hours, each day for two weeks. 'When' is not important.

Then go in and edit the booking. You can then change the times for each zoom meeting:

You can also delete meetings e.g. those that fall on weekends:






24 August 2020

665. Dealing with low gain/low volume in Samson XPD2 by boosting the gain in pulseaudio

I've 'solved' this now. See bottom of post.

Old post:

 Got the Samson XPD2 now, and it's ... interesting.

Even if I crank everything up to the max in linux, I can barely hear what I record in audacity (or anywhere -- it's a linux thing).

But if I hook up headphones to the headphone jack on the USB dongle the sound is great.

What figures?

As usual the first port of call is always dmesg:

[Sun Aug 23 05:18:02 2020] usb 2-11: new full-speed USB device number 22 using xhci_hcd
[Sun Aug 23 05:18:02 2020] usb 2-11: New USB device found, idVendor=17a0, idProduct=1616, bcdDevice= 1.00
[Sun Aug 23 05:18:02 2020] usb 2-11: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[Sun Aug 23 05:18:02 2020] usb 2-11: Product: Samson RXD wireless receiver
[Sun Aug 23 05:18:02 2020] usb 2-11: Manufacturer: Samson Technologies
[Sun Aug 23 05:18:02 2020] usb 2-11: Warning! Unlikely big volume range (=496), cval->res is probably wrong.
[Sun Aug 23 05:18:02 2020] usb 2-11: [50] FU [Mic Capture Volume] ch = 1, val = 0/7936/16
[Sun Aug 23 05:18:02 2020] input: Samson Technologies Samson RXD wireless receiver as /devices/pci0000:00/0000:00:14.0/usb2/2-11/2-11:1.2/0003:17A0:1616.0012/input/input58
[Sun Aug 23 05:18:02 2020] hid-generic 0003:17A0:1616.0012: input,hidraw7: USB HID v1.00 Device [Samson Technologies Samson RXD wireless receiver] on usb-0000:00:14.0-11/input2


Linux is normally PnP, but here there seems to be an issue. Time to start reading. Found a similar issue here: https://bugzilla.redhat.com/show_bug.cgi?id=1070706

Will update as/if I fix this.

Also, I got a female 3.5 mm to female XLR connector so that I can use a better lavalier mic. The connector should be mini-XLR -- a full-size XLR is way too big. 

Solution:

What I do now is set the input volume in the terminal using pulseaudio (pacmd/pactl).

By default you can only set the input volume to 150%, but using the command line you can go as crazy as you like.

First identify the card index number: 

pacm list-sources|egrep "name|index"

    index: 26
   name: <alsa_input.usb-Samson_Technologies_Samson_RXD_wireless_receiver-00.analog-mono>
      alsa.name = "USB Audio"
      alsa.subdevice_name = "subdevice #0"
      alsa.card_name = "Samson RXD wireless receiver"
      alsa.long_card_name = "Samson Technologies Samson RXD wireless receiver at usb-0000:00:14.0-2, full sp"
      alsa.driver_name = "snd_usb_audio"
      device.vendor.name = "Samson Technologies Corp."
      device.product.name = "Samson RXD wireless receiver"
      device.profile.name = "analog-mono"
      alsa.mixer_name = "USB Mixer"
      device.icon_name = "audio-card-usb"

Then do (for index 26):

pactl set-source-volume 26 270%

Works great! Of course you can't touch the input slider in the pulseaudio GUI at this point. The next project is to change the pulseaudio source code to allow a higher max volume.

New microphone

I also bought a new microphone to use with the Samson: https://www.amazon.de/-/en/gp/product/B071937RZZ/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1

The sound is subjectively a lot better and I feel that it has better dynamic range, than with the stock microphone.

22 August 2020

664. Capturing sound when recording/streaming lectures/videos. A few devices.

 I'm interested in capturing sound, either during on-campus lectures, or when recording videos, or when lecturing over zoom.

Here are some of the devices that I own, and what I think:

Logitech C920 webcam with integrated microphone:

C920 HD Pro Webcam 1

The sound is ... fine. Even at a few metres distance, actually.  Nothing like a proper, dedicated microphone, but way beyond e.g. the microphone you'd find in a laptop.

BlueParrot B350-XT bluetootch headset:

Jabra Evolve 75

It's absolutely bloody awful as a sound source. Absolutely fine for listening to music with, but as a headset for recording sound it stinks. The sound during phone calls is fine, but expectations aren't generally very high. Bloody expensive too.

Logitech G930 wireless gaming headset:

Decent sound, but lacks dynamic range in terms of the microphone. Won't work well during a live lecture since it covers both ears. Great at keeping sound out, so very good as a headset for listening to music.

Samson XPD2 wireless lavalier microphone:

Have ordered, but not yet received. You can use it as a lav mic, but I'm going to experiment with using the Zoom H1n below as the input (via a 2x 3.5 mm cable plus a 3.55 mm female -> XLR converter), so that I can record on the H1n simultaneously as I live-stream. We'll see how it works out.

I also bought what is supposed to be a better Lavalier mic (J-082S 044) and a 3.5 mm/XLR adapter:


Blue Yeti microphone:

Yeti microphone image

This is my default microphone for video conferencing and recording videos. It's a great microphone. Cheaper than the crappy B350-XT above. Has several different pickup patterns. I love it. 

I'm using it together with a boom arm I got off of Amazon ('Neuma Professional Microphone Stand with Pop Protection').

Zom Handy H1n sound recorder:
Zoom H1n 2-Input / 2-Track Portable Handy Recorder ZH1N B&HZoom APH1N Accessory Pack for H1N Handy Recorder | Recorders - Store DJ

This is my favoure toy though. It's small, light and have great sound. It's a stereo microphone when use as a sound recorded. You can also hook it up via USB (and have it powered via USB) and use it as a high-quality MONO microphone when recording videos or video conferencing. You can NOT record at the same time as you're using it as a USB microphone. I also got the Zoom APH 1 N/GE Accessories Bundle.

The portability makes it great for a number of uses. You can pass it between lecturers that want to record good-quality sound for lecture videos, and it's easy to take home (the Blue Yeti is a heavy beast).

You can also stick it the podium when giving a lecture and it will capture surprisingly good sound. You can record sound and replace webcam sound in post using e.g. KDENLive. You can attach a lavalier mic and use it to record sound during a live lecture and replace webcam sound in post. And more.

It has a 3.5 mm mic input and a 3.5 mm headphone output. I'm planning on experimenting with recording on the H1n at the same time as I've got the headphone output connected to the Samson (above) so that I can stream the sound to my laptop, and share it via zoo, since wireless technologies can be unstable in a lecture hall with lots of phones with wifi running (anywhere you have students). We'll see how it works out.


----------------
Once the audio is taken care of, I plan on using the following for the visual, and use OBS Studio to tie it all together.

Document camera JOURIST DC80

H1n Audio Recorder front viewH1n Audio Recorder front viewWebcam Logitech C920

H1n Audio Recorder front viewC920 HD Pro Webcam 1


I've also ordered a chromakey set for fancier video production. Will be interesting to see how it turns out.

663. Giving a zoom + on-campus lecture (on linux, win and mac)

Preamble:

The uni admins aren't making it easy for us. 

I can handle doing everything on-campus, giving good, or occasionally very good, lectures using the white board and making it dynamic by actually engaging with the target, the students. I can often get them to share my excitement over the amazing stuff we're discussing (especially MO theory -- it's my favourite topic, and my favourite lecture). 

I can handle doing everything online if necessary, optimising my lectures to work through zoom or, even better, do away with lectures completely and rely on pre-recorded videos that take advantage of the video format, and use them to flip the class. We can then meet up on zoom to discuss the topics.

But what we're being asked to do is to focus on on-campus teaching, while making sure that everything is being streamed live online to avoid students from showing up to class when infectious.

Note that in our lecture halls we don't have computers. We're expected to bring our own, and we use single projectors. We also don't get any help from IT. Nothing is ever recorded here.

This is incredibly primitive and unprofessional compared to how things were done back in Australia.

What I will show here:

A few approaches to making a lecture work OK for both on-campus and online students simultaneously, and easily. The solutions assume that there's no competency, interest or support from IT.

1. The Basic
The easiest approach is to start zoom on your laptop, share a set of slides and stream it. You need to think about audio though, and there are a number of wireless solutions.

We've been told to use bluetooth headsets, but bluetooth has poor audio. Using 2.4 GHz wireless headsets, like my old logitech G930, gives better audio, but then you can't hear the local audience properly. 

My preferred solution is to use a Samson XPD2: 
http://www.samsontech.com/samson/products/wireless-systems/xpd-series/xpd2lav/

It's not a headset -- sound won't come out of it, but you can crank up the sound on your computer (or even use external speakers -- I have a very old HP USB speakers that are just about loud enough for a lecture hall (https://support.hp.com/ca-en/document/c02574017)

You can obviously switch input to webcam/document cam etc., but it's pretty basic.

If you have a document camera you can use this just like a webcam. Or you use e.g. https://gitlab.com/docphees/doccam to manage your document camera, and then use the window as input to zoom through share screen.

2. With a bit of Flair

This is a somewhat technical solution on linux, but I think it's easier on win/mac. What we can do is to set up a virtual webcam. The contents of the virtual webcam will be supplied by obs-studio

We then use obs-studio -- in studio mode no less -- to switch between different types of views.

virtual webcam: If you're on linux you need to install v4l2loopback (either as the dkms in the deb repo, or by a very simple compile), and if you're on linux you need the v4lsink. If you're on win/mac you can simply install the virtual camera plug-in for obs-studio.

On linux you need to create a virtual webcam:
sudo modprobe v4l2loopback video_nr=10 card_label="OBS Video Source" exclusive_caps=1

In obs-studio you then choose Tools/V4L2 Video Output and choose /dev/video10

obs-studio
Once that's up and running, set up at least two scenes in obs-studio, and pick studio mode.

I've set up one scene with a lion and a styracosaurus on a webcam, with the background chromakeyed out* over a molecular simulations video, and another one showing the guardian website, but one could've been the window with your slides, and another could be a document camera.


I've then set up ctrl+shift+alt+5 to switch between them:


You can even have different audio input depending on the scene. Useful if you're using wired microphones and moving between different stations in your lecture hall.

In zoom: now all you need to do is to pick the virtual webcam device as your input in zoom. There is a CPU overhead to using obs-studio, so expect the laptop to keep the fan on throughout the lecture.

*The chromakey background is the blue cover of an Office Depot notebook :)

21 August 2020

662. Mini-post: Getting a bluetooth headset to work on linux -- B350-XT

 I have a BlueParrot  B350-XT which is causing issues on linux. It pairs fine, and shows up as a sound device, but it won't actually play sound or record sound.


Looking at dmesg -T, I see

[Tue Aug 18 01:25:33 2020] Bluetooth: hci0: BCM: chip id 63
[Tue Aug 18 01:25:33 2020] Bluetooth: hci0: BCM: features 0x07
[Tue Aug 18 01:25:33 2020] Bluetooth: hci0: BCM20702A
[Tue Aug 18 01:25:33 2020] Bluetooth: hci0: BCM20702A1 (001.002.014) build 0000
[Tue Aug 18 01:25:33 2020] bluetooth hci0: firmware: failed to load brcm/BCM20702A1-050d-065a.hcd (-2)
[Tue Aug 18 01:25:33 2020] bluetooth hci0: Direct firmware load for brcm/BCM20702A1-050d-065a.hcd failed with error -2
[Tue Aug 18 01:25:33 2020] Bluetooth: hci0: BCM: Patch brcm/BCM20702A1-050d-065a.hcd not found


To solve this, unplug/turn off your headset. REMOVE/FORGET the device  so that you can re-pair it.


Download the hcd file to ~/Downloads, then
me@niobium:/lib$ sudo mkdir /lib/firmware/brcm
me@niobium:/lib$ sudo cp ~/Downloads/BCM20702A1-050d-065a.hcd /lib/firmware/brcm/

Now try again. 
Output from dmesg -T:
[Tue Aug 18 01:33:59 2020] Bluetooth: hci0: BCM: chip id 63
[Tue Aug 18 01:33:59 2020] Bluetooth: hci0: BCM: features 0x07
[Tue Aug 18 01:33:59 2020] Bluetooth: hci0: BCM20702A
[Tue Aug 18 01:33:59 2020] Bluetooth: hci0: BCM20702A1 (001.002.014) build 0000
[Tue Aug 18 01:33:59 2020] bluetooth hci0: firmware: direct-loading firmware brcm/BCM20702A1-050d-065a.hcd
[Tue Aug 18 01:33:59 2020] Bluetooth: hci0: BCM20702A1 (001.002.014) build 1482
[Tue Aug 18 01:33:59 2020] Bluetooth: hci0: Broadcom Bluetooth Device


09 July 2020

661. Teaching during the pandemic, part 4: making simple video lectures

This post is a bit different from the previous ones -- it simply shows what I've been doing for some time to create supporting videos for my students.


I record my voice using Audacity, and I use KDENLive to make the videos. I make slides using google docs.

Once you've got used to this you can make a bunch of short videos (aim at 6 minutes or so) in a single day.

Here's my work flow:

1. Create a script for the audio. 
I basically write down everything I'm going to say before I've made my slides. I then make the slides to match the script.

I use gedit to write my script.

2. Create the slides to match the audio
I use google slides:


I export each slide as a png:
3. Record the audio in audacity
Use a good microphone! I'm using a Blue Yeti, which is great.

NOTE: each audio file should correspond to a single slide, or part of a slide. Not the other way around. It makes step 4 easier, and helps if you need to redo the audio for a section.

Export the audio in a suitable format (e.g. flac)
4. Fire up KDENLive

Import your clips.

Add your audio to the Audio channel

Then add the png files to the video channel. Stretch the duration of each image file to match the duration of the audio.


Once you're done, render the video:

That's all!


Now you can combine the teaching posts to create something that works for you. Here are the links again:
* Mobile phone lavalier mic: http://verahill.blogspot.com/2020/07/658-teaching-during-pandemic-part-1-how.html
* Recording (several) cameras and syncing: http://verahill.blogspot.com/2020/07/659-teaching-during-pandemic-part-2.html
* Dealing with audio: http://verahill.blogspot.com/2020/07/660-teaching-in-pandemic-part-3-what.html

660. Teaching in the pandemic, part 3: What I'll be doing to capture live lectures. Audio.

I've looked at a few different solutions, but I've basically settled on recording video and audio separately. The downside of this is that I won't stream. The advantage is that I can do post-processing to add clearer pictures of slides etc.

The video part is pretty straight forward. See e.g. http://verahill.blogspot.com/2020/07/659-teaching-during-pandemic-part-2.html

When it comes to audio I've explored a range of solutions:

* Bluetooth headset -- this would've allowed me to stream, but the sound quality is just too poor with bluetooth (I tried Blueparrot B350-XT). For an example of how bad it can be, check out this corporate(!) video:
Advantage: wireless, can stream, only covers one ear
Disadvantage: Sound quality

* 2.4 GHz Wireless headset -- I tested Logitech G930. The sound quality is OK, but it covers both ears, and makes it hard/ uncomfortable to deal with a live audience.
Advantage: sound quality, wireless, can stream
Disadvantage: shuts out the live audience

* 'Normal' microphones -- I have a number of microphones, including Blue Yeti. Many of them are wired (USB), and none of them will work in capturing a moving (i.e. mobile) lecturer.
Advantage: superior audio -- when very close, streaming
Disadvantage: poor audio unless you're right in front of the mic

* Mobile phone lavalier mic -- See here for how to do that: http://verahill.blogspot.com/2020/07/658-teaching-during-pandemic-part-1-how.html.
Advantage: great sound, mobile, can potentially stream
Disadvantage: drains phone battery, can be tricky to set up LAN, if using receiving device (laptop) as hotspot you may not be able to connect to the internet (i.e. can't stream)

My chosen solution:
* Using a portable audio recorder (e.g. dictaphone) --  I've got a Zoom H1n, and a lavalier microphone. I love this microphone. It's lightweight, portable, not too expensive, and the internal XY microphone is great (to my ears). The amplifier for external mics is a bit weak, but it works for my purposes, especially if you post-process in Audacity. But that leaves you having to sync your video and your audio in post. I've already showed you how easy it is to do that here: http://verahill.blogspot.com/2020/07/659-teaching-during-pandemic-part-2.html

Note that you need to invest in a decent lavalier microphone as well. Also note that most these days seem to come with a 3.5 mm TRRS connector (good for mobile phones), and the Zoom needs 3.5 mm TRS (the old standard). Many of the cheap/affordable lavalier mics that you find on e.g. Amazon come with TRS/TRRS adapters, so it's not much of an issue.

Advantage: potentially great sound, great battery life
Disadvantage: you can't stream live, needs a lavalier microphone

So there we are -- I'll set up a single webcam to record video directly to my laptop. I'll capture the sound using it as well, but mostly to help me sync the audio later. I'll record my voice using a dictaphone and a lavalier microphone, post-process the sound in Audacity, then import video and audio in KDENLive, where I'll sync everything. I can then add pictures of my slides as well, and don't have to worry about the image quality during recording.

659. Teaching during the pandemic, part 2: Recording with two cameras (on linux)

This is a very short post. What if you need to set up two (web)cameras that capture from e.g. different whiteboards?

I had a look at OBS studio, and it's not stable for me. Sometimes I get a cam image, and sometimes I don't. I also had issues with getting two cameras to work. I also looked at webcamoid and cheese. The frame rates were too bad.

What does work for me is guvcview. This is available in the debian repos.

I'll also show you how to sync the sound using KDENLive

1. Install guvcview
sudo apt-get install guvcview

2. Start guvcview.
Then go to video controls.

Select a new Device, then select New

Now you've got both feeds showing:
Then you can simply record:

I won't go into how to switch back and forth between angles in KDENLive. I'll just show you how to sync the videos using the audio:

Import both clips into KDENLive and put them in separate channels. Right-click on one of the tracks, and make it the audio reference:

Align the other clip:
They are now aligned:

Note that you could have done this with a pure audio track as well (we'll get to that in the next post).

You can then start cutting away bits you don't want using the x/scissors:

658. Teaching during the pandemic, part 1: How to use a mobile phone as a wireless lavalier microphone

This pandemic isn't going anywhere soon. We'll be using online/remote teaching or hybrid teaching models for at least the next two semesters up here, and it's time to figure out how to do it in a way that works for the students, as well as us lecturers, in spite of not actually getting any more time to prepare our classes than we would during a normal year.

This post is linux-centric, but the solution should be applicable to OSX and Win as well.

Using a mobile phone as a wireless lavalier microphone
While I've made proper videos in the past, I haven't tried recording 'live' lectures before. We've been asked to resume on-campus lectures this fall, but have also been told to make sure that we record everyhting so that students don't show up to class in spite of being sick.

I've moved away from using powerpoints to using the whiteboard for my lectures (I've surveyd my students -- 95% in class after class prefer chalk-and-talk).

Simply using a camera with a static microphone to record won't cut it -- it won't capture the sound properly, in particular not when you're up at the whiteboard. Also, audio-quality matters -- if you have to choose between good audio and good video, pick audio.

What do you need?
You need
* an android phone (similar solutions should be available for iOS)
* for the phone and your recording device (e.g. laptop or computer) to be online and able to connect to each-other (e.g. a LAN). You can use the laptop as a hotspot.
* the program LANMic installed on your phone
* OBS Studio to receive the stream from LANMic. There are other programs -- as long as they can receive rtsp streams, they are OK.


How-to

1. Install LANmic on your phone. Connect a lavalier/lapel mic to your phone. Install OBS Studio on your computer.

2. Both devices (phone and computer) need to be able to communicate with each other over the LAN.

If you have EduRoam, this might not be the case. In that case, use your computer to set up a wifi hotspot. See the end of this post for how to do that.

3. Start LANmic on your phone, select rtsp and start streaming. Note the address of your phone (here: rtsp://192.168.2.13:8080)
It'll look like this because nothing's connect to it:


4. Start OBS Studio and add your sources.

I've just made a quick example here. To add the phone, add Media Source, uncheck local file, and enter the address from the previous step.




If all goes well you'll see the meter for the moble mic moving.


Your phone will now look like this:


This isn't a perfect solution, but it works. Importantly, it will allow you to record everything on the fly/and or stream it and/or stream via zoom (have a look at https://obsproject.com/forum/resources/obs-virtualcam.539/).

In the next few posts I'll be exploring other solutions


Here's how to set up a wifi hotspot on debian:

Open Network:









Set up hotspot:




Then connect your phone to the new network. Note that this means that you won't have any network connectivity, unless you're also using a LAN cable.



29 November 2019

657. More on charges in nwchem and gaussian

A now ten-year old paper introduced the concept of Pauling bond-strength conserving terminations (PBS ) in the use of molecular codes for calculations involving extended crystalline systems ('Quantum-Chemical Calculations of Carbon-Isotope Fractionation in CO2(g), Aqueous Carbonate Species, and Carbonate Minerals' by James R. Rustad, Sierra L. Nelmes, Virgil E. Jackson, and David A. Dixon --  see link). The authors used NWChem for the calculations, most likely due to the affiliation between the lead author and PNNL, where NWChem is developed, and where the researchers have been banned from using Gaussian.

I use Gaussian almost exclusively these days, mainly due to how fast it is.

Unfortunately, Gaussian and NWChem behave quite differently when it comes to introduction of specified nuclear charges, so I here compare the two codes in terms of how to set up PBS calculations.

NWChem (6.8):
scratch_dir /scratch
Title "charge"

Start  charge

echo

charge 0

geometry noautosym noautoz units angstrom
 Mg     0.00000     0.00000     0.00000
 O     0.00000     2.09000     0.00000
 O     1.47785     2.22045e-16     1.47785
 O     -1.47785     -1.11022e-16     1.47785
 O     0.00000     -2.09000     0.00000
 O     -1.47785     2.22045e-16     -1.47785
 O     1.47785     -1.11022e-16     -1.47785
 H1     -0.691981     2.65500     -0.691981 charge 0.5 
 H1     0.691981     2.65500     0.691981 charge 0.5 
 H1     1.87737     0.978609     1.87737 charge 0.5 
 H1     1.87737     -0.978609     1.87737 charge 0.5 
 H     -1.18539     7.33956e-09     2.56935
 H     -2.56935     -7.33957e-09     1.18539
 H     -0.691981     -2.65500     0.691981
 H     0.691981     -2.65500     -0.691981
 H     -1.87737     -0.978609     -1.87737
 H     -1.87737     0.978609     -1.87737
 H     1.18539     -2.20187e-08     -2.56935
 H     2.56935     2.20187e-08     -1.18539
end

basis "ao basis" spherical print
  H library "def2-svp"
  Mg library "def2-svp"
  O library "def2-svp"
END

dft
  mult 1
  direct
  XC pbe0
  grid xfine
  mulliken
end

task dft energy   

This gives an energy of -655.860806066326.

Removing the charges for H1 and setting the total charge to +2 gives an energy of -657.044328628867

Gaussian (16.A01):
WRONG:
%nprocshared=6
%Mem=800000000
%Chk=charge.chk
#P GFINPUT rPBE1PBE/def2svp 5D  NoSymm  Punch=(MO) Pop=(full) 

charge

0 1 ! charge and multiplicity
 Mg     0.00000     0.00000     0.00000
 O     0.00000     2.09000     0.00000
 O     1.47785     2.22045e-16     1.47785
 O     -1.47785     -1.11022e-16     1.47785
 O     0.00000     -2.09000     0.00000
 O     -1.47785     2.22045e-16     -1.47785
 O     1.47785     -1.11022e-16     -1.47785
 H(znuc=0.5)     -0.691981     2.65500     -0.691981
 H(znuc=0.5)     0.691981     2.65500     0.691981
 H(znuc=0.5)     1.87737     0.978609     1.87737
 H(znuc=0.5)     1.87737     -0.978609     1.87737
 H     -1.18539     7.33956e-09     2.56935
 H     -2.56935     -7.33957e-09     1.18539
 H     -0.691981     -2.65500     0.691981
 H     0.691981     -2.65500     -0.691981
 H     -1.87737     -0.978609     -1.87737
 H     -1.87737     0.978609     -1.87737
 H     1.18539     -2.20187e-08     -2.56935
 H     2.56935     2.20187e-08     -1.18539

gives an energy of -655.679686484!

However,
2 1  ! charge and multiplicity
gives an energy of -655.860712881, which is what we want.

Removing the znuc specifications and using
2 1  ! charge and multiplicity
gives an energy of -657.044229333

Keeping the znuc specifications and defining those protons as fragment 2, and the rest of the cluster as fragment 1
 2 1 -2 1 4 1! charge and multiplicity
gives an energy of -655.860712881


Conclusion: 
both NWChem and Gaussian can be made to use PBS, but while you use the intended cluster charge (0) in NWChem, you need to use the unmodified charge (+2) in gaussian.

29 September 2019

656. Rant: On Academia and the English language

I used to think that (postgraduate) students didn't know how to write good manuscripts because they don't learn how to do so during their undergraduate education. I'm now even more cynical about it -- I believe that we actually actively teach them bad practices instead.

1. Honours students are particularly problematic, since they haven't yet had to write a thesis and are mainly exposed to scientific writing in the form of lab reports. Unfortunately, the way lab reports are written does not resemble any form of document that the students will produce in the career -- whether they go into industry or academia. So what's the point? Sure, they get to do a bit of thinking about the science behind the experiment in the process of writing -- and that's great -- but it does not teach them how to write up science.

2. The biggest problem is that students, regardless of level, are often told to write a certain number of words as part of their academic assignments --'write at least 800 words'. The idea is to make sure that they put in enough work, but the outcome is that you get papers with a lot of filler words and phrases.

I had a masters (by research) student write something along the lines of 
"'During the first week(s) of the course, a literature search will be conducted where appropriate sources are gathered'"
instead of
"Targets will be synthesised according to literature procedures"

It would be better to give students assignments where they are told what must be addressed in their essays, and then graded accordingly if they do a bad job of it. If they can complete the task in 400 words instead of 600, so be it.

I now tell my students to read Orwell's "Politics and the English language" in order to learn how to write, as it deals with this directly, and contains some great examples.

3. Postgraduate science writing courses are often geared towards teaching students to write popular science texts, and are often given by people outside their fields. Firstly, they are PhD students and first need to be able to write about science as experts before learning to write pop sci -- they WILL need to do the former, but are unlikely to need to do the latter. Secondly, (bad) pop sci writing often ends up being so devoid of actual information that it's impossible for someone in the field to figure out what it's about -- the way the Nobel prize in chemistry is presented in the newspapers is often so short on detail that it's impossible to know what the discovery is.

4.  Role models are hard to find. Few students think that the type of writing they see in social media works for science, but they might not realise that journalists are great sinners along the lines of point 2. Authors of fiction vary in quality, and I find it hard to read modern literature because of how self-indulgent many authors are.

I tell students at the beginning of their postgraduate course to have a look at some of the papers that they read when doing the initial literature search for their research, pick out one good and one bad example, and then try to work out WHY they felt that way.


30 October 2018

655. Linux for Edu -- creating lecture videos on linux

We're 'encouraged' to save money on teaching. The easiest (laziest?) way of doing this is to reduce teacher-led time. The ultimate time-saver (in terms of creation of content) is to simply record your lectures using screen-casting.

It's not a very good solution though.

From the point of the lecturer it is not very inspiring, recording 40 minutes of voice-over without mistakes in one take is hard, and updating the slides in the future is hard or impossible. Some solve the voice-over and update issue by using synthetic voices, but they are even more monotonous and uninspiring than most lecturers.

From the point of the student it can be hard to focus for 40 minutes, especially if all you're seeing is a series of slides with a droning voice over. There are other aspects that are bad too: you don't get to interact with the lecturer or your peers, and the lecture content/pace etc. can't be adjusted based on the dynamics of the class.

Some of these aspects can be solved or at least amended by using video editing software. The key is to not simply take a lecture and make a video, but to try to make the most of the medium, without having to become an expert at editing.

Key to making videos is to:
* make them short
...so that students don't need set aside a lot of time to watch them, and can maintain their concentration. It also helps you as a lecturer stay enthusiastic about the video project until it's finished. A long video will make you sick of it before you're done.

* cut everything up into small chunks
...so that you can replace slides and sections, and so you can (re-)record the narration is small chunks. This way you can do as many takes as you need to make sure that the voice over is punchy. No droning!

* to make them engaging
...so that it's fun to watch. This latter bit I haven't cracked. I have decided on a gimmick  though, where I put a countdown timer in the videos. I think/hope that it makes the student feel that the video is moving along quickly and feels 'dynamic'.

Received wisdom dictates that you should include a video of yourself lecturing. There's nothing precluding you from doing that in snippets too and using short Dissolve transitions between the video snippets.


Software:
One should use different tools for different purposes, so I use
* EasyScreenCast or OBSStudio for capturing the desktop if necessary
Make sure to record as webm. Note: You need to transcode the VP8 webm files using the following command or they may show up as black when you render the video in kdenlive:
avconv -i in.webm -c:v libvpx -c:a vorbis -quality best -f webm out.webm

* Audacity for recording audio

* Cheese for recording videos of myself

* Synfig for making simple animation

* kdenlive for video editing

So, here's a quick overview of how to make a simple video using static slides (no screen casting):

1. I made slides in google slides, and then exported each one as a PNG file

2. I recorded the narration using audacity. One recording for each slide. Cut and export.

3. I put it together in kdenlive 
Just drag the length of the slide images to match the lengths of the narration. I also put in a countdown timer as video 2, and overlayed it with the 'composite and transform' transition. I could easily have done the same with a video/videos of myself recorded in cheese.

Either way, the point is that it's very easy to do this.


I also tried to make a simple animation in synfig, but it didn't really pan out. Might be a post in the future -- the students are struggling with visualising 3D objects like orbitals and molecules, and creating animations might help here.


26 October 2018

654. Screen-casting on linux (debian 9)

Minipost:
I'm interested in making course videos where I show my desktop (I might have a full-screen presentation going), but where I also want to show my face.

I'm using debian.

Solution:
To screen-cast the desktop I'm using EasyScreenCast, which is a Gnome Extension: https://extensions.gnome.org/extension/690/easyscreencast/

Not much to say about it really, other than that it works very well.

To get my face on the desktop I use guvcview, which is in the repos.

To make guvcview stay on top even during a full-screen presentation I followed this: https://www.linuxquestions.org/questions/linux-general-1/how-to-make-guvcview-stay-always-on-top-4175541777/

My son's orca lecturing on the importance of experiments in formulating new theories
kdenlive seems like an interesting editor for post-production, but I haven't got that far yet.

20 August 2018

653. Energy decomposition analysis the manual/multiwfn way -- nwchem

I have a very large system (390 atoms, 3918 functions, 6474 primitives) where I want to analyse the bonding. Whereas I can reduce the size of the system a little bit, there's a large conjugated ad charged system in the middle which I can't really reduce. Either way, when I use GAMESS US to do NEDA, the calc seems to hang for days without ever progressing, and LMOEDA/CMOEDA keep running out of memory.

I recently had a look at Multiwfn, and section 4.100.8 in the manual shows how to do simple EDA as a multistep computation. The example uses multiwfn to input initial fragment wavefunctions to compute the DE_orb with Gaussian. Incidentally, this is something which is very easy to do with nwchem without using multiwfn.

I'll use NH3..BH3 as the example at RHF/6-31G*.


Nwchem:

1. Optimise NH3..BH3
scratch_dir /home/me/scratch Title "NH3BH3-nw" Start NH3BH3-nw charge 0 geometry noautosym noautoz units angstrom N 0.0720500 -0.00961700 -0.336156 H 0.871540 0.292859 -0.862886 H -0.685935 0.618297 -0.534511 H -0.187686 -0.922713 -0.663436 B 0.415920 -0.0366410 1.31774 H 0.709693 1.10584 1.58004 H -0.612009 -0.411733 1.83072 H 1.33214 -0.818018 1.41958 end basis "ao basis" cartesian print B library "6-31G*" H library "6-31G*" N library "6-31G*" END scf RHF nopen 0 end task scf optimize
Energy=-82.61181818

2. Run SE calcs on the BH3 and NH3 fragments:
scratch_dir /home/me/scratch Title "BH3-nw" Start BH3-nw charge 0 geometry noautosym noautoz units angstrom B 0.192902 -0.0151808 0.928551 H 0.486935 1.12724 1.19093 H -0.834959 -0.390362 1.44154 H 1.10930 -0.796437 1.03042 end basis "ao basis" cartesian print B library "6-31G*" H library "6-31G*" END scf RHF nopen 0 vectors output bh3.movecs end task scf energy
Energy=-26.368337779376
and
scratch_dir /home/me/scratch Title "NH3-nw" Start NH3-nw charge 0 geometry noautosym noautoz units angstrom N -0.150737 0.0117141 -0.725185 H 0.648571 0.314333 -1.25225 H -0.908696 0.639770 -0.923690 H -0.410582 -0.901249 -1.05260 end basis "ao basis" cartesian print N library "6-31G*" H library "6-31G*" END scf RHF nopen 0 vectors output nh3.movecs end task scf energy
Energy=-56.184296916045

3. Finally, use the two movecs created in step 2:
scratch_dir /home/andy/scratch Title "NH3BH3-nw" Start NH3BH3-nw charge 0 geometry noautosym noautoz units angstrom N 0.0720500 -0.00961700 -0.336156 H 0.871540 0.292859 -0.862886 H -0.685935 0.618297 -0.534511 H -0.187686 -0.922713 -0.663436 B 0.415920 -0.0366410 1.31774 H 0.709693 1.10584 1.58004 H -0.612009 -0.411733 1.83072 H 1.33214 -0.818018 1.41958 end basis "ao basis" cartesian print B library "6-31G*" H library "6-31G*" N library "6-31G*" END scf RHF nopen 0 vectors fragment nh3.movecs bh3.movecs output nh3bh3.movecs end task scf
4. Parse the output from step 4:
iter energy gnorm gmax time ----- ------------------- --------- --------- -------- 1 -82.5357150919 7.36D-01 2.88D-01 0.1 2 -82.6078664771 2.30D-01 5.23D-02 0.1 3 -82.6117699706 2.03D-02 7.47D-03 0.1 4 -82.6118181287 2.23D-04 5.79D-05 0.1 5 -82.6118181326 2.51D-06 7.28D-07 0.1 Final RHF results ------------------ Total SCF energy = -82.611818132574 One-electron energy = -190.292457149391 Two-electron energy = 67.248334359392 Nuclear repulsion energy = 40.432304657425 Time for solution = 0.1s
So, according to the Multiwfn Manual at 4.100.8, using the values from above:
DEtot=-82.61181818-(-26.368337779376-56.184296916045)= -37 kcal/mol (-155 kJ/mol)
DEorb=-82.611818132574-(-82.5357150919)= -48 kcal/mol (-200 kJ/mol)
DEsteric=DEtot-DEorb= 11 kcal/mol (45 kJ/mol)

This is essentially the Kitaura-Morokuma method.

See e.g. Frenking et al.in Energy Decomposition Analysis on page 44. Eq 2 defines Eint in the same way DEtot is defined above, and Eq 7 is the same Eorb as here.

DEstruc here is then DEelstat + DEPauli.

How to resolve these two factors from one another, is a problem for another day.
You can also run the calcs using a single input file:
scratch_dir /home/me/scratch Title "NH3BH3-nw-eda" Start NH3BH3-nw-eda echo charge 0 geometry molecule noautosym noautoz units angstrom N -0.150737 0.0117141 -0.725185 H 0.648571 0.314333 -1.25225 H -0.908696 0.639770 -0.923690 H -0.410582 -0.901249 -1.05260 B 0.192902 -0.0151808 0.928551 H 0.486935 1.12724 1.19093 H -0.834959 -0.390362 1.44154 H 1.10930 -0.796437 1.03042 end geometry ammonia noautosym noautoz units angstrom N -0.150737 0.0117141 -0.725185 H 0.648571 0.314333 -1.25225 H -0.908696 0.639770 -0.923690 H -0.410582 -0.901249 -1.05260 end geometry borohydride noautosym noautoz units angstrom B 0.192902 -0.0151808 0.928551 H 0.486935 1.12724 1.19093 H -0.834959 -0.390362 1.44154 H 1.10930 -0.796437 1.03042 end basis "ao basis" cartesian print N library "6-31G*" B library "6-31G*" H library "6-31G*" END set geometry ammonia scf vectors output ammonia.movecs end task scf set geometry borohydride scf vectors output borohydride.movecs end task scf set geometry molecule scf vectors input fragment ammonia.movecs borohydride.movecs output molecule.movecs end task scf