Visual reality simulation method for harmful gas diffusion concentration value in virtual reality training scene

By combining CFD calculation and visualization technology, accurate visualization of the diffusion concentration values ​​of harmful chemical gases in virtual reality scenes is achieved, solving the problem of poor visual realism and providing a realistic training environment.

CN120745480APending Publication Date: 2025-10-03CHINESE PEOPLES LIBERATION ARMY ARMY CHEM DEFENSE COLLEGE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510737584.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-04
Publication Date
2025-10-03

AI Technical Summary

Technical Problem

The visualization effect of the diffusion of harmful chemical gases in existing virtual reality scenes cannot correspond one-to-one with the gas concentration data, resulting in poor visual realism and inability to scientifically guide virtual training for gas diffusion accidents.

Method used

Combining CFD calculation and visual visualization technology, accurate visual simulation of gas concentration values ​​is achieved through gridded volume fog units, multi-noise function optimization and lighting rendering, including data format conversion, spatial coordinate conversion, concentration data mapping and lighting calculation.

Benefits of technology

The gas diffusion scene has achieved a strong visual realism, which can scientifically display the diffusion trend of the accident, making it easier for rescue personnel to understand the laws of the accident and improve training effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120745480A_ABST
    Figure CN120745480A_ABST
Patent Text Reader

Abstract

The invention provides a visual reality simulation method for a harmful gas diffusion concentration value in a virtual reality training scene. The method comprises the following steps: step 1, processing CFD (Computational Fluid Dynamics) data of a virtual three-dimensional environment space based on a time sequence; step 2, carrying out numerical visual mapping of chemical harmful gas attributes and CFD concentration data through the gridded volume fog unit; 3, constructing a plurality of gas concentration scene visual reality optimization of noise superposition processing in the gridding volume fog unit; 4, realizing a rendering visual scene with a visual vivid effect of concentration diffusion under the action of illumination and gas molecules in the grid space; and 5, screening and processing the concentration data based on a threshold value, improving the rendering calculation efficiency, and realizing a real-time gas diffusion visual scene with a visual vivid effect. The chemical harmful gas diffusion CFD concentration value result can be accurately and visually simulated, the obtained harmful gas diffusion virtual reality scene can fully reflect CFD concentration value data details, and the visual effect is high in reality sense.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method for simulating the scientific visualization and visual realism of the diffusion of toxic and harmful gas concentrations in a virtual reality (VR) scene, and belongs to the technical field of visualization simulation training of harmful gas diffusion in a virtual reality environment. Background Art

[0002] Currently, accidents and incidents such as hazardous chemical explosions and toxic gas leaks pose a significant threat to public health and life. Virtual reality (VR) technology is being widely used to create realistic chemical gas diffusion training scenarios, allowing rescue workers to immerse themselves in them, understand the patterns of gas diffusion, and organize appropriate response training accordingly.

[0003] In the past, virtual reality scenes of chemical harmful gas diffusion mainly used random algorithms to generate smoke-like effects, which were only schematic. Instead of achieving a one-to-one correspondence between gas concentration values ​​at different time positions and real visualization effects in three-dimensional space based on gas concentration data, it caused the problem of distorted visual effects in gas diffusion simulation.

[0004] The goal of visual realism is to ensure that the gas diffusion visualization in a virtual reality environment reflects the effects of gas properties, concentration, lighting, and distance on human vision. By enhancing the realism of virtual reality gas diffusion scenes, the resulting virtual reality scenes can be used to scientifically demonstrate the diffusion of hazardous gases in accidents such as leaks and explosions, facilitating accident research and providing a direct understanding of the hazards faced by rescue personnel. Furthermore, they can be used to construct virtual reality training scenarios for gas accidents, meeting the urgent need for improved training effectiveness in immersive accident scenarios.

[0005] Computational Fluid Dynamics (CFD) technology has matured. Numerous comparisons of simulation and experimental results have shown that the diffusion patterns of hazardous gases calculated using CFD models are highly consistent with experimental measurements. Therefore, CFD has become the primary method for simulating and predicting the hazards of such gas diffusion accidents. However, the spatial concentration distribution of hazardous chemical gas diffusion calculated using CFD models is limited in its presentation, typically displayed via a two-dimensional interface or, in conjunction with a GIS system, a three-dimensional scatter plot. These results are primarily used for theoretical research on hazardous gas diffusion patterns. Only a few researchers have studied the visualization of CFD simulation results in virtual reality environments, which lacks the realistic visual quality of human vision. Furthermore, some techniques use randomized algorithms from computer graphics to simulate the concentration distribution of hazardous gas diffusion to construct virtual reality scenarios. While these scenarios produce highly realistic diffusion effects, they focus solely on visual effects and fail to map variations in gas concentration values ​​to the level of visualization. Consequently, they can only be used for schematic virtual training, failing to achieve the realistic correspondence between gas diffusion patterns within a virtual environment and providing ineffective guidance for virtual training of gas diffusion accidents.

