Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on multi-core parallelism
By adopting the Monte Carlo simulation method with multi-core parallelism in the spacecraft simulation software, the problem of low computing efficiency in the existing technology is solved, and efficient atomic oxygen or ultraviolet flux calculation is achieved, which significantly improves CPU/memory utilization and calculation accuracy, and reduces costs.
Patent Information
- Application Number
- CN202210759741.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-30
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2042-06-30
AI Technical Summary
In the prior art, the calculation method of spacecraft simulation software results in low CPU/memory utilization, long task response time, and poor user experience.
The Monte Carlo simulation method based on multi-core parallelism is adopted. By obtaining the number of cores of the spacecraft simulation software running platform, the number of parallel tasks is determined, and sub-threads are established for each core and calculation tasks are allocated. The lock mechanism is used to avoid data writing conflicts, and the calculation results are finally output.
Without changing the calculation accuracy, the CPU/memory utilization is greatly improved, the time and cost of Monte Carlo simulation is significantly reduced, and the accuracy of atomic oxygen/ultraviolet radiation flux is improved, which reduces the cost of calculation, use and research of atomic oxygen/ultraviolet radiation flux on the surface of the spacecraft.
Smart Images

Figure CN115204010B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of spacecraft simulation calculation, and more particularly, to a Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on multi-core parallelism. Background Art
[0002] In the application scenarios of spacecraft simulation software in teaching, demonstration, etc. of spacecraft design, the software operation platform is generally an ordinary desktop computer with limited memory and no computing GPU configured. During the software operation, it is necessary to display the differences in erosion / etching effects of different protective coating materials attached to the outer surface during the service of the spacecraft due to exposure to atomic oxygen / ultraviolet irradiation environment. The strength of the erosion effect and the etching effect depends on the magnitude of the atomic oxygen / ultraviolet irradiation flux and the selection of the spacecraft surface coating material. The atomic oxygen / ultraviolet irradiation flux depends on factors such as the flight altitude of the spacecraft, flight orientation, atomic oxygen density, ultraviolet irradiation intensity, etc. This requires the simulation software to calculate the atomic oxygen or ultraviolet flux at each location on its surface according to the flight environment parameters of the spacecraft.
[0003] Currently, most simulation software uses Monte Carlo simulation to calculate the atomic oxygen / ultraviolet irradiation flux of each unit on the spacecraft surface. This method divides the spacecraft surface into grid cells, and then calculates the flux of each grid cell by statistically counting the number of simulated particles that touch each grid cell in a given total number of experiments. In each random experiment, atomic oxygen particles / simulated ultraviolet irradiation particles are generated at random positions and their final velocities are synthesized according to the flight velocity of the spacecraft and the thermodynamic motion velocity of atomic oxygen, and the grid cells touched during the movement of the simulated particles and the grid cells touched after specular reflection or diffuse reflection are calculated. The computational complexity of this method grows superlinearly with the total number of grid cells in the spacecraft surface subdivision and linearly with the total number of random experiments. Moreover, the current calculation methods of these simulation software result in low CPU / memory utilization, long task response time, and poor user experience. Even for medium-scale grid subdivision and total number of random experiments, it takes a long time to wait for the flux calculation results, which limits their applications. Summary of the Invention
[0004] The problem solved by the present invention is at least one aspect of the low CPU / memory utilization, long task response time, and poor user experience caused by the current calculation methods of simulation software in the prior art.
[0005] To solve the above problems, the present invention provides a Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on multi-core parallelism, including the following steps:
[0006] Step S1, obtain the number of cores of the spacecraft simulation software operation platform, and determine the number of parallel tasks according to the number of cores;
[0007] Step S2: According to the calculation project category, establish sub-threads for each core participating in parallel computing, allocate calculation tasks to them, and allocate statistical space for each of the sub-threads according to the calculation project category;
[0008] Step S3: The main thread of the spacecraft simulation software operation platform establishes a shared variable, and the main thread locks or unlocks the shared variable according to the completion results of the calculation tasks by each of the sub-threads;
[0009] Step S4: The main thread outputs the calculation result according to the completion results of all the sub-threads for the calculation tasks.
[0010] Preferably, in step S1, the determining the number of parallel tasks according to the number of cores includes:
[0011] When the number of cores is less than or equal to the first threshold, the multi-core parallel mechanism is not started;
[0012] When the number of cores is greater than the first threshold and less than or equal to the second threshold, the number of parallel tasks is the number of cores - 1;
[0013] When the number of cores is greater than the second threshold, the number of parallel tasks is the number of cores - 2.
[0014] Preferably, in step S2, the allocating statistical space for each of the sub-threads includes: allocating statistical space for calculation results and result distributions for each of the sub-threads.
[0015] Preferably, in step S2, the project category includes atomic oxygen flux or ultraviolet flux.
[0016] Preferably, in step S2, when calculating the atomic oxygen flux, establish the sub-threads for each core participating in parallel computing, and evenly distribute the total number of random experiments to each of the sub-threads.
[0017] Preferably, in step S2, when calculating the atomic oxygen flux, allocate independent memory space for each of the sub-threads for the statistics of the calculation results and result distributions.
[0018] Preferably, in step S2, when calculating the ultraviolet flux, establish the sub-threads for each core participating in parallel computing, and evenly distribute the total number of spacecraft surface dissection grids to each of the sub-threads.
[0019] Preferably, in step S2, when calculating the ultraviolet flux, allocate independent memory space for each of the sub-threads for the statistics of the result distributions, and each of the sub-threads uses shared memory space for the statistics of the calculation results.
[0020] Preferably, in step S3, the main thread locks or unlocks the shared variable according to the completion results of the computing task by each of the sub-threads, including: after one of the sub-threads completes the calculation and starts to access the shared variable, the main thread locks the shared variable, and after the sub-thread completes the access to the shared variable, the main thread unlocks the shared variable.
[0021] Preferably, in step S4, the main thread outputs the calculation result according to the completion result of the calculation task by all the sub-threads, including: when all the sub-threads complete the calculation task, the main thread aggregates the calculation results of each sub-thread and outputs the final calculation result and result distribution data.
[0022] The advantage of the Monte Carlo simulation method of atomic oxygen or ultraviolet flux based on multi-core parallelism described in the present invention over the prior art is that the Monte Carlo simulation method of atomic oxygen or ultraviolet flux based on multi-core parallelism accelerates the Monte Carlo simulation calculation process of atomic oxygen / ultraviolet radiation flux on the surface of spacecraft by reasonable division of calculation tasks, reasonable use of lock mechanism to avoid data writing conflicts and other technical means, the steps are simple and easy to implement, and the CPU / memory utilization rate can be greatly improved without changing the calculation accuracy, thereby greatly reducing the time and cost of Monte Carlo simulation, and the accuracy of atomic oxygen / ultraviolet radiation flux can be improved by refining the spacecraft surface grid or increasing the total number of random experiments within the same calculation time, thereby reducing the cost of calculation, use and research of atomic oxygen / ultraviolet radiation flux on the surface of spacecraft, which is of great significance. It has obvious advantages and broad application prospects in the promotion, teaching, demonstration of spacecraft simulation software and the application of spacecraft surface coating material erosion / demolition effect technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 This is a flow chart of a Monte Carlo simulation method of atomic oxygen or ultraviolet flux based on multi-core parallelism in an embodiment of the present invention;
[0024] Figure 2 This is a schematic diagram of calculation results of a Monte Carlo simulation method for atomic oxygen flux based on a single nucleus in an embodiment of the present invention;
[0025] Figure 3 This is a schematic diagram of calculation results of a Monte Carlo simulation method of atomic oxygen flux based on multi-core parallelism in an embodiment of the present invention;
[0026] Figure 4 It is a schematic diagram of calculation results of a Monte Carlo simulation method of ultraviolet flux based on a single core in an embodiment of the present invention;
[0027] Figure 5 It is a schematic diagram of calculation results of the Monte Carlo simulation method of ultraviolet flux based on multi-core parallelism in an embodiment of the present invention. Detailed implementation manners
[0028] The technical solutions in the embodiments of the present application will be clearly and elaborately described below with reference to the accompanying drawings.
[0029] In the description of the embodiments of the present application, the description of the term "some embodiments" means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0030] It should also be noted that in the description of the embodiments of the present application, the term "comprising" or any other variant thereof is intended to cover a non-exclusive inclusion, such that a process, method, article or terminal device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or terminal device. Without further limitation, the elements defined by the statement "comprising..." do not preclude the presence of additional identical elements in the process, method, article or terminal device comprising the said elements.
[0031] As Figure 1 shown, an embodiment of the present invention provides a Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on multi-core parallelism, including the following steps:
[0032] Step S1: Obtain the number of cores of the spacecraft simulation software operation platform, and determine the number of parallel tasks according to the number of cores;
[0033] Step S2: Establish sub-threads for each core participating in parallel computing according to the calculation project category, allocate calculation tasks, and allocate statistical space for each of the sub-threads according to the calculation project category;
[0034] Step S3: The main thread of the spacecraft simulation software operation platform establishes a shared variable, and the main thread locks or unlocks the shared variable according to the completion results of the calculation tasks by each of the sub-threads;
[0035] Step S4: The main thread outputs the calculation result according to the completion results of the calculation tasks by all the sub-threads.
[0036] In this embodiment, by reforming the Monte Carlo simulation method, the data sharing and data collection in the computing tasks are reasonably arranged without changing the calculation results, and the multi-core parallel architecture of modern computers is fully utilized to accelerate the Monte Carlo simulation process, so that it can be adapted to both teaching and demonstration scenarios on ordinary desktops and large-scale simulation experiment scenarios.
[0037] In some embodiments, in step S1, the determining the number of parallel tasks according to the number of cores includes:
[0038] When the number of cores is less than or equal to the first threshold, the multi-core parallel mechanism is not started;
[0039] When the number of cores is greater than the first threshold and less than or equal to the second threshold, the number of parallel tasks is the number of cores - 1;
[0040] When the number of cores is greater than the second threshold, the number of parallel tasks is the number of cores - 2.
[0041] In some preferred embodiments, the first threshold is 2 and the second threshold is 4. Thus, the computing tasks can be reasonably divided according to the number of cores, saving costs and improving the computing time.
[0042] In some embodiments, in step S2, the allocating statistical space for each of the sub-threads includes: allocating statistical space for calculation results and result distributions for each of the sub-threads.
[0043] In some embodiments, in step S2, the item categories include atomic oxygen flux or ultraviolet flux. Thus, this method can not only implement the simulation calculation of atomic oxygen flux, but also implement the simulation calculation of ultraviolet flux, with a wide range of applications.
[0044] In some embodiments, in step S2, when calculating the atomic oxygen flux, sub-threads are respectively established for each core participating in the parallel calculation, and the total number of random experiments is evenly distributed to each of the sub-threads. And independent memory spaces are allocated for each of the sub-threads for the statistics of the calculation results and result distributions. Thus, the task allocation and storage of calculation data can be reasonably carried out, improving the CPU / memory utilization rate and saving time and costs.
[0045] In some other embodiments, in step S2, when calculating the ultraviolet flux, sub-threads are respectively established for each core participating in the parallel calculation, and the total number of spacecraft surface meshes is evenly distributed to each of the sub-threads. And independent memory spaces are allocated for each of the sub-threads for the statistics of the result distributions, and each of the sub-threads uses a shared memory space for the statistics of the calculation results. Thus, the task allocation and storage of calculation data can be reasonably carried out, improving the CPU / memory utilization rate and saving time and costs.
[0046] In some embodiments, in step S3, the main thread locks or unlocks the shared variable according to the completion results of the computing tasks by each of the sub-threads, including: after one of the sub-threads finishes its calculation and starts to access the shared variable, at this time, the main thread locks the shared variable to prevent other sub-threads from accessing the shared variable. After the sub-thread finishes accessing the shared variable, the main thread unlocks the shared variable to allow other sub-threads to access the shared variable. Thus, by reasonably using the lock mechanism, data write conflicts are avoided, which may affect the accuracy of the calculation results.
[0047] In some embodiments, in step S4, the main thread outputs the calculation result according to the completion results of all the sub-threads for the computing task, including: when all the sub-threads complete the computing task, the main thread aggregates the calculation results of each of the sub-threads and outputs the final calculation result and the result distribution data. Thus, by aggregating the data after multi-core parallelism, the CPU / memory utilization rate is improved, and the calculation time is significantly reduced.
[0048] To verify the effectiveness of the Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on multi-core parallelism in this embodiment, the Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on a single core is calculated with the same grid density, number of particles, and number of particle reflections for comparison. As Figures 2 - 5 shown, Figure 2 is a schematic diagram of the calculation result of the Monte Carlo simulation method for atomic oxygen flux based on a single core in the embodiment of the present invention. The calculation time under a single core is 666.234 seconds; Figure 3 is a schematic diagram of the calculation result of the Monte Carlo simulation method for atomic oxygen flux based on multi-core parallelism in the embodiment of the present invention. The calculation time under dual-core 4 threads is 175.339 seconds; Figure 4 is a schematic diagram of the calculation result of the Monte Carlo simulation method for ultraviolet flux based on a single core in the embodiment of the present invention. The calculation time under a single core is 251.648 seconds; Figure 5 is a schematic diagram of the calculation result of the Monte Carlo simulation method for ultraviolet flux based on multi-core parallelism in the embodiment of the present invention. The calculation time under dual-core 4 threads is 70.263 seconds. Among them, Figure 2 and Figure 3 for the atomic oxygen flux, the magnitude of the atomic oxygen flux is represented by the change in the depth of color. The darker the color, the larger the atomic oxygen flux; Figure 4 and Figure 5 for the ultraviolet irradiation flux, the magnitude of the ultraviolet irradiation flux is represented by the change in the depth of color. The darker the color, the larger the ultraviolet irradiation flux. It can be seen from the figure that the calculation results of the Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on multi-core parallelism in this embodiment are basically the same as those of the Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on a single core.
[0049] Therefore, the Monte Carlo simulation method of atomic oxygen or ultraviolet flux based on multi-core parallelism in this embodiment accelerates the Monte Carlo simulation calculation process of atomic oxygen / ultraviolet radiation flux on the surface of spacecraft by reasonable division of calculation tasks, reasonable use of lock mechanism to avoid data writing conflicts and other technical means. The steps are simple and easy to implement. It can greatly improve CPU / memory utilization without changing the calculation accuracy, thereby greatly reducing the time and cost of Monte Carlo simulation. It can also improve the accuracy of atomic oxygen / ultraviolet radiation flux by refining the spacecraft surface grid or increasing the total number of random experiments within the same calculation time, reducing the cost of calculation, use and research of atomic oxygen / ultraviolet radiation flux on the surface of spacecraft, which is of great significance. It has obvious advantages and broad application prospects in the promotion, teaching, demonstration of spacecraft simulation software and the application of spacecraft surface coating material erosion / erosion effect technology.
[0050] Although the present invention is disclosed as above, the protection scope of the present invention is not limited thereto. Those skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention, and these changes and modifications will fall within the protection scope of the present invention.
Claims
1. A Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on multi-core parallelism, characterized in that, it includes the following steps: Step S1, obtain the number of cores of the spacecraft simulation software operation platform, and determine the number of parallel tasks according to the number of cores; Step S2, according to the calculation project category, establish sub-threads for each core participating in parallel computing and allocate calculation tasks, and allocate statistical space for each sub-thread according to the calculation project category, where the project category includes atomic oxygen flux or ultraviolet flux, including: When calculating the atomic oxygen flux, establish the sub-threads for each core participating in parallel computing, and evenly distribute the total number of random experiments to each sub-thread, and allocate independent memory space for each sub-thread for the statistics of calculation results and result distributions; When calculating the ultraviolet flux, establish the sub-threads for each core participating in parallel computing, and evenly distribute the total number of meshes of the spacecraft surface dissection to each sub-thread, and allocate independent memory space for each sub-thread for the statistics of the result distribution, and each sub-thread uses shared memory space for the statistics of the calculation results; Step S3, the main thread of the spacecraft simulation software operation platform establishes a shared variable, and the main thread locks or unlocks the shared variable according to the completion results of each sub-thread for the calculation task; Step S4, the main thread outputs the calculation result according to the completion results of all sub-threads for the calculation task.
2. The Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on multi-core parallelism according to claim 1, characterized in that, in step S1, the determining the number of parallel tasks according to the number of cores includes: When the number of cores is less than or equal to the first threshold, the multi-core parallel mechanism is not started; When the number of cores is greater than the first threshold and less than or equal to the second threshold, the number of parallel tasks is the number of cores - 1; When the number of cores is greater than the second threshold, the number of parallel tasks is the number of cores - 2.
3. The Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on multi-core parallelism according to claim 1, characterized in that, in step S3, the main thread locks or unlocks the shared variable according to the completion results of each sub-thread for the calculation task, including: after a sub-thread finishes calculating and starts to access the shared variable, the main thread locks the shared variable, and after the sub-thread finishes accessing the shared variable, the main thread unlocks the shared variable.
4. The Monte Carlo simulation method for atomic oxygen or ultraviolet flux based on multi-core parallelism according to claim 1, characterized in that, in step S4, the main thread outputs the calculation result according to the completion results of all sub-threads for the calculation task, including: when all sub-threads complete the calculation task, the main thread aggregates the calculation results of each sub-thread and outputs the final calculation result and result distribution data.
Citation Information
Patent Citations
Cluster GPU acceleration-based multi-source full path Monte-Carlo simulation method
CN104317655A
Monte Carlo grid parallel dose calculation method and device and storage medium
CN110504016A