Disclosure of Invention
The invention provides a method for quickly rendering infrared radiation characteristics of a hypersonic aircraft aiming at the requirement of quickly visualizing the physical field characteristics of the hypersonic aircraft, which is used for solving the problems of large data volume and slow rendering of the physical field characteristics of the hypersonic aircraft emphatically, realizing the mapping from a dense grid to a sparse grid by using a heterogeneous interpolation technology so as to reduce the data volume, and improving the rendering efficiency on the premise of ensuring the simulation reliability. The method comprises the steps of firstly, establishing a three-dimensional geometric model of the hypersonic aircraft, carrying out physical field resolving under typical working conditions, and obtaining temperature field data of the surface of the aircraft; completing heterogeneous interpolation of temperature field data, and realizing sparseness of the temperature field data; performing infrared physical field resolving according to the aircraft surface temperature field data obtained by interpolation, and calculating the infrared radiation of the aircraft surface; converting the infrared radiation brightness into color data, superposing infrared noise on the color data, and finally rendering the infrared radiation characteristic of the hypersonic aerocraft based on Unity 3D.
The invention provides a method for quickly rendering infrared radiation characteristics of a hypersonic aircraft, which specifically comprises the following steps:
establishing a three-dimensional geometric model of a hypersonic aircraft, and performing physical field resolving under typical working conditions to obtain temperature field data of the surface of the aircraft;
step 101, geometric creation: given key appearance parameters of the hypersonic aircraft, generating a geometric model of the hypersonic aircraft by using a NURBS (non-uniform rational B-spline) technology, and converting the geometric model into a standard STL format.
Step 102, geometric restoration: and (2) introducing the geometric model into a Fluent _ mesh (Fluent is computational fluid mechanics software, is divided into a grid division mode and a solution mode, and the grid division mode is expressed by the Fluent _ mesh) to divide the surface element and check and repair the geometric quality of the surface element.
Step 103, generating a computational grid of the CFD (computational fluid dynamics) of the hypersonic vehicle: and performing basin setting and key part encryption on the STL model of the aircraft, and setting parameters to generate a polyhedral mesh for CFD solution.
And 104, solving a physical field under a typical working condition: selecting Fluent as CFD calculation software, defining boundary and incoming flow conditions, giving basic solving parameters, performing CFD calculation, and obtaining all flow field resolving results after calculation convergence.
And 105, extracting temperature field data.
And step two, carrying out heterogeneous interpolation on the temperature field data to obtain a sparse grid suitable for rendering and temperature data mapping.
Step 201, grid calibration: the dense grid for CFD computation is aligned with the target sparse grid.
Step 202, reference point determination: most data are stored in a point-by-point mode, in the heterogeneous data mapping process, a reference point corresponding to a target mapping point needs to be determined, and a FLANN algorithm is used for searching a nearest neighbor point as the reference point.
Step 203, heterogeneous interpolation: and the data mapping among grids with different structures, densities and spatial relations is realized by adopting a simplex gravity center interpolation method.
And step three, calculating infrared radiation characteristics. And performing infrared physical field calculation according to the sparse grid temperature field data obtained by interpolation, and calculating the infrared radiation brightness of the surface of the aircraft.
And step four, rendering the infrared radiation characteristics of the hypersonic aerocraft based on Unity 3D.
The invention has the advantages that:
(1) the method constructs a complete technical process of rendering the infrared radiation characteristic of the hypersonic aircraft, and lays a foundation for subsequent multi-physical-field simulation and simulation data visualization of the hypersonic aircraft.
(2) The heterogeneous interpolation algorithm provided by the invention effectively reduces the data volume through the mapping from the dense computational grid to the sparse rendering grid. By adopting the FLANN and simplex gravity center interpolation method, the interpolation efficiency is high, and the method can adapt to high-dimensionality complex interpolation.
(3) The rendering process is based on Unity3D Shader, the rendering efficiency is high, and the rendering of the infrared radiation characteristic of the hypersonic aircraft can be realized under the condition of low resource consumption.
Detailed Description
The following describes in detail a specific embodiment of the present invention with reference to the drawings.
The invention provides a method for quickly rendering infrared radiation characteristics of a hypersonic aircraft aiming at the requirement of quickly visualizing the physical field characteristics of the hypersonic aircraft, and the overall flow chart is shown in figure 1. The method specifically comprises the following steps:
step one, establishing a three-dimensional geometric model of the hypersonic aircraft, performing physical field calculation under typical working conditions, and acquiring temperature field data of the surface of the aircraft. The method comprises the following specific steps:
step 101, geometric creation: given key appearance parameters of the hypersonic aircraft, generating a geometric model of the hypersonic aircraft by using a NURBS (non-uniform rational B-spline) technology, and converting the geometric model into a standard STL format. The expression form of NURBS surface is:
wherein p and q are spline orders (generally taken as 3), and Ni,p(u)、Nj,q(v) Node vectors in u and v directions (according to NURBS correlation rules, default values are selected), n and m are respectively the number of control points in u and v directions, and P isi,jCartesian coordinates, w, of control pointsi,jIs the weight of the corresponding control point. According to the expression, the key profile parameters comprise the Cartesian coordinates and the weight, P, of the key control points of the aircraft surfacei,jAnd wi,j。
The STL-formatted mesh generated by this step is subsequently referred to as a sparse mesh.
Step 102, geometric restoration: and (3) introducing the geometric model into the Fluent _ mesh to divide the surface element, and checking and repairing the geometric quality of the surface element, wherein the repairing is mainly used for repairing an error normal vector and a sharp surface element in the generation process of the geometric facet. The geometry after repair has no problems of free patches, multi-patch intersection, repeated patches and the like, and Skewness (deflection degree) is reduced to below 0.9.
Step 103, generating a CFD computational grid of the hypersonic aircraft: and performing basin setting and key part encryption on the aircraft STL format geometric model, and setting parameters to generate a polyhedral mesh for CFD solution. The parameters include the type of volume mesh (tetrahedral, hexahedral, etc.), the maximum and minimum cell sizes, the cell growth rate, the number of layers grown from a face or a curve.
And 104, solving a physical field under a typical working condition: selecting Fluent as CFD calculation software, setting basic solving parameters under a given typical working condition, and carrying out CFD calculation to obtain all flow field calculation results. The typical working conditions comprise the following parameters: the engine state (on, off), the flight Mach number Mach, the attack angle alpha, the flight altitude H, the atmospheric pressure P and the temperature T (the standard atmosphere USSA-1976 issued in 1976 in the United states is selected, and the corresponding atmospheric pressure and temperature can be obtained by table lookup after the flight altitude is given). The basic solution parameters mainly include: solver type (generally selected based on density solution), fluid type (compressible fluid or incompressible fluid), atmosphere type (selected ideal atmosphere), relaxation factor (between 0 and 1), and maximum number of iterations of solution (generally set to about 800).
And 105, extracting temperature field data.
The CFD flow field calculation result comprises data of multiple physical fields such as pressure, temperature and the like, and the required surface temperature field data is extracted after the calculation result is derived (in a CFD-Post format). The specific method for extracting the temperature field data comprises the following steps:
i. decomposing the flow field and acquiring surface grid data;
acquiring a connection relation of the surface grid points;
reading data of a required flow field on the surface grid points line by line;
and converting the extracted data into a Tecplot format for storage, wherein the first half of the data stores the coordinates (x, y, z) of the surface grid points and the corresponding temperature values, and the second half of the data stores the connection relation of the surface grid points.
In order to facilitate subsequent data processing, the Tecplot format data are segmented and stored as geometric data and temperature field data. The geometric data comprises surface grid point coordinates and grid point connection relations, and the temperature field data are temperature values of corresponding grid points. The segmented geometric data is subsequently referred to as dense grid data.
And step two, carrying out heterogeneous interpolation on the temperature field data based on a FLANN (fast nearest neighbor approximation search function library) and a simplex gravity center interpolation algorithm, and realizing data mapping from a dense grid to a sparse grid.
In fact, the number of dense grid data points used for the CFD calculation is too large, either with respect to three-dimensional rendering or further force analysis, coupling iteration data volume. Therefore, an effective heterogeneous interpolation algorithm is needed to map dense data onto the initially created sparse grid, so as to reduce the data volume of subsequent rendering. The heterogeneous interpolation process is shown in fig. 2, and three key problems to be solved are: grid alignment, reference point determination and heterogeneous interpolation. The method comprises the following specific steps:
step 201, grid calibration: firstly, reading in grid data and flow field data including dense grid, sparse grid and temperature field data by a reader. The dense grid and the target sparse grid are aligned by a comparator. For the X43A example, the normalized sparse grid and the dense grid used for CFD calculation adopt the same basic geometry, and the size, position, and angle are adjusted so that the sparse grid and the dense grid are in approximately the same spatial state.
Step 202, reference point determination: most data are stored in a point-by-point mode, in the heterogeneous data mapping process, a reference point corresponding to a target mapping point needs to be determined, and a finder is used for finding a nearest neighbor point by using FLANN to serve as the reference point.
The method adopts the dense grid point nearest to the target interpolation point in the XYZ coordinate system as the reference point. Considering the matching problem of the search algorithm, FLANN is used to implement this process, and the principle is that the fastest search method can be automatically selected from a plurality of basic search schemes according to the search characteristics, and a specific reference point search flow is shown in fig. 3. Firstly, respectively establishing sparse point queues and dense point queues according to read sparse grids and dense grids, and sequentially searching reference points of each point from front to back according to the sequence of the sparse point queues. For each point in the sparse point queue, FLANN (fast nearest neighbor approximation search function library) automatically selects the optimal algorithm from three search algorithms (K-D Tree, K-Means and Hierarchical Tree) to search the nearest neighbor point in the dense point queue and obtain indexes, wherein the indexes of the reference points are the search results.
Step 203, heterogeneous interpolation: and after the reference point is obtained, obtaining sparse temperature field data by adopting a heterogeneous interpolation algorithm.
The invention adopts a simplex gravity center interpolation method to realize data mapping among grids with different structures, densities and spatial relations. A schematic diagram of the interpolation of the simplex barycenter in different dimensions is shown in FIG. 4. Simplex is a generalization of triangles and tetrahedrons, an n-dimensional simplex refers to a convex polyhedron containing n +1 nodes (one-dimensional simplex is a line segment, two-dimensional simplex is a triangle, and three-dimensional simplex is a tetrahedron). Taking the solution of the P point data as an example, the length of the line segment in one dimension, the area in two dimensions and the volume in three dimensions are selected as weights, and the data of the P point can be obtained according to the data of the reference point. The principle can be summarized as the following formula:
Kx=ω1K1+ω2K2+...+ωnKn
in the formula, KxData for target interpolation points, K1,K2,…,KnData of the 1 st, 2 nd, … th, n reference points, ω1,ω2,…,ω n1,2, …, the weights of the n reference points (the sum of the weights is 1). KxAnd KnIt should be chosen according to the actual requirements, which refer to the temperature data of the corresponding vertex of the aircraft surface. The number of reference points is determined by the interpolation dimension, and the weight of interpolation is the volume ratio of the simplex.
The vertex is (v)0,…,vn) The volume calculation formula of the n-th order simplex of (1) is as follows:
in the present invention, the three-dimensional form shown in fig. 4(c) is adopted, 4 reference points are provided, and the interpolation weight is a volume ratio.
And thirdly, performing infrared physical field calculation according to the sparse grid temperature field data obtained by interpolation, and calculating the infrared radiation brightness of the surface of the aircraft.
As infrared radiation propagates through the atmosphere, certain wavelengths of radiation are gradually attenuated during transmission due to absorption and scattering by gases, vapors, solid particles and dust in the atmosphere. In the invention, only simulation of infrared radiation characteristics under the condition of zero-line-of-sight single working condition is considered. Relatively speaking, infrared radiation of three bands dominates, namely: 1-3 μm band, 3-5 μm band and 8-14 μm band. Infrared radiation detection is typically focused on these three bands, referred to as "atmospheric windows". Under supersonic speed and hypersonic speed states, infrared radiation under a wave band of 8-14 mu m is most remarkable and is suitable for being used as a key simulation wave band. Under the condition of the wave band, the calculation formula of the infrared radiation characteristic of the surface of the aircraft is as follows:
in the formula Iself(,Tw) Brightness of infrared radiation, TwIs the radiation source temperature; λ is the wavelength of the infrared radiation wave, λ1、λ2The upper and lower limit wavelengths of the selected infrared band; material emissivity of the facet; c. C1Is a first radiation constant having a value of c1=3.7419×10-16W·m2;c2Is a second radiation constant having a value of c2=1.4388×10-2m·K。
Step four, rendering the infrared radiation characteristics of the hypersonic aerocraft based on Unity3D, wherein the rendering process is shown in fig. 5. The method comprises the following specific steps:
step 401, data reading: in the scheme adopted by the invention, the rendering result is always reflected on the same set of standardized sparse grid, and the infrared field data needs to be updated frequently, so that the data extraction is divided into two parts, namely grid data reading in the initialization stage and infrared field data reading in the rendering stage.
(1) Grid data;
the sparse grid adopts an STL binary format, reading, splitting and rendering of STL binary grid data are realized based on a C # file interface, and the data are read and then stored in a UnityEngine in a Unity integrated data structure. The generation and the updating of the grids are mainly divided into four steps of node setting, connection setting, material setting and normal vector setting.
Node setting: XYZ coordinate information of each grid node in the sparse grid is extracted, and the node coordinate information is stored in a memory in the form of a linked list of third-order vectors.
Connection setting: based on the node storage sequence, the three points determine a triangular surface element for one group, and the triangular surface element is stored in a shaping array form.
Setting materials: and opening the rendering function of the vertex color in the material.
Setting a normal vector: the normal vector information is read from the STL.
(2) Infrared field data;
a binary format is adopted as a storage format of infrared field data, the binary data is quickly read into an internal memory by using a C # tool and is split, and the data is read and then stored in a self-defined one-dimensional floating point number array.
Step 402, infrared field data homogenization treatment: firstly, the data is mapped to an interval from 0 to 1 by adopting a linear normalization method, and then the data is homogenized.
Physical field distribution of the hypersonic vehicle, such as a pressure field, a temperature field, a speed field and the like, often generates distortion at key geometric nodes, so that flow field data are not uniformly distributed, and infrared field data need to be subjected to homogenization treatment. In fact, the flow field data is already in one-to-one correspondence with the gray information after being normalized, and the situation that the data distribution is not uniform is the same as the problem that the contrast of the gray image is too low, so the image sharpening algorithm is adopted for processing. The adopted algorithm is histogram homogenization, also called histogram flattening, and the image gray value can be subjected to nonlinear stretching through the algorithm, so that the distribution of pixels in a certain range is uniform, the homogenization process is shown in fig. 6, wherein an abscissa G in fig. 6 represents the gray level of the pixel, and an ordinate P represents the frequency of the gray level of the pixel (namely the number of the pixels).
Step 403, infrared rendering mapping: after the homogenization treatment, the infrared characteristic information which is stored on the surface of the aircraft in a gray information form is acquired, and then the characteristics in the infrared radiation divergence process are simulated by adopting a fragment shader method of infrared mapping. The implementation of this part can be divided into three main techniques: texture mapping, outward radiation and noise superposition, and the rendering process is based on Unity Shader.
(1) Mapping textures;
texture mapping refers to the overall control of the color mixing, hue, brightness, etc. of a rendered scene by inputting different texture pictures. In the present invention, different texture mapping schemes, such as gray scale, pseudo color, etc., may be employed for different application scenarios. The pseudo-color scheme comprises the following specific steps:
1) after the grid is read in step 401, a GameObject object (referred to as an aircraft object for short) is created, and the infrared field data processed in step 402 is used as the color data of the vertex, so as to update the mesh filter.
2) The self-defined Shader1 performs patch rendering on the aircraft grid data, the RenderType is set to Opaque, the LOD is set to 200, a basic surface Shader mode is adopted, and the FallBack is set to Diffuse. And then binding Shader1 to the mashRenderer material of the aircraft object to finish rendering the patch.
3) Custom Shader2 renders aircraft infrared radiance. Reading in texture pictures of color codes; in essence, the infrared field data processed in step 402 takes values between (0,1), and may correspond to the color patch texture as gray scale data; writing a fragment shader function frag1, and sampling color patch textures by using a tex2D function according to gray data to obtain corresponding pixel color values; and binding the Shader2 to the Main camera to realize the rendering of the infrared radiance of the aircraft.
(2) Radiating outwards;
the light itself has the characteristics of refraction, reflection, diffraction and the like, and the light which is usually intuitively perceived has the effect of divergence and is different from a pure color boundary. The invention adopts the fuzzification method to simulate the light divergence effect, and can obviously sense the radiation from a high radiation area to a low radiation area. The specific implementation method comprises the following steps:
1) let _ MainTex be a white picture and use the tex2D function to perform texture sampling to obtain the pixel color c. The color description class color in Unity is used to deliver color throughout Unity, in the form of (r, g, b, a), each color component is a floating point number between 0 and 1, the component (r, g, b) defines a color in the RGB (red green blue) color space, and the Alpha component (a) represents transparency.
2) Setting the four-dimensional texture coordinate offset [4] (-0.3, 0.4; -0.3, -0.4; 0.3, -0.4; 0.3,0.4), the variable glow is calculated:
glow=0.0113*(2.0-max(c.r,c.g))
and then, performing four times of offset texture sampling on the pixel color c according to a four-dimensional offset [4], and controlling the blurring degree by adjusting a _ BlurAmount parameter:
c’=c+tex2D(_MainTex,i.uv+_BlurAmount*glow*offsets[j])
where c' is the processed pixel color, c is the pixel color sampled in step 1), tex2D is the texture sampling function of unity, i.uv is the texture coordinate, _ BlurAmount is the blur level, glow is the intermediate variable for calculation, and offsets [ j ] is the given texture coordinate offset (j is 1,2,3, 4).
3) And binding Shader2 to Main camera to realize outward radiation rendering effect.
(3) Noise superposition;
and simulating the noise to simulate the effect of receiving the infrared image by the infrared receiver under the condition of different signal-to-noise ratios. The method comprises the following specific steps:
1) and generating a Berlin noise texture picture.
2) The noise texture picture is read in, and the UV coordinate offsets (_ rnd.x, _ rnd.y) are set.
3) The fragment Shader function frag3 is written in Shader2 and the noise texture is sampled from the offset UV coordinates using the tex2D function.
4) Binding Shader2 to Main camera can directly render the noise effect.