CFD Calculations on Raspberry Pi: A Comprehensive Guide

I love finding project inspiration anywhere. While many ideas are fleeting, generally lasting no more than a day or two, there are always some ideas that linger in my mind and eventually materialize into interesting projects. Let me introduce one of those ideas: Performing CFD calculations on my handheld device.

Back in October, I got the inspiration for this CFD project after using an Arduino Uno in a project. (Translator’s note: a model of microcontroller) I can tell you that it is only the size of a credit card. This made me wonder if it was possible to perform CFD calculations on a microcomputer the size of the Uno. I had considered using a phone, but the difficulty of compiling open-source CFD software like OpenFOAM on iOS or Android intimidated me.

So, why not try using a Raspberry Pi?

CFD Calculations on Raspberry Pi: A Comprehensive Guide

The $35 Raspberry Pi, the size of a credit card.

The Raspberry Pi, developed by the Raspberry Pi Foundation, is a microcomputer the size of a credit card, running on a Linux-based system. It sold 100,000 units on the first day of its launch in spring 2012! The goal of the Raspberry Pi is to provide an affordable computer for education, teaching kids about how computers work and programming principles. However, enthusiasts found that this tiny development board could actually run 1080P videos and interface with numerous sensors and other devices. Now, two years after its release, over 2.5 million units of the Raspberry Pi have been sold.

In early February, Momentum Analysis released a message that their OpenFOAM cavity flow case successfully ran on two Raspberry Pis!

CFD Calculations on Raspberry Pi: A Comprehensive Guide

Momentum Analysis used a cluster made up of two Raspberry Pis.

The team at Momentum Analysis used a compiled version of OpenFOAM provided by Rheologic. They ultimately compiled a binary version for the Raspberry Pi, so I no longer needed to compile it myself. I could just buy a Raspberry Pi and get started right away!

A few days later, Momentum Analysis wrote a great blog post about how to build what they called a computing cluster of two pies. In the article, they discussed how to set up the Raspberry Pi, how to obtain the binary files edited from OpenFOAM, and even described some tests they conducted.

Alright. It’s time for me to run CFD on my own Raspberry Pi.

By the way, shortly after Momentum Analysis published their blog post, I saw an article about people in the Dallas/Fort Worth area building a 40-pi cluster. The results were incredible…

CFD calculations on the Raspberry Pi

Before I purchased the Raspberry Pi, I did a lot of research. My experience is that when a development board costs around $35, the accessories can stack up. Of course, you’ll need a charger, cables, and a keyboard. After looking around, I figured out what I needed and where to buy it. I chose ModMyPi. ModMyPi started just making cases for the Raspberry Pi, but quickly began selling a range of accessories. Although they are not affiliated with the Raspberry Pi Foundation, they donate 5% of their profits to the foundation.

I didn’t buy the full kit from ModMyPi, just some necessary accessories. If you’re interested in conducting the same experiment, here’s a list of everything I purchased from ModMyPi. Note that prices have gone up slightly since I bought these items.

  • Raspberry Pi – B Series

  • 16GB Samsung Micro SD card pre-installed with NOOBS (Class 10 UHS-I)

  • Cyntech’s Raspberry Pi development board with SD card slot

  • HDMI conversion cable 2m 1.4V (gold-plated)

  • Raspberry Pi cooling kit

The B series Raspberry Pi comes with 512MB of RAM, while the A model only has 256MB. This is important for compiling software and running CFD calculations. I chose to spend a little more on a high-performance SD card pre-installed with NOOBS. The NOOBS (New Out of Box Software) package allows for easy installation of many supported Linux distributions, including the official Raspbian distribution based on Debian.

The heat sinks are interesting. I hope to be able to overclock the 700Mhz processor to 1Ghz without significantly shortening the lifespan of the Raspberry Pi. While the heat sinks may not dissipate that much heat, they look cool.

CFD Calculations on Raspberry Pi: A Comprehensive Guide

Three small heat sinks integrated on the development board.

OpenFOAM on the Raspberry Pi

Last week I received everything, so I only had a few days to do some preliminary research. The first thing I did was configure my Raspberry Pi to run OpenFOAM, following the blog post from Momentum Analysis. After making the necessary updates and settings, I downloaded OpenFOAM and ran the cavity case in less than an hour. I was able to run OpenFOAM on the Raspberry Pi.

I could actually run CFD simulations on a handheld device!

CFD Calculations on Raspberry Pi: A Comprehensive Guide

CFD calculations on a handheld device.

A few days later, I decided to test the mesh generated by Pointwise using the Raspberry Pi version of OpenFOAM. I conducted a steady-state RANS calculation on the NACA 0012 angle of attack, and the results converged in five minutes. I was overjoyed! Not only could I run CFD on the Raspberry Pi, but I could also test our mesh on it.

SU2 for the Raspberry Pi

I achieved my goal. I performed CFD calculations on a handheld device. However, I was just repeating someone else’s work. The team at Momentum Analysis had already done this. And they did it with parallel computing. What could I do differently? Could I use a different solver? Why not try SU2.

