X-Space re-entry plasma (part 3)

I’ve heavily optimized the plasma mesh, and have added post-processing. Right now post-processing is a simple blur, which already makes the picture nice through.

The face structure now stores indexes of triangles which are boundary to the current face – during rendering it only draws those edges of the plasma mesh which are not shared by two triangles exposed to airflow.

In simpler words, it only draws those triangles which do not intersect/coincide with other triangles of the mesh:

With the shader applied the end result looks like this:




X-Space re-entry plasma (part 2)

I’ve recorded how the effect looks like inside the simulator. The first video is the Orion capsule re-entering atmosphere. Notice that plasma gradually builds up until it reaches peak intensity:

The second video is the early portion of the upper stage re-entry. The stage will burn up later in more dense layers of the atmosphere, but during this stage heat flux is still low enough for heat to be conducted across the whole upper stage itself:

I will add post-processing and will optimize the mesh greatly – should make this effect slightly nicer (smoother), and reduce requirements towards the resources.

X-Space re-entry plasma

I’m working on adding a new special effect – the plasma that appears due to ionization by kinetic and thermal iteraction with boundary layer around the spacecraft. I’ve figured out I could base this effect on the “shadow volumes” approach:

  1. Compute boundary layer thickness
  2. Compute mach wave for the entire spacecraft (right now fixed at a very high mach number – this affects how trail “grows” over distance)
  3. Generate “shadow” mesh for every triangle, extrude the initial mesh to account for the boundary layer thickness
  4. Draw the mesh with some procedural noise

This is what kind of mesh is built for a spacecraft:

Right now the end effect is quite laggy, and looks sort of bad from front and back. There’s no optimization that would merge each triangles shadow into a single simpler mesh, but I am working on that.

But it already looks quite nice, and very heavily depends on geometry of the object:

I will post how it looks like animated in the next blog entry.

X-Space smoke rendering

I’ve added some smoke rendering. It’s a procedural smoke renderer (the trail is unique and is generated “on fly” by the GPU). This smoke rendering approach is also very cheap.

The smoke is particle based, but each texture is generated based on simple relations and perlin noise. It is also fake-lighted (calculates normal between billboard surface and sun, and then paints gradient over it).

The fake gradient applied over the smoke is done by computing the “shadow vector”, direction of which points to the darker part of the smoke billboard/sprite (it’s equal to projection of sun vector onto the billboard). Then this is used to compute the gradient itself:

The end result is:

And here’s how it looks like animated:

Heat conductivity simulation (implemented)

I have implemented the approach from previous post. Here are some pictures of what I ended up with.

The story about these pictures: I’ve removed a little bit of thermal protection system from the shuttle, and observed how heat was conducted throughout the entire wing by aluminium internal structure.

X-Space does not model turbulent heat flow over missing TPS tiles yet, so in total the amount of heat is not that great – the structure could sustain the whole reentry with this amount of tiles missing. But in reality the heat flux over the area with missing tiles would be much greater!




The wing structure quickly heats up, but not quick enough (due to no turbulent flow that must happen over missing tiles):

Heat conductivity simulation (theory)

I thought up of a nice way to simulate heat conductivity in parallel with other drag/heating physics calculations (and in parallel with X-Plane). So I went and did it. It sped up execution quite a lot!

The primary idea: heat flux is computed in the main thread. It is asynchronously read by the heat conduction thread, and the heat flux is accounted for when calculating the equations of heat conduction.

It’s a slightly complex piece of software, but while main thread runs at simulator FPS the heating thread will run at constant 30 FPS (or less, but not less than 10 FPS) in parallel, doing all the calculations. Each heating simulation frame the thread copies temperature data back to main thread (asynchronously).

The conduction is done between two faces, and two layers in each face. These layers and their temperature data correspond to the model shown on the picture.

There are two subroutines:

  • Conduction calculation once for every pair of two triangles which are connected by heat conduction (right now that only includes triangles which share vertices)
  • Conduction calculation between layers on every triangle

There are two big ideas here. First of all, the common 1D fourier law (heat conduction equation) is used to compute heat flow between layers and between triangles:
  \dot Q = k A \dfrac{\Delta T}{\Delta x}

In the later equations A_{ij} is the way to refer to triangle i, layer j.

Flow between two layers of two triangles (between hull of triangle 1 and 2, between TPS of triangle 1 and 2) is computed:
d = distance(1,2) (distance between two triangles)

l = \sqrt{\dfrac{area_1 + area_2}{2 * 0.433}} (estimated triangle edge length)

\Delta x_1 = \dfrac{d mass_1}{mass_{11} + mass_{21}} (distance across first triangle)

\Delta x_2 = \dfrac{d mass_2}{mass_{11} + mass_{21}} (distance across second triangle)

k_{eff} = \dfrac{k_{11} \Delta x_1 + k_{21} \Delta x_2}{d} (effective heat conductivity coefficient)

\dot Q_1 = k_{eff} \cdot 1.0 \cdot l \cdot \dfrac{T_{21} - T_{11}}{\Delta x} (heat conducted via hull)

