Traditional computational fluid dynamics (CFD) techniques deduce the dynamic variations in flow fields by using finite elements or finite differences to solve partial differential equations. CFD usually involves several tens of thousands of grid nodes, which entail long computation times and significant computational resources. Fluid data are usually irregular data, and there will be turbulence in the flow field where the physical quantities between adjacent grid nodes are extremely nonequilibrium. We use a graph attention neural network to build a fluid simulation model (GAFM). GAFM assigns weights to adjacent node-pairs through a graph attention mechanism. In this way, it is not only possible to directly calculate the fluid data but also to adjust for nonequilibrium in vortices, especially turbulent flows. The GAFM deductively predicts the dynamic variations in flow fields by using spatiotemporally continuous sample data. A validation of the proposed GAFM against the two-dimensional (2D) flow around a cylinder confirms its high prediction accuracy. In addition, the GAFM achieves faster computation speeds than traditional CFD solvers by two to three orders of magnitude. The GAFM provides a new idea for the rapid optimization and design of fluid mechanics models and the real-time control of intelligent fluid mechanisms.
I. INTRODUCTION
Intuitively, the vortex is not only a common flow motion state but also one of the most mesmerizing issues in fluid physics. Unfortunately, the academic community still cannot give an accurate definition of a vortex. Although some widely used vortex identification criteria exist, such as the Q criterion,1 the lambda2 criterion,2 etc., each has defects. Therefore, the numerical calculation3 to directly resolve the complete form N–S equations or the reduced-order models4 with certain assumptions has become the primary method of vortex research. Respect for physical facts and rigorous mathematical derivations are the unshakable and reliable keystones of the approach. However, the cost for high accuracy of complex flow simulations is a dramatically increasing demand for computing resources.
In recent years, data-driven deep learning5 has experienced explosive growth and has gradually developed into a new paradigm of computational fluid dynamics (CFD) research. A well-trained deep learning network can perform a real-time and dynamic flow motion deduction, particularly for uncertain, incomplete, and complex flow patterns.6 Undoubtedly, the features outperform offline analysis-focused patterns and have unlimited potential compared to the traditional one-case-one-calculation model. This paper aims to establish a high-efficiency deep learning fluid model for flow motions with nonequilibrium and unsteady characteristics like the vortex.
However, deep learning networks are usually propertyless or non-physical. For physics-related problems like a vortex flow, the network training must be constrained by the existing knowledge of physical laws to avoid non-physical solutions. To implant the physical laws into the underlying logic of a deep learning network and guide the training direction, two main methods are generally utilized: observation bias or inductive bias.7
Observation bias methods train a model and inversely infer physical patterns and flow field information by using observational data. This approach, which was widely used in early deep learning research, requires the samples to exhibit specific physical patterns (for example, simulation or experimental data that satisfy the typical hyperbolic conservation laws) to enable the training and constraining of the neural network so that the output reflects the characteristics of the samples.8–10 For example, Kashefi et al. directly used the flow field data with velocity and pressure variation patterns to train the PointNet architecture and predicted the velocity and pressure evolution patterns of incompressible laminar flow fields around cylinders.11 Eivazi et al. proposed a two-step model that uses an auto-encoder network for nonlinear dimensionality reduction and parametric characteristic extraction from the raw data and then inputs the dimensionality-reduced characteristic data into a long short-term memory (LSTM) network to extrapolate the temporal variation patterns of flow field data not used in the training stage.12 In general, learning physical patterns by neural networks can be constrained to a certain degree by using data that reflect the underlying physics or specific characteristics of the flow field.
However, observational bias methods are poorly coupled with the underlying physics. Specifically, this approach does not consider physical patterns in the network architecture design, resulting in uncertainty in the convergence process.7
To overcome the adverse effects of this uncertainty on the efficiency of network training, the accuracy of the computations, and the generalizability of the model, the inductive bias method designs the network from the architecture building level with raw data-relevant general rules, thereby equipping the neural network with a priori knowledge of given tasks. Such a network can be trained with more rigorous constraints in a more targeted manner, resulting in better convergence performance.13–17 For example, Ling et al. added a multiplicative layer with an invariant tensor basis to a deep neural network and input the product of this layer with the last hidden layer into the output layer.18 Thereby, the output from the model necessarily has the Galilean invariance property. In addition, inductive bias methods can optimize the network architecture based on the available flow field data characteristics. For example, Chen et al. used a graph convolutional neural network (GCNN) with a relational inductive bias (i.e., rules for constraining the relationship and interaction between entities during the learning stage) to compute the unstructured data of laminar flows around two-dimensional (2D) obstacles.19
Therefore, we use the graph structure as the computational object of the model. Generally, the relationship between any two of the flow calculation units is non-orthogonal non-uniform, while the data requirements of the calculation format are orthogonal uniform. Performing non-orthogonal non-uniform to orthogonal uniform coordinate transformation on data is cumbersome and loses computational accuracy and efficiency. The advantage of graph-structured data is that such coordinate transformation processing can be avoided, and the nonlinear adjacency relationship between data nodes can be directly established.20 Although the computational entities of a graph neural network are also nodes, node relationships are represented by edges between nodes. It is easy to directly establish a graph structure with a nonlinear adjacency relationship through a sampling algorithm and directly train and calculate experimental and traditional simulation data in non-Euclidean space.21 In this way, the calculation efficiency can be significantly improved, and the reduction of calculation accuracy caused by coordinate transformation can be avoided. For example, the constraints on the relationships and interactions between nodes in the network learning process are the inductive biases based on physical constraints in graph neural networks.22
Next, the design of the interaction criterion between adjacent nodes is carried out by the vortex characteristics. There are two types of convolutions in graph neural networks: spectral convolution and spatial convolution.23 However, the spectral convolution technique is based on the global Laplace transform of the whole graph, which requires a fixed graph structure.24 Therefore, spectral convolutions have limited applications in real CFD scenarios. The spatial convolution calculation consists of two parts: first, the neighbor node and edge features are aggregated into a hidden node state, and then the node features are updated with the hidden node state.25 Spatial convolution can aggregate adjacent information by parameterizing the weight function. The edge weights can be calculated through some trainable weight functions, which have adopted the features of each node pair. In the process of information aggregation of adjacent nodes of turbulence data, the strong nonequilibrium of turbulent physical quantities among adjacent grid nodes can be adjusted by edge weights. In the traditional numerical difference, when the value of the physical quantity of the adjacent node is greatly different from that of the calculation node, the calculation result of the calculation node is often greatly affected. Inspired by this, we use the graph attention mechanism as the weight function of spatial convolution and assign weights by the influence between node-pairs.26 This enables the adjustment of nonequilibrium in vortices, especially turbulent flows.
In summary, we propose a graph-attention fluid simulation model with observational and inductive biases. The vortex field data provide the observation bias with a conservation law, and the inductive bias is provided by the nearest neighbor sampling algorithm27 and the graph attention mechanism.
The remainder of this paper is organized as follows. Section II describes the basic mathematical principles, network architecture, and computation process of the graph attention neural network to build a fluid simulation model (GAFM). Section III examines the application scope and performance of the GAFM. In particular, we test the network architecture and analyze the errors in comparison with different methods, then analyze the spatiotemporal errors of the 2D flow fields around a cylinder predicted by the GAFM. Then, we test the relative error between the GAFM calculation results and the Taylor–Green vortex analytical solution and verify the prediction accuracy of the GAFM in a high Reynolds number flow field. We also test the performance of the GAFM in the case of different boundary conditions and geometric conditions and investigate the applicability of the GAFM to three-dimensional (3D) flow fields. Finally, Sec. IV summarizes the results of the present study and outlines possible directions for future research.
II. BASIC PRINCIPLES OF THE GAFM
A. Data transformation
The flow field data can be considered as non-uniform non-orthogonal grid nodes with physical properties in non-Euclidean space. There exists a spatial coordinate relationship between these grid nodes, and this relationship is mapped to an adjacency relationship in a non-Euclidean space using a nearest-neighbor sampling algorithm. The distances between the computing node and its neighboring nodes are computed based on the coordinates of the computing node in the Cartesian coordinate system. The four nodes with the smallest distance to the computing node are defined as the neighboring nodes. The sampling algorithm is as follows:
where D is the set of distances of all nodes to node i; i is the index of the computing node; a is the index of all nodes; D′ is the set of distances between nodes arranged in ascending order; j is the set of indices corresponding to the first five inter-node distances of D′, including i itself; and ne[i] is the index of node i’s neighboring nodes.
The spatial coordinates of grid nodes in the Cartesian coordinate system are mapped to adjacency relationships in the non-Euclidean space by using the nearest-neighbor sampling algorithm. The grid nodes and their associated physics are transformed into a structured graph G(N,E), as shown in Fig. 1.
Mapping of flow field grid nodes from a Cartesian coordinate system into a non-Euclidean space. Blue dots represent grid nodes in the Cartesian coordinate system, while red nodes represent nodes in the non-Euclidean space.
Mapping of flow field grid nodes from a Cartesian coordinate system into a non-Euclidean space. Blue dots represent grid nodes in the Cartesian coordinate system, while red nodes represent nodes in the non-Euclidean space.
The structure graph includes not only the adjacency relationship of nodes but also the characteristics of nodes. Next, according to the fluid motion law in the flow field, the node feature is constructed. In the flow field, the fluid is usually in a stable flow state before passing through the obstacle, and the fluid flow state becomes unstable after the disturbance of the obstacle. Therefore, the instability of the fluid flow state is a process change. The model is trained by the physical information of the flow field with the fluid instability process, so that the model can learn the changing law of the fluid. We take k physical quantities continuously distributed in time as the eigenvectors of nodes in the structure graph. The structured graph can be expressed as
where C, U, V, and P are the concentration, x-direction velocity, y-direction velocity, and pressure, respectively, of the flow field; X and Y are the x- and y-axis coordinates, respectively; T is the time step between adjacent time moments; N is the set of node feature vectors; and E is the set of relationships among the nodes.
For a structured graph G(N,E) of dynamic flow field data with s nodes, the set of node feature vectors can be expressed as , where i is the index of node features and denotes c, u, v, and p at k consecutive points in time. The set of relationships among nodes can be expressed as , where ne denotes the neighboring relationships of node i, j is the set of indices of node i’s neighboring nodes, and ei,j is the edge between a pair of neighboring nodes.
B. Design of the GAFM’s attention mechanism
An appropriate attention mechanism must be selected based on the physical characteristics of the flow field data. There exist inter-coupling relationships between flow field data, e.g., the partial derivative relationship between physical quantities expressed by the Navier–Stokes equations and concentration transport equations,
As shown in Eqs. (2) and (3), the velocity, pressure, density, and viscosity coefficients are not linearly related, nor do they have a simple one-to-one relationship. To describe the nonlinear relationships between physical quantities, the parameter matrix for solving the self-attention coefficient is transformed into a higher-dimensional space. For the many-to-many relationships between physical quantities, the different edge relationships between the data are described in different representation subspaces by using a multi-head attention mechanism. In summary, the GAFM combines single- and multi-head attention mechanisms to cluster node information.
C. Network architecture of the GAFM
Different physical quantities of a flow field usually have significantly different numerical values. For example, for the flow around a cylinder, the x- and y-axis velocities will be quite different. To prevent such numerical differences from reducing the prediction accuracy, a normalization layer is added before the parameter layer of the neural network. The normalized physical feature vectors are expressed as
where H is the set of vectors that are input to the parameter layer, , and BN is the normalization operation.
The output from the normalization layer is input to the parameter layer. The parameter layer clusters node information using self-attention and multi-head attention mechanisms, and then updates this information by using a parameter matrix. The computation process for a single node is as follows:
where qi and ki are the query and keyword vectors, respectively, and Wq and Qk are the parameter matrices of the query and keyword vectors, respectively,
where eij is the attention coefficient between nodes i and j; d is the dimensionality of the query and keyword vectors; s is the dot product; and σ is the LeakyReLU activation function.
For a multi-head attention mechanism, the number of attention coefficients is related to the number of heads. The query vector, keyword vector, and attention coefficients of the multi-head attention mechanism can be obtained as
where is the rth attention coefficient of the multi-head attention mechanism; and and are the corresponding parameter matrices of the query and keyword vectors.
A linear combination of the feature vectors of neighboring nodes is obtained by using the attention coefficients, and the feature vectors of the neighboring nodes are multiplied by the parameter matrix as
where is the output from the attention layer; W is the parameter matrix corresponding to the single-head attention mechanism; P is the mosaic operation; R is the number of heads of the multi-head mechanism; Wr is the parameter matrix corresponding to the multi-head mechanism; and σ is the LeakyReLU activation function. The sets of output vectors from the single- and multi-head attention layers can be expressed uniformly as .
The trained GAFM better approximates the real fluid mechanics. The GAFM’s network architecture consists of a normalization layer and a graph attention layer. The normalization layer has 32 dimensions and is located between the input layer and the graph attention layer. The intermediate layer consists of three 32-dimensional graph attention layers. The output layer consists of one four-dimensional graph attention layer. The first and third layers of the intermediate layer are multi-head attention layers. The second layer is a self-attention layer. A dropout layer with a dropout rate of 0.5 is added between each pair of adjacent layers. The dropout layers are added to prevent overfitting. Table I presents the network parameters, as shown in Fig. 2.
Network details of the GAFM.
Layer . | Heads . | Dimensionality . | Activation function . |
---|---|---|---|
1 | 4 | 4 | Leaky_ReLU |
2 | 1 | 16 | Leaky_ReLU |
3 | 4 | 4 | Leaky_ReLU |
4 | 1 | 1 | ⋯ |
Layer . | Heads . | Dimensionality . | Activation function . |
---|---|---|---|
1 | 4 | 4 | Leaky_ReLU |
2 | 1 | 16 | Leaky_ReLU |
3 | 4 | 4 | Leaky_ReLU |
4 | 1 | 1 | ⋯ |
Training the GAFM to learn clustered data patterns via learnable parameterized matrices.
Training the GAFM to learn clustered data patterns via learnable parameterized matrices.
The network is optimized by using the Adam optimizer during training. The loss function is defined to minimize the root-mean-square loss function,
The network architecture consists of four graph attention layers. Table I lists the number of heads, the dimensionality of vectors Q and K, and the activation function of each layer.
The trained GAFM can be expressed as follows:
where the input vector is the feature vector of node i in the structured graph from moment t–k to moment t; ; is the feature vector of node i’s neighboring nodes in the structured graph from moment t–k to moment t; i[ne] is the index set of node i’s neighboring nodes; is the edge relationship between nodes i and j; fθ is the parameter function consisting of the parameter matrix θ, which belongs to the parameter space Θ; and the output vector is the predicted feature vector of node i at moment t + k + 1.
D. Workflow of the GAFM
The GAFM first maps C, U, V, and P at consecutive moments in a Cartesian coordinate system to structured graphs in a Euclidean space. The GAFM’s network then predicts C, U, V, and P at the next moment. The GAFM uses the output from the current computational step as the input to the next step, whereupon the first values of C, U, V, and P in the sequence are deleted. Thereby, the GAFM performs continuous inferential computations. The GAFM significantly outperforms traditional CFD in terms of computation speed and efficiency. Taking the flow field around the two-dimensional cylinder as an example, the working flow diagram of the GAFM is obtained, as shown in Fig. 3.
Workflow of the GAFM for computing the 2D flow around a cylinder, with the 3D network architecture of the GAFM presented in 2D form.
Workflow of the GAFM for computing the 2D flow around a cylinder, with the 3D network architecture of the GAFM presented in 2D form.
III. EXPERIMENTS
A. Test methods
The GAFM was realized by using TensorFlow, tf_geometric,28 and sklearn on a computer equipped with a NVIDIA TITAN RTX 2070 GPU and an Intel(R) Xeon(R) E5-2660 v4 @ 2.00 GHz CPU.
The tests considered the 2D flow around a cylinder (Reynolds number, Re = 100; Peclet number, Pec = 100), Taylor–Green vortex, 2D flow around a cylinder (Reynolds number, Re = 14 400), 2D flow around a cylinder under the Neumann and Dirichlet boundary conditions (Re = 200; Pec = 2000), flow around a half-cylinder (Re = 5; Pec = 15), 3D flow around a cylinder (Re = 100; Pec = 100), and a 3D aneurysm (Re ≈ 98.21, Pec ≈ 98.21). All datasets contain physics data for 201 moments. We use the data of the first 90% of the time as the training set, and the data of the last 10% of the time as the test set. Table II describes the objectives of these tests.
Overview of tests.
Data (train and test) . | Boundary condition . | Initial condition . | Δt (s) . | Computational time (single moment) (s) . | Objective . |
---|---|---|---|---|---|
Taylor–Green vortex | ⋯ | ⋯ | ⋯ | 0.3058 | Test model accuracy |
2D flow around | Third-type | Re = 100, | 0.08 | 0.3041 | Network architecture optimization |
a cylinder | Pec = 100 | and error analysis | |||
2D flow around | ⋯ | Re = 14 400 | 0.08 | 0.3008 | Test the prediction accuracy |
a cylinder | of the GAFM for turbulent fields | ||||
2D flow around | First-type | Re = 200, | 0.08 | 0.3499 | Analysis of the GAFM accuracy for under |
a cylinder | Pec = 2000 | vortex onset, fusion, and dissipation | |||
first-type boundary condition | |||||
2D flow around | Second-type | Re = 200, | 0.08 | 0.3828 | Analysis of the GAFM accuracy |
a cylinder | Pec = 2000 | for vortex onset, fusion, and dissipation | |||
under second-type boundary condition | |||||
2D flow around | Third-type | Re = 5, | 1 | 0.3495 | Test the generalizability of the |
a half-cylinder | Pec = 15 | GAFM to different boundary conditions | |||
3D flow around | Third-type | Re = 100, | 0.08 | 0.4495 | Test the prediction accuracy |
a cylinder | Pec = 100 | of the GAFM for 3D flow fields with several | |||
physical quantities and large amounts of data | |||||
Aneurysm | ⋯ | Re ≈ 98.21, | 0.09 | 0.3736 | Test the applicability |
blood flow | Pec ≈ 98.21 | of the GAFM to real 3D flow fields |
Data (train and test) . | Boundary condition . | Initial condition . | Δt (s) . | Computational time (single moment) (s) . | Objective . |
---|---|---|---|---|---|
Taylor–Green vortex | ⋯ | ⋯ | ⋯ | 0.3058 | Test model accuracy |
2D flow around | Third-type | Re = 100, | 0.08 | 0.3041 | Network architecture optimization |
a cylinder | Pec = 100 | and error analysis | |||
2D flow around | ⋯ | Re = 14 400 | 0.08 | 0.3008 | Test the prediction accuracy |
a cylinder | of the GAFM for turbulent fields | ||||
2D flow around | First-type | Re = 200, | 0.08 | 0.3499 | Analysis of the GAFM accuracy for under |
a cylinder | Pec = 2000 | vortex onset, fusion, and dissipation | |||
first-type boundary condition | |||||
2D flow around | Second-type | Re = 200, | 0.08 | 0.3828 | Analysis of the GAFM accuracy |
a cylinder | Pec = 2000 | for vortex onset, fusion, and dissipation | |||
under second-type boundary condition | |||||
2D flow around | Third-type | Re = 5, | 1 | 0.3495 | Test the generalizability of the |
a half-cylinder | Pec = 15 | GAFM to different boundary conditions | |||
3D flow around | Third-type | Re = 100, | 0.08 | 0.4495 | Test the prediction accuracy |
a cylinder | Pec = 100 | of the GAFM for 3D flow fields with several | |||
physical quantities and large amounts of data | |||||
Aneurysm | ⋯ | Re ≈ 98.21, | 0.09 | 0.3736 | Test the applicability |
blood flow | Pec ≈ 98.21 | of the GAFM to real 3D flow fields |
B. Network architecture optimization and comparative error analysis
Various network architectures were tested to optimize the network depth by using data for a 2D flow around a cylinder with Re = 100 and Pec = 100 and the third-type boundary condition. Error analysis was performed under the same conditions with the optimal network architecture.
To identify the optimal network architecture, the prediction accuracy of the GAFM using network architectures consisting of different numbers of layers was compared. The test started with two graph attention layers, with two layers successively added until the prediction accuracy of the GAFM no longer increased or decreased significantly.
As shown in Table III, a network architecture consisting of two layers achieves very poor prediction accuracy for all four physical quantities. This indicates that a network architecture consisting of only two graph attention layers is inadequate for fitting real dynamic flow fields due to the small number of parameters. With four or more layers, the accuracy of the network output is much better and only varies slightly as the number of layers increases; thus, four graph attention layers are sufficient to meet the requirements for the fitting of real dynamic flow fields. The prediction accuracy for all the physical quantities fluctuates as the number of layers increases. Based on comprehensive considerations, a four-layer network architecture was adopted for subsequent experiments.
Comparison of relative L2 errors for 2D flow around a cylinder using network architectures consisting of different numbers of layers.
. | L2 relative error . | |||
---|---|---|---|---|
Layers . | C . | U . | V . | P . |
2-layer | 1.0466 | 0.2822 | 0.6935 | 0.1309 |
4-layer | 0.0453 | 0.0262 | 0.0239 | 0.0201 |
6-layer | 0.0471 | 0.0287 | 0.0250 | 0.0221 |
8-layer | 0.0447 | 0.0286 | 0.0270 | 0.0267 |
10-layer | 0.0461 | 0.0268 | 0.0320 | 0.0263 |
12-layer | 0.0455 | 0.0281 | 0.0321 | 0.0311 |
. | L2 relative error . | |||
---|---|---|---|---|
Layers . | C . | U . | V . | P . |
2-layer | 1.0466 | 0.2822 | 0.6935 | 0.1309 |
4-layer | 0.0453 | 0.0262 | 0.0239 | 0.0201 |
6-layer | 0.0471 | 0.0287 | 0.0250 | 0.0221 |
8-layer | 0.0447 | 0.0286 | 0.0270 | 0.0267 |
10-layer | 0.0461 | 0.0268 | 0.0320 | 0.0263 |
12-layer | 0.0455 | 0.0281 | 0.0321 | 0.0311 |
The GAFM, a self-attention model, and GraphSAGE were constructed to have four-layer network architectures. The self-attention model and the GAFM only differed in the number of heads of attention. The prediction accuracy was measured by using the relative L2 error.
As shown in Table IV, the GAFM outperformed the other models significantly in terms of computational accuracy. A comparison of the prediction errors of the GAFM and GraphSAGE indicates that the attention mechanism outperforms the mean aggregator in terms of fitting the real dynamic flow fields. Comparing the prediction errors of the GAFM and self-attention model, it is clear that the fitting function yielded by the multi-head attention mechanism provides an approximation of the fluid dynamics, as shown in Fig. 4. In addition, the GAFM outperforms the HFM model significantly in terms of the velocity and pressure predictions and is only slightly inferior to the HFM for the concentration predictions.
Relative L2 errors of predictions yielded by different methods for 2D flow around a cylinder.
. | Relative L2 error . | |||
---|---|---|---|---|
Method . | C . | U . | V . | P . |
GAFM | 0.0453 | 0.0262 | 0.0239 | 0.0201 |
Self-attention | 0.0484 | 0.0298 | 0.0251 | 0.0215 |
GraphSAGE | 0.0219 | 0.0573 | 1.0000 | 0.7692 |
Hidden fluid mechanics (HFM)30 | 0.0153 | 0.0680 | 0.0701 | 0.0987 |
. | Relative L2 error . | |||
---|---|---|---|---|
Method . | C . | U . | V . | P . |
GAFM | 0.0453 | 0.0262 | 0.0239 | 0.0201 |
Self-attention | 0.0484 | 0.0298 | 0.0251 | 0.0215 |
GraphSAGE | 0.0219 | 0.0573 | 1.0000 | 0.7692 |
Hidden fluid mechanics (HFM)30 | 0.0153 | 0.0680 | 0.0701 | 0.0987 |
Comparison of relative L2 errors of the GAFM and graph self-attention network architectures in the prediction of 2D flow around a cylinder (horizontal axis represents time).
Comparison of relative L2 errors of the GAFM and graph self-attention network architectures in the prediction of 2D flow around a cylinder (horizontal axis represents time).
The GAFM outperforms network architectures using only a single-head attention mechanism in terms of rate of decrease of the loss curve and the minimum of the loss function, as shown in Fig. 5.
Experimental training of models for the prediction of 2D flow around a cylinder using the mean squared error as the loss function (numerical values of the loss curve for GraphSAGE are multiplied by 0.1 for better visual display).
Experimental training of models for the prediction of 2D flow around a cylinder using the mean squared error as the loss function (numerical values of the loss curve for GraphSAGE are multiplied by 0.1 for better visual display).
C. Taylor–Green vortex with analytical solution data
Since the experimental data of the flow around the cylinder are obtained by numerical methods, that is, the data accuracy of the training set and the test set is insufficient. To more objectively verify the prediction accuracy of the GAFM for the real vortex field, we use the analytical solution of Taylor–Green vortex29 as the experimental data to test the accuracy of the GAFM operation.
As shown in Fig. 6, both the velocity field and the vorticity field GAFM of Taylor–Green vortex have extremely high computational accuracy. Specifically, in vorticity, the deviation between the numerical results of the GAFM and the analytical solution is much smaller than that of GCN and GraphSAGE, as shown in Table V.
GAFM prediction results and analytical solution data in the Taylor–Green vortex experiment.
GAFM prediction results and analytical solution data in the Taylor–Green vortex experiment.
L2 relative errors of Taylor–Green vortex experiment.
. | Relative L2 error . | ||
---|---|---|---|
Method . | U . | V . | ω . |
GAFM | 0.0112 | 0.0107 | 0.0088 |
GCN | 0.0107 | 0.0108 | 0.0105 |
GraphSAGE | 1.0000 | 1.0000 | 0.7071 |
. | Relative L2 error . | ||
---|---|---|---|
Method . | U . | V . | ω . |
GAFM | 0.0112 | 0.0107 | 0.0088 |
GCN | 0.0107 | 0.0108 | 0.0105 |
GraphSAGE | 1.0000 | 1.0000 | 0.7071 |
D. Analysis of the spatiotemporal error of the GAFM
Using the GAFM to predict the 2D flow around a cylinder yielded estimates for various physical quantities at 195 moments in time. The relative and absolute spatial errors of these predictions at the 95th moment are now analyzed.
The distributions of the relative and absolute errors in the prediction of physical quantities of the flow field are presented in Fig. 7. The relative error is the smallest for C, whereas the relative errors of V and P are large. The reference thermodynamic map values of C are all greater than zero, whereas those of V and P may be positive or negative. The relative errors in V and P are greatest at the boundary between positive and negative values. This may be because small deviations in the predictions of physical quantities with values close to zero necessarily produce a large relative error. In terms of the absolute error, large values are mainly concentrated in two zones in the flow field: the zone near the cylinder, where the mesh is densest, and the zone with dramatic variations in the physical quantities. The convolutional kernel of the GAFM computes five nodes (including the computing node); thus, the convolutional kernel covers a relatively small area in the area of the dense mesh. This may lead to inadequate physical information being clustered by the convolutional kernel, thus reducing the computational accuracy.
Spatial distribution of the relative errors of the GAFM in the prediction of a 2D flow around a cylinder.
Spatial distribution of the relative errors of the GAFM in the prediction of a 2D flow around a cylinder.
Figure 8 shows the temporal variations in the average relative L2 error of the predictions for four physical quantities over 195 moments in time (16 s). The flow field distributions at the points of the maximum and minimum errors are also shown. In the case of the concentration C, the maximum error corresponds to the moment at which the vortex dissipates, while the minimum error corresponds to the moment the vortex emerges. For U, V, and P, the maximum error corresponds to the moment at which the red and blue zones reach their maximum extent, while the minimum error corresponds to the red and blue zones reaching their minimum extent. This result indicates that larger variations in the numerical values of the velocity, pressure, and concentration fields lead to larger relative L2 errors. The spatial distribution of the relative errors is consistent with that of the absolute errors.
Temporal variations in the relative L2 errors produced by the GAFM in predicting the concentration of a 2D flow around a cylinder and true value simulated flow fields at points of maximum/minimum error.
Temporal variations in the relative L2 errors produced by the GAFM in predicting the concentration of a 2D flow around a cylinder and true value simulated flow fields at points of maximum/minimum error.
E. 2D flow around a cylinder under high Reynolds number
In the low Reynolds number flow field, the flow characteristics of the vortex flow are mostly laminar flow. Compared with laminar flow, the non-equilibrium between transition flow and turbulent flow is more obvious. Therefore, in order to verify the computational accuracy of the GAFM in transitional flow and turbulent flow field, the velocity and pressure accuracy of the GAFM is analyzed in a two-dimensional cylindrical flow field with a Reynolds number of 14 400.
Combining Table VI and Fig. 9, it is obtained that the prediction accuracy of the GAFM for U and P is higher, while the prediction accuracy of V is relatively lower. It is mainly reflected that the value of V output by the GAFM is generally low, but the vortex characteristics are better.
The L2 relative error of the two-dimensional cylinder flow experiment under the condition of Re = 14 400.
. | Relative L2 error . | ||
---|---|---|---|
Flow condition . | U . | V . | P . |
Cylinder 2D (Re = 14 400) | 0.0533 | 0.2505 | 0.0584 |
. | Relative L2 error . | ||
---|---|---|---|
Flow condition . | U . | V . | P . |
Cylinder 2D (Re = 14 400) | 0.0533 | 0.2505 | 0.0584 |
Comparison of predictions yielded by the GAFM and true-value simulation results for 2D flow around a cylinder under the initial condition of Re = 14 400.
Comparison of predictions yielded by the GAFM and true-value simulation results for 2D flow around a cylinder under the initial condition of Re = 14 400.
F. 2D flow around a cylinder under different boundary conditions
We now consider different types of boundary conditions. The test described in Sec. III C predicted the flow field under the third-type boundary condition. The GAFM was also used to predict the 2D flow around a cylinder under Dirichlet (first-type) and Neumann (second-type) boundary conditions.
In the 2D flow around a cylinder, the concentration largely reflects the vorticity. In addition, under the third-type boundary condition, the concentration field has the largest relative L2 error and is the most difficult to compute. Under the third-type boundary condition, there is a vortex-onset stage, but no vortex-dissipation stage. Under the Dirichlet and Neumann boundary conditions, there exist vortex-onset, vortex-fusion, and vortex-dissipation stages, as shown by the striped concentration heat map. It is more difficult to predict dynamic flow fields in the presence of vortex fusion and dissipation.
The 2D flow around a cylinder was predicted by using the GAFM under the Dirichlet boundary condition and initial conditions of Re = 100 and Pec = 2000. The Dirichlet boundary condition defines a constant concentration at the outlet.
As shown in Table VII, the prediction accuracy for C is far lower than that for U, V, and P. Figure 10 indicates that the predicted and reference values of U, V, and P are very similar in terms of both the overall trend and the local patterns. The prediction accuracy for C is relatively poor. More specifically, the predicted concentration field at the outlet of the flow field is overly smooth when compared with the reference values, and the high-concentration stripes fuse earlier in the predicted concentration field. The zonal high concentration area of C showed the phenomenon of fracture. Meanwhile, it can be seen from (a) (Right) in Fig. 11 that the prediction accuracy is low in the grid sparse area. In combination with the Fourier spectrum and the grid node distribution of field data of the fracture region with high concentration in Fig. 11, we analyzed the reasons for this phenomenon: (1) From the perspective of frequency: In the predicted value of the GAFM, transverse wave is more accurate, but some high-frequency longitudinal wave is missing, which may be due to the simple network structure of the GAFM, which cannot accurately fit all frequency signals. (2) From the perspective of node distribution: in the case of sampling equal number of neighbor nodes, the physical quantity gradient between neighbor nodes in the sparse area is much larger than that in the dense area, so there is gradient nonequilibrium in the sampling area between the sparse area and the dense area. As a result, the concentration field prediction accuracy of the GAFM in sparse areas and partially dense areas is insufficient.
Relative L2 errors of the predictions for 2D flow around a cylinder under the Dirichlet boundary condition.
. | Relative L2 error . | |||
---|---|---|---|---|
Flow condition . | C . | U . | V . | P . |
Dirichlet streaks | 0.1083 | 0.0189 | 0.0251 | 0.0178 |
. | Relative L2 error . | |||
---|---|---|---|---|
Flow condition . | C . | U . | V . | P . |
Dirichlet streaks | 0.1083 | 0.0189 | 0.0251 | 0.0178 |
Comparison of predictions yielded by the GAFM and true-value simulation results for 2D flow around a cylinder under the Dirichlet boundary condition and initial conditions of Re = 100 and Pec = 2000.
Comparison of predictions yielded by the GAFM and true-value simulation results for 2D flow around a cylinder under the Dirichlet boundary condition and initial conditions of Re = 100 and Pec = 2000.
(a): Left: Reference concentration field under the Dirichlet boundary condition; Right: Superposition of concentration field predicted by the GAFM and grid node distribution of field data under the Dirichlet boundary condition; (b): Left: Reference concentration field in the bottom-left corner of the flow domain under the Dirichlet boundary condition; Right: Center-transformed Fourier frequency spectrum of the reference concentration field in the bottom-left corner of the flow domain under the Dirichlet boundary condition; (c): Left: GAFM-predicted concentration field in the bottom-left corner of the flow domain under the Dirichlet boundary condition; Right: Center-transformed Fourier frequency spectrum of the GAFM-predicted concentration field in the bottom left corner of the flow domain under the Dirichlet boundary condition.
(a): Left: Reference concentration field under the Dirichlet boundary condition; Right: Superposition of concentration field predicted by the GAFM and grid node distribution of field data under the Dirichlet boundary condition; (b): Left: Reference concentration field in the bottom-left corner of the flow domain under the Dirichlet boundary condition; Right: Center-transformed Fourier frequency spectrum of the reference concentration field in the bottom-left corner of the flow domain under the Dirichlet boundary condition; (c): Left: GAFM-predicted concentration field in the bottom-left corner of the flow domain under the Dirichlet boundary condition; Right: Center-transformed Fourier frequency spectrum of the GAFM-predicted concentration field in the bottom left corner of the flow domain under the Dirichlet boundary condition.
Next, the GAFM was used to predict the 2D flow around a cylinder under the Neumann boundary condition with initial conditions of Re = 100 and Pec = 2000. The Neumann boundary condition assigns the concentrations a constant gradient in the direction normal to the outlet. Figure 12 compares the results with the reference values.
Comparison of predictions yielded by the GAFM and true-value simulation results for 2D flow around a cylinder under the Neumann boundary condition and initial conditions of Re = 100 and Pec = 2000.
Comparison of predictions yielded by the GAFM and true-value simulation results for 2D flow around a cylinder under the Neumann boundary condition and initial conditions of Re = 100 and Pec = 2000.
The fracture phenomenon of high concentration zone is more obvious in the concentration diagram in Fig. 13. The concentration field predicted by the GAFM in Fig. 13 also suffers from the loss of part of high-frequency longitudinal wave and the inaccuracy of prediction in sparse region and part of dense region. The overall prediction accuracy is shown in Table VIII.
(a): Left: Reference concentration field under the Neumann boundary condition; Right: Superposition of the concentration diagram predicted by the GAFM and the grid node distribution diagram of field data under Newman boundary conditions; (b): Left: Reference concentration field in the bottom-left corner of the flow domain under the Neumann boundary condition; Right: Center-transformed Fourier frequency spectrum of the reference concentration field in the bottom-left corner of the flow domain under the Neumann boundary condition; (c): Left: GAFM-predicted concentration field in the bottom-left corner of the flow domain under the Neumann boundary condition; Right: Center-transformed Fourier frequency spectrum of the GAFM-predicted concentration field in the bottom-left corner of the flow domain under the Neumann boundary condition.
(a): Left: Reference concentration field under the Neumann boundary condition; Right: Superposition of the concentration diagram predicted by the GAFM and the grid node distribution diagram of field data under Newman boundary conditions; (b): Left: Reference concentration field in the bottom-left corner of the flow domain under the Neumann boundary condition; Right: Center-transformed Fourier frequency spectrum of the reference concentration field in the bottom-left corner of the flow domain under the Neumann boundary condition; (c): Left: GAFM-predicted concentration field in the bottom-left corner of the flow domain under the Neumann boundary condition; Right: Center-transformed Fourier frequency spectrum of the GAFM-predicted concentration field in the bottom-left corner of the flow domain under the Neumann boundary condition.
Relative L2 errors of the predictions for 2D flow around a cylinder under the Neumann boundary condition.
. | Relative L2 error . | |||
---|---|---|---|---|
Flow condition . | C . | U . | V . | P . |
Neumann streaks | 0.1339 | 0.0216 | 0.0276 | 0.0208 |
. | Relative L2 error . | |||
---|---|---|---|---|
Flow condition . | C . | U . | V . | P . |
Neumann streaks | 0.1339 | 0.0216 | 0.0276 | 0.0208 |
G. 2D flow around a cylinder under different geometric conditions
The generalizability of the GAFM to external flow fields under different geometric conditions was investigated by using data for the 2D flow field around a half-cylinder.
As shown in Fig. 14, the GAFM accurately predicts the overall patterns of C, U, V, and P but fails to accurately predict the local patterns. For example, the predicted concentration field exhibits a concavity in the high-concentration area near the half-cylinder, and the predicted velocity field has a large error in the region where the velocity changes direction. However, the GAFM exhibits good overall prediction accuracy, confirming its generalizability to external flow fields under different geometric conditions, as shown in Table IX.
Comparison of predictions yielded by the GAFM and true-value simulation results for 2D flow around a half-cylinder.
Comparison of predictions yielded by the GAFM and true-value simulation results for 2D flow around a half-cylinder.
H. Prediction performance of the GAFM for 3D flow fields
Compared with the PDEs for 2D flow around a cylinder, the system describing 3D flow around a cylinder has an additional z-axis velocity, and so its expression is more complex. Thus, 3D flows around a cylinder are more difficult to compute. In addition, the number of grid nodes for 3D flow around a cylinder is an order of magnitude higher than that for the 2D case. Thus, traditional CFD usually has a greater computational load in the case of 3D flows. First, the accuracy of the GAFM in predicting the 3D flow around a cylinder was examined under the third-type boundary condition with initial conditions of Re = 100 and Pec = 100.
As shown in Fig. 15, the GAFM-predicted distributions of the physical quantities exhibit overall consistency with the reference values, despite local inconsistencies. Compared with the reference concentration field, the GAFM-predicted concentration field has unsmooth edges and discontinuities in areas that should be continuous. Overall, the GAFM predictions for the 3D flow field are consistent with the reference values. To verify whether deepening the number of network layers can improve the prediction accuracy of the 3D flow field, we use the GAFM with 4, 6, and 8 layers of network architectures to calculate the 3D flow field. As shown in Table X, deepening the number of network layers will reduce the prediction accuracy of the 3D flow field, which indicates that the GAFM has over-fitting as the number of layer increases.
Comparison of predictions yielded by the GAFM and true-value simulation results for 3D flow around a cylinder.
Comparison of predictions yielded by the GAFM and true-value simulation results for 3D flow around a cylinder.
Relative L2 error of predictions for 3D flow around a cylinder.
. | Relative L2 error . | ||||
---|---|---|---|---|---|
Layers . | C . | U . | V . | W . | P . |
4 | 0.1072 | 0.0552 | 0.0615 | 0.0973 | 0.0621 |
6 | 0.1286 | 0.0693 | 0.0746 | 0.1230 | 0.0755 |
8 | 0.1392 | 0.0741 | 0.0831 | 0.1373 | 0.0888 |
. | Relative L2 error . | ||||
---|---|---|---|---|---|
Layers . | C . | U . | V . | W . | P . |
4 | 0.1072 | 0.0552 | 0.0615 | 0.0973 | 0.0621 |
6 | 0.1286 | 0.0693 | 0.0746 | 0.1230 | 0.0755 |
8 | 0.1392 | 0.0741 | 0.0831 | 0.1373 | 0.0888 |
The previous tests were all performed by using classical data for the flow around a cylinder. To test the performance of the GAFM in predicting real dynamic flow fields, we compared the model output against data from an aneurysm blood flow. The aneurysm blood flow has the characteristics of large-scale, complex data and nonperiodic flow. These flow patterns are closer to those observed in real-world applications. The aneurysm blood flow data have initial conditions of Re ≈ 98.21 and Pec ≈ 98.21.
Figure 16 presents transverse (left) and longitudinal (right) cross-sections of the 3D aneurysm blood flow, as the flow patterns cannot be adequately visualized by using 3D graphs. The figure shows the absolute values of the concentration, pressure, and velocity of the aneurysm blood flow. As shown in Table XI, the best prediction performance of the GAFM is for the pressure values.
Comparison of predictions yielded by the GAFM and true-value simulation results for 3D aneurysm blood flow. Left: Transverse cross-section; Right: Longitudinal cross-section.
Comparison of predictions yielded by the GAFM and true-value simulation results for 3D aneurysm blood flow. Left: Transverse cross-section; Right: Longitudinal cross-section.
IV. SUMMARY AND OUTLOOK
This paper has described a GAFM that uses inductive bias and observational bias to learn the dynamics of real flow fields. Among them, the inductive bias is that the GAFM can automatically adjust the nonequilibrium of physical quantities between adjacent nodes of vortexes (especially turbulent currents) through the attention mechanism. The observation bias is that the GAFM uses a dataset that conforms to the conservation law to train the network architecture and constrains the learnable parameters in the neural network so that it can conform to the actual flow field dynamics. The GAFM is capable of the rapid computations required for the prediction of fluid flows and is faster than traditional CFD by two to three orders of magnitude in terms of solving PDEs. As the GAFM requires relatively little computational resources, it can be integrated into a small computational unit. The present work advances the real-time inference of flow fields by using intelligent fluid mechanisms.
The proposed GAFM was analyzed by considering the 2D flow around a cylinder. The optimal network architecture depth was identified by comparing the results when using different numbers of layers. The attention mechanisms were then validated by comparing the prediction errors of the GAFM with those of GraphSAGE, a self-attention model, and an HFM model. In the Taylor–Green vortex experiment, the degree of deviation between the numerical solution of the GAFM operation and the analytical solution of Taylor–Green vortex is obtained. In a series of simulations of the 2D flow around a cylinder, the zones with the greatest spatial errors and the times at which the largest prediction errors occurred were identified. In the high Reynolds number two-dimensional cylindrical flow field, the calculation accuracy of the GAFM for turbulent flow is verified. The prediction accuracy of the GAFM under the Dirichlet and Neumann boundary conditions was also analyzed, and the vortex-onset, -fusion, and -dissipation phenomena were verified based on the striped patterns of the concentration heat maps. Overall, the test results show that the GAFM achieves good prediction accuracy for the vortex-onset stage, but the accuracy worsens in the vortex-fusion and -dissipation stages. In addition, the striped patterns in the concentration heat maps exhibit discontinuities along the upper and bottom boundaries of the flow fields. The predicted concentration field has large errors in certain local zones. Analysis of the frequency spectrum of these zones suggests two possible reasons. First, compared with the reference concentration field, the predicted concentration field has lost some high-frequency information in the longitudinal direction. Second, the predicted concentration field contains significant medium- and low-frequency noise. To enhance the learning of high-frequency information and filter out medium- and low-frequency noise, the sampling method should be improved, and the convolution area should be increased.
The generalizability of the GAFM to external flow fields with different geometries was validated by considering the flow around a half-cylinder, and the prediction accuracy of the GAFM for 3D dynamic flow fields was verified against the 3D flows around a cylinder and from an aneurysm. The prediction accuracy of the GAFM for 3D flows around a cylinder was found to be lower than for 2D flows around a cylinder. In particular, the GAFM was observed to have low prediction accuracy for the 3D aneurysm blood flow. Thus, to improve the capability of the GAFM in the case of large amounts of data and complex flow patterns, the GAFM network architecture should be optimized to improve its applicability in different scenarios. The major conclusions from this study can be summarized as follows:
The multi-head attention mechanism of the GAFM plays a significant role in improving the prediction accuracy for dynamic flow fields.
The GAFM has high computation accuracy and fast computation speed but requires relatively little computational resources.
The GAFM has high prediction accuracy for 2D flows around a cylinder under different boundary conditions and different geometric conditions, confirming its strong generalizability.
The GAFM performs well in the prediction of 3D flow fields with large amounts of data and complex physics, thus providing a new idea for the real-time inference of external flows using intelligent fluid mechanisms.
ACKNOWLEDGMENTS
This research was funded by the National Natural Science Foundation of China (Grant No. U20A2071).
AUTHOR DECLARATIONS
Conflict of Interest
The authors have no conflicts to disclose.
Author Contributions
Qiang Liu: Conceptualization (lead); Data curation (lead); Formal analysis (lead); Investigation (lead); Methodology (lead); Resources (equal); Software (lead); Validation (lead); Visualization (lead); Writing – original draft (lead); Writing – review & editing (lead). Wei Zhu: Conceptualization (lead); Funding acquisition (lead); Methodology (lead); Project administration (lead); Resources (lead); Supervision (lead); Writing – original draft (lead); Writing – review & editing (lead). Feng Ma: Conceptualization (lead); Investigation (lead); Methodology (lead); Resources (lead); Supervision (lead); Writing – review & editing (equal). Xiyu Jia: Conceptualization (lead); Methodology (equal); Project administration (equal); Supervision (lead); Writing – original draft (lead); Writing – review & editing (lead). Yu Gao: Conceptualization (equal); Data curation (equal). Jun Wen: Formal analysis (equal); Methodology (equal); Visualization (equal).
DATA AVAILABILITY
The data that support the findings of this study are openly available at https://drive.google.com/drive/folders/1mrJzBi1_IhbVebjeJ0qIo5dEx3f7xrQi?usp=sharing.