A few years ago, a group from Stanford University’s Aerospace Design Lab released an open-source CFD solver. The Stanford University Unstructured software suite, abbreviated SU2, is a C++ toolkit for solving partial differential equations. The team released version 3.0 of the code this January.

In the past few weeks, I have been exploring some internal research using SU2 for CFD, so I am somewhat familiar with the code and can compile it reliably. So, I decided to download the SU2 source code and attempt to compile it on the Raspberry Pi. My new goal was to package the SU2 binaries for the Raspberry Pi and run the NACA 0012 case. However, that’s easier said than done.

CFD Calculations on Raspberry Pi: A Comprehensive Guide

Velocity field of NACA 0012, computed from the Raspberry Pi.

I didn’t want to do anything fancy; I just wanted to achieve a simple single-threaded compiled version. I followed the installation guide provided by the SU2 developers, configured the makefile using only the prefix parameter, and then used the make command to compile the source code. After about 30 minutes of compilation, the Raspberry Pi threw an ambiguous error message. Soon after, all applications crashed, and the GUI became unresponsive. Unfortunately, the Raspberry Pi is not equipped with a power switch, so I had to unplug it to turn it off. So far, that’s all I’ve done with SU2 on the Raspberry Pi.

I reconnected the power and restarted the Raspberry Pi, receiving a kernel error message…

Power off, power on, kernel error…

Power off, power on. No response. Now the Raspberry Pi won’t boot anymore…

I pulled the circuit board from the case and tested the voltage on the two contact points on the board. No voltage. This indicated that the fuse had blown, and it would take a few minutes to reset. Long story short, using the fsck suite, this process repeated six times…

The issue was either the SD card or the power supply. I suspected that the current from devices like the motherboard, Ethernet cable, HDMI cable, SD card, and USB keyboard exceeded the capacity of the ASUS Nexus 7 charger. This, in turn, pulled the voltage down below 4.75V, causing voltage instability. Therefore, I replaced the previous power supply with a 5V 2.1A iPad 3 charger and have not encountered any stability issues since.

Another potential issue was limited memory. I monitored memory usage during compilation and observed that memory exceeded the 152MB limit. As a result, I disabled the GUI using the raspi-config tool, minimizing the memory access for the GPU. Then, I assigned a static IP to the Raspberry Pi on my home network and enabled SSH access. No longer needing an HDMI cable and USB dongle, this not only solved the memory issue but also reduced stability issues.

Every time I tried something new, I would attempt to compile again, getting further from success each time. I estimated that the entire compilation would take about three hours to complete. Once the compilation was finished, I ran make install and then archived and compressed the results.

I first ensured that SU2_CFD could operate by using the examples that came with SU2. Sure enough, the steady-state Euler calculation for the NACA 0012 converged in three minutes.

I now have a Raspberry Pi version of SU2!

CFD Calculation Pi!

This is a fantastic project. While I appreciate the work done by Momentum Analysis and Rheologic, I am even more grateful that I did not stop at the pre-compiled OpenFOAM they provided. This project exposed some issues that the Raspberry Pi electronics encountered while compiling OpenFOAM, resolved error messages, and taught me how to compile and run CFD software on a handheld device.

If you are interested in this project and plan to purchase your own Raspberry Pi, here are some lessons I summarized.

1. Choose a good power supply.

I emphasize this point. While the Raspberry Pi circuit board does not require that much power, external devices increase the power demand. The Raspberry Pi itself requires a 5V 1A power supply. Most phone chargers will allow it to work normally, but in my experience, some may not work. I recommend using a stable power supply, preferably 5.25V and 2A, to accommodate any slight voltage drops and connect more peripherals.

2. Provide a static IP address for the Raspberry Pi and enable SSH.

If you plan to do any type of development or CFD calculations, abandon the GUI and enable SSH on the Raspberry Pi. Simply having the router assign a static IP to the Raspberry Pi is not enough; you must also edit the network interfaces file. Below is a nice video describing how to provide a static IP address for your Pi.

At the same time, you need to manually enable SSH, as SSH is turned off by default. This can be done through the Raspberry Pi software configuration tool, raspi-config.

3. Expand the file system and adjust CPU/GPU memory allocation ratios.

If you installed the Raspberry Pi using the NOOBS package, the file system will automatically occupy the entire SD card. However, if you installed the operating system in another way, you will need to manually expand the file system to utilize all available memory on the SD card. You can also use the raspi-config tool to do this. You may also want to provide the GPU with the minimum amount of memory. This can be done using the same tool.

4. Overclock.

Finally, overclocking. The Raspberry Pi does not generate much heat and does not consume much energy. Efficiency can be improved through overclocking. The default frequency of the Raspberry Pi is 700Mhz. I overclocked the CPU to 1GHz, increasing performance by 50%. This is where the heat sinks come in handy.

Alright, do you want to try some CFD on the Raspberry Pi?

CFD Chinese Network | CFD Community | CFD Encyclopedia

This article is sourced from the internet. You can read the original text by clicking here.

Leave a Comment

×