The hull is assumed to be 1 meter thick, and conduction is done over the triangle edge. The edge is approximated by taking triangle as an equilateral triangle – this works well for “good” heating mesh.

For flow between thermal protection system layer (all variables not mentioned are same as for the hull layer):
k_{eff} = \dfrac{k_{10} \Delta x_1 + k_{20} \Delta x_2}{d} (effective heat conductivity coefficient)

\dot Q_0 = k_{eff} \cdot \dfrac{thickness_1 + thickness_2}{2} \cdot l \cdot \dfrac{T_{20} - T_{10}}{\Delta x} (heat conducted via TPS)

These two heat changes are used to compute total change of heat in two layers due to conduction between two triangles:
\Delta Q_{11} = Q_1 \cdot \Delta t
\Delta Q_{21} = -Q_1 \cdot \Delta t
\Delta Q_{10} = Q_0 \cdot \Delta t
\Delta Q_{20} = -Q_0 \cdot \Delta t

But this will probably explode/cause unstable simulations at high deltatime! There is one more step here, which makes sure it will not explode under any conditions.

The idea is very very simple. I’m sure it’s been discussed before elsewhere, but it goes like this: the maximum change of heat is limited by difference in temperatures – it is not possible to transfer heat from colder to hotter object. This seems obvious, but here’s the maximum delta heat computed from this rule:
\Delta MaxQ_{11} = \Delta t \cdot 0.5 \cdot Cp_{11} \cdot mass_{11} \cdot |T_{21} - T_{11}|
\Delta MaxQ_{21} = \Delta t \cdot 0.5 \cdot Cp_{21} \cdot mass_{21} \cdot |T_{21} - T_{11}|
\Delta MaxQ_{10} = \Delta t \cdot 0.5 \cdot Cp_{10} \cdot mass_{10} \cdot |T_{20} - T_{10}|
\Delta MaxQ_{20} = \Delta t \cdot 0.5 \cdot Cp_{20} \cdot mass_{20} \cdot |T_{20} - T_{10}|

The 0.5 factor means that the most heat that can be transferred between two triangles is only enough to put them in thermal equality. Also the smallest limit out of all these four is found, and is used to clamp all values of heat. It is important that in all conductive transfer at this step there will be no more heat transferred than the smallest of these variables!

Change in temperature is computed at this step as:
\Delta T = \dfrac{\Delta Q_{ij}}{Cp_{ij} \cdot mass_{ij}}

The second idea: compute heat conduction between layers of a single face. It’s important to do this independently of heat conduction between triangles – this makes simulation much more stable as amount of heat that conducts between layers is usually much different from amount conducted between triangles.

Due to where temperature variables are measured, the equations here are very simple (this is for a single triangle):
\dot Q = k_0 \cdot area \cdot \dfrac{T_{1} - T_{0}}{\Delta x}
\Delta MaxQ_0 = \Delta t \cdot 0.5 \cdot Cp_0 \cdot mass_0 \cdot |T_{1} - T_{0}|
\Delta MaxQ_1 = \Delta t \cdot 0.5 \cdot Cp_1 \cdot mass_1 \cdot |T_{1} - T_{0}|

This might look a bit confusing – if someone wishes to implement a similar simulation, here’s the (latest as of writing this post) source code:
http://dev.wireos.com/hg/x-space/file/source/dragheat.c (line 762)

Free free to contact me and I’ll try to help you.

IVSS – Internal Vessel Systems Simulator

I’m working on a new project. It is called “IVSS” (Internal Vessels Systems Simulator). The goal of this project is to provide a general framework for designing and running detailed realtime simulations.

The whole simulator runs a lot of smaller simulations – each of which calculates its part of the system. The simulator may be quite complex including many subsystems. It will be able to run on many cores, and even on several machines over the network.

The idea behind it is this: it can be used for engineering modelling while there’s still no detailed schematic of the aircraft available, and most importantly it will be possible to integrate this simulator with real hardware (the hardware-in-loop approach).

There will be a way to define all sorts of things, including panels (which should simplify my life a lot – I can design panels full of switches procedurally, having some algorithm placing switches and labels around, baking them into textures, and exporting as a 3D model later)

This is an extension of something I worked on before – the XSV simulation framework. It became too hard to write internal systems in Lua. That approach was also limited – could only run on a single core.

The new IVSS will be available both as a standalone application, and as a plugin for the X-Plane flight simulator. XGDC3 OS will be using IVSS as its framework.

Ideas for heating simulator

I’ve got two ideas for heating simulator:

  1. Implement a highly parallel thermal conductivity simulation: if heat flux changes very slightly, then heat conductivity can be computed in parallel thread (on another core), only reading last known heat flux (any last known heat flux), and writing back some value of temperature. If these variables change slowly, then the whole simulation will run correctly.
  2. Add layers of TPS to simulate non-linear temperature distribution for low-conductivity materials. This will improve calculations related to spacecraft heat shields.

The first idea is actually a little method I’m working on: a way to write highly parallel analog simulations, making use of the fact that distortion due to irregular sampling (if sample was taken from SOME frame, not just last one) can be made very low, less than simulation error.

This method is the base for one upcoming project – an internal systems simulator, but a bit more on it in a different post…