Tag Archives: computational fluid dynamics

Simulating the Hadley Cell using Energy2D

Download the models
Although it is mostly used as an engineering tool, our Energy2D software can also be used to create simple Earth science simulations. This blog post shows some interesting results about the Hadley Cell.

The Hadley Cell is an atmospheric circulation that transports energy and moisture from the equator to higher latitudes in the northern and southern hemispheres. This circulation is intimately related to the trade winds, hurricanes, and the jet streams.

As a simple way to simulate zones of ocean that have different temperatures due to differences in solar heating, I added an array of constant-temperature objects at the bottom of the simulation window. The temperature gradually decreases from 30 °C in the middle to 15 °C at the edges. A rectangle, set to be at a constant temperature of -20 °C, is used to mimic the high, chilly part of the atmosphere. The viscosity of air is deliberately set to much higher than reality to suppress the wild fluctuations for a somehow averaged effect. The results show a stable flow pattern that looks like a cross section of the Hadley Cell, as is shown in the first image of this post.

When I increased the buoyant force of the air, an oscillatory pattern was produced. The system swings between two states shown in the second and third images, indicating a periodic reinforcement of hot rising air from the adjacent areas to the center (which is supposed to represent the equator).

Of course, I can't guarantee that the results produced by Energy2D are what happen in nature. Geophysical modeling is an extremely complicated business with numerous factors that are not considered in this simple model. Yet, Energy2D shows something interesting: the fluctuations of wind speeds seem to suggest that, even without considering the seasonal changes, this nonlinear model already exhibits some kind of periodicity. We know that it is all kinds of periodicity in Mother Nature that help to sustain life on the Earth.

Simulating geometric thermal bridges using Energy2D

Fig. 1: IR image of a wall junction (inside) by Stefan Mayer
One of the mysterious things that causes people to scratch their heads when they see an infrared picture of a room is that the junctions such as edges and corners formed by two exterior walls (or floors and roofs) often appear to be colder in the winter than other parts of the walls, as is shown in Figure 1. This is, I hear you saying, caused by an air gap between two walls. But not that simple! While a leaking gap can certainly do it, the effect is there even without a gap. Better insulation only makes the junctions less cold.

Fig. 2: An Energy2D simulation of thermal bridge corners.
A typical explanation of this phenomenon is that, because the exterior surface of a junction (where the heat is lost to the outside) is greater than its interior surface (where the heat is gained from the inside), the junction ends up losing thermal energy in the winter more quickly than a straight part of the walls, causing it to be colder. The temperature difference is immediately revealed by a very sensitive IR camera. Such a junction is commonly called a geometric thermal bridge, which is different from material thermal bridge that is caused by the presence of a more conductive piece in a building assembly such as a steel stud in a wall or a concrete floor of a balcony.

Fig. 3: IR image of a wall junction (outside) by Stefan Mayer
But the actual heat transfer process is much more complicated and confusing. While a wall junction does create a difference in the surface areas of the interior and exterior of the wall, it also forms a thicker area through which the heat must flow through (the area is thicker because it is in a diagonal direction). The increased thickness should impede the heat flow, right?

Fig. 4: An Energy2D simulation of a L-shaped wall.
Unclear about the outcome of these competing factors, I made some Energy2D simulations to see if they can help me. Figure 2 shows the first one that uses a block of object remaining at 20 °C to mimic a warm room and the surrounding environment of 0 °C, with a four-side wall in-between. Temperature sensors are placed at corners, as well as the middle point of a wall. The results show that the corners are indeed colder than other parts of the walls in a stable state. (Note that this simulation only involves heat diffusion, but adding radiation heat transfer should yield similar results.)

What about more complex shapes like an L-shaped wall that has both convex and concave junctions? Figure 3 shows the IR image of such a wall junction, taken from the outside of a house. In this image, interestingly enough, the convex edge appears to be colder, but the concave edge appears to be warmer!

The Energy2D simulation (Figure 4) shows a similar pattern like the IR image (Figure 3). The simulation results show that the temperature sensor placed near the concave edge outside the L-shape room does register a higher temperature than other sensors.

Now, the interesting question is, does the room lose more energy through a concave junction or a convex one? If we look at the IR image of the interior taken inside the house (Figure 1), we would probably say that the convex junction loses more energy. But if we look at the IR image of the exterior taken outside the house (Figure 3), we would probably say that the concave junction loses more energy.

