Perspective Projection

July 4th, 2012

GSnap is finally able to use perspective projection rather than orthographic projection when rendering images of the gas component. I’ll likely make perspective projection an option for all types of views in the future since it is such a computationally inexpensive operation (it just requires one addition, one division, and two multiplications for each particle).

Here’s an example of the difference between orthographic projection and perspective projection. First, the boring old orthographic projection, which gives no sense of relative distance (click for larger images)…

Orthographic projection
With perspective projection, foreground objects (z < 0) appear larger while the background objects (z > 0) appear smaller. Objects located near z=0 are only slightly effected by the transformation operation… Read the rest of this entry »

Depth of Field

June 30th, 2012

I have implemented a simple “depth of field” effect in GSnap’s volume rendering class in order to draw attention to a region of interest in the center of the volume. This will be a bit more useful once part of the volume rendering scheme has been re-written. It will be most useful when rendering frames for an animation. The images below show snapshots rendered with and without the depth of field effect turned on. Click for larger versions.
 
The galaxy in the background is blurred when the depth of field effect is turned on. A foreground object would have also been blurred.

GSnap’s New CLI & Parameter File Reader

June 13th, 2012

Within the past week, I have completely redesigned GSnap’s command line interface to allow more flexibility. I also added a configuration file reader which allows certain settings to be stored in a configuration file. The previous command interface was implemented one option at a time as I developed the code. It used a very inelegant collection of “if else if” statements, the commands needed to be entered in a very specific order, and there was no way of easily combining several flags. In other words, the interface wasn’t very useful and the code was a mess. I could have used the GNU GetOpt (the C++ equivalent of GNU getopt) to improve the interface, but I ended up writing my own command line parser that outwardly functions in the same way as getopt. I did this partially because I wanted to have the experience of writing such a parser and partially because I wanted to comply with two of my self-imposed guidelines:
  • GSnap should be maximally platform-independent.
  • Additional libraries (beyond the Qt Framework and standard C++ library) should be used only when they
    • greatly contribute to the functionality or performance of the code and
    • cannot be easily implemented in a few hours of coding.
Among other things, the new interface allows me to create interpolated snapshots of arbitrary combinations of particle types from arbitrary directions.  Here’s an example of a particularly complicated command that the new interface can interpret:

gsnap -It 101110 –frames 2 –theta 0.55 –phi 0.1 –beg snapshot_510 –end snapshot_511 -c 10 0 0 –out snap_510

Translation:

-I specifies that we want gnsap to output interpolated images (rather than interpolated snapshots)

-t  101110 specifies that particle types 0, 2, 3, and 4 will be included in the images.
 
–frames 2 specifies that two intermediate interpolated images will be created.

–theta 0.55 –phi 0.1 indicate the viewing direction in spherical coordinates.

–beg  snapshot_510 and –end snapshot_511 indicate that the two end-point snapshots that will be used in the interpolation are snapshot_510 and snapshot_511, where snapshot_510 is to be interpreted as the earlier of the two snapshots.

–out snap_510 specifies that the base name of the interpolated images is snap_510. The two output images will be named  snap_510.1.png and snap_510.2.png.

-c 10 0 0 indicates that the frame should be centered on x = 10 kpc, and y = z = 0 kpc before being rotated and viewed from the theta, phi direction.

Except for the flags that require an input value, these command line arguments can be entered in any order. For instance, this is an equivalent, valid command:

gsnap –out snap_510 -t 101110 -Ic 10 0 0 –phi 0.1 –end snapshot_511 –frames 2 –theta 0.55 –beg snapshot_510 

The new interface, combined with a Python script, will allow GSnap to create video frames that include rotation and zoom while the simulation evolves with time.

Installing CUDA in Ubuntu

June 2nd, 2012

I wanted to try the Thrust CUDA library, so I decided to upgrade my CUDA installation to the most recent version. The procedure was a little less straightforward than I had expected.  I had two problems:

1)  Version 4.2 of the CUDA compiler is incompatible with versions of GCC newer than 4.6.  I mostly use GCC 4.8 (beta) on my machine, but I also have an older version installed. I specified the older version of gcc and g++ in the Makefile, but that didn’t fix the problem. In order to compile CUDA code successfully, I ultimately had to create links to the older gcc and g++ executables in /usr/local/cuda/bin/.

2)  Some of the example programs in the CUDA SDK  failed to link due to an error:

         /usr/bin/ld: cannot find -lcuda

Ultimately, the solution was to create links to libcuda.so and libcuda.so.1 in the /usr/lib/ directory:

    sudo ln -s /usr/lib/nvidia-current/libcuda.so /usr/lib/libcuda.so
    sudo ln -s /usr/lib/nvidia-current/libcuda.so.1 /usr/lib/libcuda.so.1

More info: The files, libcuda.*, are shared objects (dynamically linked libraries) provided by the NVIDIA driver.  Even though /usr/lib/nvidia-current/ was in the linker’s library path, $LD_LIBRARY_PATH, the linker reported an error.

Notes on getting Qt and CUDA to work together: cudaspace.wordpress.com/2011/04/07/qt-creator-cuda-linux/ and the update cudaspace.wordpress.com/2012/07/05/qt-creator-cuda-linux-review/

Resolution Comparison

June 1st, 2012

Before running a high resolution simulation on the supercomputer, I first perform test simulations at a much lower resolution to verify that the merger will take place in a reasonable amount of time. Running the low resolution simulations also allows me to be more selective; I can select the most interesting cases to run at  high resolution. In this post, I’ll very briefly show how the low resolution simulations compare with their high resolution counterparts.  Even though the low resolution simulations contain only 1/50th as many particles, the general appearance is remarkably similar to the high resolution version.

Below are images of the low resolution and high resolution simulation at equivalent times from the same viewing direction:

 It appears that the outer ~95% of the galaxies are essentially the same. One can imagine that “stacking” 50 low resolutions would yield results very similar to the high resolution simulations in the outer regions of the system. The nuclear regions, however, are considerably different.

Particles vs. Volume Rendering

May 20th, 2012

My first high resolution galaxy simulation is currently running on the supercomputer. Here’s a visualization of the gas in a recent snapshot. First, I show the individual SPH particles, then I show the smoothed volume rendering using GSnap’s current volume rendering scheme.

 

10 million particles

May 18th, 2012

Here’s a video of the current version of GSnap manipulating a freshly created GADGET-2 snapshot containing slightly more than 10 million particles. With my current computing resources, it appears that I won’t be able to run full merger simulations with this many particles, but it’s nice to see that GSnap can easily handle snapshots of this size. This video also demonstrates some of the GUI improvements mentioned in the previous post. 

View with 720p HD quality for best results.

GSnap is Usable

April 15th, 2012

The GSnap GUI workflow is now much more streamlined. Clicking on any point in the preview window now shifts the selected point to the center of the frame and rotates the snapshot so that the current viewing direction becomes the new z-axis. A context menu and keyboard shortcuts have been added to the preview window as well.  A particularly useful shortcut allows the user to compute $$\sigma_*$$ for stars appearing in the slit by simply pressing “s” while the preview window is active.  There is little need to switch back and forth between the main window and the preview window.

GSnap now has a simple logo. It will eventually have its own web page and a built-in help browser / user manual. At this point, I need to work on other aspects of my research project. Before I begin the other work though, I thought it would be good to summarize GSnap’s current capabilities. 



GSnap can:
Read the rest of this entry »

GSnap GUI Improvements

April 13th, 2012

Here’s a video demonstrating new features of the GSnap GUI.  It’s clear that the work flow could be streamlined quite a bit.

Set the quality to HD for best viewing results.




Volume Rendering 2.0

April 6th, 2012

I made some improvements to the volume rendering scheme today.  Here are the snapshots from the previous post, rendered using the improved code:


And here’s a video animation of the test simulation: Read the rest of this entry »