A flow field prediction method based on token selection Transformer
Through the flow field prediction method based on token selection Transformer, the airfoil geometric parameters are extracted and physical information characteristics are fused, and the limitations of airfoil feature extraction and flow field detail prediction in the prior art are solved, thereby achieving higher flow field prediction Accuracy.
Patent Information
- Application Number
- CN202410350715.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-26
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-03-26
AI Technical Summary
Existing deep learning flow field prediction methods have limitations in extracting airfoil features and predicting flow field details, especially when it is close to the airfoil surface, making it difficult to accurately capture the geometric features and flow field details of the airfoil.
The flow field prediction method based on token selection Transformer is adopted. The airfoil geometric parameters are extracted through the token selection Transformer network, and the parameter fusion network is fusion physical information characteristics are constructed. Finally, the flow field prediction network based on multi-layer perceptron is trained to improve the flow field Prediction accuracy.
This method can extract airfoil features more accurately, improve flow field prediction accuracy, especially near the airfoil surface, and enhance the model's expression ability and generalization ability.
Smart Images

Figure CN118395886B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the fields of computational fluid dynamics and artificial intelligence technology, and specifically relates to a flow field prediction method based on token selection Transformer. Background Art
[0002] Flow field prediction is the process of predicting and simulating the motion state of a fluid. It has a wide range of applications in chemical engineering, climate, and aerodynamics. Taking aerodynamics as an example, obtaining flow field data near an aircraft airfoil is a crucial step in the design and optimization of an aircraft. Initially, the main means of obtaining airfoil flow field data was through wind tunnel testing. Although this method has relatively accurate results, the experimental design requires a lot of prior knowledge, and the experimental cycle is long. The resource overhead required to build wind tunnel equipment is large, so it is mostly used in the later stages of aircraft design. With the rise of high-performance computing and numerical simulation methods, computational fluid dynamics (CFD) methods have gradually become the main means of simulating flow fields near airfoils. CFD methods mainly discretize continuous fluid equations, such as the Navier-Stokes equations, and numerically approximate these equations to obtain flow field data. However, CFD solutions under complex conditions require a large number of iterative processes, and the requirements for CPU and memory are also high.
[0003] In recent years, with the widespread application of artificial intelligence and neural networks, methods based on deep learning and data-driven have become a new means of obtaining flow field data. This method only requires a certain amount of time to train the network model in the early stage, and then the trained model can be used to complete the flow field prediction of different airfoils within a few seconds. However, the existing deep learning flow field prediction methods also have some limitations: many CNN-based flow field prediction methods project the flow field data into a uniformly distributed Cartesian grid. This pixelation method will cause a large amount of flow field details to be missing, especially near the airfoil surface; and the existing airfoil geometric parameter acquisition method cannot accurately capture the most effective geometric features of the airfoil. Therefore, how to more accurately extract airfoil features and predict flow field details is the direction that the flow field prediction method based on deep learning needs to be optimized. Summary of the invention
[0004] In view of the shortcomings of the prior art, the present invention proposes a flow field prediction method based on token selection Transformer, which can extract more accurate and effective airfoil features and improve the flow field prediction accuracy, especially near the airfoil surface.
[0005] In order to solve the above technical problems, the present invention is implemented in the following ways:
[0006] A flow field prediction method based on token selection Transformer includes the following steps:
[0007] S1, obtaining airfoil shape data set and real flow field data set;
[0008] S2, extracting airfoil geometric parameters through token selection Transformer network;
[0009] S3, construct parameter fusion network to fuse physical information features;
[0010] S4, training the flow field prediction network based on multi-layer perceptron;
[0011] S5. Use the trained flow field prediction model to predict the pressure field and velocity field on different airfoil data.
[0012] Furthermore, the step S1 specifically includes the following steps:
[0013] S11, selecting a reference airfoil from the UIUC airfoil database, performing airfoil fitting by using a non-uniform rational B-spline interpolation method, and selecting a control point on the airfoil fitting curve as a new x-coordinate and y-coordinate of the current airfoil;
[0014] S12, performing maximum and minimum normalization processing on all new airfoil coordinates in step S11, and the expression is as follows:
[0015]
[0016] Among them, x i ,y i Indicates the coordinates of the current airfoil, x min ,y min is the global minimum, x max ,y max is the global maximum value, x j ,y i is the normalized coordinate;
[0017] S13, generating an airfoil shape grayscale image according to the normalized coordinates, wherein the pixel value on the airfoil geometry curve is 1, the pixel value not on the airfoil geometry curve is 0, and the pixel values at other positions are in the range [0,1], thereby obtaining an airfoil shape data set;
[0018] S14, dividing the computational grid, performing CFD solution on the airfoil samples in the airfoil data set, obtaining real data of different airfoil samples under different flow conditions, and forming a real flow field data set.
[0019] Furthermore, the step S2 specifically comprises the following steps:
[0020] S21, serialize the airfoil images in the airfoil shape data set obtained in step S1, and i Divide and flatten the blocks into a series of two-dimensional tokens p i ,pic i and p i The expression is as follows:
[0021]
[0022] in, represents a real number set, H, W and C represent the width, height and number of channels of the airfoil image respectively, P represents the width and height of the selected partition block, N = H*W / P 2 Indicates the number of divided two-dimensional tokens;
[0023] S22. Add a learnable embedding CLStoken to the acquired token sequence, with the dimension consistent with other token dimensions, and then obtain the complete token sequence representation I of each airfoil image, the specific expression of which is as follows:
[0024]
[0025] Among them, p cls Represents CLStoken, p0, p1, ... p n-1 Indicates the N tokens obtained above, D = P 2 *C represents the dimension of token;
[0026] S23, reduce the dimension of I through a multi-layer perceptron network, so that the dimension of each token is reduced from D to I' is obtained, and its specific expression is as follows:
[0027]
[0028] S24, p' in step S23 cls As global features, p′0, p′1, ....p′ n-1 As a local feature, the global feature p′ cls With each local feature p′ i Perform splicing to obtain splicing features Its expression is as follows:
[0029]
[0030] S25. Record the N+1 splicing features obtained in step S24 as Then input it into another multi-layer perceptron network followed by a normalization layer to calculate the importance score vector S of the feature, which is expressed as follows:
[0031]
[0032] Among them, MLP() represents the function of the multi-layer perceptron network, and Softmax() represents the normalized exponential function, which converts the output of MLP into a probability value between [0,1];
[0033] S26. Use the importance score vector S to filter out the token index M with the top K importance among all N+1 tokens. The expression is as follows:
[0034] M∈{0,1} (N+1)*K
[0035] Each element in M is a one-hot indicator, and its value is selected from the set {0, 1};
[0036] S27, use the transpose of the matrix M in step S26 and I to perform matrix multiplication to obtain the most important K airfoil parameter features of the given airfoil
[0037]
[0038] Furthermore, the step S3 specifically comprises the following steps:
[0039] S31. For each grid point coordinate, calculate the shortest distance d to the airfoil geometry curve, which is expressed as follows:
[0040]
[0041] Where (x, y) represents the X-axis coordinate and Y-axis coordinate of the grid point. Indicates the X-axis and Y-axis coordinates of a point on the airfoil geometry curve;
[0042] S32, construct a parameter fusion network, input the horizontal and vertical coordinates of each grid point, the shortest distance from the coordinate to the airfoil geometric boundary, and the normalized Reynolds coefficient and angle of attack into a multi-layer perceptron network for feature fusion and dimension upgrading, and finally obtain the physical information feature p phy , which is expressed as follows:
[0043]
[0044] in, and They represent the normalized Reynolds coefficient and angle of attack respectively, and D represents the dimension of the fused physical information feature, which is consistent with the dimension of each airfoil feature extracted in step S2.
[0045] Furthermore, the step S4 specifically comprises the following steps:
[0046] S41. Rank the top K airfoil parameter features by importance With physical information characteristics p phy As the input of the flow field prediction network based on the multi-layer perceptron, the output of the flow field prediction network is the flow field data corresponding to the grid point coordinates, and its expression is as follows:
[0047]
[0048] Among them, f predict () represents the function of the flow field prediction network, and They represent the predicted values of the velocity component in the x direction, the velocity component in the y direction, and the pressure, respectively;
[0049] S42. For the flow field prediction network, design the loss function Loss MLP The expression is as follows:
[0050]
[0051] Where N represents the total number of samples, u i , v i , p i Represents the true value of the x-direction velocity component, the y-direction velocity component and the pressure;
[0052] S43. Train the model on the GPU server, set different model parameters and iteration steps for multiple rounds of training, and select the model with the smallest prediction error on the test data as the final flow field prediction model.
[0053] Furthermore, the specific method of step S5 is as follows:
[0054] Using the trained flow field prediction model, different airfoil characteristics, Reynolds number, and angle of attack information are input, and the pressure field and velocity field near the airfoil under the corresponding airfoil and flow conditions are output; the flow field data is visualized using processing software to facilitate subsequent work such as airfoil optimization, aerodynamic performance analysis, and aerodynamic noise prediction.
[0055] Compared with the prior art, the present invention has the following beneficial effects:
[0056] With the help of Transformer's self-attention mechanism and through the token selection module, the airfoil features can be screened more accurately, while parameter redundancy can be avoided to a certain extent; normalized coordinate values are extracted for different airfoil shapes and standardized images are generated to facilitate subsequent neural network processing; the flow field grid position information and the flow field parameter physical information are fused using a neural network and aligned with the airfoil parameter features, which can enhance the expression and generalization capabilities of the model to a certain extent; compared with the existing deep learning flow field prediction methods, the present invention improves the accuracy of flow field prediction, especially near the surface of the airfoil structure. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 It is a schematic diagram of the flow chart of the flow field prediction method of the present invention. DETAILED DESCRIPTION
[0058] The specific implementation of the present invention is further described in detail below with reference to the accompanying drawings and specific examples.
[0059] like Figure 1 As shown, a flow field prediction method based on token selection Transformer includes the following steps:
[0060] S1, obtaining airfoil shape data set and real flow field data set;
[0061] S2, extracting airfoil geometric parameters through token selection Transformer network;
[0062] S3, construct parameter fusion network to fuse physical information features;
[0063] S4, training the flow field prediction network based on multi-layer perceptron;
[0064] S5. Use the trained flow field prediction model to predict the pressure field and velocity field on different airfoil data.
[0065] Furthermore, the step S1 specifically includes the following steps:
[0066] S11, selecting a reference airfoil from the UIUC airfoil database, performing airfoil fitting by using a non-uniform rational B-spline interpolation method, and selecting a control point on the airfoil fitting curve as a new x-coordinate and y-coordinate of the current airfoil;
[0067] S12, performing maximum and minimum normalization processing on all new airfoil coordinates in step S11, and the expression is as follows:
[0068]
[0069] Among them, x i ,yi Indicates the coordinates of the current airfoil, x min ,y min is the global minimum, x max ,y max is the global maximum value, x j ,y j is the normalized coordinate;
[0070] S13, generating an airfoil shape grayscale image according to the normalized coordinates, wherein the pixel value on the smooth curve (airfoil geometry curve) formed by the airfoil coordinate points is 1, the pixel value not on the airfoil geometry curve is 0, and the pixel values at other positions are in the range [0,1], thereby obtaining an airfoil shape data set;
[0071] S14, dividing the calculation grid, performing CFD solution on the airfoil samples in the airfoil data set, obtaining the real flow field data of different airfoil samples under different flow conditions, and forming a real flow field data set.
[0072] Furthermore, the step S2 specifically comprises the following steps:
[0073] S21, serialize the airfoil images in the airfoil shape data set obtained in step S1, and i Divide and flatten the blocks into a series of two-dimensional tokens p i ,pic i and p i The expression is as follows:
[0074]
[0075] in, represents a real number set, H, W and C represent the width, height and number of channels of the airfoil image respectively, P represents the width and height of the selected partition block, N = H*W / P 2 Indicates the number of divided two-dimensional tokens;
[0076] S22, adding a learnable embedding CLStoken to the token sequence obtained in step S21, with the dimension consistent with other token dimensions, and then obtaining a complete token sequence representation I of each airfoil image, the specific expression of which is as follows:
[0077]
[0078] Among them, p cls Represents CLStoken, p0, p1, ... p n-1 Indicates the N tokens obtained above, D = P 2 *C represents the dimension of token;
[0079] S23, reduce the dimension of I through a multi-layer perceptron network, so that the dimension of each token is reduced from D to I' is obtained, and its specific expression is as follows:
[0080]
[0081] Among them, p′ cls ,p′0,p′1,...,p′ n-1 It is the representation of N+1 tokens including CLStoken after dimensionality reduction;
[0082] S24, p' in step S23 cls As global features, p′0, p′1, ....p′ n-1 As a local feature, the global feature p′ cls With each local feature p′ i Perform splicing to obtain splicing features Its expression is as follows:
[0083]
[0084] Among them, i is the subscript of each local feature, with a value range of [0, N-1], and the global feature p′ cls Splice it with itself to get a total of N+1 splicing features;
[0085] S25. Record the N+1 splicing features obtained in step S24 as Then input it into another multi-layer perceptron network followed by a normalization layer to calculate the importance score vector S of the feature, which is expressed as follows:
[0086]
[0087] Among them, MLP() represents the function of the multi-layer perceptron network, and Softmax() represents the normalized exponential function, which converts the output of MLP into a probability value between [0,1];
[0088] S26. Use the importance score vector S to filter out the token index M with the top K importance among all N+1 tokens. The expression is as follows:
[0089] M∈{0,1} (N+1)*K
[0090] Each element in M is a one-hot indicator, and its value is selected from the set {0, 1};
[0091] S27, use the transpose of the matrix M in step S26 and the token representation I obtained in step S22 to perform matrix multiplication to obtain the most important K airfoil parameter features of the given airfoil
[0092]
[0093] Furthermore, the step S3 specifically comprises the following steps:
[0094] S31. For each grid point coordinate, calculate the shortest distance d to the airfoil geometry curve, which is expressed as follows:
[0095]
[0096] Where (x, y) represents the X-axis coordinate and Y-axis coordinate of the grid point. Indicates the X-axis and Y-axis coordinates of a point on the airfoil geometry curve;
[0097] S32, construct a parameter fusion network, input the horizontal and vertical coordinates of each grid point, the shortest distance from the coordinate to the airfoil geometric boundary, and the normalized Reynolds coefficient and angle of attack into a multi-layer perceptron network for feature fusion and dimension upgrading, and finally obtain the physical information feature p phy , which is expressed as follows:
[0098]
[0099] in, and They represent the normalized Reynolds coefficient and angle of attack respectively, and D represents the dimension of the fused physical information feature, which is consistent with the dimension of each airfoil feature extracted in step S2.
[0100] Furthermore, the step S4 specifically comprises the following steps:
[0101] S41. Rank the top K airfoil parameter features by importance With physical information characteristics p phy As the input of the flow field prediction network based on the multi-layer perceptron, the output of the flow field prediction network is the flow field data corresponding to the grid point coordinates, and its expression is as follows:
[0102]
[0103] Among them, f predict () represents the function of the flow field prediction network, and They represent the predicted values of the velocity component in the x direction, the velocity component in the y direction, and the pressure, respectively;
[0104] S42. For the flow field prediction network, design the loss function Loss MLP The expression is as follows:
[0105]
[0106] Where N represents the total number of samples, u i , v i , p i Represents the true value of the x-direction velocity component, the y-direction velocity component and the pressure;
[0107] S43. Train the model on the GPU server, set different model parameters and iteration steps for multiple rounds of training, and select the model with the smallest prediction error on the test data as the final flow field prediction model.
[0108] Furthermore, the specific method of step S5 is as follows:
[0109] Using the trained flow field prediction model, different airfoil characteristics, Reynolds number, and angle of attack information are input, and the pressure field and velocity field near the airfoil under the corresponding airfoil and flow conditions are output; the flow field data is visualized using processing software to facilitate subsequent work such as airfoil optimization, aerodynamic performance analysis, and aerodynamic noise prediction.
[0110] The above description is only an implementation mode of the present invention. It is stated again that for ordinary technicians in this technical field, several improvements can be made to the present invention without departing from the principle of the present invention. These improvements are also included in the protection scope of the claims of the present invention.
Claims
1. A flow field prediction method based on token selection Transformer, characterized by: The following steps are involved: S1, obtaining airfoil shape data set and real flow field data set; S2, extracting airfoil geometric parameters through token selection Transformer network; S3, construct parameter fusion network to fuse physical information features; S4, training the flow field prediction network based on multi-layer perceptron; S5, using the trained flow field prediction model to predict the pressure field and velocity field on different airfoil data; The step S2 specifically comprises the following steps: S21, serialize the airfoil images in the acquired airfoil shape data set, and perform i Block partitioning and flattening are performed to convert it into a series of two-dimensional tokens p i ,pic i and p i The expression is as follows: in, represents a set of real numbers, H, W and C represent the width, height and number of channels of the original image respectively, P represents the width and height of the selected partition block, N = H*W / P 2 Indicates the number of divided two-dimensional tokens; S22. Add a learnable embedding CLStoken to the acquired token sequence, with the dimension consistent with other token dimensions, and then obtain the complete token sequence representation I of each airfoil image, the specific expression of which is as follows: Among them, p cls Represents CLS token, p0, p1, ... p n-1 represents the n tokens obtained in step S21, D = P 2 *C represents the dimension of token; S23, reduce the dimension of I through a multi-layer perceptron network, so that the dimension of each token is reduced from D to I' is obtained, and its specific expression is as follows: S24, p' in step S23 cls As global features, p′0, p′1, ....p′ n-1 As a local feature, the global feature p′ cls With each local feature p′ i Perform splicing to obtain splicing features Its expression is as follows: S25. Record the N+1 splicing features obtained in step S24 as Then input it into another multi-layer perceptron network followed by a normalization layer to calculate the importance score vector S of the feature, which is expressed as follows: Among them, MLP() represents the function of the multi-layer perceptron network, and Softmax() represents the normalized exponential function, which converts the output of MLP into a probability value between [0,1]; S26. Use the importance score vector S to filter out the token index M with the top K importance among all N+1 tokens. The expression is as follows: M∈{0,1} (N+1)*K Each element in M is a one-hot indicator, and its value is selected from the set {0,1}; S27, use the transpose of the matrix M in step S26 and I to perform matrix multiplication to obtain the most important K airfoil parameter features of the given airfoil The step S3 specifically comprises the following steps: S31. For each grid point coordinate, calculate the shortest distance d to the airfoil geometry curve, which is expressed as follows: Where (x, y) represents the X-axis coordinate and Y-axis coordinate of the grid point. Indicates the X-axis and Y-axis coordinates of a point on the airfoil geometry curve; S32, construct a parameter fusion network, input the horizontal and vertical coordinates of each grid point, the shortest distance from the coordinate to the airfoil geometric boundary, and the normalized Reynolds coefficient and angle of attack into a multi-layer perceptron network for feature fusion and dimension upgrading, and finally obtain the physical information feature p phy , which is expressed as follows: in, and They represent the normalized Reynolds coefficient and angle of attack respectively, and D represents the characteristic dimension of the fused physical information, which is consistent with the characteristic dimension of each airfoil extracted in step S2.
2. The flow field prediction method based on token selection Transformer according to claim 1 is characterized in that: The step S1 specifically includes the following steps: S11, selecting a reference airfoil from the UIUC airfoil database, performing airfoil fitting by using a non-uniform rational B-spline interpolation method, and selecting a control point on the airfoil fitting curve as a new x-coordinate and y-coordinate of the current airfoil; S12, performing maximum and minimum normalization processing on all new airfoil coordinates in step S11, and the expression is as follows: Among them, x i ,y i Indicates the coordinates of the current airfoil, x min ,y min is the global minimum, x max ,y max is the global maximum value, x j ,y j is the normalized coordinate; S13, generating an airfoil shape grayscale image according to the normalized coordinates, wherein the pixel value on the airfoil geometry curve is 1, the pixel value not on the airfoil geometry curve is 0, and the pixel values at other positions are in the range [0,1], thereby obtaining an airfoil shape data set; S14, dividing the computational grid, performing CFD solution on the airfoil samples in the airfoil data set, obtaining real data of different airfoil samples under different flow conditions, and forming a real flow field data set.
3. The flow field prediction method based on token selection Transformer according to claim 1 is characterized in that: The step S4 specifically comprises the following steps: S41. Rank the top K airfoil parameter features by importance With physical information characteristics p phy As the input of the flow field prediction network based on the multi-layer perceptron, the output of the flow field prediction network is the flow field data corresponding to the grid point coordinates, and its expression is as follows: Among them, f predict ( ) represents the function of the flow field prediction network, and They represent the predicted values of the velocity component in the x direction, the velocity component in the y direction, and the pressure, respectively; S42. For the flow field prediction network, design the loss function Loss MLP The expression is as follows: Where N represents the total number of samples, u i , v i , p i Represents the true value of the x-direction velocity component, the y-direction velocity component and the pressure; S43. Train the model on the GPU server, set different model parameters and iteration steps for multiple rounds of training, and select the model with the smallest prediction error on the test data as the final flow field prediction model.
4. The flow field prediction method based on token selection Transformer according to claim 1 is characterized in that: The specific method of step S5 is as follows: Using the trained flow field prediction model, different airfoil characteristics, Reynolds numbers, and angle of attack information are input, and the pressure field and velocity field near the airfoil under the corresponding airfoil and flow conditions are output; the flow field data is visualized using processing software.
Citation Information
Patent Citations
Pollen image classification method based on cross attention distillation Transformer
CN113887610A
Airfoil optimization method fusing CNN (Convolutional Neural Network) and Swin Transform network
CN115795683A