Which statement is correct? I will leave that to you. You can download the Energy2D simulations from this link, play with them, and see if they help you figure out the answer. These simulations also include simulations of the reverse cases in which heat flows from the outside into the room (the summer condition).

Complete undo/redo support in Energy2D

In Version 2.3 of Energy2D, I have added full support of undo/redo for most actions. With this feature, you can undo all the way back to your starting point and redo all the way forward to your latest state. This is not only a must-have feature for a design tool with a reasonable degree of complexity, but also a simple -- yet powerful -- mechanism for reliably collecting very fine-grained data for understanding how a user interacts with the software.

Why are we interested in collecting these action data?

From the perspective of software engineering, these action data provide first-hand information for quality assurance (QA). QA engineers can analyze these data to measure the usability of the software, to identify behavior patterns of users, and to track results from version to version to gauge if an adjustment has led to better user experience.

From the perspective of education and training, these action data encode users' cognitive processes. Any interaction with the software, especially with a piece of highly visual and responsive software like Energy2D, is automatically a process of cognition. A fundamental thesis in learning science is to understand how we can design interactive materials that maximize learning for all students. These precious fine-grained action data may hold an important key to that understanding.

This idea of using the stack of actions stored in the undo manager of a piece of software to record and replay the entire process of interaction is a unique feature that has been implemented in our Energy2D and Energy3D software and proven a non-obtrusive, high-fidelity, and low-bandwidth technique for data collection.

Energy2D video tutorials in English and Spanish

Many users asked if there is any good tutorial of Energy2D. I apologize for the lack of a User Manual and other tutorial materials (I am just too busy to set aside time for writing up some good documentations).

So Carmen Trudell, an architect who currently teaches at the School of Architecture of the University of Virginia, decided to make a video tutorial of Energy2D for her students. It turned out to be an excellent overview of what the software is capable of doing in terms of illustrating some basic concepts related to heat transfer in architectural engineering. She also kindly granted permission for us to publish her video on Energy2D's website so that other users can benefit from her work.

If you happen to come from the Spanish-speaking part of the world, there is also a Spanish video tutorial made by Gabriel Concha based on an earlier version of Energy2D.

Energy2D recommended in computational fluid dynamics textbook

Computational fluid dynamics (CFD) is an important research method that uses numerical algorithms to solve and analyze problems that involve fluid flows. Computers are used to perform the calculations required to simulate the interaction of liquids and gases with surfaces defined by boundary conditions. Today, almost every branch of engineering rely on CFD simulations for conceptual design and product design.

A recent textbook "Computational Fluid Dynamics, Second Edition: A Practical Approach" by Profs. Jiyuan Tu, Guan Heng Yeoh, and Chaoqun Liu has recommended Energy2D as "Shareware CFD" for beginners. Here is a quote from their excellent book:
"Nevertheless, first-time CFD users may wish to search the Internet to gain immediate access to an interactive CFD code. (Users may be required to register in order to freely access the interactive CFD code.) The website is http://energy.concord.org/energy2d/index.html provides simple CFD flow problems for first time users to solve and allows colorful graphic representation of the computed results."

Happy New Year from Energy2D

In the year 2014, Energy2Dhas incorporated a radiation simulation engine and a particle simulation engine, expanding its modeling capacity and making it a truly multiphysics simulation package. To celebrate the New Year, I made some simulations that demonstrate these multiphysics features using objects shaped after the numbers of 2015.

These simulations feature the fluid dynamics engine, the heat conduction engine, the thermal radiation engine, and the particle dynamics engine. If you are curious enough, you can click this link to run the simulations.

These shapes were drawn using Energy2D's polygon and ring tools, which allow users to create a wide variety of arbitrary 2D shapes. Many users probably do not know how versatile the polygon tool actually is (the original triangle icon on the tool bar probably misleads some to think it is only good for drawing triangles -- so I changed it to look like a cross-section of an I-beam). The polygon tool allows one to easily draw a polygon with maximally 256 control points for adjusting its shape later. One can draw an approximate shape and then drag these control points to get it to the exact shape. To modify a shape even further, one can also insert a control point by double-clicking on an existing point. A new point will be added to the adjacent position, which you can then drag around. To delete a control point, just hold down the SHIFT key while double-clicking on it. In addition, a polygon can be rotated, twisted, compressed, or elongated using the corresponding fields in its property window (there is currently no graphical user interface for doing those things, however).