[0006] To address issues such as inconsistent data formats for gas diffusion concentration field data and visualization tools, how different concentration clouds correspond to different visualization effects, and poor realism, the present invention proposes a visual visualization simulation method that combines gas diffusion CFD calculations with visual visualization technology to achieve precise mapping of chemical gas diffusion concentration values ​​in virtual reality scenes. This method primarily relies on CFD simulation to obtain scientifically accurate spatial distribution data of harmful gas diffusion concentrations. Through spatial processing of CFD concentration data such as position and time, numerical mapping using a gridded volume fog unit method, scene realism optimization based on multiple noise functions, and visual rendering of grid space lighting and gas molecule interactions, the method achieves a highly realistic gas diffusion visualization simulation effect. The simulation effect corresponds one-to-one with the gas diffusion concentration numerical results, achieving a scientific visualization effect for human vision. This method solves the problem that previous chemical gas diffusion virtual reality scenes used random algorithms to generate similar smoke effects, but could not achieve a one-to-one correspondence between gas concentration values ​​at different time positions and the actual visualization effect in three-dimensional space based on measured concentration data or CFD numerical simulation results, resulting in poor visual realism of gas diffusion simulations. Summary of the Invention

[0007] The present invention relates to a method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality scene. This method achieves a harmful gas diffusion scene in a virtual reality space that approximates the gas diffusion scene's visual effects to those seen by the human eye in real life, namely, visually presenting the gas concentration visualization realism. This visual realism ensures that the gas diffusion visualization scene's visual effects, influenced by varying gas properties, lighting, and gas diffusion concentration values, are realistic.

[0008] The method of the present invention is applied to achieve scientific visualization mapping between CFD concentration data of harmful gas diffusion and virtual reality scenes obtained by visualization simulation, and a scene rendering optimization method is used to make the diffusion scene vivid and realistic, thereby improving the realism of the virtual reality gas diffusion scene. The obtained virtual reality scene can be used to scientifically demonstrate the diffusion trend of harmful gases in accidents such as leakage and explosion, facilitating relevant accident research and rescue personnel to intuitively understand the laws of accident hazards. It can be used to construct virtual reality training scenes for gas accidents, meeting the urgent need of personnel to improve training effects in immersive and realistic chemical accident scenes.

[0009] The method proposed in the present invention can accurately visualize and simulate the CFD concentration value results of chemical harmful gas diffusion. The obtained virtual reality scene of harmful gas diffusion can fully reflect the details of the CFD concentration value data. The scene effect corresponds one-to-one with the CFD data of gas diffusion concentration, and the visual effect has a strong sense of reality.

[0010] The present invention provides a method for realizing a precise visualization simulation of the diffusion of toxic and harmful chemical gases in a virtual reality scene by combining CFD calculation results, comprising the following steps:

[0011] Step 1: Time-series-based CFD data processing of gas diffusion concentration in a virtual three-dimensional environment.

[0012] The precise concentration field data for gas diffusion in a virtual 3D environment is unified with the data format of visualization tools. Using CFD methods, gas diffusion concentration values ​​affected by wind direction, wind speed, and terrain are calculated to obtain CFD concentration data at discrete time / space points. This CFD concentration data for chemically hazardous gases is processed and converted into a time-series-based database supported by the virtual 3D environment (Unity3D).

[0013] (1) CFD concentration data format conversion

[0014] (a) Data conversion to ASCAII. In CFD software (such as Fluent), export the grid node spatial coordinates and the corresponding toxic gas mass concentration data to ASCAII format.

[0015] (b) ASCAII to .txt. Open the ASCAII data using Notepad and save it in .txt format. The data contains multiple lines of data, each representing the x, y, and z coordinates of a grid node and the toxic gas mass concentration at that node.

[0016] (c) Convert .txt to .csv. Use relevant software to open the .txt file and save it as .csv format.

[0017] (2) Establish a database and support reading time-series-based CFD concentration value data

[0018] (a) Create a database. Import the .csv file into a lightweight database software (e.g., SQLite) in a relational database management system to create a database.

[0019] (b) Reading data. The data reading interval is determined based on the CFD data interval and actual needs. Data can be read from the database to the virtual reality environment software at fixed intervals.

[0020] (3) Virtual reality space coordinate system conversion

[0021] The coordinate system of CFD data is inconsistent with that of virtual reality space (such as Unity3D construction space), which will cause the concentration data to not match the virtual scene. The problem can be solved by changing the order of coordinate axis assignment.

[0022] (a) Assign the x-coordinate value in the CFD data to the x-coordinate in the virtual reality space;

[0023] (b) assigning the value of the y coordinate in the CFD data to the z coordinate in the virtual reality space;

[0024] (c) Assign the value of the z coordinate in the CFD data to the y coordinate in the virtual reality space.

[0025] Step 2: Numerical visualization mapping of chemical hazardous gas properties and CFD concentration data is performed through gridded volumetric fog cells.

[0026] There are two main problems in the realistic visualization of harmful gas clouds with different concentrations: one is how to simulate the gas diffusion effect at different positions in three-dimensional space based on CFD data visualization, and the other is how to simulate the gas diffusion effect at different concentration values ​​based on CFD data visualization.

