Thursday, November 24, 2011

OpenFOAM and FEniCS Fedora Install Notes

Notes on installing OpenFOAM and FEniCS from source on Fedora 14.

Both projects implement ideas similar to A Livermore Physics Applications Language (NALPAL, why ALPAL): take high-level descriptions of partial differential equations and automatically generate code to solve them with numerical approximations based on finite-volume (OpenFOAM) or finite-element (FEniCS) methods.

Steps for OpenFOAM

  1. Install Fedora packages for paraview, cmake, flex, qt, zlib.
    [root@deeds foo]$ yum -y install paraview cmake flex qt-devel libXt-devel zlib-devel zlib-static scotch scotch-devel openmpi openmpi-devel
    You probably already have gnuplot and readline installed, if not, install those too.
  2. Unpack the OpenFOAM tarball:
    [jstults@deeds OpenFOAM]$ tar -zxvf OpenFOAM-2.0.1.gtgz
  3. Add the environment variable definitions to the bashrc file
    source $HOME/OpenFOAM/OpenFOAM-2.0.1/etc/bashrc
    [jstults@deeds OpenFOAM]$ source ~/.bashrc
  4. Run the OpenFOAM-X.y.z/bin/foamSystemCheck script, you should get something that says, "System check: PASS", "Continue OpenFOAM installation."
  5. Go to the top-level directory, since you defined the proper environment variables that is something like
    [jstults@deeds OpenFOAM]$ cd $WM_PROJECT_DIR
  6. Make it
    [jstults@deeds OpenFOAM-X.y.z]$ ./Allwmake
  7. Various Consequences ensue...

Steps for FEniCS

Required components: Python packages FFC, FIAT, Instant, Viper and UFL, and Python/C++ packages Dolfin and UFC

  1. Install things packaged for Fedora
    [root@deeds FEniCS]$ yum -y install python-ferari python-instant python-fiat
  2. Download the other components from launchpad, and install using
    [jstults@deeds FEniCS]$ python install --prefix=~/FEniCS
    for the Python packages, and
    [jstults@deeds FEniCS]$ cmake -DCMAKE_INSTALL_PREFIX=$HOME/FEniCS ./src
    [jstults@deeds FEniCS]$ make
    [jstults@deeds FEniCS]$ make install
    for the C++/Python packages (DOLFIN and UFC).

OR, do it automatically if you have root and internet access (I still haven't got this to work: a bit of buffoonery on my part, problems finding boost libraries).

  1. Download Dorsal
  2. Run the script
    [jstults@deeds FEniCS]$ ./
  3. Execute the yum command in the output from the script in another terminal.
    [root@deeds FEniCS]$ yum install -y redhat-lsb bzr bzrtools subversion \ libxml2-devel gcc gcc-c++ openmpi-devel openmpi numpy swig wget \ boost-devel vtk-python atlas-devel suitesparse-devel blas-devel \ lapack-devel cln-devel ginac-devel python-devel cmake \ ScientificPython mpfr-devel armadillo-devel gmp-devel CGAL-devel \ cppunit-devel flex bison valgrind-devel
    I also installed the boost-openmpi-devel and boost-mpich2-devel packages as well. MPI on Fedora is kind of a mess. I added these two lines to my bashrc:
    module unload mpich2-i386
    module load openmpi-i386
  4. When the packages are installed, go back to the terminal running and hit ENTER.

I ended up downloading the development version of dorsal to get the latest third-party software built, because it's so easy:
[jstults@deeds dorsal]$ bzr branch lp:dorsal
Pretty darn slick, Yea for distributed version control systems! Boo for dependency hell!

FEniCS is currently under heavy development towards a 1.0 release, so I expect to be able to build it on Fedora 14 Real Soon Now ; - )

Update: Johannes and friends got me straightened out.

Thursday, November 17, 2011

Qu8k Accelerometer Data

There was a pretty cool amateur rocket shot recently that was an attempt to win the Carmack micro-prize. The rocket is called Qu8k, designed and built by Derek Deville and friends. One of the stipulations of the prize is collection of a GPS location by the onboard avionics at an altitude above 100kft (as long as the velocity is low, this should theoretically not require an unrestricted GPS).

Of course, since the other stipulation of the prize is a detailed report about the shot and the data collected, this gives us number crunching nerds a neat data set to play with. Derek posted a spreadsheet of the accelerometer data, along with a simple first order integration (twice) to get velocity and altitude. I tried an FFT-based method to compare against the first order approach in the spread-sheet, and a second-order trapezoidal rule integration. The python script to do the integration and make the two plots below is on github.

The errors in the numerical integration are not terrible (the plots of the trajectories using the different approaches are indistinguishable in the eye-ball norm).

One of the cool things about Python is the array masking capability. That makes implementing the temperature ratio component of the 1976 US Standard atmosphere (to estimate Mach number) 7 lines of code.