MATLAB Code for Simulating Multilayer Flows with Counter-Directed Zones in a Vertical Layer

Published: 15 January 2026| Version 1 | DOI: 10.17632/p2n3rgd9g7.1
Contributors:
,

Description

This repository contains a ready-to-run MATLAB script for the computational analysis and visualization of complex velocity profiles in a viscous fluid flow within a vertical plane layer. The core feature of the studied flow is the presence of multiple embedded layers (zones) where the direction of the longitudinal velocity component is opposite to the main flow. The script implements an exact analytical solution for a three-dimensional velocity field, dependent on vertical and transverse coordinates. The user can explore three distinct pre-configured cases, each demonstrating a different flow topology: with one, two, or three internal shear layers (zero-velocity surfaces). The code automatically calculates these surfaces and generates a comprehensive set of informative plots. Key visualizations include: 1) Individual velocity profiles U(z) with highlighted counter-flow zones and directional arrows, 2) A comparative plot of all three cases, 3) A 2D contour map of the velocity field Vx(y,z) and its cross-sections for the most complex three-layer case, 4) An analytical plot of the first and second derivatives of U(z), revealing shear gradients and inflection points linked to the zero-velocity surfaces. The primary result is the clear graphical demonstration of how controlled variations in physical parameters (thermodynamic forces, volumetric energy release, boundary conditions) can generate complex multi-layer flow structures with alternating direction. This code is useful for researchers and students in fluid dynamics, applied mathematics, and engineering, providing a tool for studying shear flows, stability analysis, and educational demonstration of exact solutions to the Navier-Stokes equations.

Files

Steps to reproduce

Download the file Multilayer_Flow_Simulation_CounterDirected_Zones.m. Open the file in MATLAB (version R2018a or later recommended). Run the script. No additional toolboxes or input files are required. The script will execute sequentially, printing parameters to the command window and generating three separate figure windows with all plots described above. To modify parameters (e.g., angles, intensities Omega, Gamma, pressure gradients P1, P2), edit the corresponding sections in the "SYSTEM PARAMETERS" and "PARAMETERS FOR THREE CASES" blocks of the code and re-run.

Institutions

  • Samara State Technical University
  • Ural'skij federal'nyj universitet imeni pervogo Prezidenta Rossii B N El'cina

Categories

Computer Science, Engineering, Physics, Software, Mechanical Engineering, Computational Physics, Fluid Dynamics

Licence