[0027] To address the first issue, a specific numerical mapping method is used to map small spaces within the CFD concentration data to small spaces within the volumetric fog. This method theoretically allows for the expression of harmful gas diffusion effects at different locations in space. By reading in harmful gas concentration data from spatial grid nodes and numerically mapping them to corresponding locations in space (a relatively small space), volumetric fog points are generated. Each data point generates a volumetric fog point, and the collection of all data points is mapped to form a collection of fog points. This creates a fog effect scenario of gas diffusion at different locations in space, as shown in the following two sections.

[0028] (1) Visual numerical mapping. The processed and coordinate-converted gas CFD concentration data is converted into an abstract visual object. That is, the position corresponding to each data point in the virtual environment constructed by the virtual reality software is mapped to generate a volumetric fog unit. Here, the abstract visual object is used to represent the toxic gas diffusion scene in the virtual environment. The gas properties include gas molecule size, color, transparency, etc., which need to be determined in combination with the color, density and other properties of the toxic and harmful gas.

[0029] (2) Modify the abstract object properties of the volume fog unit according to the grid. The concentration field data grid is mapped to the volume fog space size. However, the spatial discretization during concentration field calculation is non-uniform. Therefore, it is necessary to modify the size of the volume fog unit according to the grid size at different locations to reasonably determine the radiation range of the volume fog unit.

[0030] To address the second issue, we study the expression of volumetric fog density. In volumetric fog, the thickness of the fog effect and other visual effects are controlled by the fog density Fog.density, as shown below (3).

[0031] (3) Concentration data normalization is used to map the concentration data values ​​at the corresponding positions to the volume fog unit.

[0032] Uniformly display the visualization effects of all concentration ranges of toxic gases in the space, from the highest concentration to the lowest concentration. Using the normalization method, the concentration value is normalized to (0, 1) and then numerically mapped to the fog density Fog.density of the volume fog. Fog.density is used to show different visualization effects of clouds with different concentrations.

[0033] Step 3: Construct multiple gas concentration scenes with noise superposition processing in the gridded volume fog unit to optimize the visual realism.

[0034] To address the issue of abrupt scene transitions and poor visual realism caused by different concentration values ​​at different locations, the following steps are performed.

[0035] (1) Construct a noise function.

[0036] (a) Construct a noise generator. Construct two functions, Noise(int x, int y, int z) and SmoothNoise(int x, int y, int z). If the input (x, y, z) is located at an integer grid point, the Noise(int x, int y, int z) function outputs a random noise between -1 and 1. If the input (x, y, z) is not located at an integer grid point, the SmoothNoise(int x, int y, int z) function generates a random gradient value, which is the weighted average of the Noise(int x, int y, int z) values ​​of the eight nearest integer grid points.

[0037] (b) Calculate the pseudo-random gradient value of the grid points around the gridded volume fog unit. Assume that the coordinates of the 8 integer grid points closest to the input position are (x0, y0, z0), (x1, y0, z0), (x0, y1, z0), (x1, y1, z0), (x0, y0, z1), (x1, y0, z1), (x0, y1, z1) 1, y1,z1), apply Smooth Noise(int x,int y,int z) function to calculate the pseudo-random gradient value l at each grid point i , i is 1-8.

[0038]

[0039] Among them, x0, x1, y0, y1, z0, and z1 are all integers, representing spatial coordinate values.

[0040] (c) Perform K harmonic interpolations on the x coordinate. Apply S(t)=6t to the above equation (1). 5 -15t 4 +10t 3 The function performs K harmonic interpolations on l1 and l2, l3 and l4, l5 and l6, l7 and l8 in sequence at coordinate x, as shown in the following formula (2) where K = 5, and obtains the results m1, m2, m3, and m4;

[0041]

[0042] (d) Perform K harmonic interpolations on the y coordinate. Use the same method to apply equation (3) to perform K harmonic interpolations on m1 and m2, m3 and m4 on the y coordinate to obtain the results n1 and n2;

[0043]

[0044] (e) Perform K harmonic interpolations on the z coordinate. Use the same method to apply Equation (4) to perform N harmonic interpolations on n1 and n2 on the z coordinate, and finally obtain the noise value P of the input position point (x, y, z).

[0045]

[0046] At this point, the unique noise value at the corresponding position can be obtained by inputting the position. However, the texture effect obtained by using a single noise is not realistic. In order to obtain a noise texture that is more consistent with the natural world, a method of superimposing multiple noises is usually used.

[0047] (f) Superimposed noise: Multiple noises are weighted and superimposed using Equation (5). By changing the amplitude, frequency, and frequency doubling of the superimposed noise, a more detailed and realistic fog noise texture is produced.

[0048]

[0049] Where P is the amplitude. The larger the amplitude, the rougher the noise effect, and the smaller the amplitude, the smoother the noise transition. α is the frequency, that is, the interval size of the sampling data. The higher the frequency, the more details the noise texture shows, and of course the more calculations are required. N is the frequency multiplication, that is, the number of superimposed noise functions. The larger the frequency multiplication, the smaller the influence of each noise in the produced noise.

[0050] (2) Use noise function to optimize gas concentration scenario.

[0051] (a) The spatial coordinates are passed as input to the noise function, which returns a series of continuous noise values ​​(between -1 and 1) through function calculation.

