A method to construct spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM
By providing a method to construct spatial probability density and time uniform distribution of any field quantity OpenFOAM, the problem of OpenFOAM weak in data post-processing is solved, and fast, convenient and automated calculations are achieved, and computing efficiency and analysis capabilities are improved.
Patent Information
- Application Number
- CN202410893653.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-07-04
AI Technical Summary
OpenFOAM is relatively weak in data post-processing, and lacks a method of quickly, conveniently and automatically building arbitrary field volume spatial probability density and time-equality distribution, resulting in the manual calculation of massive data files, which consumes a lot of time and computing resources.
It provides a method to construct the probability density and time-equality distribution of any field quantity of OpenFOAM, including setting the OpenFOAM working path, reading the discrete grid file, traversing the time folder, defining the global scalar, determining the upper and lower bounds of the field quantity, processing the field quantity values in segments, calculating the mean and probability density during the time, and saving the results to the standard file.
The spatial probability density and time uniform distribution of any field quantity in the OpenFOAM simulation results are achieved quickly, conveniently and automatically constructed, reducing the amount of manual calculation, improving the calculation efficiency, and supporting post-processing analysis and statistical law research.
Smart Images

Figure CN118862729B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of post-processing and analysis of numerical simulation results, and in particular to a method for constructing spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM. Background Art
[0002] With the rapid development of computer software and hardware technology, computational fluid dynamics (CFD) has been widely used in aerospace and weapons industry, shipbuilding and ocean, energy and electricity, vehicles and ground transportation, heavy industrial machinery, electronic appliances and other fields. OpenFOAM is an open source C++ class library based on the finite volume method and object-oriented, with significant advantages such as open code, free access, convenient expansion, and support for large-scale parallel computing. Compared with commonly used CFD commercial software such as ANSYS Fluent, STAR-CD, STAR-CCM+, CFX and other closed algorithms and expensive copyrights, OpenFOAM source code is completely open, with strong flexibility and easy scalability, and can achieve personalized customization and code development according to user research needs. It supports polyhedral meshes, can handle complex geometric configurations, and has powerful simulation and analysis capabilities for fluid flow, combustion, heat transfer and various multi-physics field coupling problems.
[0003] In addition, most CFD commercial software is designed and used for Windows systems, and it is generally difficult to fully utilize computer hardware resources. The security and scope of use of Windows systems are also attracting more and more attention from enterprises, research institutes and universities. The Linux system kernel is safe, reliable and pure, and is more suitable for large-scale parallel computing. Therefore, compared with commercial software, OpenFOAM based on the Linux system has unique advantages. It has become the world's most influential, widely used and most widely used open source CFD platform, integrating a large number of solvers and applications for various problems. However, due to the diversity of the physical world and the richness of research problems, OpenFOAM is relatively weak in data post-processing. For specific research problems, users are usually required to develop appropriate post-processing codes themselves, and the scope of application is also relatively limited. For example, OpenFOAM unsteady-state simulations often save a large number of intermediate results, which can better analyze the instantaneous characteristics of variables, but usually lack research methods for overall evolution processes and statistical laws.
[0004] The spatial probability density and time-averaged distribution of OpenFOAM field quantities are an important statistical analysis method. In flow field simulation, state parameters such as temperature, pressure, velocity, and component concentration are usually more important. For example, for various power systems such as internal combustion engines, gas turbines, aircraft engines, rockets, and ramjets, in addition to monitoring the instantaneous temperature, pressure, and components in the combustion chamber, the average changes in the above parameters over a period of time and the probability of certain key states are also of great significance. In the ignition process, it is necessary to master the probability distribution of successful ignition in different batches of experiments / simulations, analyze the local flow, thermodynamics, and thermochemical states of successful ignition, improve the ignition design, and increase the ignition success rate. In a non-uniform combustion system, it is necessary to master the frequency, location, and average value of the high-temperature zone over a period of time in order to optimize the combustion organization and enhance the safety design of the combustion chamber structure. In a hypersonic power system, the statistical distribution of supersonic and subsonic combustion zones affects the rapidity of fuel mixing, the efficiency of combustion organization, and the effectiveness of flame stabilization.
[0005] However, the output of OpenFOAM files is highly discretized, and different field quantities at different times are stored in the form of independent files, while statistical research usually requires the results of multiple times and different field quantities as sample data. If the time average of key field quantities is not recorded in time during the OpenFOAM simulation, it will be difficult to obtain it after the calculation is completed, and re-simulation will consume a lot of time and computing resources. Therefore, the manual calculation of massive data files is extremely large, and it is necessary to develop a computer program that can quickly, conveniently and automatically construct the spatial probability density and time-averaged distribution of any field quantity (scalar field, vector field) in OpenFOAM. Summary of the invention
[0006] The purpose of the present invention is to provide a method for constructing the spatial probability density and time-averaged distribution of any field quantity in OpenFOAM, which can quickly, conveniently and automatically construct the spatial probability density and time-averaged distribution of any scalar field or vector field in a large number of transient simulation results of OpenFOAM, and save them in the OpenFOAM standard file reading and writing mode to facilitate further post-processing analysis. It can also provide method support for the study of the evolution process and statistical laws of characteristic field quantities.
[0007] To achieve the above object, the present invention provides a method for constructing the spatial probability density and time-averaged distribution of any field quantity in OpenFOAM, comprising the following steps:
[0008] S1. Set the current working path of OpenFOAM, read multiple discretized grid files and create example grids;
[0009] S2, read the field quantity data in the time folder, traverse all the moments in the working directory, and define the global scalar Nt to store the number of time folders;
[0010] S3. Determine the upper and lower bounds of the field quantity in the entire calculation domain according to the specific simulation problem, and segment the target field quantity values between the extreme values;
[0011] S4, creating blank field files X_Avg, X_Stage and PDF_i (i=1, 2, ...) in the working directory, where the number of PDF_i files is consistent with the number of segments in step S3;
[0012] S5, in the above step S4, all grids of the blank field have an initial value of 0, and the time-averaged field quantity, the time-averaged field quantity segmentation identifier, and the instantaneous field quantity segmentation probability are stored respectively;
[0013] S6, through the if condition, matching the field value of each grid in which segment it falls, adding 1 to the corresponding count, and obtaining the segmented distribution of the field value on all grids;
[0014] S7, traverse all the time points, divide the number of times in the above step S6 by the total number of time folders Nt, obtain the segmented probability of the transient field quantity and save it to the file PDF_i;
[0015] S8, adding the instantaneous field quantities at different times according to the corresponding grids and dividing by the total number of times to obtain the time average value of each grid and save it to the X_Avg file;
[0016] S9. Match the segmented distribution of the time-averaged field quantity through the if condition and mark it with different values, traverse all grids and save the results to the X_Stage file.
[0017] Preferably, in step S2, the field quantity X is a scalar field or a vector field, the initial value of Nt is 0, and its value increases by 1 at each reading moment, and the frequency of occurrence of the field quantity in each segment is divided by Nt to obtain the frequency. When there are enough transient data, the probability is approximated by the frequency.
[0018] Preferably, in step S4, the time-averaged field quantity X_Avg is segmented, and the segment information of the time-averaged field quantity of each grid will be stored in the blank field file X_Stage. When i in PDF_i=1, the field file PDF_1 is used to store the probability that the field quantity values on all grids fall in the first segment. When i in PDF_i=2, the field file PDF_2 is used to store the probability that the field quantity values on all grids fall in the second segment, and so on.
[0019] Preferably, in step S5, when creating blank field files X_Avg, X_Stage and PDF_i, the initial values are all set to 0, so the initial values on all grid cells are also 0; X_Avg is used to store the average field quantity of the period, X_Stage stores the digital identification information of the average field quantity appearing in a certain segment, and PDF_i corresponds one-to-one to the field quantity segment i.
[0020] Preferably, in step S6, assuming that X[cellJ] is less than the upper limit value of the first segment at a certain moment, the value of PDF_1[cellJ] on the grid is increased by 1, cellJ is the unique number of grid cell J, and the remaining segments of the field quantity X are deduced in this way. All grids are traversed to obtain the values of all PDF_i[cellJ]. If cellJ has never had a field quantity value falling in segment i, PDF_i[cellJ] maintains the initial value of 0.
[0021] Preferably, in step S7, all moments are traversed to obtain the cumulative value of PDF_i[cellJ] on all grids, which is then divided by the total number of time folders Nt to approximate the segmented spatial probability density distribution of the transient field quantity, and the result is saved to the corresponding field file based on the OpenFOAM standard file reading and writing method.
[0022] Preferably, in step S8, while traversing all moments, the field quantities at different instants on each grid are accumulated, and after the last moment is completed, they are divided by the total number of time folders Nt to obtain the time-averaged field quantity value on all grids during the period, and the result is saved in the blank field file X_Avg.
[0023] Preferably, in step S9, the X_Avg file is read in, and according to the segmentation in step S4, the if condition is used to determine in which segment the time-averaged field value on each grid falls, and the numerical identification information on all grids is saved in the X_Stage file.
[0024] Therefore, the present invention adopts the above method to construct the spatial probability density and time-averaged distribution of any field quantity in OpenFOAM, and the beneficial effects are as follows:
[0025] (1) The present invention is oriented to the OpenFOAM numerical simulation results, and can quickly and conveniently calculate the spatial probability density and time-averaged distribution of both scalar fields and vector fields.
[0026] (2) The present invention divides and identifies the time-averaged field quantity in physical space, which can quickly and accurately identify the average distribution of the calculation configuration over a period of time.
[0027] (3) The present invention can guide the numerical simulation of physical problems, such as the improved design of power systems, by monitoring the time evolution of key field quantities and studying statistical laws.
[0028] (4) The results of the present invention are stored in the form of OpenFOAM standard field quantity files, which is convenient for further post-processing analysis and easy to promote. Similar methods can be used to extract key flow field information, such as ignition probability, fuel mixing boundary, and premixed / diffusion combustion mode.
[0029] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is an overall flow chart of an embodiment of a method for constructing spatial probability density and time-averaged distribution of any field quantity in OpenFOAM according to the present invention;
[0031] Figure 2 It is a schematic diagram of a model scramjet combustion chamber simulation problem of an embodiment of a method for constructing spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM according to the present invention;
[0032] Figure 3 It is the segmented spatial probability density distribution of the temperature in the combustion chamber of an embodiment of a method for constructing the spatial probability density and time-averaged distribution of any field quantity in OpenFOAM of the present invention;
[0033] Figure 4 The time-averaged temperature in the combustion chamber and its segmented numerical identification in an embodiment of a method for constructing the spatial probability density and time-averaged distribution of any field quantity in OpenFOAM according to the present invention;
[0034] Figure 5 The spatial probability density distribution of the premixed / diffusion combustion mode in the combustion chamber in an embodiment of a method for constructing the spatial probability density and time-averaged distribution of any field quantity in OpenFOAM according to the present invention;
[0035] Figure 6 The invention discloses a method for constructing spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM, and discloses a spatial probability density distribution of supersonic / subsonic combustion modes in a combustion chamber. DETAILED DESCRIPTION
[0036] The technical solution of the present invention is further described below through the accompanying drawings and embodiments.
[0037] Unless otherwise defined, technical or scientific terms used in the present invention shall have the common meanings understood by one having ordinary skills in the field to which the present invention belongs.
[0038] like Figure 1 As shown, a method for constructing the spatial probability density and time-averaged distribution of any field quantity in OpenFOAM includes the following steps:
[0039] S1. Set the current working path of OpenFOAM, read multiple discretized grid files and create a case grid, which can be a structured or unstructured grid;
[0040] S2. Read the field quantity data in the time folder, traverse all the moments in the working directory, and define a global scalar Nt to store the number of time folders;
[0041] The field quantity X can be a scalar field (such as temperature, pressure) or a vector field (velocity, vorticity). The initial value of Nt is 0, and its value increases by 1 every time a moment is read. The frequency of the field quantity in each segment is divided by Nt to obtain the frequency. When there are enough transient data, the probability is approximated by the frequency.
[0042] S3. Determine the upper and lower bounds of the field quantity in the entire calculation domain according to the specific simulation problem, and segment the field quantity values between the extreme values;
[0043] Assuming that the instantaneous field value is in the range of 200-3500, it is divided into 8 sections for example: X<300, 300≤X<800, 800≤X<1300, 1300≤X<1800, 1800≤X<2300, 2300≤X<2800, 2800≤X<3300, 3300≤X. It can be divided into arbitrarily segments according to actual conditions.
[0044] S4, creating blank field files X_Avg, X_Stage and PDF_i (i=1, 2, ...) in the working directory, where the number of PDF_i files is consistent with the number of segments in step S3;
[0045] The time-averaged field quantity X_Avg is similarly segmented, and the segment information of the time-averaged field quantity of each grid will be stored in the blank field file X_Stage. For example, when i in PDF_i is 1, the field file PDF_1 is used to store the probability that the field quantity values on all grids fall in the first segment (X<300) (approximated by dividing the frequency by the total number of time moments). When i in PDF_i is 2, the field file PDF_2 is used to store the probability that the field quantity values on all grids fall in the second segment (300≤X<800), and so on.
[0046] S5, in the above step S4, all grids of the blank field have an initial value of 0, and the time-averaged field quantity, the time-averaged field quantity segmentation identifier, and the instantaneous field quantity segmentation probability are stored respectively;
[0047] When creating blank field files X_Avg, X_Stage and PDF_i, the initial values are all set to 0, so the initial values on all grid cells are also 0; X_Avg is used to store the average field quantity of the period, X_Stage stores the digital identification information of the average field quantity appearing in a certain segment, and PDF_i corresponds one-to-one to the field quantity segment i.
[0048] S6, through the if condition, match the segment in which the field value of each grid falls, and add 1 to the corresponding count to obtain the segmented distribution of the field value of all grids;
[0049] Assume that at a certain moment X[cellJ] is less than the upper limit of the first segment, 300, then the value of PDF_1[cellJ] on the grid is increased by 1, cellJ is the unique number of grid cell J; the segments of the field quantity X are deduced in the same way, and all grids are traversed to obtain the values of all PDF_i[cellJ]. If cellJ has never had a field quantity value falling in segment i, then PDF_i[cellJ] remains at the initial value of 0.
[0050] S7. Traverse all moments, divide the number of times in the above step S6 by the total number of time folders Nt, obtain the segmented probability of the transient field quantity and save it in the file PDF_i.
[0051] Traverse all moments, obtain the cumulative value of PDF_i[cellJ] on all grids, and then divide it by the total number of time folders Nt to approximate the segmented spatial probability density distribution of the transient field quantity. Save the result to the corresponding field file based on the OpenFOAM standard file reading and writing method (IOdictionary class).
[0052] S8, adding the instantaneous field quantities at different times according to the corresponding grids and dividing by the total number of times to obtain the time average value of each grid and save it to the X_Avg file;
[0053] While traversing all moments, the field quantities at different instants on each grid are accumulated. After the last moment is completed, it is divided by the total number of time folders Nt to obtain the time-averaged field quantity value on all grids during this period of time, and the result is saved in the blank field file X_Avg.
[0054] S9. Match the segmented distribution of the time-averaged field quantity through the if condition and mark it with different values, traverse all grids and save the results to the X_Stage file.
[0055] Read the X_Avg file, and according to the segmentation in step S4, use the if condition to determine which segment the time-averaged field value on each grid falls into. For example, all grids with X_Avg[cellJ]<300 are marked with a value of 0.1, and so on. The numerical identification information on all grids is saved in the X_Stage file.
[0056] In this embodiment, after the user completes the non-steady-state numerical simulation of the physical problem using OpenFOAM, it is necessary to extract the grid file of the calculated configuration and the result files such as temperature, pressure, and components to carry out post-processing analysis.
[0057] The functions and effects of the algorithm of the present invention are further described below by two specific embodiments. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, rather than limiting the applicable scenarios of the present invention.
[0058] Embodiment 1
[0059] The physical problem of the combustion chamber of the scramjet engine model with support plate configuration is shown as follows Figure 2 The height of the combustion chamber inlet (y direction) is 50mm and the total length (x direction) is 340mm. A support plate with a length of 32mm and a height of 6mm is placed at x1=77mm downstream of the combustion chamber inlet along the center line of y=25mm.
[0060] A circular hole with a diameter of 1 mm is opened on the back of the support plate (at x0 = 109 mm) for injecting hydrogen fuel, and the upper wall of the combustion chamber has a 3° inclination starting from x2 = 100 mm. The air flow at the combustion chamber inlet has a Mach number of 2.0, a static temperature of 340K, and a static pressure of 0.1 MPa.
[0061] Measured by mass fraction, the air composition is 73.6% nitrogen, 23.2% oxygen and 3.2% water vapor. Pure hydrogen is injected into the combustion chamber at a speed of 1200m / s, with a static temperature of 350K and a static pressure of 0.1MPa. After the hydrogen is mixed with air, it is forced to ignite and the combustion is organized downstream of the support plate. Under the complex shock wave-flame-turbulence interaction, this is a typical unsteady flow and combustion system, and the temperature and speed span a large range, which can better demonstrate the effect of the present invention.
[0062] In this embodiment, the temperature is divided into 8 sections: T<300K, 300K≤T<800K, 800K≤T<1300K, 1300K≤T<1800K, 1800K≤T<2300K, 2300K≤T<2800K, 2800K≤T<3300K, 3300K≤T. A total of Nt=1000 instantaneous result data at different times are used. Figure 3 The spatial probability density distribution of the temperature field in the combustion chamber in the above 8 sections is shown.
[0063] There is a high probability that a local area T < 300K (lower than the free flow temperature of 340K) will appear on the lower wall of the combustion chamber. This is mainly caused by the expansion wave generated by the trailing edge of the support plate and then reflected after incident on the lower wall. This area actually experiences the action of two expansion waves, so the temperature is significantly lower than the free flow temperature.
[0064] The mainstream gas temperature that is not directly affected by combustion is mostly in the range of 300–800K ( Figure 3The red area in the first row of the right figure). Immediately following the support plate, there are two long strips of combustion zones with medium temperatures (800K≤T<1300K and 1300K≤T<1800K), located above and below the rear edge of the support plate, respectively. This is the reaction induction zone, where the fuel is sprayed out from the back of the support plate and mixed with the incoming air and forced to ignite. In the early stage of ignition, the reaction rate is slow and the temperature is low. However, it is located in the reflow zone of the support plate, with good flame stability, and plays a good role as a flame stabilizing source for the overall combustion stability. Further downstream of the support plate, the probability of the high temperature zone increasing with the progress of combustion, but the probability of exceeding 3300K is extremely small. Figure 3 It shows the probability density distribution of temperature field in physical space very well, and characterizes the statistical characteristics of the flame zone over a period of time.
[0065] Figure 4 The average temperature in the combustion chamber and its segmented numerical identification information distribution are given. The average temperature is divided into 6 sections: T_Avg < 300K, 300K ≤ T_Avg < 800K, 800K ≤ T_Avg < 1300K, 1300K ≤ T_Avg < 1800K, 1800K ≤ T_Avg < 2300K, 2300K ≤ T_Avg < 2800K, and each section is identified by the values 0.1, 0.2, 0.3, 0.4, 0.5 and 0.6 respectively. Figure 4 The instantaneous temperature in the figure represents the average change of the temperature field during this period. Although the instantaneous temperature is as high as 3300K and above, the average temperature of the whole field does not exceed 2800K. The T_Stage cloud diagram shows the block distribution of the average temperature of different sections in the physical space, which can provide a certain reference for the design of the combustion chamber.
[0066] Embodiment 2
[0067] It is still the physical problem in Example 1, but this example illustrates the effectiveness of this method from another perspective. In addition to being applicable to general scalar field or vector field data of OpenFOAM simulation results, it is also applicable to logical field quantities with certain physical meanings. For example, premixed and diffusion combustion modes are important characteristics of power systems, which involve issues such as how to improve combustion efficiency and how to organize combustion. Supersonic and subsonic combustion modes are one of the core issues in the design of hypersonic power systems, which determine the ignition reliability, flame stability and combustion efficiency of the engine. The method of the present invention is also applicable to such logical field quantities with significant binary or multi-valued characteristics.
[0068] Figure 5The spatial probability density distribution of the premixed combustion mode and the diffusion combustion mode in the combustion chamber is shown. Similar to the aforementioned segmentation method, for any instant, the if condition is used to determine whether cellJ is premixed combustion or diffusion combustion, and the corresponding count is increased by 1. After traversing all moments, the cumulative number of premixed or diffusion combustion on all grids is obtained, and the approximate value of the probability density is obtained by dividing it by the total number of moments. The spatial probability density calculation method of supersonic combustion and subsonic combustion modes is similar and will not be repeated here. Figure 5 and Figure 6 The spatial probability density distribution of different combustion modes in the combustion chamber is established, which plays an important guiding role in the study of the statistical characteristics of the combustion chamber and its improved design. It also shows that this method can support the in-depth analysis of the OpenFOAM simulation results and is an effective supplement to the study of instantaneous parameter changes.
[0069] Therefore, the present invention adopts the above-mentioned method for constructing the spatial probability density and time-averaged distribution of any field quantity in OpenFOAM, which can quickly and conveniently construct the spatial probability density and time-averaged distribution of any field quantity in the OpenFOAM simulation results, including but not limited to scalar fields (such as temperature, pressure, components), vector fields (velocity, vorticity) and logical fields (premixed / diffusion combustion mode, supersonic / subsonic combustion mode), which can support in-depth analysis of the numerical simulation results of actual physical problems and research on statistical laws.
[0070] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that they can still modify or replace the technical solution of the present invention with equivalents, and these modifications or equivalent replacements cannot cause the modified technical solution to deviate from the spirit and scope of the technical solution of the present invention.
Claims
1. A method for constructing spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM, characterized in that: The following steps are involved: S1. Set the current working path of OpenFOAM, read multiple discretized grid files and create example grids; S2, read the field quantity data in the time folder, traverse all the moments in the working directory, and define the global scalar Nt to store the number of time folders; S3. Determine the upper and lower bounds of the field quantity in the entire calculation domain according to the specific simulation problem, and segment the target field quantity values between the extreme values; S4, creating blank field files X_Avg, X_Stage and PDF_i (i=1, 2, ...) in the working directory, where the number of PDF_i files is consistent with the number of segments in step S3; S5, in the above step S4, all grids of the blank field have an initial value of 0, and the time-averaged field quantity, the time-averaged field quantity segmentation identifier, and the instantaneous field quantity segmentation probability are stored respectively; S6, through the if condition, matching the field value of each grid in which segment it falls, adding 1 to the corresponding count, and obtaining the segmented distribution of the field value on all grids; S7, traverse all the time points, divide the number of times in the above step S6 by the total number of time folders Nt, obtain the segmented probability of the transient field quantity and save it to the file PDF_i; S8, adding the instantaneous field quantities at different times according to the corresponding grids and dividing by the total number of times to obtain the time average value of each grid and save it to the X_Avg file; S9, matching the segmented distribution of the time-averaged field quantity through the if condition and marking it with different values, traversing all grids and saving the results to the X_Stage file; In step S6, the if condition is specifically as follows: assuming that X[cellJ] is less than the upper limit of the first segment at a certain moment, the value of PDF_1[cellJ] on the grid is increased by 1, cellJ is the unique number of grid cell J, and the remaining segments of the field quantity X are deduced in this way. All grids are traversed to obtain the values of all PDF_i[cellJ]. If cellJ has never had a field quantity value falling in segment i, PDF_i[cellJ] remains at the initial value of 0.
2. A method for constructing spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM according to claim 1, characterized in that: In step S2, the field quantity X is a scalar field or a vector field, the initial value of Nt is 0, and its value increases by 1 every time a moment is read. The frequency of occurrence of the field quantity in each segment is divided by Nt to obtain the frequency. When there are enough transient data, the probability is approximated by the frequency.
3. A method for constructing spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM according to claim 2, characterized in that: In step S4, the time-averaged field quantity X_Avg is segmented, and the segment information of the time-averaged field quantity of each grid will be stored in the blank field file X_Stage. When i in PDF_i=1, the field file PDF_1 is used to store the probability that the field quantity values on all grids fall in the first segment. When i in PDF_i=2, the field file PDF_2 is used to store the probability that the field quantity values on all grids fall in the second segment, and so on.
4. A method for constructing spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM according to claim 3, characterized in that: In step S5, when creating the blank field files X_Avg, X_Stage and PDF_i, the initial values are all set to 0, so the initial values on all grid cells are also 0; X_Avg is used to store the average field quantity of the period, X_Stage stores the digital identification information of the average field quantity appearing in a certain segment, and PDF_i corresponds one-to-one to the field quantity segment i.
5. A method for constructing spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM according to claim 4, characterized in that: In step S7, all moments are traversed to obtain the cumulative value of PDF_i[cellJ] on all grids, which is then divided by the total number of time folders Nt to approximate the segmented spatial probability density distribution of the transient field quantity. The result is saved to the corresponding field file based on the OpenFOAM standard file reading and writing method.
6. A method for constructing spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM according to claim 5, characterized in that: In step S8, while traversing all moments, the field quantities at different instants on each grid are accumulated, and after the last moment is completed, they are divided by the total number of time folders Nt to obtain the time-averaged field quantity value on all grids during this period, and the result is saved in the blank field file X_Avg.
7. A method for constructing spatial probability density and time-averaged distribution of arbitrary field quantities in OpenFOAM according to claim 6, characterized in that: In step S9, the X_Avg file is read in, and according to the segmentation in step S4, the if condition is used to determine in which segment the time-averaged field value on each grid falls, and the numerical identification information on all grids is saved in the X_Stage file.
Citation Information
Patent Citations
Simulation method, system equipment and medium for two-phase flow heat conduction of fractured porous rock-soil body
CN116933682A
Water turbine numerical simulation platform building method and system based on OpenFOAM software
CN117634091A