Method for simulating waviness of circumferential field
Through Python program scripts, the circumferential field ripple is calculated in the electromagnetic simulation software, and the executable file is generated, which is directly loaded and executed in the electromagnetic simulation software, which solves the problem of inefficient calculation of the circumferential field ripple in the existing technology and achieves high efficiency , lightweight simulation results are displayed.
Patent Information
- Application Number
- CN202411309400.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-01-03
AI Technical Summary
The method of calculating the circumferential field corrugation using simulation software in the prior art is inefficient. It is necessary to manually import and export data between different software to increase the risk of errors. Moreover, the simulation software occupies a large storage space and cannot realize the corrugation calculation lightly.
Read the magnetic field data in the electromagnetic simulation software through Python program scripts, calculate and encapsulate the corrugation data, generate executable simulation execution files, and load and execute directly in the electromagnetic simulation software to display the simulation results, avoiding dependence on Matlab software , improves computing efficiency and storage space utilization.
It realizes efficient calculation and simulation of circumferential field wrigility, reduces data processing errors, reduces storage space usage, has the advantages of lightweight, and improves simulation efficiency and accuracy.
Smart Images

Figure CN119249723A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of nuclear fusion, and in particular to a simulation method for toroidal field corrugation. Background Art
[0002] Toroidal field magnets are important magnets for generating magnetic fields to confine plasma in tokamak fusion devices. Toroidal field magnets are usually formed by circumferentially arranging multiple toroidal field coils. There are gaps between adjacent toroidal field coils, where the magnetic field is weakened, generating toroidal field ripples, which in turn lead to energy loss of high-energy particles in plasma. Therefore, the calculation and simulation of toroidal field ripples are of great significance for the design and manufacture of toroidal field magnets.
[0003] In the related art, the toroidal field magnetic field value is usually calculated in advance in the electromagnetic simulation software, and then the toroidal field magnetic field value is imported into the simulation software such as Matlab to calculate the toroidal field corrugation; when calculating, the corresponding magnetic field is usually calculated first, and according to the number of toroidal field coils, the maximum and minimum values of the magnetic field in different meridian planes are derived to obtain the toroidal field magnetic field value, and then the toroidal field magnetic field value is imported into the simulation software, and the simulation software is used to calculate and plot the corrugation simulation result with R as the horizontal axis and Z as the vertical axis.
[0004] However, the method of exporting the toroidal field magnetic field value and then importing it into the simulation software to calculate the toroidal field waviness not only requires manual data import and export between different software, which is inefficient and increases the risk of errors, but also the corresponding simulation software is usually bloated; for example, Matlab usually occupies tens or even hundreds of gigabytes of storage space, and the method of using simulation software to calculate the toroidal field waviness cannot realize the waviness calculation in a lightweight way. Summary of the invention
[0005] In view of this, the present invention provides a method for simulating the toroidal field corrugation to solve the problem that the method of calculating the toroidal field corrugation using simulation software cannot realize the corrugation simulation efficiently and lightly.
[0006] The present invention provides a method for simulating toroidal field waviness, comprising: using a Python program script to read magnetic field data of a toroidal field coil calculated in electromagnetic simulation software, wherein the magnetic field data is used to calculate the waviness data of the toroidal field; calculating the waviness data of the toroidal field based on the magnetic field data in the Python program script; encapsulating a code containing the waviness data in the Python program script to generate a simulation execution file executable by the electromagnetic simulation software; using the electromagnetic simulation software to load and execute the simulation execution file, and displaying the waviness simulation result in the electromagnetic simulation software.
[0007] In one embodiment, the magnetic field data includes an R value range, a Z value range and a magnetic field value of a specified circumferential angle in a cylindrical coordinate system; the calculation of the corrugation data of the circumferential field based on the magnetic field data in a Python program script includes: calculating the corrugation data of all points to be calculated on a reference surface with R value as the horizontal coordinate and Z value as the vertical coordinate in a Python program script; using a python drawing library file to define the drawing properties of a corrugation simulation diagram based on the corrugation data; using the python drawing library file to determine the drawing range of the corrugation simulation diagram based on the R value range and the Z value range.
[0008] In one embodiment, the python drawing library file includes a matplotlib library file; before using the python drawing library file to define the drawing properties of drawing a corrugation simulation graph based on the corrugation calculation result, it includes: importing the matplotlib library file in the Python program script.
[0009] In one embodiment, the method of calculating the corrugation data of all points to be calculated on a reference surface with R value as the horizontal coordinate and Z value as the vertical coordinate in a Python program script includes: using the Python program script to extract the maximum magnetic field value and the minimum magnetic field value in all specified circumferential angles of the points to be calculated; using the corrugation calculation formula preset in the Python program script to calculate the corrugation data of all points to be calculated in sequence based on the maximum magnetic field value and the minimum magnetic field value.
[0010] In one embodiment, the specified toroidal angle includes the toroidal angle corresponding to the meridian plane where the toroidal field coil is located and the meridian plane between two toroidal field coils.
[0011] In one embodiment, the use of the electromagnetic simulation software to load and execute the simulation execution file and display the corrugation simulation results in the electromagnetic simulation software includes: configuring the simulation execution file to a preset loading path of the electromagnetic simulation software to map it to an operation button in the electromagnetic simulation software.
[0012] In one embodiment, configuring the simulation execution file to a preset loading path of the electromagnetic simulation software to map it to an operation button in the electromagnetic simulation software includes: configuring the simulation execution file to a cable modeling path in the electromagnetic simulation software, and mapping the operation button corresponding to the simulation execution file in the cable modeling operation bar in the operation interface of the electromagnetic simulation software.
[0013] In one embodiment, before using the Python program script to read the magnetic field data of the toroidal field coil calculated in the electromagnetic simulation software, it also includes: cleaning the magnetic field data to obtain the R value range, Z value range and magnetic field value of the specified toroidal angle in the cylindrical coordinate system.
[0014] In one embodiment, the electromagnetic simulation software package is at least one of Maxwell, PExprt, RMxprt, Q3D, and HFSS.
[0015] In one embodiment, the Python program script is encapsulated into the electromagnetic simulation software.
[0016] The simulation method of the toroidal field waviness of the present invention uses a Python program script to read the magnetic field data of the toroidal field coil calculated in the electromagnetic simulation software, and the magnetic field data is used to calculate the waviness data of the toroidal field; the toroidal field waviness data is calculated based on the magnetic field data in the Python program script; the code containing the waviness data is encapsulated in the Python program script to generate a simulation execution file executable by the electromagnetic simulation software; the simulation execution file is loaded and executed by the electromagnetic simulation software, and the waviness simulation result is displayed in the electromagnetic simulation software. By encapsulating the Python program script, the calculation and simulation of the waviness can be realized in the electromagnetic simulation software development configuration without installing the Matlab software, and the storage space is small, which has the advantage of being lightweight; the simulation execution file is executed by the electromagnetic simulation software, and the data does not need to be exported to other simulation software, which can improve the data processing efficiency and reduce the error probability. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 It is a flowchart of a method for simulating toroidal field waviness according to an embodiment of the present invention. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0020] This application provides a simulation method for toroidal field waviness, such as Figure 1 As shown, the method comprises the following steps:
[0021] Step S101. Using a Python program script to read the magnetic field data of the toroidal field coil calculated in the electromagnetic simulation software, the magnetic field data is used to calculate the waviness data of the toroidal field. In this embodiment, the electromagnetic simulation software may include Maxwell, PExprt, CircuitDesign, Emit, 2DExtractor, Q3DExtractor, HFSS, lcepak, twinBuilder and other software that can be used for electromagnetic simulation. In this embodiment, Maxwell is used as an example for description.
[0022] The magnetic field data of the toroidal field coil is calculated in advance in Maxwell. The magnetic field data calculated in Maxwell may include the selected cylindrical coordinate system, the R value range and Z value range defined in the cylindrical coordinate system, and the magnetic field values of each toroidal field angle. The R value range and the Z value range are defined based on the size of the toroidal field coil.
[0023] Write a program script based on Python language, develop and configure in Maxwell, export the magnetic field data of the toroidal field coil calculated in Maxwell, and use the Python program script to read the magnetic field data. In this embodiment, the read magnetic field data may include the selected cylindrical coordinate system, the R value range under the defined cylindrical coordinate system, the Z value range, the specified toroidal field angle and the magnetic field value corresponding to the specified toroidal field angle.
[0024] S102. Calculate the waviness data of the toroidal field based on the magnetic field data in the Python program script. When the Python program script is written in Python, a waviness calculation formula is preset in the Python program script. After the Python program script reads the magnetic field data, the parameters required by the waviness calculation formula can be extracted to calculate the waviness data of all points to be calculated on the reference surface with R value as the horizontal coordinate and Z value as the vertical coordinate.
[0025] Specifically, the maximum magnetic field value and the minimum magnetic field value in all specified circumferential angles of the point to be calculated are extracted based on the Python program script.
[0026] Based on formula (1), the waviness δ(R, Z) of all the points to be calculated with R as the horizontal coordinate and Z as the vertical coordinate is calculated:
[0027]
[0028] In formula (1), B max is the maximum magnetic field value at each specified toroidal angle, B min is the minimum value among all the specified toroidal angles. In one embodiment, in order to simplify the calculation, the maximum magnetic field value may be the magnetic field value of the meridian plane where the toroidal field coil is located, and the minimum magnetic field value may be the magnetic field value of the meridian plane between two adjacent toroidal field coils, and further, may be the intersection of the meridian plane of the half gap between two adjacent toroidal field coils and the central axis on the midplane.
[0029] In one embodiment, the points to be calculated may be multiple points with specified R values and Z values, or may be multiple points evenly distributed within the R value range and the Z value range according to preset R value intervals and Z value intervals, which is not limited in this embodiment.
[0030] After obtaining the waviness data of multiple points to be calculated, the drawing properties of the waviness simulation graph can be defined based on the waviness data through a python drawing library file. For example, the drawing properties may include the presentation form and presentation color of the simulation graph.
[0031] In one embodiment, a python drawing library file is imported into the written Python program script. For example, python drawing library files such as matplotlib library files, seborn library files, and ggplot library files can be used. In this embodiment, the matplotlib library file is taken as an example for explanation.
[0032] In one embodiment, after importing the matplotlib library file, the parameters required to extract the corrugation calculation formula are read, the corrugation data of all points to be calculated on the reference surface with R value as the horizontal coordinate and Z value as the vertical coordinate are calculated respectively, and the color corresponding to the corrugation value is defined using the matplotlib library file.
[0033] It can be defined that as the waviness value increases, the color gradually changes. For example, the smallest waviness can be dark blue. As the waviness value increases, the color changes from dark blue to light blue, then to light green, and then to light yellow. In this embodiment, the definition of drawing color can be determined by those skilled in the art based on needs.
[0034] The simulation diagram can be presented in the form of a corrugation cloud map, or in the form of a corrugation area division map, or in a map without area division. In this embodiment, all points to be calculated are presented in the form of a cloud map after defining colors according to the corrugation values. It can also be divided into multiple corrugation value intervals based on the size distribution of the corrugation value, and different intervals are defined with different colors. In this embodiment, the drawing form of the corrugation can be determined based on the needs of those skilled in the art.
[0035] The python drawing library file is used to determine the drawing range of the corrugation simulation graph based on the R value range and the Z value range, thereby completing the presentation form and presentation range of the corrugation simulation graph.
[0036] S103. Encapsulate the code containing the corrugation data of the toroidal field in the Python program script to generate a simulation execution file executable by the electromagnetic simulation software. Encapsulate the corrugation calculation code in the Python program script to generate a simulation execution file executable by the electromagnetic simulation software. In this embodiment, after the calculated corrugation data is plotted and the plotting range is defined, the calculation results of the corrugation, the data corresponding to the plotting properties and the plotting range and the corresponding code are encapsulated to generate a simulation execution file executable by the electromagnetic simulation software. In this embodiment, the simulation execution file can be a Maxwell executable exe file generated based on the python code as a simulation execution file, and the simulation execution file is placed in the specified path of the Maxwell software installation package. Directly execute the simulation execution file in Maxwell to display the simulation execution results in Maxwell.
[0037] S104. Use the electromagnetic simulation software to load and execute the simulation execution file, and display the waviness simulation result in the electromagnetic simulation software. After the simulation execution file is placed in the specified path of the Maxwell software installation package, an interface operation button for executing the simulation execution file can be associated in Maxwell, and then the corresponding operation button in the Maxwell software can automatically execute the simulation execution file to realize the extraction of the waviness simulation graph.
[0038] In the present application, a Python program script is used to read the magnetic field data of the toroidal field coil calculated in the electromagnetic simulation software; the corrugation data of the toroidal field is calculated based on the magnetic field data in the Python program script; the code containing the corrugation data is encapsulated in the Python program script to generate a simulation execution file executable by the electromagnetic simulation software; the simulation execution file is loaded and executed by the electromagnetic simulation software, and the corrugation simulation result is displayed in the electromagnetic simulation software. The Python program script is encapsulated on the electromagnetic simulation software, and the configuration is developed in the electromagnetic simulation software. The Python program script is used as a plug-in for the electromagnetic simulation software, and the electromagnetic simulation software is extracted in the Python program script. The data of magnetic field calculation of the toroidal field coil is obtained, and the magnetic field data used to calculate the corrugation is extracted, the corrugation is calculated, and a simulation execution file executable by the electromagnetic simulation software is generated. The electromagnetic simulation software then loads and executes the simulation execution file to display the corrugation simulation result, which is equivalent to encapsulating the python program script on the electromagnetic simulation software. After development and configuration in the electromagnetic simulation software, the electromagnetic simulation software can directly extract data for corrugation calculation, process data, calculate corrugation and display corrugation simulation. Therefore, there is no need to manually export data and then simulate through Matlab software. It is realized that the corrugation simulation diagram can be drawn without installing Matlab software, which not only improves the simulation efficiency, but also can realize corrugation simulation in a lighter way.
[0039] In one embodiment, a Founder executable file is generated in a python program script, which can be placed in a specified path of a Maxwell software installation package according to a pre-set path, and a new function operation button is mapped to an operation button in the electromagnetic simulation software. By clicking the operation button, the exe file can be automatically executed to extract and display the corrugation simulation results.
[0040] Exemplarily, taking Maxwell as an example, the simulation executable file is placed in the installation package path, which can be the path of cable modeling in the electromagnetic simulation software, and the operation button corresponding to the simulation execution file is mapped in the cable modeling operation bar in the operation interface of the electromagnetic simulation software. Exemplarily, the path can be in the Toolkits folder. The specific path is: D:\Program Files\AnsysEM\v222\Win64\syslib\Toolkits\Maxwell3D\Cable Modeling. At the same time, if you want to configure plug-ins for other software, you can choose different folders such as HFSS or Icepak. After the configuration is completed, start the software, select the Maxwell module, and select Maxwell3D->Toolkits->Cable Modeling->AddMeun in the ribbon menu bar in the Maxwell software. Among them, the AddMenu button is the operation button corresponding to the simulation execution file, and the name of the operation button can be the name of the simulation execution file.
[0041] The python program script is encapsulated in the electromagnetic simulation software. After the development and configuration in the electromagnetic simulation software, the magnetic field data calculated in the electromagnetic simulation software can be automatically extracted through the python program script for calculating the data for the waviness, and the waviness is automatically calculated, and the drawing properties of the waviness simulation are defined. Then, the electromagnetic simulation software executable file is generated, and automatically configured to the specified path of the electromagnetic simulation software installation package. The operation button corresponding to the simulation execution file is mapped to the corresponding position in the electromagnetic simulation software. Click the operation button to execute the simulation execution file, and get the waviness simulation result in the electromagnetic simulation software. One-click generation of waviness simulation results is achieved in the electromagnetic simulation software, which improves data processing efficiency and reduces the probability of errors.
[0042] An embodiment of the present invention also provides a computer device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus, the memory is used to store a computer program; the processor is used to execute a method in any of the above embodiments by running the computer program stored in the memory.
[0043] The above are only preferred implementations of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
[0044] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0045] The above are only preferred implementations of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for simulating toroidal field waviness, characterized in that: include: Using a Python program script to read the magnetic field data of the toroidal field coil calculated in the electromagnetic simulation software, the magnetic field data is used to calculate the waviness data of the toroidal field; Calculating the waviness data of the toroidal field based on the magnetic field data in a Python program script; Encapsulating the code containing the waviness data in a Python program script to generate a simulation execution file executable by the electromagnetic simulation software; The simulation execution file is loaded and executed using the electromagnetic simulation software, and the corrugation simulation result is displayed in the electromagnetic simulation software.
2. The method for simulating the toroidal field waviness according to claim 1, characterized in that: The magnetic field data includes an R value range, a Z value range and a magnetic field value of a specified circumferential angle in a cylindrical coordinate system; The step of calculating the waviness data of the toroidal field based on the magnetic field data in the Python program script includes: In the Python program script, calculate the waviness data of all points to be calculated on the reference surface with R value as the horizontal coordinate and Z value as the vertical coordinate; Using a python drawing library file to define drawing properties of a corrugation simulation graph based on the corrugation data; The python drawing library file is used to determine the drawing range of the corrugation simulation diagram based on the R value range and the Z value range.
3. The method for simulating the toroidal field waviness according to claim 2, characterized in that: The python drawing library file includes a matplotlib library file; Before using the python drawing library file to define the drawing properties of drawing the corrugation simulation diagram based on the corrugation calculation result, it includes: Import the matplotlib library file in the Python program script.
4. The method for simulating the toroidal field waviness according to claim 2, characterized in that: The calculation of the waviness data of all points to be calculated on the reference surface with R value as the horizontal coordinate and Z value as the vertical coordinate in the Python program script includes: Use Python script to extract the maximum and minimum magnetic field values in all specified circumferential angles of the points to be calculated; The waviness data of all the points to be calculated are calculated in sequence based on the maximum magnetic field value and the minimum magnetic field value using the waviness calculation formula preset in the Python program script.
5. The method for simulating the toroidal field waviness according to any one of claims 2 to 4, characterized in that: The specified toroidal angle includes the toroidal angle corresponding to the meridian plane where the toroidal field coil is located and the meridian plane between two toroidal field coils.
6. The method for simulating the toroidal field waviness according to claim 1, characterized in that: The using the electromagnetic simulation software to load and execute the simulation execution file, and displaying the waviness simulation result in the electromagnetic simulation software comprises: The simulation execution file is configured to a preset loading path of the electromagnetic simulation software to be mapped to an operation button in the electromagnetic simulation software.
7. The method for simulating the toroidal field waviness according to claim 1, characterized in that: The step of configuring the simulation execution file to a preset loading path of the electromagnetic simulation software to map the simulation execution file to an operation button in the electromagnetic simulation software includes: The simulation execution file is configured in the path of cable modeling in the electromagnetic simulation software, and an operation button corresponding to the simulation execution file is mapped in the cable modeling operation bar in the operation interface of the electromagnetic simulation software.
8. The method for simulating the toroidal field waviness according to claim 2, characterized in that: Before using the Python program script to read the magnetic field data of the toroidal field coil calculated in the electromagnetic simulation software, the method further includes: The magnetic field data is cleaned to obtain an R value range, a Z value range, and a magnetic field value of a specified circumferential angle in a cylindrical coordinate system.
9. The method for simulating the toroidal field waviness according to claim 1, characterized in that: The electromagnetic simulation software package is at least one of Maxwell, PExprt, CircuitDesign, Emit, 2DExtractor, Q3DExtractor, HFSS, Icepak, and twinBuilder.
10. The method for simulating the toroidal field waviness according to claim 1, characterized in that: The Python program script is encapsulated into the electromagnetic simulation software.
Citation Information
Patent Citations
Python and Maxwell-based three-dimensional electromagnetic torque automatic analysis method for permanent magnet spherical motor
CN109858123A