My 2D Hydrodynamic GPU code is over an order of magnitude faster than CPU codes (its source is available on GitHub). It is wasteful if I do not apply it to study some (astro-) physical problems. It turns out that, by introducing a simple -term, the [...]]]>

My 2D Hydrodynamic GPU code is over an order of magnitude faster than CPU codes (its source is available on GitHub). It is wasteful if I do not apply it to study some (astro-) physical problems. It turns out that, by introducing a simple -term, the modified vorticity equation

can take into account Coriolis force. The above equation is now a local (and, of course, two-dimensional) representation of the atmosphere on planets. This so called -plane approximation is used to study zonal jets of Jupiter’s atmosphere.

So I started playing around with the new equation. It will take me a while to find out what are the important questions to address. Nevertheless, the following movie shows a subdomain of a two-dimensional, incompressible hydrodynamic *test-run* in the -plane. The color, just like my previous movies, represents vorticity.

I would like to thank PDC for providing the Zorn cluster, which makes the development possible. The Zorn cluster is named after a painter Anders Zorn because it has GPUs. The code is now available for download on GitHub.

]]>LaTeX generates `*.aux`

files for labels and citations. For each citation, I want to get the corresponding BibTeX entry from ADS. This turns out to be a relatively easy job. I employ the ADS “bibkey” such as `2009ApJ...701..521C`

in my LaTeX manuscripts. After LaTeX-ing, I can simply run the following script to generate my BibTeX file:

#!/usr/bin/perl $aux = ($#ARGV >= 0) ? "$ARGV[0]" : "ms"; $bib = ($#ARGV >= 1) ? "$ARGV[1]" : $aux; open AUX, "< $aux.aux"; while() { if ($_ =~ m/\\citation\{/i) { foreach (split(',', substr($_, 10, -2))) { push @code, $_ if $_ =~ m/(\d{4}\D\S{13}[A-Z.:])/i; } } } close AUX; $server = 'adsabs.harvard.edu'; $script = 'cgi-bin/nph-bib_query'; $opt{data_type} = 'BIBTEX'; $opt{db_key} = 'ALL'; $opt{nocookieset} = '1'; $url = "http://$server/$script?"; $url .= "$_=$opt{$_}&" foreach keys %opt; $url .= "bibcode="; $url .= "$_&" foreach @code; use LWP::Simple; $all = get $url; die "ERROR: Couldn't get bibTeX data\n" unless defined $all; @line = split('\n', $all); open BIB, "> $bib.bib"; $head = '% '; foreach (@line) { $_ =~ s/\ \&/\ \\and/g; print BIB "$head$_\n"; $head = '' if $_ =~ m/^Retrieved/; } close BIB;

To use it for your own research, simply download the code from GitHub,

$ curl -O https://raw.githubusercontent.com/chanchikwan/adsbib/master/adsbib $ chmod 755 adsbib

Suppose your LaTeX document is called `ms.tex`

, this is how you use it:

$ ls -lh -rwxr-xr-x 1 ckchan staff 864B Apr 26 2010 adsbib -rw-r--r-- 1 ckchan staff 53K Oct 22 17:21 ms.tex $ latex ms; ls ms.aux ms.dvi ms.log ms.tex # no BibTeX bibliography file $ ./adsbib ms; ls ms.aux ms.bib ms.dvi ms.log ms.tex # BibTeX file is created $ bibtex ms $ latex ms

That’s it. Enjoy and happy paper writing!

]]>While there are many great existing tutorial online (e.g., from the Pro Git book, official git website, GitHub, Bitbucket, to Roger Dudler), my slides touch features that are mot useful for scientists working in a group. Please feel [...]]]>
`git`

tutorial:

While there are many great existing tutorial online (e.g., from the Pro Git book, official `git`

website, GitHub, Bitbucket, to Roger Dudler), my slides touch features that are mot useful for scientists working in a group. Please feel free to take a look. Comments are welcome.

In my most recent paper, *The Power of Imaging: Constraining the Plasma Properties of GRMHD Simulations using EHT Observations of Sgr A**, submitted to ApJ on October 9, 2014 and accepted without revisions on November 1, 2014, I demonstrate how an application of cutting edge imaging technologies can push the frontiers of science, literally, to the center of our galaxy (currently occupied by the 4 million solar mass black hole named Sgr A*).

The paper, which is featured in a press release on November 5, 2014, show-cased GRay, an open source, ultra-fast GPU-based, massive parallel general relativistic ray tracing algorithm written in CUDA, capable of calculating images over 100 times faster than traditional algorithms, and its application to the preliminary images collected from the Event Horizon Telescope.

]]>We introduce GRay, a massively parallel integrator designed to trace the trajectories of billions of photons in a curved spacetime. This GPU-based integrator employs the stream processing paradigm, is implemented [...]]]>
*GRay: a Massively Parallel GPU-Based Code for Ray Tracing in Relativistic Spacetimes*” on arXiv. Here is the abstract:

We introduce GRay, a massively parallel integrator designed to trace the trajectories of billions of photons in a curved spacetime. This GPU-based integrator employs the stream processing paradigm, is implemented in CUDA C/C++, and runs on nVidia graphics cards. The peak performance of GRay using single precision floating-point arithmetic on a single GPU exceeds 300 GFLOP (or 1 nanosecond per photon per time step). For a realistic problem, where the peak performance cannot be reached, GRay is two orders of magnitude faster than existing CPU-based ray tracing codes. This performance enhancement allows more effective searches of large parameter spaces when comparing theoretical predictions of images, spectra, and lightcurves from the vicinities of compact objects to observations. GRay can also perform on-the-fly ray tracing within general relativistic magnetohydrodynamic algorithms that simulate accretion flows around compact objects. Making use of this algorithm, we calculate the properties of the shadows of Kerr black holes and the photon rings that surround them. We also provide accurate fitting formulae of their dependencies on black hole spin and observer inclination, which can be used to interpret upcoming observations of the black holes at the center of the Milky Way, as well as M87, with the Event Horizon Telescope.

The paper is submitted to ApJ. Hopefully it will be accepted soon!

]]>2 eggs will break if you drop them above a particular height H. You are asked to find out H to its closet integer multiple of 1ft. It is known that 1ft <= [...]]]>

2 eggs will break if you drop them above a particular height H. You are asked to find out H to its closet integer multiple of 1ft. It is known that 1ft <= H <= 100ft; and there is a 100ft stairway that you can climb up to drop your eggs.

What is the fewest number of drops it would take to find the “breaking height” H?

I will put the solution in the comment at some point.

]]>We examine the generation of hydromagnetic stresses and energy density in the boundary layer around a weakly magnetized star in the shearing-sheet approximation. This region, where the angular frequency is expected to increases [...]]]>
*On Hydromagnetic Stresses in Weakly Magnetized Stellar Boundary Layers*” on arXiv. Here is the abstract:

We examine the generation of hydromagnetic stresses and energy density in the boundary layer around a weakly magnetized star in the shearing-sheet approximation. This region, where the angular frequency is expected to increases with radius, is stable against the magnetorotational instability. We provide analytic solutions for the long-term evolution of shearing MHD waves, which exhibit non-trivial dynamics. Even though their associated stresses oscillate around zero, their energy density can be amplified significantly. This is consistent with the findings of numerical simulations of MHD boundary layers and suggest that their detailed structure could differ appreciably from those derived within the standard framework of turbulent viscosity.

The paper is also submitted to ApJ. Hopefully it will be accepted soon!

]]>