## 08 December 2011

### I'm a doctor, not a grad student

Well, all the hard work and perseverance has finally paid off. I have passed my thesis defense, and I don't have any revisions to my thesis! Those so inclined may download my dissertation for fun and enrichment.

## 20 November 2011

### Living up to all the hyphe

Today I dreamt of paired, hyphenated words.

• hoity-toity
• arsy-versy
• topsy-turvy

And the bonus word:

• hubble-bubble

I will never utter the mundane word 'hookah' again. Why prefer a common, understandable word when a ludicrous, fanciful one is available?

## 19 November 2011

### Color spacing out

On certain pages---and only certain pages---of my LaTeX-written dissertation, sub-pixel anti-aliasing was strangely unavailable. On these pages, where I'd embedded PDFs created in Illustrator, the print quality would also suffer. And this behavior only appeared in documents generated on one computer, which has pdftex-1.40.12; not my other, which has pdftex-1.40.11. Moving the PDF file from one computer to the other preserved the behavior of that PDF.

After a little hunting, I determined the problem to occur only when Illustrator saved its PDFs in a CMYK color space, which were then embedded in the newer pdftex-generated document. Telling Illustrator to use an RGB color space for that document fixed the problem.

The things you learn as a nuclear engineer.

## 19 October 2011

Google voice transcription of background noise when someone accidentally pocket dialed me:

Hey hey, how sorry bye. Hey, Just okay bye bye bye. Ciao. Thank you. Hello How, yeah Okay bye. Ohh okay, bye. But quo, okay bye bye, okay bye okay Kirk, bye. Cook please bye hey. Hello Hello. Hello. I think. Bye still talk, cost the commercial. Okay bye. Dick, call and Mark, dot, com hey, book. Hey check. Thanks, hey, spoke out bye drop left bye bye, back okay okay bye bye. Hey. Okay bye. Okay, bye Park City. Hey, hey. Hey, bye hey hey you, bye hey pitch. That's perfect book, good okay. I'll talk to you. If you are. I love you bye bye. What's up are you back bro. Hello, hey hello.

Clearly, Google expects a large fraction of phone messages to consist of "hey," "hello," "bye."

## 12 October 2011

### Captions

The Rackham dissertation requirements state that "at least" the first sentence of all figure captions must appear in the "List of figures" at the beginning of the thesis. I follow the stylistic convention of having a brief description of the figure as the first sentence, and a sometimes lengthy elaboration afterward. It is unwieldy to have a paragraph of explanatory text appear in the index at the beginning, so I've been using the \caption[as it appears in index]{as it appears on the page} feature of LaTeX captions to have only the first sentence show in the index. To prevent the duplication of text, and to comply with the requirement that the first sentence must exactly match, I wrote the following simple but very useful LaTeX macro:

