Hi, Higashi here.
Last time I ran five Python simulations of air flowing through a U-bend, changing the duct length, inlet speed and inlet temperature. This time I used those CFD results to train a neural network to predict the flow for itself.
Air enters at the lower left, turns at the far right and comes back to the outlet at the upper left. A short section of straight duct looks much the same on either leg, yet the air flows in opposite directions. Can a model that sees only a small patch of the duct tell the two apart?
I compared the model with computational fluid dynamics (CFD), looking for two things: which way the air moves and when the warm air reaches the outlet. The original simulations are in my five-case comparison of U-bend shapes and inlet conditions.
Looking at one cell and its neighbors to predict 0.1 seconds ahead
Imagine picking one of the small boxes, or cells, that make up the duct. The model reads the velocity, temperature and other quantities in that cell and the cells around it. Its job is to predict the state of the center cell 0.1 seconds later. A model trained on CFD results to stand in for the original flow calculation is called a surrogate model.

I built a 3D convolutional neural network (CNN) in PyTorch. A CNN working on a photograph looks at neighboring pixels across a flat image. Here it also looks through the depth of the duct. Stacking three layers that each read 3 × 3 × 3 cells gives the center cell access to three cells in each direction, or 7 × 7 × 7 cells in all. Each layer produces 16 features. The final layer converts these into seven values for the center cell.
What else should the model know? When all the air is at rest, a small patch in the outward leg looks much like one in the return leg. I included the coordinates and information about the boundaries so that the model could tell where it was.
| Input | What the model receives |
|---|---|
| Current air state | The three velocity components (u, v, w), static pressure p relative to atmospheric pressure, temperature T, turbulent kinetic energy k and its dissipation rate ε. The last quantity describes how quickly turbulent kinetic energy is lost. |
| Position and geometry | Cell-center coordinates x, y and z on a common scale, the fraction of the cell occupied by fluid, and flags for cells touching the inlet or outlet. |
| Location of the boundaries | For each of the six face directions (positive and negative x, y and z), the fraction of the face occupied by inlet, outlet or wall. Separate near-wall indicators distinguish cells in the first three layers inward from the wall. |
| Inlet conditions during the next 0.1 seconds | Every cell receives the inlet velocity and temperature histories. Cells touching the inlet also receive velocity, temperature, k and ε weighted by the inlet face fraction. The inlet k and ε are calculated from velocity. Each history contains 11 points at 0.01-second intervals, including both ends. |
| Outlet and walls | Outlet static pressure is 0 Pa gauge. During outflow there is no diffusive heat flux through the outlet. Any backflow enters at 300 K. Cells touching the outlet also receive the k and ε histories for backflow. The walls are no-slip and adiabatic, so there is no heat exchange with the duct wall. |
The outputs are u, v, w, p, T, k and ε for the center cell 0.1 seconds later. The output layer keeps k and ε nonnegative, and cells outside the duct are excluded. The only future information supplied to the model consists of prescribed conditions such as the inlet history. The network has to work out the future velocity and temperature inside the duct itself.
Using the whole predicted field to advance another 0.1 seconds
Applying the same model to every fluid cell gives us the whole flow field at 0.1 seconds. We can then use all those values together to predict the field at 0.2 seconds. This is an autoregressive prediction: the model’s own output becomes its next input.

The CFD mesh spacing is 0.5 mm and the duct has a 6 mm square cross section. The air starts at rest at 300 K. Inlet speed and temperature rise to their peaks over 0.1 seconds and return to their starting values over the next 0.1 seconds. This cycle repeats five times. CFD snapshots are 0.01 seconds apart, while each AI prediction advances 0.1 seconds. For training, I shifted the starting time to form pairs such as 0.00 and 0.10 seconds, then 0.01 and 0.11 seconds. For the final test I started from the initial state and made ten consecutive predictions to reach one second.
I trained on four of the original five cases. In the standard duct (69 mm flow path), I used 2 m/s and 350 K, and 1 m/s and 350 K. In the shorter duct (45 mm), I used 2 m/s and 350 K, and 1 m/s and 325 K. These speeds and temperatures are inlet peaks. I kept the standard duct at 2 m/s and 325 K for testing, since that combination was absent from training.
I also ran an extra CFD case with a speed halfway between the two training speeds. It uses the standard duct and a peak of 350 K, with 1.5 m/s between 1 and 2 m/s. That is the case in the animation below.
Did the CNN get the return flow right?
CFD is on the left and the CNN with coordinates and boundary information is on the right. The colors show horizontal velocity u. Orange is rightward flow in the lower leg, and purple is leftward flow in the upper leg. Watch the opposite colors deepen as the inlet speed pulses.