[0052] (b) Map the noise value output by the noise function to between 0 and 1, multiply it by the gas concentration value information in the texture data, and save it back to the original texture.

[0053] ρ(x,y,z)=ρ0+k·n(x,y,z) Formula (6)

[0054] Among them, ρ(x,y,z) represents the volume fog density at the spatial position (x,y,z), ρ0 is the basic volume fog density, k is the noise influence coefficient, and n(x,y,z) is the noise value at this position. Its value range is usually [0,1]. By adjusting the value of k, the degree of influence of noise on the volume fog density can be controlled.

[0055] This not only achieves a continuous and natural transition in the visualization of concentration changes between CFD grid format data, but also adds a certain amount of noise disturbance, which is more in line with the actual gas changes and can achieve the purpose of optimizing the realism of the gas fog effect.

[0056] Step 4: Rendering a visualization scene that achieves a realistic visual effect of concentration diffusion caused by the interaction of light and gas molecules in the grid space;

[0057] The concentration of gas molecules is calculated in a relatively closed grid space (noise function sampling), and then the physical interactions between the incident light and the gas molecules (i.e., light scattering, transmission, and absorption) are calculated step by step. The calculation results of each step are accumulated to obtain the interaction between light and gas molecules. Then, by sampling the shadow texture and corresponding rendering processing, the visual scene is rendered onto a screen such as a display.

[0058] (1) Calculation of light scattering rate

[0059] The Rayleigh phase function is used to describe the angular distribution of short-wavelength light in various directions during the scattering process.

[0060]

[0061] For long-wavelength light, the Henye-Greenstein phase function is used for simulation. The parameters in the formula have the same meaning as the parameters of the Rayleigh phase function mentioned above.

[0062]

[0063] In formulas (7) and (8), θ represents the angle between the light direction and the observer's line of sight, that is, the scattering angle; g represents the asymmetric factor anisotropy, which describes the directional dependence of the scattered light, that is, the amount of scattering in one direction. The value range is [-1, 1]. A positive value indicates backscattering, and a negative value indicates forward scattering.

[0064] (2) Light transmission calculation

[0065] The Lambert-Beer law model is used to determine light transmission. This model states that light transmittance is exponentially related to the distance the light travels through a medium. Simply put, T is the energy remaining after light travels a certain distance through a medium, after consuming the energy lost due to scattering and absorption. This is the transmittance from A to B.

[0066]

[0067] Where e is the base of the natural logarithm, and βe(x) is the sum of the scattering and absorption coefficients. This formula integrates the βe() function over all points x in the medium where light passes, yielding the current energy of the light particle A->B.

[0068] (3) Ray tracing

[0069] The above integral is obtained by transmitting light to each pixel on the screen and iterating multiple times. Move along the ray with a pre-calculated step size, integrating the results of each step until the transmittance reaches 0, or the maximum number of steps is reached. Ray tracing technology is a rendering technology that realizes the illumination of light sources in the scene and indirect illumination after reflection of objects. It can simulate the real-world lighting in real scenes. With the help of rasterization technology, the computer converts the triangular facets that make up the 3D model into pixels on the 2D screen, assigns an initial color value to each pixel based on the data stored in the triangle vertices, changes the pixel color based on the collision of light and pixels in the scene, applies the above-mentioned noise texture to the pixels, and generates the final color applied to the pixels.

[0070] (4) Add shadow texture

[0071] In order to simulate a real shadow effect, the shadow texture needs to be sampled so that the algorithm can determine whether a point in space is in shadow, and the result is saved to the texture.

[0072] Step 5: Filter and process the concentration data based on the threshold value to improve the rendering calculation efficiency and realize a real-time gas diffusion visualization scene with realistic visual effects.

[0073] Visualizing the concentration data of all data points would be computationally intensive, making real-time rendering difficult on standard computers. This would result in significant delays and lags in the training scene. Two approaches were used to address this issue: one was to filter the gas diffusion data based on the hazardous concentration of hazardous chemical gases, visualizing only those data points above a certain concentration and discarding all other data points. The other approach was to filter the data from the perspective of the virtual trainee, limiting the data points visible within their field of view to those that were obscured during display.

[0074] Therefore, gases below the threshold concentration are no longer the focus of virtual training and can be discarded. Only screening out data points with values ​​greater than or equal to the threshold concentration will not have a negative impact on training. On the contrary, it can promote the actual organization and implementation of virtual training according to the actual hazard range of the accident, thereby improving training efficiency and effectiveness.

[0075] Threshold-based mixture models

[0076]

[0077] Among them, ρ0 and ρ1 are different volume fog density values, T is the threshold, and n(x, y, z) is the noise value. When the noise value is greater than the threshold, ρ1 is used as the volume fog density, otherwise ρ0 is used. This model can achieve specific effects by adjusting the threshold and different density values.

[0078] Filtering data from the perspective of trainees in virtual training can significantly reduce the number of rendered harmful gas volume fog units without almost affecting the visualization effect from the trainees' perspective.

[0079] Compared with the prior art, the present invention has the following beneficial effects:

[0080] 1. The method described in the present invention can visualize the harmful gas spatial concentration field data obtained by CFD calculation, obtain a chemical harmful gas diffusion scene that conforms to real laws, and achieve the realism of the visual effect of the harmful gas concentration diffusion scene. The chemical harmful gas diffusion scene created by the invention is vivid and lifelike, and can provide a gas diffusion simulation training environment with realistic visual effects and in line with scientific laws for emergency rescue virtual training of chemical hazardous gas leaks and explosion accidents.

[0081] 2. This invention utilizes volumetric fog atomization technology and noise function realism optimization technology from computer graphics, innovatively combining them with CFD calculation methods for gas diffusion concentration to produce visual effects that better align with the actual spatial concentration distribution of hazardous gases. Since the gas diffusion CFD method already considers factors such as altitude, temperature, and wind field when studying gas diffusion concentration values, this method cleverly combines the CFD concentration value with the volumetric fog density, effectively addressing the effects of altitude, temperature, and wind field on fog density. It also uses noise functions to address the lack of detail in volumetric fog, improving realism and simulating a more accurate and realistic gas diffusion effect. This method fully reflects the visual impact of the spatial distribution of hazardous gas concentrations, facilitating relevant personnel's understanding of the harmful gas diffusion hazards associated with related accidents. This method achieves realistic visualization of gas concentration CFD data in the virtual reality engine Unity3D, providing insights for constructing realistic virtual environments for gas hazard incidents based on VR.

[0082] 3. This invention takes advantage of the gridded volumetric fog unit method to create a highly realistic gas diffusion effect. It innovatively maps spatial concentration data one by one into gridded volumetric fog units. This method can not only reflect scientific CFD gas concentration data, but also create an atomization effect similar to smoke when toxic gases diffuse, providing a new way to realistically visualize harmful gas concentration field data. BRIEF DESCRIPTION OF THE DRAWINGS

[0083] Figure 1 It is a schematic flow diagram of the present invention.

[0084] Figure 2a Visualization rendering effect of the same chemical harmful gas changing dynamically over time (12 seconds). Figure 2b Rendering effect for visualization of the same chemical harmful gas changing dynamically over time (44 seconds).

[0085] Figure 2c Output the diffusion effect of harmful chemical gases in a simulated three-dimensional environment and the concentration data at any point.

[0086] Figure 3 This is the diffusion visualization effect of harmful chemical gases in a virtual reality scene achieved by the method of the present invention.

[0087] Figure 4 It is the visual effect of the diffusion of harmful chemical gases in a real training scene in a documentary about chemical defense troops. DETAILED DESCRIPTION

[0088] The present invention is applied to realize the visualization process of the diffusion visual effect of a certain chemical harmful gas (referred to as chemical harmful gas No. 1).

[0089] The following steps are to visualize the diffusion of hazardous chemical gas No. 1 over a 1,000 square meter mountainous terrain containing buildings for 5 minutes under sunny conditions and a force 3 easterly wind:

[0090] Step 1: CFD data processing of chemical harmful gas concentration No. 1:

[0091] (1) No. 1 chemical hazardous gas CFD data format conversion.

[0092] (a) Data conversion to ASCAII. In Fluent software, select to export the grid node spatial coordinates and the corresponding toxic gas mass concentration data to ASCAII format.

[0093] (b) ASCAII to .txt. Open the ASCAII data using Notepad and save it in .txt format. The data contains over 700,000 lines of data, each representing the x, y, and z coordinates of a grid node and the mass concentration of the No. 1 chemical hazardous gas at that node.

[0094] (c) Convert .txt to .csv. Use Excel to open the .txt file and save it as .csv.

[0095] (2) Establish a database and read the time-based CFD concentration value data.

[0096] (a) Establish a database. The .csv file is imported into a SQLite database (a lightweight, ACID-compliant relational database management system) by assigning database table names based on diffusion duration, gas type, and wind speed. Concentration query indexes are assigned to the records in the database. This significantly speeds up cross-queries under complex conditions, enabling real-time acquisition of concentration values ​​(querying millions of records takes less than 0.05 seconds).

[0097] (b) Reading data. A timer is added to the code to obtain the current time in real time. When the interval reaches 10 seconds (i.e., data is read every 10 seconds), the weather, wind speed, diffusion time, and gas type 1 stored in the queue are used as parameters in a SQL statement to query the database. The concentration query interface method is called to read the data into the virtual reality environment software Unity3D.

[0098] (3) Space coordinate system conversion:

[0099] The CFD data is inconsistent with the Unity3D space coordinate system, which will cause the concentration data to not match the virtual scene. The problem is solved by changing the order of coordinate axis assignment.

[0100] (a) Assign the x-coordinate value in the CFD data to the x-coordinate in Unity3D;

[0101] (b) Assign the value of the y coordinate in the CFD data to the z coordinate in Unity3D;

[0102] (c) Assign the z-coordinate value in the CFD data to the y-coordinate in Unity3D.

[0103] Step 2: Use the gridded volume fog unit to perform numerical visualization mapping of the properties and concentration of chemical harmful gas No. 1:

[0104] (1) Visual Mapping. Convert the processed and coordinate-converted CFD data into an abstract visual object. That is, map the position corresponding to each data point in the Unity3D virtual environment to generate a volumetric fog unit. Select Density and its sub-options in the software's third-party library interface, find the dynamic library where the Density function is located, and pass the normalized concentration value into the Strength assignment.

[0105] (2) Modify the abstract object properties. The size of the volumetric fog unit needs to be modified according to the grid size at different locations to reasonably determine the radiation range of the volumetric fog unit. In this paper, the radiation range of the volumetric fog is set to 20m based on the average size of the grid division.

[0106] (3) Normalization of concentration data and numerical mapping. Using the normalization method, with the minimum value of the gas concentration being 0 and the maximum value being 1, all concentration values ​​are normalized to (0, 1). Then, the value of Fog.density is adjusted in real time according to the changes in the gas concentration value. The fog density Fog.density controls the thickness of the fog effect. The larger the value, the higher the fog density, that is, the thicker the fog effect. The smaller the value, the lower the fog density, that is, the thinner the fog effect. The visualization effect of all concentration ranges is displayed. A script that updates the value of each volume fog unit is mounted on it.

[0107] Step 3: Optimize the scene realism by superimposing multiple noise functions on the gridded volume fog unit:

[0108] (1) Constructing a noise function. The invention uses the third-party library Aura2 to construct a noise function according to the method described in the invention content, and calculates the pseudo-random gradient value of the grid points around the gridded volume fog unit. Five harmonic interpolation operations are performed on the x-coordinate, y-coordinate, and z-coordinate respectively. By changing the amplitude, frequency, and frequency doubling of the superimposed noise, a more detailed and realistic smoke noise texture is produced.

[0109] (2) Use noise function to optimize the scene.

[0110] (a) Set the noise function's starting point to (0, 0, 0), its rotation to (0, 0, 0), its scale to 1, and its spatial coordinates to the default. Find the dynamic library containing the noise function and use code to set its sampling speed to 1.

[0111] (b) Unity3D maps the output noise value to between 0 and 1, automatically multiplies it by the concentration information in the texture data, and then saves it back to the original texture.

[0112] Step 4: Render the gas concentration diffusion under the action of grid space lighting and gas molecules to obtain the final visualization scene:

[0113] (1) Since Unity does not support precise custom lighting settings, the visual rendering of the present invention is completed using the third-party library Aura2. First, import the third-party library, and then check the lighting options Light in its software interface.

[0114] (2) Find the dynamic library where the illumination function is located and use code to set the illumination color, intensity, filter value, and filter range. The color of the gas is affected by the color of the light source and will appear different colors during visualization.

[0115] (3) Add shadow texture

[0116] (a) Save the shadow texture. Create a command buffer mounted on the light component and set it to execute after the shadow texture is created. Unity3D generates the shadow map using the same parameters as the current rendering object and automatically saves it as "ShadowMap".

[0117] (b) Calculate the shadow map coordinates. Use the depth value of the current pixel to calculate the world space coordinates of the current pixel. Use the world space coordinates and the cascade weights to calculate the coordinates of the shadow map corresponding to the point on the ray.

[0118] (c) Sample the shadow texture. Use the shadow map coordinates to sample the shadow texture, determine whether the point on the ray is in the shadow, and save the result to the shadow item.

[0119] After adding shadow textures, the three-dimensional scene built by Unity3D will be closer to the shadow effect of the real environment.

[0120] (4) Call the function of the dynamic library to perform mixed calculation processing on the geometric objects and gases in the scene, and sample their surfaces to obtain surface color values, thereby obtaining the scene rendering results.

[0121] The color of the gas is dynamically affected by the color of the light source and will appear in different colors during the visualization process, as shown in Figure 2.

[0122] Step 5: Filter concentration data to improve rendering efficiency and achieve the final real-time visualization of the gas diffusion scene:

[0123] The minimum hazardous concentration of gas No. 1 to personnel is 5 mg / m 3 Long-term exposure (more than 10 minutes) to this concentration will be harmful to health. Only filtering out data points with concentration values ​​greater than or equal to the threshold concentration will not have a negative impact on training.

[0124] Data was filtered from the trainee's perspective. Three methods were used to improve rendering efficiency. First, frustum culling was enabled automatically by Unity when the game scene was running, requiring no additional configuration. Next, occlusion culling was enabled by checking Occusion Culling in the camera options. In the Inspect Properties panel, volumetric fog units that might be occluded were set to static (Occluder Static). Occusion Culling was selected under Windows options, and baking was performed. Near and far culling was enabled to eliminate volumetric fog units more than 100 meters from the camera. Experiments showed that using this data filtering method to process visualization data significantly improved visualization rendering efficiency, resulting in smooth, uninterrupted images. This not only significantly reduced the amount of computation required, but also had minimal impact on the realism of the visualization scene.

[0125] Figure 3 This method generates diffusion scenes and Figure 4 Comparison of toxic gas diffusion effects in real scenarios.