\newcommand{\Caption}[2]{\caption[#1]{#1#2}}


Now, I can write my caption as \Caption{Cross-sections in my test problem.}{Light regions have $\sigma=1$.} without having to manually duplicate the first sentence.

## 27 September 2011

### Trilinos GCC Warnings patch

If anyone else is as tired as I am of spurious warnings when compiling Epetra, Teuchos, and Belos modules in Trilinos with -Wall -Wextra, I have created a patchfile that corrects the deficient code.

## 21 September 2011

### Fully integrated LaTeX in Macvim

I've been less than pleased with TeXShop on Lion. I do most of my editing in Vim using Vim-LaTeX, but I compile with TeXShop. Most importantly, I sometimes use SyncTeX to jump between my compiled document and source.

To switch away from TeXShop, I want both an integrated compiler and an external editor with SyncTeX. Skim with this configuration fit the bill. Yet Vim-LaTeX won't play nicely with my dissertation, which uses a file for each chapter and the TeXShop convention of

% !TEX root = ../thesis.tex


to denote the true TeX file. The solution involves this feature of Vim-LaTeX, and the following function I wrote:

" Look for main file by looking in the first 20 lines, same as TeXShop, for:
" % !TEX root = [filename].tex
" Author: Seth R. Johnson
let g:Tex_MainFileExpression = 'SRJMainFile(modifier)'

function! SRJMainFile(fmod)
let s:Tex_Match = '\v^\s*\%\s+!TEX\s+root\s+\=\s+\zs(.*\.tex)\ze\s*$' let s:lnum = 1 while s:lnum < 20 let s:basefile = matchstr( getline(s:lnum), s:Tex_Match) if !empty(s:basefile) break endif let s:lnum += 1 endwhile if !empty(s:basefile) let s:origdir = fnameescape(getcwd()) let s:newdir = fnameescape(expand('%:p:h')) exec 'cd'.s:newdir let s:basefile = fnamemodify(s:basefile, a:fmod) exec 'cd'.s:origdir else let s:basefile = expand('%'.a:fmod) endif return s:basefile endfunction " Command-R will write, open for viewing, compile, go to the end of the quickfix, hide the " preview, switch back to main window map <D-r> :w<cr><leader>lv<leader>llG<C-w>p:q<cr> imap <D-r> <ESC><D-r> " Inverse search nnoremap <D-S-LeftMouse> <leader>ls  Now typing \ll in my individual chapter files will compile the true thesis. Typing \lv will open the thesis in Skim, \ls will jump from the TeX source to the corresponding output line, and command-shift-clicking in Skim will cause MacVim to jump to the appropriate source line. Command-R is a shortcut to compile and view. UPDATE 2011/9/25: I've uploaded my vim scripts to GitHub. UPDATE 2011/9/27: Modify the "reverse lookup" in Skim to be --remote-silent +":silent %line" "%file" to avoid the obnoxious Press ENTER to continue prompt in Vim. ## 15 September 2011 ### Making a "lite" git repository I've had my research in a git repository for more than a year and a half. Because most of my computational experiments are small (i.e., single processor rather than supercluster), I've stored a number of results in the repository rather than in a separate directory. Well, 18 months and many obsolete and regenerated results later, my repository is rather bloated. Preferring to only modify my thesis, figures, and related files on my new MacBook Air, I chose to create a new "thesis" repository. To preserve the history of modifications I'd already performed, git filter-branch is the way to go. (Stack Overflow was helpful in finding out the details.) The only sticking point was in getting the large HDF5 files to be removed in garbage collection (git gc): removing .git/refs/original and expiring the reflog. #!/bin/bash git clone --no-hardlinks /Users/seth/_research thesis cd thesis git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch \ research_* _testproblems* _python* meeting_notes* *.h5 *.silo \ .gitignore .gitxattr_json anisotropic_ss ideas_include technotes" \ --prune-empty -- --all git remote rm origin rm -rf .git/refs/original/ git reflog expire --expire=0 --all git gc --prune=now  Anyhow, I now have a nice, clean, 20MB repository suitable for putting on an ultraportable and for later uploading to GitHub/elsewhere to serve mankind. ## 14 September 2011 ### Vim and TeX keywords After updating my vim installation, my command set iskeyword+=: in ~/.vim/after/ftplugin/tex.vim stopped functioning. (This was recommended by the Vim-LaTeX project.) My auto-completion for chapter references chap:intro and equations eq:blahBlah was broken because the colon was no longer interpreted as a command character. To make a long story short, I found the :verbose set isk command which told me the last file to set iskeyword: /Applications/MacVim.app/Contents/Resources/vim/runtime/syntax/tex.vim  Somehow, that syntax file is hard-wired to reset iskeyword. The solution is to add the following line or equivalent: let g:tex_isk='48-57,a-z,A-Z,192-255,:'  ## 07 June 2011 ### LaTeX ANS transaction update Those who are in the nuclear engineering business might be interested to know that I've updated the LaTeX class for ANS transaction summaries. It is now more compliant with the ANS-specified guidelines, and it uses a much better version of the Times math font. ## 05 June 2011 ### Ah, Python Another reason to write regression tests for C++ code in Python: integration with matplotlib. Here, I test my sampling algorithms with a Q-Q plot: Yes, this at one point saved me from an implementation snafu. ## 03 May 2011 ### Irony A hidden timing method (which I don't even use) in one of Trilinos' solvers ends up incurring an O(n) performance penalty, where n is the number of instantiations of the solver. By the end of my simulations this actually dominates my wall time. ## 30 April 2011 ### Silo now available on MacPorts Scientific computing developers rejoice. If you want your code to output files readable by LLNL's VisIT, there's a good chance you use the Silo library to do it. Well, if you use MacPorts, you can now download and compile silo without hassle on a Mac. I submitted a port file for Silo this morning, and the great volunteers at MacPorts had it cleaned up and in their repository by the end of the day. Now all you need to do is sudo port selfupdate && sudo port install silo, and you're good to go. ## 23 April 2011 ### Research code is now open sourced Well, after talking with a group of nuclear engineers who are interested in open sourcing their codes, and after being persuaded by my friend Mike that it was justifiable to return some of my tools to the taxpayers who've sponsored my education, I have decided to open up my research code. The project is called PyTRT, and it's available at GitHub under a Simplified BSD license. Documentation for PyTRT is available, but it is probably overwhelming. We'll see if this ever amounts to anything. ## 18 April 2011 ### Guest post: save on batteries with the Apple external track pad Apple Magic Trackpad: Run It For "Free" and Do the Environment, and Your Wallet, a Favor. Most of my AA powered toys and appliances demand a battery change before they are truly depleted. I can measure that there is residual charge and I can't bear to toss them in the trash so they just accumulate in my closet (not a good idea). Behold the Apple Magic Trackpad. It will use the old batteries down to their last Joule-drop and I can dispose of them with a clear conscience. New batteries, equivalent to what Apple includes, last me about eight weeks. Before they quit I get a battery warning and two weeks later they totally die. Nicely, one can go to the System Preferences>Trackpad and at the bottom left and read "Trackpad battery level" in percent. (If the trackpad batteries are completely dead you won't see this as there is no signal that the Trackpad even exists.) Once the batteries are dead replace them with used batteries and note the starting level. I have had previously used batteries read as high as 95% potency. These used batteries won't last as long as new ones but it is not a chore to keep them handy and replace them a bit more often. A few sensible words of caution. Use only two of the same kind of batteries (don't mix lithium and alkaline). Check them to make sure they are not swollen, misshapen or leaking (leaking chemicals can be poisonous or corrosive and will mess up your battery compartment). If possible use two old batteries from the same source, starting off at the same charge is better. Don't put them in backwards. A good way to remember is the flat side is negative and goes up against the battery door which has slot in it that looks remarkably like a "negative" sign (another intuitive apple UI). I keep one of the dimes I saved to open the battery compartment. Oh, and don't over tighten it, just a slight snug will do. Finally, if you ruin your nice Trackpad, it is not my fault. I haven't saved so many dimes that I can send you and your attorney on a South Sea vacation. —Doug Johnson ## 04 April 2011 ### Red hell and death and taxes Well, I broke down and spent the morning investigating my tax situation, which was rather confused at the end of last year. After some burrowing, I found that TurboTax was surprisingly right after all. Scholarships and fellowships that are reported on Form 1098-T rather than Form W-2 count neither for "earned income credit" (on Schedule M) nor for IRA purposes. As regards Schedule M, which covered 2009's "Making Work Pay" credit, the "Earned Income Worksheet" line 4a specifically subtracts scholarship income: so people who rely solely on fellowships for their income are not eligible for earned income credits. Finding out eligibility for Roth IRAs took considerably more digging, because on some portions of the 1040A instruction sheet, it says that scholarships count as "earned income." If you look at Publication 590, it says under "What is compensation?" that "Scholarship and fellowship payments are compensation for IRA purposes only if shown in box 1 of Form W-2." You can only contribute to an IRA if you have a non-zero "compensation." So there you have it. This is not official tax advice, but you should look at the linked forms and draw the same conclusions that both TurboTax and I did. I'm glad the situation is clearer now, though of course I wish our tax system weren't such a mess. ## 15 March 2011 ### Commenting multiple photos in iPhoto ’11 When the App Store for Mac came out, I was excited at the chance to buy iPhoto without paying for the other apps that I didn't need. My excitement quickly turned to remorse as I encountered bug after bug after bug. Additionally, iPhoto removed useful functionality like the ability to use command shortcuts to switch between photos in "View" mode: in iPhoto it is now impossible to add comments to a number of photos in succession without a lot of mousing around. I wrote an Applescript to partially overcome this limitation. It takes the selection and gives a dialog box for commenting each one. If the selection is contiguous it will properly display the photos in full screen mode as you comment them. (* Quickly comment the selected photos in iPhoto '11, viewing them in full screen if the selection is contiguous. Authored by Seth R Johnson, licensed under Simplified BSD. *) tell application "iPhoto" activate -- this works best with contiguous photos set sel_photos to selection if number of sel_photos is 0 or (class of item 1 of sel_photos is not photo) then error "Please make sure photos are selected." end if -- press the space bar to make the photos full screen tell application "System Events" to keystroke " " repeat with this_photo in sel_photos tell this_photo set c to comment of this_photo display dialog "Enter the comment for photo '" & (title of this_photo) & "':" default answer c buttons {"Cancel", "Apply"} default button 2 set new_comment to text returned of result if c is not new_comment then set the comment of this_photo to new_comment end if end tell -- Press the right arrow key to advance to the next photos in the album tell application "System Events" to keystroke (ASCII character 29) end repeat end tell ## 02 March 2011 ### Sharing research code The more I work on my research code, PyTRT (a research code with several dozen transport methods—diffusion, Monte Carlo, P1, SN, IMC, etc.—implemented in 1D and 2D), the more I'm convinced this could be a useful tool to many people in methods development. I'm forced to ask myself what I should do with it after I graduate. It's entirely likely that I will continue to use it in my next career, but should I release it to the public, or to my department, or to whom? Should I try to sell it? It was developed using funds from an NSF GRF, which "encourages Fellows to share software and inventions, once appropriate protection for them has been secured, and otherwise act to make the innovations they embody widely useful and usable," and from an NEUP fellowship, under which the "DOE claims no rights to any inventions or writings that might result from its fellowship awards." That seems to leave me all the flexibility I need. Does anyone have an opinion to offer? ## 23 February 2011 ### Particle tracking bugs Tracking Monte Carlo particles (or in this case, ray traces) through a geometry can be tricky because of the subtlety of edge cases. Today I discovered that my tracking routine failed when given a direction of −0.0 . I never imagined that the existence of signed zeroes in IEEE floating point arithmetic could ever bite me. ## 21 February 2011 ### Starting Terminal.app with multiple tabs in multiple directories Almost every time I open up Terminal, I've wanted three tabs open with three particular directories. That means using Cmd-Tab a lot and tab completion to change the directory. I finally got fed up with that and invented a solution to take care of that automatically. The first step is creating a "Window group" in the terminal. Go to the menu item "Windows < Save Windows as Group…", make up a name, and make sure "use this group at startup" is checked. The second step is to edit your ~/.bash_profile and add something like this, where each "if" statement gets a different command. This is adaptable to changing the base directory, sshing, etc. # change PWD to python by default function change_default_directory() { TTYN=$(tty | sed -e 's/.*ttys$$[0-9]*$$/\1/')
if [[ $TTYN == 000 ]]; then cd ~/_code/pytrt/ elif [[$TTYN == 001  ]]; then
cd ~/_code/_build/pytrt/
elif [[ $TTYN == 002 ]]; then cd ~/_code/_build/pytrtDEBUG/ elif [[$TTYN == 003  ]]; then
cd ~/_research/current/
fi
}

if [ -n "\$PS1" ]; then
change_default_directory;
fi

Add more elif blocks if you open five windows, take away more if you open fewer. Enjoy!

## 12 February 2011

### Reflecting on the hard work I've put into my research code

I am still proud of my code to get the angle in a quadrature set reflected across an axis. It's a little crazy.

const AngleT& getReflectedAngle(const AngleT& a, unsigned int axis ) const {
return angles_[ (a.getOctantIndex() ^ (1 + ( axis << 1)) + 1) * numAnglesPerOctant_ - 1 - a.getSubIndex() ];
}