As for the New Year's resolutions, in 2015, the ring shape will be enhanced into a new tool called the shape subtractor, which allows users to subtract a shape from another to make a hollow one.

On the numerical simulation side, we will continue to improve the accuracy of the existing simulation engines by adding an explicit solver as an option for users to overcome some of the problems related to the implicit solvers.

On the multiphysics modeling side, we will try to support multiple fluids, which seems simple at first glance but has turned out to be a very difficult mathematical problem. With the capacity of multiple fluids, we will also be able to add an electromagnetism solver in order to model effects such as electrorheological fluids (fluids whose viscosity changes with respect to an applied electric field).

We wish all Energy2D users a very successful new year!

The deception of unconditionally stable solvers

Unconditionally stable solvers for time-dependent ordinary or partial differential equations are desirable in game development because they are highly resilient to player actions -- they never "blow up." In the entertainment industry, unconditionally stable solvers for creating visual fluid effects (e.g., flow, smoke, or fire) in games and movies were popularized by Jos Stam's 1999 paper "Stable Fluids."

Figure 1: Heat conduction between two objects.
The reason that a solver explodes is because the error generated in a numerical procedure gets amplified in iteration and grows exponentially. This occurs especially when the differential equation is stiff. A stiff equation often contains one or more terms that change very rapidly in space or time. For example, a sudden change of temperature between two touching objects (Figure 1) creates what is known as a singularity in mathematics (a jump discontinuity, to be more specific). Even if the system described by the equation has many other terms that do not behave like this, one such term is enough to crash the whole solver if it is linked to other terms directly or indirectly. To avoid this breakdown, a very small time step must be used, which often makes the simulation look too slow to be useful for games.

The above problem typically occurs in what is known as the explicit method in the family of the finite-difference methods (FDMs) commonly used to solve time-dependent differential equations. There is a magic bullet for solving this problem. This method is known as the implicit method. The secret is that it introduces numerical diffusion, an unphysical mechanism that causes the errors to dissipate before they grow uncontrollably. Many unconditionally stable solvers use the implicit method, allowing the user to use a much larger time step to speed up the simulation.

There ain't no such thing as a free lunch, however. It turns out that we cannot have the advantages of both speed and accuracy at the same time (efficiency and quality are often at odd in reality, as we have all learned from life experiences). Worse, we may even be deceived by the stability of an unconditionally stable solver without questioning the validity of the predicted results. If the error does not drive the solver nuts and the visual looks fine, the result must be good, right?

Figure 2: Predicted final temperature vs. time step.
Not really.

The default FDM solver in Energy2D for simulating thermal conduction uses the implicit method as well. As a result, it never blows up no matter how large the time step is. While this provides good user experiences, you must be cautious if you are using it in serious engineering work that requires not only numerical stability but also numerical reliability (in games we normally do not care about accuracy as long as the visual looks entertaining, but engineering is a precision science). In the following, I will explain the problems using very simple simulations:

1. Inaccurate prediction of steady states

Figure 3. Much longer equilibration with a large time step.
Figure 1 shows a simulation in which two objects at different temperatures come into contact and thermal energy flows from the high-temperature object into the low-temperature one. The two objects have different heat capacities (another jump discontinuity other than the difference in initial temperatures). As expected, the simulation shows that the two objects approach the same temperature, as illustrated by the convergence of the two temperature curves in the graph. If you increase the time step, this overall equilibration behavior does not change. Everything seems good at this point. But if you look at the final temperature after the system reaches the steady state, you will find that there are some deviations from the exact result, as illustrated in Figure 2, when the time step is larger than 0.1 second. The deviation stabilizes at about 24°C -- 4°C higher than the exact result.
Figure 4. Accurate behavior at a small time step.

2. Inaccurate equilibration time

The inaccuracy at large time steps is not limited to steady states. Figure 3 shows that the time it takes the system to reach the steady state is more than 10 times (about 1.5 hours as opposed to roughly 0.1 hours -- if you read the labels of the horizontal time axis of the graph) if we use a time step of 5 seconds as opposed to 0.05 second. The deceiving part of this is that the simulation appears to run equally quickly in both cases, which may fool your eyes until you look at the numerical outputs in the graphs.

3. Incorrect transient behaviors