[0126] In response to the problems raised in the background technology, the present invention utilizes CFD data processing technology, a gridded volume fog unit mapping method, a noise function scene optimization technology, and a visualization rendering technology to realize a visualization visual simulation using the CFD calculation results of gas diffusion concentration, solving the problem of the harmful gas concentration value not corresponding to the visualization simulation effect. Using the method of the present invention, developers only need to obtain accurate CFD simulation results of harmful gas diffusion, and follow the above steps to process data, visualize concentration values, optimize realism, and render visually, so as to obtain a virtual reality scene of harmful gas diffusion corresponding to the CFD data through visualization simulation, and the visual effect of the scene is vivid and realistic and conforms to the laws of reality. If the CFD simulation results take into account the dynamic effects of complex factors such as terrain, building obstruction, weather, and the properties of harmful gases on gas diffusion, the harmful gas diffusion scene obtained by visualization simulation can also reflect the effects of the above complex factors on its diffusion scene. Accordingly, the present invention can be used to guide theoretical research on the laws of relevant accident hazards, and can also be used to construct a realistic virtual reality training environment for relevant accidents.

[0127] The present invention is not limited to CFD results of chemical harmful gas diffusion concentration. Others can also use the method of the patented invention to visualize and simulate other types of CFD results, such as temperature fields and wind fields, to obtain scene effects that correspond one-to-one with the CFD results.

Claims

1. A method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality training scene, characterized in that: It includes the following steps: Step 1: Time-series-based CFD data processing of gas diffusion concentration in virtual 3D environment space; Step 2: Use gridded volumetric fog cells to perform numerical visualization mapping of chemical hazardous gas properties and CFD concentration data; Step 3: Construct multiple gas concentration scenes with noise superposition processing in the gridded volume fog unit to optimize the visual realism; Step 4: Rendering a visualization scene that achieves a realistic visual effect of concentration diffusion caused by the interaction of light and gas molecules in the grid space; Step 5: Filter and process the concentration data based on the threshold value to improve the rendering calculation efficiency and realize a real-time gas diffusion visualization scene with realistic visual effects.

2. The method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality training scene according to claim 1, characterized in that: In step 1, specifically: processing the chemical hazardous gas CFD concentration data, converting and storing it into a time-series-based database supported by the virtual three-dimensional environment space Unity3D, including: CFD concentration data format conversion; (a) Data is converted to ASCAII format; in the CFD software, select to export the grid node spatial coordinates and the corresponding toxic gas mass concentration data as ASCAII format data; (b) ASCAII to .txt: Open the ASCAII data using Notepad and save it in .txt format. The data contains multiple lines of data, each representing the x, y, and z coordinates of a grid node and the toxic gas mass concentration at that node. (c) Convert .txt to .csv: Use relevant software to open the .txt file and save it as data in .csv format.

3. The method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality training scene according to claim 2, characterized in that: In step 1, further comprising: establishing a database and supporting reading of time-series-based CFD concentration value data; (a) Establishing a database: Importing the .csv file into a lightweight database software of a relational database management system to establish a database; (b) Reading data: Determine the time interval for reading data based on the CFD data time interval and actual needs, and read data from the database to the virtual reality environment software at fixed intervals.

4. The method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality training scene according to claim 3, characterized in that: In step 1, it further includes: virtual reality space coordinate system conversion; The inconsistency between CFD data and virtual reality space coordinate system will cause the concentration data to not match the virtual scene. This problem can be solved by changing the order of coordinate axis assignment. (a) Assign the x-coordinate value in the CFD data to the x-coordinate in the virtual reality space; (b) assigning the value of the y coordinate in the CFD data to the z coordinate in the virtual reality space; (c) Assign the value of the z coordinate in the CFD data to the y coordinate in the virtual reality space.

5. The method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality training scene according to claim 1, characterized in that: In step 2, the small space in the CFD concentration data is mapped to the small space in the volumetric fog through the numerical mapping method. By reading the harmful gas concentration data in the spatial grid node, the fog points of the volumetric fog are generated at the corresponding positions in the space through numerical mapping. Each data point generates a volumetric fog point, and the set of all data points is mapped to generate a set of fog points, realizing the fog effect scene of gas diffusion at different positions in the space. Specifically: Visual numerical mapping: Convert the processed and coordinate-converted gas CFD concentration data into an abstract visual object. That is, the position corresponding to each data point in the virtual environment constructed by the virtual reality software is mapped to generate a volumetric fog unit. Here, the abstract visual object is used to represent the toxic gas diffusion scene in the virtual environment. The gas properties include gas molecular size, color, and transparency, which need to be determined in combination with the color and density properties of the toxic and harmful gas. Modify the abstract object properties of the volume fog unit according to the grid; the size of the volume fog unit needs to be modified according to the grid size at different positions to reasonably determine the radiation range of the volume fog unit.

6. The method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality training scene according to claim 5, characterized in that: In step 2, further comprising: normalizing the concentration data to map the concentration data values ​​at the corresponding positions to the volume fog unit; Uniformly display the visualization effects of all concentration ranges of toxic gases in the space, from the highest concentration to the lowest concentration. Using the normalization method, the concentration value is normalized to (0, 1) and then numerically mapped to the fog density Fog.density of the volume fog. Fog.density is used to show different visualization effects of clouds with different concentrations.

