Engee documentation
Notebook

Aerodynamic modeling of the web

Introduction

The movement of the canvas in the wind is a fascinating physical phenomenon that combines aerodynamics, wave theory and computational mathematics. This example presents a mathematical model of wave propagation in a flexible web fixed at one edge (imitation of a flagpole).

The model is based on a superposition of harmonic components: a longitudinal traveling wave, its second harmonic and a transverse wave. The amplitude of the waves fades smoothly at the fixed edge, simulating the real behavior of the fabric. For high-performance 3D visualization, the GLMakie library is used, which allows you to achieve smooth animations even on high-resolution grids.

You can upload any image — from the national flag to a work of art — and see how it "comes to life" under the influence of digital wind, adjusting the parameters of speed, frequency and intensity of waves.

Libraries used

We will attach the necessary libraries. To create a three-dimensional graphic animation with a texture, we will need the GLMakie library.

In [ ]:
using Images, FileIO, LinearAlgebra, GLMakie

Visual modeling function

This function accepts the texture and geometric parameters of the canvas, creating a three-dimensional coordinate grid of a given resolution. At each time step, a new vertical displacement of each vertex is calculated as a superposition of traveling longitudinal and transverse waves with exponential attenuation at the fixed edge. The wave field is parameterized by amplitude, frequency, and propagation velocity, which makes it possible to simulate a wide range of wind conditions, from complete calm to stormy winds.

In [ ]:
function аэродинамическое_моделирование_полотна(текстура, Ширина, Высота, nx, ny, квс, амплитуда, частота, скорость, время, модель)    
    изображение = load(текстура)
    изображение = rot180(изображение)
    изображение = reverse(изображение, dims=2)
    x = range(0, Ширина, length=nx)
    y = range(0, Высота, length=ny)
    X = repeat(reshape(x, 1, :), ny, 1)
    Y = repeat(y, 1, nx)
    шаг_времени = 1/квс
    число_кадров = floor(Int, время / шаг_времени)
    X_данные = X
    Z_данные = Y .- 0.7
    фигура = GLMakie.Figure(size=(800, 600))
    оси = GLMakie.Axis3(фигура[1, 1], aspect=(1, 1, 1), limits=((0, Ширина), (0.5, 1.5), (-2.5, 2.0)))
    оси.xspinesvisible = false
    оси.yspinesvisible = false
    оси.zspinesvisible = false
    GLMakie.hidedecorations!(оси)
    GLMakie.hidexdecorations!(оси, grid=false)
    GLMakie.hideydecorations!(оси, grid=false)
    GLMakie.hidezdecorations!(оси, grid=false)
    Y_данные = ones(size(X))
    полотно = GLMakie.surface!(оси, X_данные, Y_данные, Z_данные, color = изображение, backlight = 0.0, alpha = 0.85, shading = false)
    GLMakie.lines!([0.0, 0.0], [1.0, 1.0], [-2.0, Высота - 0.7], linestyle = :solid, linewidth = 3, color = GLMakie.RGB(0.5, 0.5, 0.5), label = "")
    камера = оси.scene.camera_controls
    GLMakie.update_cam!(оси.scene, камера, GLMakie.Vec3f(30, 0, 0))
    function волна(t)
        текущее_время = t * шаг_времени
        Y_новая = zeros(size(X))
        for j in 1:ny
            for i in 1:nx
                эффект_волны = амплитуда * (
                    sin(2*pi*частота*(X[j,i]/Ширина - скорость*текущее_время)) +
                    0.5*sin(3*pi*частота*(2*X[j,i]/Ширина - скорость*текущее_время + 0.5)) +
                    0.3*sin(pi*частота*(3*Z_данные[j,i]/Высота + скорость*текущее_время)))
                эффект_волны = эффект_волны * min(1, X[j,i]/0.5)
                Y_новая[j,i] = 1.0 + эффект_волны
            end
        end
        return Y_новая
    end
    GLMakie.record(фигура, модель, 1:число_кадров; framerate = квс) do кадр
    Y_новая = волна(кадр)
    полотно[2] = Y_новая
    end
end
Out[0]:
аэродинамическое_моделирование_полотна (generic function with 1 method)

Let's create several visual models using different textures and wave parameters.

The Banner of Victory

Due to the approaching 81st anniversary of Victory in the Great Patriotic War (at the time of publication of this example), we use the image of the Victory Banner as the texture of the canvas. Let's define the wave and other parameters, and create an animation model.

In [ ]:
текстура = "Знамя_Победы.png"
Ширина = 4.0
Высота = 2.5
nx = 960
ny = 480
квс = 20
амплитуда = 0.03
частота = 0.8
скорость = 0.9
время = 16
модель = "Модель_1.gif"

аэродинамическое_моделирование_полотна(текстура, Ширина, Высота, nx, ny, квс, амплитуда, частота, скорость, время, модель)
Модель_1.gif

The Flag of Russia

We will slightly increase the amplitude of the waves and the wind speed. We use the image of the national flag of the Russian Federation as a texture.

In [ ]:
текстура = "Флаг_России.png"
Ширина = 4.0
Высота = 2.5
nx = 960
ny = 480
квс = 20
амплитуда = 0.04
частота = 0.8
скорость = 1.5
время = 16
модель = "Модель_2.gif"

аэродинамическое_моделирование_полотна(текстура, Ширина, Высота, nx, ny, квс, амплитуда, частота, скорость, время, модель)
Модель_2.gif

Engee logo

We will reduce the amplitude and speed of the wind speed, and slightly increase the frequency of the waves. We use the image of the Engee logo as a texture.

In [ ]:
текстура = "Engee_flag.png"
Ширина = 4.0
Высота = 2.5
nx = 960
ny = 480
квс = 20
амплитуда = 0.01
частота = 1.5
скорость = 1.1
время = 16
модель = "Модель_3.gif"

аэродинамическое_моделирование_полотна(текстура, Ширина, Высота, nx, ny, квс, амплитуда, частота, скорость, время, модель)
Модель_3.gif

Conclusion

This example demonstrates an elegant synthesis of applied mathematics and modern computer graphics. The presented tool can be used not only for educational and demonstration purposes, but also serve as the basis for more complex simulations: adding turbulence, interacting with obstacles, calculating web tensions and ruptures.

Possible directions of development:

  • Interactive real-time parameter management

  • Modeling of several interacting canvases

  • Consideration of gravity and elastic properties of the material

  • Modeling parachutes, sails, and other canvas products

  • Export to augmented reality formats

"Digital wind" is not just an animation of a flag. This is an introduction to exploring the beauty of physical processes hidden behind familiar phenomena.