Let’s stop at 0.9 seconds, when the inlet speed reaches its peak. In the top row below, both CFD and the CNN show air moving right in the lower leg and left after the bend in the upper leg. The mean horizontal velocity in the straight part of the return leg was −1.50 m/s in CFD and −1.51 m/s in the CNN. At this instant the averages are remarkably close.

The average hides some local differences. Across the whole duct and all ten prediction times, the root mean square error (RMSE) in the velocity vector was 0.297 m/s. The lower row also shows that the two methods put the warm air in different parts of the duct.
Does the warm air reach the outlet at the right time?
The walls are adiabatic, and the CFD model does not store heat in the duct material. Even so, outlet temperature does not move in step with inlet temperature. Warm air entering the duct takes time to travel around the bend.

In the 1.5 m/s case on the right, the CFD outlet warmed from 321.1 K to 334.1 K between 0.9 and 1.0 seconds, a rise of about 13 K. Over the same interval the CNN went from 327.7 K to 328.4 K, a rise of about 0.7 K. It got the direction right but missed most of the warm pulse arriving at the outlet.
The 2 m/s, 325 K case on the left diverged much earlier. At just 0.1 seconds, the mean outlet temperature was 312.9 K in CFD and 332.7 K in the CNN. Both had started from the same still air at 300 K. After just one prediction, the CNN’s mean outlet temperature already exceeded the hottest air admitted at the inlet, 325 K. Looking across all cells over the full second, the highest CNN temperature reached 359.2 K.
Why was the temperature already off after 0.1 seconds?
My first thought was that the model kept feeding its errors back into itself. I tried giving it the correct CFD field before every prediction in the 2 m/s, 325 K case. Across the same ten times, the outlet-temperature RMSE was 17.1 K when starting each step from CFD and 15.9 K in the autoregressive run. Add the roughly 20 K error on the very first step, and error accumulation alone cannot explain what happened at the outlet.
The training data had no pair that differed only in temperature
Three of the four training cases had a 350 K inlet peak. The only 325 K case was the short duct at 1 m/s. Shifting the start times gave me 364 training pairs, but none showed what happens when only inlet temperature changes at a fixed speed in the same duct. That makes it hard to tell whether a change in outlet temperature comes from the inlet temperature, the speed or the length of the duct.
I checked two CFD runs in the standard duct at 2 m/s. Halving the inlet rise from 50 K to 25 K also halved the rise above 300 K in every cell at every saved time. In this CFD setup, temperature does not change the velocity or the air properties, and no heat enters through the wall. Had the CNN picked up this relationship? I changed only the inlet temperature and gave it the same initial field.
| Peak inlet temperature | CFD | 3D CNN |
|---|---|---|
| 350 K (training condition) | 325.85 K | 336.10 K |
| 325 K (test condition) | 312.93 K | 332.72 K |
| Drop at the outlet when the inlet is cooler | 12.9 K | 3.4 K |
The CNN did predict a cooler outlet when I cooled the inlet, but the drop was only about a quarter of the CFD result. Even in the 350 K case it saw during training, its first outlet prediction was about 10 K too high. A shortage of 325 K examples seems unlikely to explain the whole discrepancy.
How far can heat travel in a single prediction?
On the 0.5 mm grid, three cells in the upstream direction give the CNN a direct view of the current temperature only 1.5 mm upstream. During the first 0.1 seconds, inlet speed rises linearly from 0 to 2 m/s, giving a mean of 1 m/s. Multiply that by 0.1 seconds and you get 100 mm. This is the volume of air admitted divided by the duct area. Individual air parcels can travel different distances. Still, in a duct with a 69 mm flow path, 1.5 mm is a short distance compared with the volume passing through the inlet in one prediction step.
Every cell receives the inlet temperature and speed histories, so a cell near the outlet knows how hot the incoming air is. To predict where a patch of warm air just upstream of the bend will be 0.1 seconds later, the intervening velocity and temperature fields also matter. This CNN predicts each cell’s temperature directly. Its output is free to exceed the inlet maximum, and the model has no heat balance tying a cell’s temperature change to the heat carried in from neighboring cells.

The animation and slices use the model trained for 24 epochs. I also extended training to 72 epochs on the same data. The combined one-step error across the seven quantities fell on the training cases, but it increased on the 2 m/s, 325 K test.
This experiment leaves two possibilities worth separating. I would first add cases that differ only in inlet temperature at a fixed speed in the same duct, then compare outlet temperature on held-out cases. With that training set fixed, I could let the network see farther upstream and check whether it gets the arrival time of the warm air right.
You can watch the original CFD heat pulse travel through the bend in the earlier post on changing inlet temperature and tracking the transient flow.


コメント