7. The method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality training scene according to claim 1, characterized in that: In step 3, specifically: construct a noise function; (a) Construct a noise generator. Construct two functions, Noise(int x, int y, int z) and SmoothNoise(int x, int y, int z), respectively. If the input (x, y, z) is located at an integer grid point, the Noise(int x, int y, int z) function outputs a random noise between -1 and 1. If the input (x, y, z) is not at an integer grid point, the SmoothNoise(int x, int y, int z) function generates a random gradient value, which is obtained by weighted average of the Noise(int x, int y, int z) values ​​of the eight nearest integer grid points. (b) Calculate the pseudo-random gradient value of the grid points around the gridded volume fog unit; assume that the coordinates of the 8 integer grid points closest to the input position are (x0, y0, z0), (x1, y0, z0), (x0, y1, z0), (x1, y1, z0), (x0, y0, z1), (x1, y0, z1), (x0, y1, z1) 1, y1,z1), apply Smooth Noise(int x,int y,int z) function to calculate the pseudo-random gradient value l at each grid point i , i is 1-8; Among them, x0, x1, y0, y1, z0, z1 are all integers, representing spatial coordinate values; (c) Perform K harmonic interpolations on the x coordinate; apply S(t) = 6t to equation (1) 5 -15t 4 +10t 3 The function performs K harmonic interpolations on l1 and l2, l3 and l4, l5 and l6, l7 and l8 at coordinate x, and obtains the results m1, m2, m3, and m4. (d) Perform K harmonic interpolations on the y coordinate; apply equation (3) to perform K harmonic interpolations on m1 and m2, m3 and m4 on the y coordinate to obtain results n1 and n2; (e) Perform K harmonic interpolations on the z coordinate; apply equation (4) to perform N harmonic interpolations on n1 and n2 on the z coordinate, and finally obtain the noise value P of the input position point (x, y, z); The unique noise value at the corresponding position is obtained by inputting the position; in order to obtain a noise texture that is more consistent with the natural world, a method of superimposing multiple noises is used; (f) Superposition noise: Use the weighted superposition of multiple noises using formula (5) and change the amplitude, frequency, and frequency doubling of the superimposed noise to produce a fog noise texture with more details and a more realistic effect. Where P is the amplitude. The larger the amplitude, the rougher the noise effect, and the smaller the amplitude, the smoother the noise transition. α is the frequency, that is, the interval size of the sampling data. The higher the frequency, the more details the noise texture shows, and the greater the calculation amount. N is the frequency multiplication, that is, the number of superimposed noise functions. The larger the frequency multiplication, the smaller the influence of each noise in the produced noise.

8. The method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality training scene according to claim 7, characterized in that: In step 3, further comprising: optimizing the gas concentration scenario using a noise function; (a) The spatial coordinates are passed as input to the noise function, which returns a series of continuous noise values ​​through function calculation; (b) Mapping the noise value output by the noise function to a value between 0 and 1, multiplying it by the gas concentration value information in the texture data, and saving it back to the original texture; ρ(x,y,z)=ρ0+k·n(x,y,z) Formula (6) Among them, ρ(x,y,z) represents the volume fog density at the spatial position (x,y,z), ρ0 is the basic volume fog density, k is the noise influence coefficient, n(x,y,z) is the noise value at this position, and its value range is [0,1]. By adjusting the value of k, the degree of influence of noise on the volume fog density can be controlled.

9. The method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality training scene according to claim 1, characterized in that: In step 4, the concentration of gas molecules is calculated in a relatively closed grid space, and the physical interaction between the incident light and the gas molecules is calculated step by step. The calculation results of each step are accumulated to obtain the interaction between the light and the gas molecules. Then, by sampling the shadow texture and performing the corresponding rendering process, the visual scene is rendered on a screen such as a monitor. include: (1) Calculation of light scattering rate: The Rayleigh phase function is used to describe the angular distribution of short-wavelength light in all directions during the scattering process; (2) Calculation of light transmission: For light transmission, the Lambert-Beer law model is used; (3) Ray tracing: Move along the ray with a pre-calculated step size, integrating the results of each step until the transmittance reaches 0 or the maximum number of steps is reached; the computer converts the triangles that make up the 3D model into pixels on the 2D screen, assigns an initial color value to each pixel based on the data stored in the triangle vertices, changes the pixel color based on the collision of light in the scene with the pixel, applies a noise texture to the pixel, and then generates the final color applied to the pixel; (4) Add shadow texture: In order to simulate a real shadow effect, the shadow texture needs to be sampled to determine whether a point in space is in the shadow, and the result is saved in the texture.

10. The method for simulating the visual realism of harmful gas diffusion concentration values ​​in a virtual reality training scene according to claim 1, characterized in that: In step 5, the threshold-based mixture model is expressed as: Among them, ρ0 and ρ1 are different volume fog density values, T is the threshold, n(x, y, z) is the noise value. When the noise value is greater than the threshold, ρ1 is used as the volume fog density, otherwise ρ0 is used. Different effects can be achieved by adjusting the threshold and different density values.