Figure 5. Incorrect behavior at a very large time step.
With a more complex system, the transient behaviors can be affected more significantly when a large time step is used. Figure 4 shows a case in which the thermal conduction through two materials of different thermal conductivities (wood vs. metal) are compared, with a small time step (1 second). Figure 5 shows that when a time step of 1,000 seconds is used, the wood turns out to be initially more conductive than metal, which, of course, is not correct. If the previous example with two touching objects suggests that the simulation result can be quantitatively inaccurate at large time steps, this example means that the results can also be qualitatively incorrect in some cases (which is worse).

The general advice is to always choose a few smaller time steps to check if your results would change significantly. You can use a large time step to set up and test your model rapidly. But you should run your model at smaller time steps to validate your results.

The purpose of this article is to inform you that there are certain issues with Energy2D simulations that you must be aware if you are using it for engineering purposes. If these issues are taken care of, Energy2D can be highly accurate for conduction simulations, as illustrated by this example that demonstrates the conservation of energy of an isolated conductive system.

Energy2D and Quantum Workbench featured in Springer books

Two recently published Springer books have featured our visual simulation software, indicating perhaps that their broader impacts beyond their originally intended audiences (earlier I have blogged about the publication of the first scientific paper that used Energy2D to simulate geological problems).

A German book "Faszinierende Physik" (Fantastic Physics) includes a series of screenshots from a 2D quantum tunneling simulation from our Quantum Workbench software that shows how wave functions split when they smash into a barrier. The lead author of the book said in the email to us that he found the images generated by the Quantum Workbench "particularly beautiful."

Another book "Simulation and Learning: A Model-Centered Approach" chose our Energy2D software as a showcase that demonstrates how powerful scientific simulations can convey complex science and engineering ideas.

Quantum Workbench and Energy2D are based on solving extremely complex partial differential equations that govern the quantum world and the macroscopic world, respectively. Despite the complexity in the math and computation, both software present intuitive visualizations and support real-time interactions so that anyone can mess around with them and discover rich scientific phenomena on the computer.

European scientists use Energy2D to simulate submarine eruptions

The November issue of the Remote Sensing of Environment published a research article "Magma emission rates from shallow submarine eruptions using airborne thermal imaging" by a team of Spanish scientists in collaboration with Italian and American scientists. The researchers used airborne infrared cameras to monitor the 2011–2012 submarine volcanic eruption at El Hierro, Canary Islands and used our Energy2D software to calculate the heat flux distribution from the sea floor to the sea surface. The two figures in the blog post are from their paper.

According to their paper, "volcanoes are widely spread out over the seabed of our planet, being concentrated mainly along mid-ocean ridges. Due to the depths where this volcanic activity occurs, monitoring submarine volcanic eruptions is a very difficult task." The use of thermal imaging in this research, unfortunately, can only detect temperature distribution on the sea surface. Energy2D simulations turn out to be a complementary tool for understanding the vertical body flow.

Their research was supported by the European Union and assisted by the Spanish Air Force.

Although Energy2D started out as an educational program, we are very pleased to witness that its power has grown to the point that even scientists find it useful in conducting serious scientific research. We are totally thrilled by the publication of the first scientific paper that documents the validity of Energy2D as a research tool and appreciate the efforts of the European scientists in adopting this piece of software in their work.

Using particle feeders in Energy2D for advection simulations

Fig. 1: Particle advection behind two obstacles.
Advection is a transport mechanism in which a substance is carried by the flow of a fluid. An example is the transport of sand in a river or pollen in the air. Advection is different from diffusion, whereas the more commonly known term, convection, is the combination of advection and diffusion.

Our Energy2D can simulate advection as it integrates particle dynamics in the Lagrangian frame and fluid dynamics in the Eulerian frame. Particles in Energy2D do not spontaneously diffuse -- they are driven by gravity or fluid, though we can introduce Brownian particles in the future by incorporating the Langevin Equation into Energy2D.

Fig. 2: Blowing away particles.
Over this weekend, I added a new object, the particle feeder, for creating continuous particle flow in the presence of open mass boundary. A particle feeder can emit a specified type of particle at a specified frequency. All these settings can be adjusted in its property window, which can be opened by right-clicking on it and selecting the relevant menu.

Figure 1 shows a comparison of particle advection behind a turbulent flow and a streamlined flow. Have you ever seen these kinds of patterns in rivers?

Figure 2 shows how particles of different densities separate when you blow them with a fan. There are six particle feeders at the top that continually drop particles. A fan is placed not far below the feeders.

With these new additions to Energy2D, we hope to be able to simulate more complex atmospheric phenomena (such as pollutant transport through jet streams) in the future.