Cyclotron magnetic field isochronicity and harmonic padding method based on concomitant variable method

By employing the magnetic field isochronous and harmonic compensation method based on the adjoint variable method, and utilizing multi-objective error functionals and adjoint loads to synchronously correct isochronous and harmonic errors in a cyclotron, the problem of mutual interference in correction in existing technologies is solved, thereby improving the accuracy and efficiency of magnetic field correction.

CN123179844APending Publication Date: 2026-11-27FUJIAN RUISIKE MEDICAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611687934.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-29
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

In existing methods for magnetic field compensation in cyclotron accelerators, isochronous correction and harmonic correction interfere with each other, leading to an increase in the number of iterations and difficulty in guaranteeing the final accuracy.

Method used

A magnetic field isochronous and harmonic padding method based on the adjoint variable method is adopted. By establishing a nonlinear static magnetic field finite element model, and using multi-objective error functionals and adjoint loads, isochronous error and target order harmonic error are corrected simultaneously, reducing the interference caused by step-by-step correction.

Benefits of technology

Synchronous correction of isochronous and harmonic errors during the same boundary update process reduces mutual interference and improves the accuracy and efficiency of magnetic field correction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123179844A_ABST
    Figure CN123179844A_ABST
Patent Text Reader

Abstract

The application provides a cyclotron magnetic field isochronicity and harmonic compensation method based on a concomitant variable method, relates to the technical field of cyclotron magnetic field compensation, and comprises the following steps: obtaining a three-dimensional solution domain of a cyclotron, material magnetization characteristics, coil excitation and a parameterized boundary of a compensation area, and establishing a nonlinear static magnetic field finite element model; solving a forward state equation according to the nonlinear static magnetic field finite element model to obtain a magnetic vector potential and an axial magnetic field of an intermediate plane; and carrying out azimuth angle Fourier decomposition on the axial magnetic field of the intermediate plane to obtain an azimuth angle average magnetic field and the amplitude and phase of a target order harmonic. The application can simultaneously correct isochronicity errors and target order harmonic errors in the same boundary updating process, and reduce mutual interference of the two types of magnetic field errors caused by step-by-step compensation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of magnetic field padding technology for cyclotrons, and in particular to a method for isochronous and harmonic padding of the magnetic field of a cyclotron based on the adjoint variable method. Background Technology

[0002] A cyclotron is a device that uses a magnetic field to confine charged particles along a spiral trajectory and continuously accelerate them. To ensure that the cyclotron frequency of the particles is synchronized with the high-frequency electric field, the azimuth-averaged magnetic field of the intermediate plane must precisely meet the isochronism condition. At the same time, the amplitude and phase of the target order harmonics in this plane directly affect the beam stability and must be strictly controlled within the allowable range. Material defects and dimensional errors in the actual processing and assembly of magnets can cause the magnetic field to deviate from the design value. Therefore, it is usually corrected by adjusting the magnetic pole gap, the shape of the pad, and other padding structures.

[0003] Existing padding methods sometimes employ a step-by-step, sequential strategy: first, the padding is adjusted based on the average magnetic field deviation to correct isochronism, and then local correction is performed based on the harmonic deviation. However, any change in the morphology of the padding structure will simultaneously alter the average magnetic field and harmonics, causing mutual interference between the two correction stages. The isochronism correction result may be destroyed by subsequent harmonic correction, and the harmonic correction will also have a reverse effect on the already corrected isochronism magnetic field. These two types of errors hinder each other in repeated isolated adjustments, not only increasing the number of iterations but also making it difficult to guarantee the final accuracy, and may even introduce new errors. Summary of the Invention

[0004] This invention provides a method for compensating for the isochronous and harmonic magnetic field of a cyclotron based on the adjoint variable method. It can simultaneously correct the isochronous error and the target order harmonic error during the same boundary update process, reducing the mutual interference between the two types of magnetic field errors caused by step-by-step compensating.

[0005] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows:

[0006] Firstly, a method for compensating for the isochronous nature and harmonics of a cyclotron magnetic field based on the adjoint variable method, the method comprising:

[0007] To obtain the three-dimensional solution domain, material magnetization characteristics, coil excitation, and parametric boundary of the padding region of the cyclotron, a nonlinear static magnetic field finite element model is established.

[0008] The forward state equation is solved by the nonlinear static magnetic field finite element model to obtain the magnetic vector potential and the axial magnetic field of the intermediate plane.

[0009] The axial magnetic field of the intermediate plane is decomposed by azimuth angle Fourier transform to obtain the azimuth average magnetic field and the amplitude and phase of the target order harmonic.

[0010] Based on the azimuth-averaged magnetic field and the amplitude and phase of the target order harmonic, the isochronous error and the target order harmonic error are determined, and a multi-objective error functional is constructed.

[0011] The adjoint load is obtained from the forward state equation and the multi-objective error functional. The inverse adjoint equation is solved by the tangent stiffness matrix when the forward state equation converges, and the adjoint field is obtained.

[0012] The shape derivative of the multi-objective error functional with respect to each padding control parameter is determined based on the magnetic vector potential, the adjoint field, and the parameterized boundary of the padding region, and the discrete gradient is obtained.

[0013] The boundary deformation step size is determined based on the discrete gradient. The parameterized boundary of the padding area is adjusted and the finite element mesh is smoothed according to the boundary deformation step size to obtain the updated parameterized boundary.

[0014] Based on the updated parameterized boundary, the forward state equation and the inverse adjoint equation are repeatedly solved until the isochronous error meets the tolerance condition and the target order harmonic error meets the beam envelope limit. The target boundary of the padding area is then output to generate padding processing data.

[0015] Secondly, the isochronous and harmonic padding system for cyclotron magnetic fields based on the adjoint variable method includes:

[0016] The acquisition module is used to acquire the three-dimensional solution domain, material magnetization characteristics, coil excitation and parametric boundary of the padding region of the cyclotron, and to establish a nonlinear static magnetic field finite element model.

[0017] The decomposition module is used to solve the forward state equation based on the nonlinear static magnetic field finite element model to obtain the magnetic vector potential and the axial magnetic field of the intermediate plane; and to perform azimuth Fourier decomposition on the axial magnetic field of the intermediate plane to obtain the azimuth average magnetic field and the amplitude and phase of the target order harmonic.

[0018] The convergence module is used to determine the isochronous error and the target order harmonic error based on the azimuth-averaged magnetic field and the amplitude and phase of the target order harmonic, and to construct a multi-objective error functional; the accompanying load is obtained based on the forward state equation and the multi-objective error functional, and the inverse accompanying equation is solved by the tangent stiffness matrix when the forward state equation converges, to obtain the accompanying field.

[0019] The update module is used to determine the shape derivative of the multi-objective error functional with respect to each padding control parameter based on the magnetic vector potential, the adjoint field, and the parameterized boundary of the padding region, and obtain the discrete gradient; determine the boundary deformation step size based on the discrete gradient, adjust the parameterized boundary of the padding region according to the boundary deformation step size and smooth the finite element mesh to obtain the updated parameterized boundary;

[0020] The iterative module is used to repeatedly solve the forward state equation and the inverse adjoint equation based on the updated parameterized boundary until the isochronous error meets the tolerance condition and the target order harmonic error meets the beam envelope limit, and outputs the padding area target boundary used to generate pad processing data.

[0021] The above-described solution of the present invention has at least the following beneficial effects:

[0022] By establishing a nonlinear static magnetic field finite element model that includes the parameterized boundary of the padding area and multiple padding control parameters, the axial magnetic field of the intermediate plane is decomposed by azimuth angle Fourier decomposition. The isochronous error formed by the azimuth angle average magnetic field and the amplitude and phase error of the target order harmonic are jointly incorporated into the multi-objective error functional, so that the two types of magnetic field errors can be evaluated in the same padding process, reducing the mutual interference caused by correcting the two types of magnetic field errors separately.

[0023] The adjoint load is generated based on the multi-objective error functional, and the inverse adjoint equation is solved using the tangent stiffness matrix corresponding to the forward state equation. The shape derivatives of each padding control parameter are determined based on the magnetic vector potential, the adjoint field, and the parameterized boundary of the padding region. Since the discrete gradient can centrally characterize the influence of multiple padding control parameters on the two types of magnetic field errors, it is not necessary to solve the perturbation for each padding control parameter separately. This helps to reduce the amount of repeated magnetic field solution in the multi-parameter padding process and improve the consistency of the boundary adjustment basis. Attached Figure Description

[0024] Figure 1 This is a schematic flowchart of a method for isochronous and harmonic padding of cyclotron magnetic field based on the adjoint variable method provided by an embodiment of the present invention.

[0025] Figure 2 This is a schematic diagram of a cyclotron magnetic field isochronism and harmonic padding system based on the adjoint variable method provided by an embodiment of the present invention.

[0026] Figure 3 This is a schematic diagram of the process for outputting the target boundary of the padding area based on the updated parameterized boundary, provided by an embodiment of the present invention. Detailed Implementation

[0027] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.

[0028] In this embodiment, the intermediate plane is the particle motion center plane of the cyclotron magnet about the axis of symmetry; the axial magnetic field is the component of the magnetic induction intensity in the direction perpendicular to the intermediate plane; the isochronous target magnetic field is the radial target magnetic field determined according to the synchronization relationship between the particle cyclotron frequency and the radio frequency; the target order harmonic is the azimuth harmonic component that needs to be controlled according to the beam resonance condition; the parameterized boundary of the padding region is the boundary in the ferromagnetic domain that allows the morphology to be changed by the padding control parameters; the padding control parameters are the parameters characterizing the spatial position of the control points of the B-spline surface.

[0029] See Figures 1 to 3 This embodiment provides a method for isochronous and harmonic padding of cyclotron magnetic field based on the adjoint variable method. The method takes the geometric data of the cyclotron magnet, the material magnetization data, the coil excitation data and the beam design conditions as inputs, and the target boundary of the padding area as output, including steps S101 to S108.

[0030] Step S101: Obtain input data and establish a nonlinear static magnetic field finite element model, including:

[0031] Step S1011: Obtain the three-dimensional solution domain. The three-dimensional solution domain is jointly defined by the yoke, magnetic poles, padding area, coil, vacuum cavity, air region, and external truncation boundary given in the cyclotron magnet design document. The geometric coordinates use a uniform length unit. The three-dimensional solution domain is divided into a ferromagnetic domain, a coil conductor domain, and a nonmagnetic domain composed of the vacuum cavity and air. The ferromagnetic domain is used to bear the magnetization characteristics of nonlinear materials, the coil conductor domain is used to bear current density excitation, and the nonmagnetic domain is used to solve the magnetic field distribution in the vacuum cavity and air region. The shared geometric interfaces between the regions adopt consistent coordinates and consistent topological connection relationships. Overlapping regions, unclosed regions, and interfaces with inconsistent normal directions are repaired before meshing.

[0032] The region division uses the component number, material identifier, excitation identifier, and spatial enclosure relationship of each closed geometric entity in the magnet design file as input. First, the component number and material identifier of each closed geometric entity are read one by one. Entities whose material identifiers can be associated with the material's magnetization characteristics and which do not have current density excitation are classified into the ferromagnetic domain. Next, the excitation identifier is read; entities with coil winding direction, inlet, outlet, and current density records are classified into the coil conductor domain. If an entity has both a ferromagnetic material identifier and an excitation identifier, the entity is recorded as an entity with conflicting attributes, and classification of that entity is stopped. The magnet design file is then returned to verify the material identifier and excitation identifier; no forced classification is performed based on either identifier. Finally, the unclassified space, located within the enclosure of the vacuum cavity's closed wall and not yet classified, is processed. The spaces belonging to the aforementioned two categories are classified into the vacuum domain, and the remaining space between the outer surface of the magnet entity, coil entity, and vacuum cavity and the external cutoff boundary is classified into the air domain. The vacuum domain and air domain are jointly marked as non-magnetic domains. After the initial classification is completed, all entities are traversed. An entity without a region identifier is recorded as an unclassified entity, and an entity with two region identifiers is recorded as a duplicated entity. For unclassified entities, the component number, material identifier, and spatial closure relationship are checked. For duplicated entities, the material identifier, excitation identifier, and entity overlap relationship are checked. When all entities have one and only one region identifier, the entity number sets of the ferromagnetic domain, coil conductor domain, and non-magnetic domain are output respectively for subsequent loading of materials, source terms, and mesh attributes according to entity number.

[0033] The three-dimensional solution domain is checked sequentially according to geometric entities, common interfaces, and region closure. First, the boundary lines and endpoint coordinates of each geometric surface are read, and boundary lines with endpoint spacing not exceeding the geometric tolerance adopted in the magnet design document are identified as the same connecting edge. Then, the connecting edges are traversed face by face along the outer surface of each region. When a connecting edge is used by only one surface, the corresponding position is marked as an unclosed position; when a connecting edge is occupied by multiple surfaces, the corresponding position is marked as an overlapping position. Subsequently, the surface normal is determined according to the node arrangement direction of each surface, thus separating the external normals of the ferromagnetic domain, coil conductor domain, and non-magnetic domain. Do not face outwards from their respective regions; fill in the geometric surfaces that are continuous with the adjacent boundaries for unclosed locations, retain the common surfaces required for region division and delete duplicate surfaces for overlapping locations, and swap the node arrangement order for surfaces with opposite directions; after processing, traverse all connected edges again, and when unclosed markers, overlapping markers and normal conflict markers are eliminated, output a 3D solution domain with region number and interface number; since the region number is directly used for subsequent material and coil excitation loading, and the interface number is directly used for shared mesh node association, this check can prevent material parameters and source terms from being loaded into the wrong region.

[0034] Step S1012: Obtain the magnetization characteristics of the material. The magnetization characteristics are provided by the magnet material data file, which records the correspondence between magnetic field strength and magnetic induction intensity in ascending order of magnetic field strength. The unit of magnetic field strength is ampere per meter, and the unit of magnetic induction intensity is tesla. The effective range of the data covers the range of magnetic induction intensity corresponding to the working point of the magnet. For each finite element integration position in the ferromagnetic domain, first determine the adjacent material data interval it falls into based on the current magnetic induction intensity, and then determine the nonlinear magnetoresistance based on the relative position of the current magnetic induction intensity between the adjacent data endpoints. When the current magnetic induction intensity is located at the common boundary of the two intervals, use the material data corresponding to the common boundary. When the current magnetic induction intensity exceeds the effective range of the material data, stop using the solution results of this round, and supplement the material magnetization data covering the working range before rebuilding the model. This ensures that the nonlinear magnetoresistance always comes from the obtained material magnetization characteristics, rather than being arbitrarily set by the solver.

[0035] The process of obtaining the nonlinear magnetoresistance is as follows: First, subtract the magnetic induction intensity at the lower end of the adjacent material data interval from the current magnetic induction intensity to obtain the increment of the current magnetic induction intensity relative to the lower end of the interval; then divide this increment by the difference between the magnetic induction intensity at the upper end and the lower end of the interval to obtain the relative position of the current working point within the interval; subsequently, obtain the difference between the magnetic field strength at the upper end and the lower end of the interval, combine this difference with the relative position, and merge it with the magnetic field strength at the lower end of the interval to obtain the magnetic field strength corresponding to the current working point; finally, divide the magnetic field strength corresponding to the current working point by the current magnetic induction intensity to obtain the nonlinear magnetoresistance at this integration position; when the magnetic induction intensities of adjacent endpoints are the same, the material data is marked as a duplicate point and merged before solving; when the current magnetic induction intensity is 0, the initial magnetoresistance given by the interval near the origin of the material data is used to avoid division by zero; after each update of the nonlinear magnetoresistance, its source interval number is retained so as to obtain the material variation relationship within the same interval when assembling the tangent stiffness matrix.

[0036] Step S1013: Obtain coil excitation; the coil excitation is provided by the magnet excitation design file, including the coil conductor domain, conductor winding direction, excitation direction, and current density, the value range of which is limited by the excitation data of the corresponding operating conditions of the cyclotron; the coil excitation is applied to the coil conductor domain, and the consistency between the excitation direction and the coil winding direction is checked; when the coil consists of multiple conductor sections, the corresponding current density is applied to each conductor section, and the current direction relationship of each conductor section is maintained; this process enables the applied current density to be used as a source term of the positive state equation.

[0037] When the excitation design document directly provides the current density, read the corresponding value and direction according to the coil conductor region number; when the excitation design document provides the single-turn current, effective number of turns, and effective conductor cross-sectional area, first combine the single-turn current and effective number of turns to obtain the total ampere-turns carried by the conductor cross-section, then divide the total ampere-turns by the effective conductor cross-sectional area to obtain the current density, and assign positive and negative directions along the tangent direction of the conductor winding direction; for each coil conductor region, check the current density direction against the inlet, outlet, and winding direction markings of that conductor region item by item; if the inlet and outlet markings are missing, or the effective cross-sectional area is missing, check the current density direction against the inlet, outlet, and winding direction markings of that conductor region item by item. When the area is 0 and the conductor domain is not closed, no source term is loaded into the region and the excitation data check result is returned. After loading is completed, the coil conductor domain number, current density magnitude, direction, and operating condition number are bound and saved for the forward state equation to read according to the region to which the unit belongs. Control points are evenly distributed along the circumference of the intercepted cylindrical surface, and the angular spacing between adjacent control points is equal. In the axial direction, control points are distributed in the axial interval corresponding to the magnetic pole boundary. Multiple layers can be evenly arranged along the axial direction. The total number of control points is determined by the required boundary deformation resolution; the higher the resolution, the denser the control points. Once the control points are selected, they remain unchanged throughout the entire iteration process.

[0038] Step S1014: Obtain the parameterized boundary and padding control parameters of the padding area. The parameterized boundary of the padding area is determined by the area on the magnetic pole surface where padding processing is allowed, and is characterized by a B-spline surface. Each control point on the B-spline surface has a fixed number and spatial coordinates. The coordinates of the control points use the same length unit as the three-dimensional solution domain. The coordinate components of each control point along the allowable deformation direction are used as padding control parameters. For any parameter position on the B-spline surface, determine the control points with non-zero active range at that position. Obtain the weights of the B-spline basis functions of these control points in the two parameter directions. Weight and merge the coordinates of each control point according to the corresponding weights to obtain the boundary coordinates of the parameter position. The control point number, parameter direction, basis function order, and node sequence remain unchanged throughout the iteration process. Only the coordinates of the control points that allow deformation are updated. Control points located on fixed connecting edges, symmetric edges, and non-processing areas are kept locked, so that each padding control parameter has a clear geometric object and allowable variation range.

[0039] The B-spline basis function weights are obtained recursively based on the basis function order and node sequence. First, the node interval where the current parameter position is located is determined in each parameter direction. The 0th-order basis function value within this node interval is set to 1, and the remaining 0th-order basis function values ​​are set to 0. Then, starting from the 1st order, the weights are calculated sequentially. The distance ratio of the current parameter position relative to the left node interval is combined with the previous left basis function value, and the distance ratio of the right node interval relative to the current parameter position is combined with the previous right basis function value. The two combined results are merged to obtain the basis function weight for the current order, until the set B-spline order is reached. When the node interval length is 0, the corresponding combined result is set to 0. When the parameter position is located at the common boundary of two node intervals, it is processed according to the later effective interval in the node sequence. When the parameter position is located at the end of the surface, the end basis function value corresponding to the end point is set to 1. After obtaining the basis function weights for the two parameter directions, the corresponding weights are combined to form the final weight of the control point relative to the surface position.

[0040] Step S1015: Finite element meshing is performed on the ferromagnetic domain, coil conductor domain, and non-magnetic domain. Each region is discretized using high-order hexahedral elements. A mesh density adapted to the magnetic field changes is arranged at the parameterized boundary, material interface, and intermediate plane of the padding area, while maintaining the mesh connection relationship on both sides of the shared interface. Each physical element establishes a correspondence with the reference element through isoparametric mapping. The Jacobian determinant of the isoparametric mapping is used to determine whether the element has been flipped. If the Jacobian determinant does not meet the element validity requirements, the local nodes are readjusted and the mesh is re-disassembled until an effective finite element mesh is obtained.

[0041] The mesh density is determined jointly from the minimum fabrication features of the padding, the curvature changes of the material interface, and the evaluation position of the magnetic field in the intermediate plane in the magnet design file. First, boundary nodes are arranged along the parameterized boundary of the padding area so that the spacing between adjacent nodes can characterize the local boundary changes caused by the control points. Then, the unit layer is extended from the boundary nodes into the ferromagnetic domain, and the interface nodes are shared on both sides of the material interface. Subsequently, the meshes of the coil conductor domain and the non-magnetic domain are connected to the existing interface nodes until the outer truncation boundary is covered. For each unit, the unit number, region number, node number, adjacent unit number, and boundary surface number are recorded. When inconsistent nodes appear on both sides of the shared interface, the interface node positions and numbers are unified first, and then adjacent body units are generated. This makes the material jump position, padding boundary position, and axial magnetic field extraction position traceable by the mesh carrier.

[0042] The target mesh size is determined in the following order: At the parameterized boundary of the padding area, the characteristic length of the influence range of the control point and the minimum processing feature of the padding given in the magnet design document are used as candidate sizes, and the candidate size with the smaller value is taken as the target mesh size of the boundary; At the material interface, the surface normal direction of adjacent positions is compared. If the direction change exceeds the allowable value of the mesh configuration, the local target mesh size is reduced and re-divided until the adjacent interface elements can maintain continuous normal change; At the intermediate plane, the radial sampling interval and the arc length of the adjacent sampling points in the azimuth direction used in step S103 are used as candidate sizes, and the candidate size with the smaller value is taken as the target mesh size of the magnetic field extraction area; When a position is constrained by more than two size rules at the same time, the smallest target mesh size is used; The element size is increased layer by layer from the fine mesh area to the coarse mesh area. When the increase in size of adjacent layers exceeds the allowable value of the mesh configuration, a transition layer is inserted; After the subdivision is completed, the actual element size of the padding area boundary, material interface and intermediate plane is checked. If the corresponding target mesh size is not reached, local subdivision is continued. Only after reaching the target mesh size is the element validity check performed.

[0043] The shape function of a high-order hexahedral element is obtained by combining one-dimensional polynomial basis functions in three reference coordinate directions. For any integration position within the reference element, the basis function values ​​of that position relative to each node in the three reference coordinate directions are calculated. Then, the basis function values ​​belonging to the same node in the three directions are combined to obtain the shape function value of that node. The changes in the shape function along the three reference coordinate directions are calculated in the same order. When performing isoparametric mapping, the coordinates of each node of the physical element are weighted and merged according to the corresponding shape function values ​​to obtain the physical coordinates of the integration position. The coordinates of each node are combined with the changes in the shape function in the three reference coordinate directions to obtain nine change components of the physical coordinates relative to the reference coordinates, and arranged in a 3x3 matrix to form the isoparametric mapping Jacobian matrix. The Jacobian determinant is obtained by subtracting the sum of the three products in the anti-diagonal direction from the sum of the three products in the main diagonal direction of the matrix. If the determinant is greater than the lower limit of mesh effectiveness, the element is retained; if it does not reach the lower limit of mesh effectiveness, the element nodes are readjusted.

[0044] Step S1016: The material magnetization properties, coil excitation, and boundary conditions are loaded onto the finite element mesh; the ferromagnetic domain is loaded with nonlinear reluctance, the coil conductor domain is loaded with applied current density, and the nonmagnetic domain is loaded with the corresponding reluctance; homogeneous Dirichlet boundary conditions are applied to the outer truncated boundary, and homogeneous Neumann boundary conditions are applied to the intermediate plane; the magnetic vector potential adopts the Coulomb gauge; the nonlinear static magnetic field finite element model is formed by the three-dimensional solution domain, finite element mesh, material parameters, source terms, boundary conditions, parameterized boundary of the padding region, and padding control parameters; since each input is loaded onto the corresponding finite element region and equation position, this model can provide a definite data basis for subsequent forward solutions.

[0045] Region attributes are loaded according to the entity number set; for each element in the ferromagnetic domain, the corresponding material number is read according to the entity number to which the element belongs, and then the material magnetization data is associated with the material number; for each element in the coil conductor domain, the corresponding coil partition number is read according to the entity number to which the element belongs, and then the current density vector is associated with the partition number; for each element in the non-magnetic domain, the magnetic parameters recorded in the solver material library using a uniform unit are read according to the vacuum domain identifier or air domain identifier; after loading, the region number, material number, and source term number of each element are checked one by one. If the ferromagnetic element is missing a material number, the coil conductor element is missing a source term number, or the non-magnetic element has a current density source term, the model assembly is stopped and the corresponding element number is returned; when the attributes of all elements are consistent with the region identifier, a one-to-one correspondence between the element number and the material parameters and source terms is formed.

[0046] When loading boundary conditions, first obtain all nodes and degrees of freedom associated with the boundary surface according to the boundary surface number; assign fixed boundary values ​​to the magnetic vector potential degrees of freedom associated with the external truncated boundary, and separate these degrees of freedom from the degrees of freedom to be solved when assembling the global equations; retain the tangential degrees of freedom of the boundary surfaces associated with the intermediate plane, and do not add external source terms passing through the intermediate plane in the boundary integral; for the Coulomb gauge, form magnetic vector potential divergence constraints according to the node connection relationship, and apply them together with the state equations, thereby eliminating the uncertain state caused by multiple magnetic vector potential representations corresponding to the same magnetic induction intensity; after loading is completed, check that each finite element has a region material identifier, each coil conductor element has a source term identifier, and each external boundary degree of freedom has a boundary identifier; after verification, combine these identifiers, degree of freedom numbers, and control parameter numbers into model version data.

[0047] Step S102, solve the forward state equations, including:

[0048] The equation of state for a nonlinear static magnetic field is as follows: ;

[0049] in The magnetic vector potential, It is a nonlinear magnetoresistive tensor. This represents a vector differential operator consisting of partial derivatives in three spatial coordinate directions; || × ‖ represents the magnitude of the magnetic flux density vector; Represents the nonlinear reluctance function. The input quantity is the magnetic flux density modulus. When using a repaired coil implementation, the vector representing the applied current density across the coil conductor domain as a whole is used. This includes the current density of the basic excitation coil and the control parameter set. Characterized current density field of the repair coil; This indicates the set of control parameters used in the current padding method. As a set of parameters, no single physical unit is set. The unit of its parameter content is determined by the selected padding method. The coordinate components of the normal perturbation vector field adopt the length unit of the magnet geometric model, and the current density field of the repair coil adopts amperes per square meter. Indicates the control parameter set The normal perturbation vector field, which is characterized, determines the three-dimensional solution domain of the boundary morphology.

[0050] Step S1021: Set initial values ​​for the magnetic vector potential. In the first round of solving, first check if there is a converged magnetic field result that is consistent with the current 3D solution domain version, material data version, and coil excitation version. If it exists, read the magnetic vector potential in the result according to the node number as the initial value. If it does not exist, set the magnetic vector potential of the internal degrees of freedom to 0, and set the boundary degrees of freedom according to the applied boundary conditions to obtain the initial value that satisfies the boundary constraints. In subsequent rounds, map the magnetic vector potential obtained from the previous round of convergence to the updated finite element mesh, and use it as the initial value of the magnetic vector potential for the current round. For each node in the updated mesh, search for the original element surrounding the node in the mesh before the update according to its spatial coordinates, reverse the spatial coordinates of the node to the reference coordinates of the original element, and then use the shape function of the original element and the magnetic vector potential of each node of the original element to obtain the magnetic vector potential of the current node. If a node fails to be located to the original element, first expand to the set of elements adjacent to the original boundary for relocation. If it still fails to be located, stop the mapping of this round and return the node number. Nodes falling on the updated boundary are corrected according to the corresponding boundary conditions.

[0051] Step S1022: Assemble the forward state equations; for each finite element, determine the magnetic induction intensity and its magnitude at each integration position based on the current magnetic vector potential, and then obtain the nonlinear magnetoresistance from the material magnetization characteristics; combine the nonlinear magnetoresistance, the curl of the element shape function, the applied current density, and the integration weight into the element residual and the element tangent stiffness matrix, and assemble them into the global solution residual and the global tangent stiffness matrix according to the node number; use the corresponding materials and source terms for the ferromagnetic domain, the coil conductor domain, and the nonmagnetic domain respectively, and process the boundary nodes according to the applied boundary conditions.

[0052] The volume integral position and integration weight are determined by the order of the hexahedral element. First, one-dimensional Gaussian integration positions and one-dimensional Gaussian integration weights corresponding to the element order are selected in the three reference coordinate directions of the reference element. Then, the integration positions in the three directions are combined term by term to form the volume integral position. The corresponding three one-dimensional integration weights are multiplied and combined with the absolute value of the isoparametric mapping Jacobian determinant to obtain the physical integration weight of the volume integral position. When the number of integration positions is insufficient to cover the integrand corresponding to the current element order, the number of integration positions in each reference coordinate direction is increased and the elements are reassembled. When the isoparametric mapping Jacobian determinant is zero or the sign is reversed, the element is marked as an invalid element and the process returns to step S1015 for re-subdivision. Thus, the residual of each element and the element tangent stiffness matrix are formed by the explicit integration position, material values, and physical integration weight.

[0053] The element residual represents the unbalanced difference between the internal magnetic field response and the source term of the applied current density after the current magnetic vector potential is substituted into the discrete state equation. To calculate the element residual, for each element degree of freedom, the nonlinear reluctance, the current magnetic flux density, and the curl of the corresponding shape function are combined, multiplied by the weight of the integration position and the isoparametric Jacobian determinant, to obtain the internal magnetic field response contribution. Then, the applied current density is combined with the corresponding shape function of that degree of freedom and multiplied by the same integration scale to obtain the source term contribution. The source term contribution is subtracted from the internal magnetic field response contribution to obtain the residual contribution at that integration position. The element residual is obtained by merging the residual contributions from all integration positions of the element. Finally, the element residuals are merged according to the global node number to obtain the global solution residual.

[0054] The element tangent stiffness matrix represents the response relationship of the element residual to the changes in each degree of freedom of the magnetic vector potential. When calculating the element tangent stiffness matrix, the changes in magnetic flux density caused by the change in magnetic vector potential and the changes in nonlinear reluctance caused by the change in magnetic flux density are determined respectively. The contributions of the two changes to the element residual are arranged according to the row and column degrees of freedom, and then multiplied by the integral weight and the isoparametric mapping Jacobian determinant to obtain the matrix contribution at each integration position. After merging the matrix contributions of all integration positions, the element tangent stiffness matrix is ​​obtained, and it is assembled into a global tangent stiffness matrix according to the global node number. The global tangent stiffness matrix retained when the forward state equation converges is used for the inverse adjoint equation in step S105.

[0055] Step S1023: The Newton-Krylov-Shure domain decomposition algorithm is used to solve the forward state equation. First, the magnetic vector potential correction direction is obtained based on the global tangent stiffness matrix and the current solution residual. Then, the three-dimensional solution domain is divided into multiple interconnected sub-regions. Krylov iteration is performed on the linear equations in each sub-region, and the boundary nodes of the sub-regions are coordinated through the Shure complement relation to obtain the global magnetic vector potential correction. The magnetic vector potential correction is multiplied by the current relaxation factor and then superimposed on the magnetic vector potential to obtain the candidate magnetic vector potential.

[0056] The sub-region partitioning takes the adjacency relationship of the aforementioned finite element elements and the number of available processing elements as input. First, an element adjacency record is formed based on the shared element surface as the connection relationship. Then, starting from the seed elements distributed in different positions of the three-dimensional solution domain, the partitioning is expanded along the adjacency record, and adjacent elements are sequentially assigned to the corresponding sub-regions. During each expansion, adjacent elements that reduce the difference in the number of elements in each sub-region and have fewer new interfaces are selected first, until all elements have obtained one sub-region number. When an element obtains two sub-region numbers, the previously assigned sub-region number is retained and duplicate numbers are removed. When an element does not obtain a sub-region number, it inherits the sub-region number from the assigned element that shares the element surface with it. After the partitioning is completed, the node that is connected by two sub-regions is recorded as the boundary node, and the node that is connected only by elements in the same sub-region is recorded as the internal node. The Schur complement relationship only coordinates the unknowns of the boundary nodes.

[0057] During domain decomposition, the finite element mesh is divided into several sub-regions based on the adjacency relationship of the elements. The degrees of freedom of each sub-region are distinguished into internal degrees of freedom belonging only to that sub-region and interface degrees of freedom shared by adjacent sub-regions. First, the current value of the interface degrees of freedom is fixed, and the response of the internal degrees of freedom of each sub-region to the current residual is obtained. Then, the contribution of the internal degree of freedom response to the interface is merged into the interface equation, resulting in a Schur complement problem containing only interface degrees of freedom. The Krylov process starts from the initial state of the interface correction and uses the Schur complement problem to apply the current interface correction to obtain the interface residual. Then, a new search direction is formed based on the preprocessing results. After each update of the interface correction, the interface residual is obtained again until the interface residual satisfies the linear solution accuracy condition. The obtained interface correction is substituted back into the internal equations of each sub-region to obtain the internal degree of freedom correction, and then merged into the global magnetic vector potential correction according to the global degree of freedom number. The interface degrees of freedom that are used repeatedly between sub-regions are only merged once to prevent the same correction contribution from being counted repeatedly.

[0058] Step S1024: Perform line search and adaptive relaxation; reassemble the solution residuals using candidate magnetic vector potentials and compare the candidate solution residuals with the solution residuals before the update; when the candidate solution residuals decrease, accept the current magnetic vector potential update and adjust the next relaxation factor according to the continuous decrease state; when the candidate solution residuals do not decrease, reduce the current relaxation factor, re-form the candidate magnetic vector potentials and recalculate the solution residuals; repeat the above process until the solution residuals meet the convergence conditions determined according to the magnetic field solution accuracy; this process controls the magnetic vector potential update with the actual decrease result of the residuals to avoid nonlinear solution oscillations caused by directly using excessively large correction amounts.

[0059] The initial value, upper and lower limits of the adaptive relaxation factor are given by the stability configuration of the nonlinear static magnetic field solver. When the candidate solution residuals continuously decrease, the relaxation factor is increased in the next iteration within the upper limit, increasing the magnetic vector potential correction. When the candidate solution residuals do not decrease, the current relaxation factor is decreased within the lower limit, decreasing the magnetic vector potential correction. If the solution residuals do not decrease after the relaxation factor reaches the lower limit, the check is performed on the coverage of the material magnetization data, the validity of the finite element mesh, and the coil excitation direction. The convergence condition is obtained by converting the magnetic field solution allowable error. During the conversion, a magnetic vector potential change that can cause the allowable error is applied to the region of interest in the magnetic field design, the corresponding discrete state equation residuals are calculated, and the magnitude of the obtained residuals is used as the convergence criterion. When the solution residuals are not higher than the criterion, the positive state equations are considered to have converged.

[0060] In step S1025, after solving the residuals to satisfy the convergence condition, the converged magnetic vector potential and the tangent stiffness matrix at the convergence of the forward state equation are output. For each sampling position on the intermediate plane, the magnetic vector potential is subjected to spatial curl processing according to the shape function derivative of the finite element at that position, and the component perpendicular to the intermediate plane is extracted to obtain the axial magnetic field of the intermediate plane. The tangent stiffness matrix, the current magnetic vector potential, the current finite element mesh, and the current material state are collectively labeled as the same round of data, and are used as the coefficient matrix of the inverse adjoint equation in step S105.

[0061] The extraction process of the axial magnetic field is as follows: First, search for the intermediate plane element surrounding the sampling position based on the spatial coordinates of the sampling position. Then, obtain the reference coordinates of the position in the reference element through the inverse positioning of the isoparametric mapping. Subsequently, obtain the magnetic vector potential components of each node and the changes of the shape function along the physical coordinate direction, respectively forming the changes of the first spatial component of the magnetic vector potential along the second spatial direction and the changes of the second spatial component of the magnetic vector potential along the first spatial direction. Combine them according to the curl direction relationship to obtain the axial magnetic field perpendicular to the intermediate plane. When the sampling position does not fall into any effective element, do not directly replace it with the neighboring node, but return the check result that the sampling position is inconsistent with the mesh coverage. When the sampling position is located at the common boundary, use the shared degree of freedom to form a consistent magnetic vector potential value.

[0062] Step S103, performing azimuth Fourier decomposition on the axial magnetic field, including:

[0063] Step S1031: Determine multiple radial sampling positions based on the radial range covered by the beam acceleration orbit; number the radial sampling positions in order from the inside out, and set sampling points with equal angular intervals along the complete azimuth range at each radial sampling position; first, obtain the highest target harmonic order to be retained, set the number of azimuth sampling points to an integer greater than twice the highest target harmonic order, then adjust it upwards to an integer power of 2 that can perform a fast Fourier transform, and use the same number of sampling points with the same azimuth zero point at each radial position; for each sampling point, locate the intermediate plane finite element according to its spatial coordinates, and then use the element shape function to interpolate the axial magnetic field to obtain the axial magnetic field azimuth sequence corresponding to each radial position; when the sampling point falls on the common boundary of the finite element, take the value according to the unified interpolation result of the shared node; when the sampling point does not fall into any intermediate plane element, return the sampling point number and radial position to step S1015 to supplement the mesh coverage.

[0064] Radial sampling positions are obtained from the orbital radius sequence in the beam design data. When there are undefined positions between adjacent orbital radii, sampling positions are supplemented according to the radial interval required for magnetic field evaluation, and the design orbital numbers to the left and right are retained. The number of azimuth sampling points is first determined by the highest target harmonic order, so that each target harmonic period within the complete azimuth has sampling points sufficient to distinguish peak, valley, and zero-crossing positions, and then adjusted upwards to an integer power of 2 that can be processed by the Fast Fourier Transform. The interval between adjacent azimuth sampling points is obtained by dividing the complete azimuth by the number of sampling points. After completing the axial magnetic field value acquisition, the periodic continuity of the beginning of the sequence and the end of the complete azimuth is checked. When the difference between the beginning and end magnetic fields corresponding to the same spatial direction exceeds the allowable error of the forward solution, the azimuth zero point, grid period connection relationship, and sampling coordinates are checked.

[0065] Step S1032: Perform a Fast Fourier Transform on each axial magnetic field azimuth sequence. The core expansion formula for the axial magnetic field is expressed as: ;

[0066] in, As a whole, it represents the axial magnetic field of the intermediate plane; Indicates the radial coordinates within the intermediate plane; It represents the azimuth angle measured from the unified azimuth zero point along a specified positive direction; This represents the set of control parameters used in the current padding method. In the geometric padding implementation, it represents the normal perturbation vector field of the geometric boundary surface of the padding area, and in the repair coil implementation, it represents the current density field of the repair coil. As a whole, it represents the azimuth-averaged magnetic field at the same radial position; Indicates the current harmonic order; As a whole, it represents the highest harmonic order that is retained; As a whole, it represents the first The cosine component coefficients of the first harmonic; cos represents the cosine function. Represents the sine function. Indicates harmonic order With azimuth The product of these is used as the input for trigonometric functions.

[0067] The Fast Fourier Transform (FFT) is performed according to the azimuth sampling point number. First, a number of sampling points sufficient to cover the target harmonic order is selected, and this number is set to an integer power of 2. Then, the axial magnetic field sequence is rearranged according to the binary reverse order of the sampling point numbers, ensuring that the sequence elements requiring step-by-step merging are adjacent. In the first stage, adjacent axial magnetic field values ​​are summed and differencing. In the second stage, the results from the previous stage, formed by adjacent four axial magnetic field values, are merged using the corresponding azimuth rotation factor. In subsequent stages, the length of the merged sequence is doubled compared to the previous stage until all sampling points are merged. The azimuth rotation factor used in each stage is determined by the ratio between the current merging position and the current sequence length; its real part contributes to the cosine component, and its imaginary part contributes to the sine component. After completing all stages, the output results are scaled according to the number of sampling points. The zero-order output corresponds to the azimuth average magnetic field, and the k-th order output corresponds to the cosine and sine component coefficients of the k-th harmonic. If the number of sampling points is insufficient to distinguish the target harmonic order, additional sampling points are added, and the axial magnetic field azimuth sequence is extracted again.

[0068] Step S1033: Determine the amplitude and phase of the target order harmonic. First, the cosine and sine components of the same order are taken as two mutually orthogonal harmonic components, and the length of the vector formed by the two harmonic components in the plane is taken as the harmonic amplitude. Then, the quadrant in which the phase is located is determined according to the signs of the cosine and sine components, and the angle in the quadrant is determined according to the ratio between the two components to obtain the harmonic phase. When both components are zero, the harmonic amplitude is determined to be zero, and the phase is marked as not participating in the phase error evaluation. When only one component is zero, the phase is determined according to the sign of the other component. This process avoids generating physically meaningless phase errors when the harmonic amplitude is zero.

[0069] The harmonic amplitude is obtained by first obtaining the product of the cosine component and itself, and the product of the sine component and itself, then merging the two products and performing a square root operation on the merged result; the harmonic phase is obtained by simultaneously identifying the arctangent of the sine and cosine components, so that the phase can cover the complete azimuth angle without losing quadrants; when comparing adjacent phases radially, the current phase is first added to or subtracted by an integer multiple of the complete angle, the value with the smallest phase difference from the previous radial position is selected, and then saved as a continuous phase sequence; this continuity only changes the equivalent representation of the phase, without changing the cosine component, sine component, and harmonic amplitude.

[0070] Step S104, determine the two types of errors and construct a multi-objective error functional, including:

[0071] Step S1041: Determine the isochronous target magnetic field; read the design correspondence between particle type, particle energy and orbital radius, radio frequency and harmonic acceleration number of the cyclotron; for each radial sampling position, first obtain the design particle energy corresponding to that position, and then determine the magnetic field strength required at that position based on the synchronization relationship between the particle cyclotron frequency and the radio frequency, thus obtaining the isochronous target magnetic field arranged radially; each target magnetic field corresponds one-to-one with the radial sampling position, and radial positions that do not fall within the design acceleration orbit range are not included in the error evaluation.

[0072] The rest mass and charge of the particle are obtained based on the particle type, and the design kinetic energy is obtained based on the current radial position. The design kinetic energy is compared with the particle's rest energy to obtain the energy correction factor reflecting the relativistic mass change. Then, the particle cyclotron frequency that needs to be maintained at this radial position is determined based on the radio frequency and harmonic acceleration number. The particle rest mass, energy correction factor, and particle cyclotron frequency are combined and scaled according to the particle charge to obtain the isochronous target magnetic field at this radial position. The particle type, radio frequency, harmonic acceleration number, and energy trajectory relationship are only combined when they belong to the same beam design version; if the versions are inconsistent, an isochronous target magnetic field is not formed.

[0073] Step S1042: Determine the target amplitude and target phase of the target order harmonics; the target harmonic order, target amplitude, target phase, and applicable radial range are given by the resonance control conditions in the beam optics design data; for each target harmonic order, convert the target amplitude and target phase in the design data to the same radial position, azimuth zero point, and phase direction as in step S103; when the design data and the magnetic field model use different radial sampling positions, interpolation is first performed between adjacent design positions according to the relative distance of the target radial position; when the target radial position exceeds the coverage of the design data, this position is not included in the target harmonic error evaluation, and a prompt to supplement the beam optics design data is returned.

[0074] During radial interpolation, the left design position is first subtracted from the target radial position to obtain the distance between the target radial position and the left design position. This distance is then divided by the distance between the right and left design positions to obtain the radial relative position. Subsequently, the difference between the target amplitude on the right and the target amplitude on the left is obtained. This difference is allocated according to the radial relative position and merged with the target amplitude on the left to obtain the target amplitude of the target radial position. Before interpolation, the target phase is converted into cosine and sine direction components. The same radial position processing is performed on the two direction components respectively. The target phase is then recovered from the two processed direction components to avoid obtaining an incorrect intermediate phase when the phase crosses the endpoint of the complete angle. When the left and right design positions are the same, the target order lacks amplitude data, or the target order lacks phase data, the corresponding radial position is marked as having incomplete target data and is not included in the error functional.

[0075] Step S1043: Determine the isochronous error; for each effective radial sampling position, subtract the isochronous target magnetic field at the same radial position from the azimuth average magnetic field to obtain the directional isochronous deviation; then retain the deviation direction and obtain the deviation magnitude according to the error evaluation requirements; when determining the target order harmonic error, compare the harmonic amplitude and target amplitude at the same radial position and the same harmonic order, as well as the harmonic phase and target phase; before phase comparison, convert the two phases to the same angular interval, and determine the phase deviation according to the shorter angular distance to avoid amplifying the error when the phase crosses the endpoint of the angular interval.

[0076] Step S1044: Determine the error weights. The isochronous error weights and the target order harmonic error weights are derived from the beam dynamics sensitivity data. When generating the sensitivity data, the azimuth-averaged magnetic field at a radial position and a target harmonic component are changed respectively, while keeping the other magnetic field components unchanged. The changed magnetic field is then input into the beam dynamics calculation, and the changes in particle phase slip and beam envelope relative to the original values ​​are recorded. Positions and harmonic components with larger changes are assigned larger weights, while positions and harmonic components with smaller changes are assigned smaller weights. Weights of the same type are then standardized. The weight file records the corresponding magnet version, beam design version, radial position, and harmonic order. If the versions are inconsistent, the weight data is regenerated, and the old weights are not directly used.

[0077] The unified scaling process for similar weights is performed as follows: First, obtain the absolute magnitude of all effective sensitivity changes and merge them to obtain the total sensitivity of the same type; then, divide the sensitivity change of each radial position or harmonic component by the total sensitivity of the same type to obtain the initial weight, so that the sum of the initial weights of the same type remains consistent; when the total sensitivity of the same type is 0, set the weight of that type to an equal weight state and record the beam dynamics input that needs to be verified; when the dimensions of the isochronous error and the target order harmonic error are inconsistent, use their respective allowable error ranges to scale the errors before applying weights, so as to avoid directly merging errors of different dimensions.

[0078] Step S1045: Construct a multi-objective error functional based on the isochronous error, the target order harmonic error, and the corresponding weights. The formula is as follows: ;

[0079] In the formula, For a strictly isochronous magnetic field distribution, For the first First harmonic component vector, For the set of harmonic orders that need to be padded (e.g.) ), and This is a spatially unsteady weighting function pre-assigned based on the beam dynamics sensitivity matrix. The multi-objective error functional represents the synchronous evaluation of isochronous error and target order harmonic error; This indicates the set of control parameters used in the current padding method. The specific content of the control parameter set is determined before the start of each implementation and remains of the same type throughout all iterations. As a whole, representing radial coordinates The lower boundary of the area participating in synchronous padding. Always represent radial coordinates; As a whole, representing radial coordinates The upper boundary of the scope participating in synchronous padding; Represents radial coordinates a tiny increment, It is a differential notation and does not represent an independent variable; As a whole, it represents the isochronous error weight; As a whole, it represents the first Weighting of target harmonic errors; This represents the azimuth-averaged magnetic field at the same radial position. As a whole, it represents the isochronous target magnetic field.

[0080] For each valid radial sampling position, the isochronous deviation is first obtained. The isochronous deviation is multiplied by itself and then multiplied by the corresponding isochronous error weight to obtain the isochronous error contribution at that position. For each target harmonic order, the cosine component deviation and sine component deviation are determined separately. The two component deviations are multiplied by themselves and then combined and multiplied by the corresponding harmonic error weight to obtain the harmonic error contribution at that position and for that order. The isochronous error contribution at the same radial position is combined with the total target harmonic error contribution. Then, numerical integration is performed according to the spacing between adjacent radial sampling positions and the area scale corresponding to the radial position to obtain the multi-objective error functional. Positions lacking target data are not included in the integration. The set of positions participating in the integration remains unchanged in the same round of forward solution and adjoint solution.

[0081] Radial numerical integration is performed segment by segment according to adjacent valid radial sampling positions. For adjacent first and second radial positions, the total error contribution of the two positions is obtained. The two total error contributions are added together and divided by 2 to obtain the representative error contribution of the radial segment. The distance between the two radial positions and the average radius of the two radial positions are then obtained. The representative error contribution, radial distance, and average radius are combined in sequence to obtain the contribution of the radial segment to the multi-objective error functional. All radial segment contributions are merged in order from the inside out to obtain the multi-objective error functional of the current round. When adjacent valid positions cross positions lacking target data, the radial segment is not directly formed by crossing the gap. Instead, the integration is terminated and restarted on both sides of the gap, thereby avoiding the implicit contribution of unevaluated regions to the error results.

[0082] Step S105, generating the accompanying load and solving the inverse accompanying equation, including:

[0083] Step S1051: Map the isochronous error to an axial dipole source; for each effective radial sampling position, determine the radial ring zone on the intermediate plane with that position as the center; determine the direction of the axial dipole source according to the direction of the isochronous error, determine the intensity of the axial dipole source according to the magnitude and weight of the isochronous error, and then distribute the axial dipole source to the mesh nodes in the radial ring zone according to the finite element shape function of the intermediate plane; when adjacent radial ring zones overlap, the loads formed by each ring zone on the same node are merged according to the node degrees of freedom.

[0084] The inner boundary of the radial ring is taken as the midpoint between the current radial sampling position and the previous effective radial sampling position, and the outer boundary is taken as the midpoint between the current radial sampling position and the next effective radial sampling position. The rings located at the beginning and end of the evaluation range are closed by the lower and upper boundaries of the evaluation range, respectively. For each azimuth sampling position within the ring, the load intensity after the isochronous deviation is weighted is obtained, and the opposite axial load direction is determined according to the positive and negative signs of the deviation. Then, the finite element element surrounding the sampling position is located, and the shape function values ​​of each node corresponding to the position are obtained. The load intensity is distributed to the node degrees of freedom according to the shape function values. Before distribution, the shape function values ​​of each node of the element are merged and the merging result is checked. If the merging result does not meet the shape function completeness requirement, the element positioning error is returned. After distribution, the node contributions of all sampling positions of the ring are merged, and the load scale is unified according to the azimuth sampling interval to obtain the axial dipole source at the radial position.

[0085] Step S1052: Map the target order harmonic error to a multipole source; for each target harmonic order, determine the azimuth period based on the harmonic order, determine the starting direction of the azimuth distribution based on the target phase, and determine the load direction and intensity at each azimuth position based on the harmonic cosine component deviation and sine component deviation; then distribute the load corresponding to each azimuth position to the mesh nodes of the intermediate plane according to the finite element shape function to form a multipole source that varies with the azimuth; when the harmonic amplitude is zero and the phase does not participate in the evaluation, the multipole source is formed only based on the deviation of the two harmonic components relative to the target component, and the invalid phase is not used alone.

[0086] The azimuth distribution of the multi-pole source is formed according to the cosine component deviation and the sine component deviation respectively. For an azimuth sampling position, the azimuth at that position is first repeated according to the target harmonic order to obtain the corresponding cosine direction weight and sine direction weight. Then, the cosine direction weight is combined with the cosine component deviation, and the sine direction weight is combined with the sine component deviation. The two results are then merged to obtain the multi-pole load intensity at that azimuth position. Subsequently, the same element positioning and shape function allocation process as for the axial dipole source is used to allocate the load intensity to the nodal degrees of freedom. After completing the complete azimuth range, it is checked whether the direction repetition relationship of the multi-pole source in each period is consistent with the target harmonic order. If they are inconsistent, the azimuth zero point, sampling point number and target phase direction are checked.

[0087] Step S1053: The axial dipole source and the multipole sources corresponding to all target orders are merged according to the same mesh node degrees of freedom to obtain the accompanying load; the accompanying load retains the radial position, harmonic order and error type markings, which are used to check whether the load covers all effective error terms in the multi-objective error functional; if there are effective error terms but no node load is formed, the spatial mapping relationship between the sampling point and the finite element mesh is rechecked.

[0088] Step S1054: Solve the inverse adjoint equation using the tangent stiffness matrix retained in step S102 and the adjoint load obtained in step S1053. The formula for the inverse adjoint equation is as follows: ;

[0089] It represents a vector differential operator consisting of partial derivatives in three spatial coordinate directions; × indicates curl operation; Represents the nonlinear magnetoresistive force that varies with the magnitude of magnetic flux density; The unit tensor represents the number of components in the magnetic field strength vector. In the entire text, only the unit tensor is represented; the number 2 represents a fixed multiple in the tangent term of the nonlinear material, and does not represent a variable; Indicates the partial derivative operation symbol; Indicates by The magnetic flux density vector obtained by ×A; Represents the vector tensor product; This represents the adjoint field vector of the inverse adjoint equation. The numerical scale is determined by the multi-objective error functional and the state equation, without assigning a separate independent unit of measurement. × The curl of the adjoint field vector is represented by ; in formula (4), As a whole, it represents the target density of the multi-objective error functional; Represents the magnetic potential vector; The partial derivative of the target density with respect to the change of each degree of freedom of the magnetic vector potential is represented as a whole. This result, after being discretized, forms the associated load. The negative sign on the right side of the equals sign indicates that the associated load takes the opposite direction of the partial derivative.

[0090] Step S1055: Apply gauge constraints and homogeneous boundary conditions compatible with the magnetic vector potential to the adjoint field. Solve the linear equation using the tangent stiffness matrix as the coefficient matrix and the adjoint load as the right-hand load to obtain the adjoint field. The adjoint field is stored together with the magnetic vector potential, tangent stiffness matrix, adjoint load, and parameterized boundary of the current cycle. If the tangent stiffness matrix and the adjoint load come from different cycles, the solution is not performed to prevent the adjoint field from corresponding to the wrong material state or boundary state.

[0091] The adjoint linear equations start from the zero adjoint field to form the initial residual. The difference between the adjoint load and the result obtained by the tangent stiffness matrix acting on the current adjoint field is used as the current residual. The current residual is preprocessed according to the sub-region division of the tangent stiffness matrix to obtain the adjoint field search direction. The adjoint field is then updated along the search direction and the residual is obtained again. After each update, the relative magnitude of the residual and the adjoint load are compared. The process stops when the adjoint solution accuracy condition is met. If the condition is not met even after the allowed number of updates, the adjoint field for that round is not output, and the process returns to check the tangent stiffness matrix constraints, adjoint load coverage relationship, and mesh validity. The adjoint solution accuracy condition and the forward solution accuracy use the same magnetic field design accuracy source, but are recorded separately to prevent the formation of discrete gradients using non-converged adjoint fields.

[0092] Step S106, determining the shape derivative and forming the discrete gradient, includes:

[0093] Step S1061: At each boundary integration position of the parameterized boundary of the padding region, determine the positive magnetic field based on the convergent magnetic vector potential, and decompose the positive magnetic field into the positive tangential magnetic field along the boundary tangential plane and the positive normal magnetic flux along the unit outward normal of the boundary; determine the adjoint magnetic field based on the adjoint field, and decompose the adjoint magnetic field into the adjoint tangential magnetic field and the adjoint normal magnetic flux; the unit outward normal of the boundary uniformly points to the outside of the ferromagnetic domain, and adjacent boundary elements use the same direction; when the normal directions are inconsistent, first correct the direction of the boundary element, and then perform the boundary integration.

[0094] The unit outward normal vector of the boundary is determined by the tangential changes in the two parameter directions of the boundary surface. First, the first tangential vector is obtained based on the change of the boundary surface shape function along the first parameter direction, and then the second tangential vector is obtained based on the change of the boundary surface shape function along the second parameter direction. The two tangential vectors are combined according to the boundary node arrangement direction to obtain the normal vector to be normalized. Then, the normal vector to be normalized is divided by its length to obtain the unit outward normal vector. The positive normal magnetic flux is obtained by combining the direction of the positive magnetic field and the unit outward normal vector. The positive tangential magnetic field is obtained by subtracting the normal component corresponding to the normal magnetic flux from the positive magnetic field. The accompanying normal magnetic flux and the accompanying tangential magnetic field are obtained from the accompanying magnetic field using the same process. When the length of the normal vector to be normalized is 0, the corresponding boundary element is marked as a degenerate element, and the element is not used to form the shape derivative. The boundary mesh is then returned for repair.

[0095] Step S1062: Based on the positive tangential magnetic field, positive normal magnetic flux, accompanying tangential magnetic field, accompanying normal magnetic flux, nonlinear magnetoresistivity, and target density, a boundary integral term is formed. The continuous shape derivative formula of the target functional with respect to the boundary motion velocity field is as follows: ;

[0096] The operation notation indicates the calculation of the first variation with respect to small changes in the boundary. The multi-objective error functional represents the synchronous evaluation of isochronous error and target order harmonic error; As a whole, it represents the first-order change of the multi-objective error functional when the parameterized boundary of the padding region undergoes a small deformation; This indicates that area integration is performed within the specified boundary region; Represents the boundary set; As a whole, the parameterized boundary of the padding region that allows deformation is represented in the lower right corner. It is a marker for the padding area; As a whole, it represents the target density of the multi-objective error functional. Only the target density is indicated. This represents the adjoint field vector obtained by the inverse adjoint equation; Represents the magnetic potential vector. It is a differential notation. Indicates the harmonic order.

[0097] At each boundary integration location, obtain the positive field data, adjoint field data, material magnetic reluctance, target density, boundary unit outward normal vector, and integration weight; form the shape sensitivity density at that integration location according to the dot product, cross product, curl, and divergence order specified by the formula; multiply the shape sensitivity density by the motion component of the boundary along the unit outward normal vector and the integration weight to obtain the contribution of that integration location to the multi-objective error functional change; combine the contributions of all integration locations of the parameterized boundary in the padding region to obtain the continuous shape derivative with respect to the boundary normal velocity field; fixed boundaries that have not undergone deformation do not participate in this boundary integration.

[0098] The boundary integration location and integration weights are obtained from the numerical integration rules adopted by the boundary elements. For each boundary integration location, the physical coordinates, two tangent vectors, and the unit outward normal vector are first obtained using the boundary shape function. Then, the positive magnetic vector potential, the adjoint field, and their spatial variations are obtained from the adjacent volume elements. Subsequently, the combination result of nonlinear magnetic reluctance and positive magnetic field is first formed according to the operation order of the continuous shape derivative formula. Then, the curl contribution of the combination result is obtained, and the adjoint field is combined with the contribution in terms of direction. At the same time, the cross product result of the adjoint field and the combination result is formed. Then, the variation of the cross product result along three spatial directions is obtained and merged into the divergence contribution. The target density, the directional combination contribution, and the divergence contribution are merged according to the positive and negative relationship of the continuous shape derivative formula to obtain the shape sensitivity density. Finally, the shape sensitivity density is combined with the boundary element area scale and integration weights to obtain the boundary contribution of the integration location. When the two sides of the material interface need to be valued separately, the fixed order is maintained according to the side pointed to by the unit outward normal to prevent the same interface from exchanging material states in different elements.

[0099] The rules for obtaining the boundary integration positions and integration weights are independent of the volume integral. First, based on the order of the boundary element in the two surface parameter directions, the corresponding one-dimensional Gaussian integration positions and one-dimensional Gaussian integration weights are selected respectively. Then, the integration positions in the two directions are combined term by term to form the boundary integration positions. The corresponding two one-dimensional integration weights are multiplied and then combined with the magnitude of the cross product of the two boundary tangent vectors to obtain the physical boundary integration weights. When the boundary is jointly represented by adjacent boundary elements, integration is performed according to the boundary element number, and the area integration positions are not repeatedly set on the common edge. When the number of integration positions is insufficient to cover the integrand corresponding to the order of the boundary shape function, the number of integration positions in the two surface parameter directions is increased and the boundary contribution is re-formed. When the magnitude of the cross product of the boundary tangent vectors is zero, the corresponding boundary element is recorded as a degenerate element and the process returns to step S1015 for repair.

[0100] Step S1063: Map the continuous shape derivative to the padding control parameters; for each B-spline control point, determine the non-zero action region of the basis function for that control point; at each boundary integration position within this action region, determine the boundary displacement caused by the unit displacement of the control point according to the B-spline basis function, and then extract the component of the boundary displacement along the unit outward normal; combine this normal component with the continuous shape sensitivity density and integration weight at the same integration position to obtain the shape derivative of the padding control parameter corresponding to that control point; lock the shape derivative of the control point and set it to a state where it does not participate in the update, and arrange the shape derivatives of the active control points according to the fixed number of the control points to form a discrete gradient; thereby establishing a one-to-one correspondence between the continuous boundary shape derivative, the B-spline control point, and the discrete gradient components.

[0101] Step S107, determine the boundary deformation direction and boundary deformation step size and update the model, including:

[0102] Step S1071: Input the current discrete gradient into the finite memory quasi-Newton optimization process; when there is no historical data in the first round of optimization, the descent direction of the discrete gradient is used as the boundary search direction; in subsequent rounds, according to the fixed number of control points, obtain the changes in control parameters and discrete gradients of adjacent rounds, and use the limited number of historical change data to correct the current descent direction in turn to obtain the boundary search direction; when the number, number or locking status of control points corresponding to the historical data changes, clear the historical data and re-form the boundary search direction from the current discrete gradient.

[0103] The specific processing of historical change data in the finite-memory quasi-Newton optimization process is as follows: Each group of historical data is traversed in chronological order from newest to oldest. The current direction to be corrected is multiplied and merged with the change in the corresponding padding control parameter of that group, and then divided by the merged result of the product of the corresponding discrete gradient change and the change in the padding control parameter, to obtain the inverse correction coefficient of that group. The inverse correction coefficient is multiplied by the change in the discrete gradient of that group and subtracted from the current direction to be corrected, until the inverse traversal of all historical data is completed. The overall scale of the direction to be corrected is adjusted according to the scale relationship between the latest set of padding control parameter changes and the discrete gradient changes. The historical data is then traversed again in chronological order from oldest to newest to determine the correction contribution already included in each group of historical data, and the padding control parameter changes of that group are used to fill in the contribution not yet included, thus obtaining the quasi-Newton search direction. If the divisor in the historical data is 0 or lower than the effective lower bound, that group of historical data is skipped. If all historical data is invalid, the descent direction of the current discrete gradient is used. This process only saves the most recent few rounds of valid historical data; data exceeding the storage limit is removed in chronological order from oldest to newest.

[0104] Step S1072: Convert the boundary search direction into the boundary deformation direction; for each active control point, read the component corresponding to the control point number from the boundary search direction, and determine the movement direction of the control point along the allowable deformation direction according to the sign of the component; then, transfer the movement direction of all active control points to the parameterized boundary of the padding area through the B-spline basis function to obtain the boundary deformation direction; fixed control points and control points in non-processing areas do not generate movement directions.

[0105] Step S1073: Determine the boundary deformation step size. First, determine the upper limit of the candidate step size based on the allowable variation range of the padding control parameters and the validity of the finite element mesh. Then, use the candidate step size to form candidate control parameters and candidate parameterized boundaries along the boundary deformation direction. Load the candidate parameterized boundaries into the candidate model, perform forward solving and error determination, and obtain the candidate multi-objective error functional. If the candidate multi-objective error functional is lower than the current multi-objective error functional and the candidate finite element mesh remains valid, accept the candidate step size as the boundary deformation step size. If the candidate multi-objective error functional does not decrease or the candidate finite element mesh is invalid, reduce the candidate step size and re-evaluate. This process determines the step size based on the actual decrease result of the multi-objective error functional, and does not use a fixed step size lacking a source.

[0106] The upper limit of the candidate step size is determined separately for all active control points. For an active control point, the remaining distance from its direction of allowable deformation to the upper and lower boundaries of the processing range is obtained, and the corresponding remaining distance is selected according to the sign of the boundary search direction. The selected remaining distance is divided by the absolute magnitude of the search direction component of the control point to obtain the upper limit of the step size for the control point not to exceed the processing range. When the search direction component is 0, the step size of the control point is not restricted. The minimum value of the upper limit of the step size of all effective control points is obtained and compared with the upper limit of the single displacement of the boundary node allowed by the mesh generation configuration. The smaller result is taken as the upper limit of the candidate step size. If the candidate evaluation fails, the candidate step size is reduced according to the step size reduction ratio given by the optimization configuration. Before each evaluation, the candidate state is re-formed from the saved current control point, current boundary, and current finite element mesh. The rejected candidate state does not enter the next evaluation to avoid the accumulation of unaccepted boundary displacements during multiple reduction processes. If the candidate step size is lower than the allowable lower limit and no error reduction result is obtained, the current boundary update is stopped and the discrete gradient direction and control parameter range are checked.

[0107] Step S1074: Update each padding control parameter according to the boundary deformation direction and boundary deformation step size; for each active control point, change the corresponding coordinates according to its movement direction and boundary deformation step size, and keep the original coordinates of the fixed control points; regenerate the parameterized boundary of the padding area using all the updated control points and the original B-spline basis function to obtain the deformed parameterized boundary; when the updated control points exceed the allowable processing area, reject this update and reduce the boundary deformation step size until all active control points are within the allowable range.

[0108] Step S1075: Perform Laplace smoothing on the finite element mesh; use the deformed parameterized boundary node displacement as the boundary displacement condition, and keep the fixed mesh nodes far from the padding area stationary; for each active body mesh node in the vicinity of the padding area boundary, obtain the adjacent nodes directly connected to that node, and use the average result of the updated position of the adjacent nodes as the candidate position of the active body mesh node, and repeat the update in the order from the boundary to the inside; after each round of smoothing, check the element Jacobian determinant, element flip state, and adjacent node spacing; if there are invalid elements, restore the mesh before smoothing and reduce the boundary deformation step size, then regenerate the boundary and perform smoothing; after the mesh meets the validity requirements, the updated finite element mesh is obtained.

[0109] The average result of adjacent nodes is calculated separately for three coordinate directions. For an active mesh node, the coordinate values ​​of all directly adjacent nodes in the current coordinate direction are merged and then divided by the number of valid adjacent nodes to obtain the average coordinate in that coordinate direction. After completing the three coordinate directions in sequence, candidate node positions are formed. When the set of adjacent nodes is empty, the original position of the node is maintained and a mesh connection error is returned. After completing a round of updating all active nodes, the distance between the position before and after the update of each active node is calculated, and the maximum distance is taken as the mesh change amount for this round. Smoothing stops when the mesh change amount meets the mesh smoothing accuracy condition and all elements remain valid. If the mesh change amount does not meet the condition, the next round continues. The mesh smoothing accuracy condition is determined by the node position tolerance in the finite element mesh generation configuration and does not use fixed values ​​that are inconsistent with the geometric length units.

[0110] Step S1076: Use the deformed parameterized boundary as the updated parameterized boundary, replace the padding region parameterized boundary in the current nonlinear static magnetic field finite element model with the updated parameterized boundary, and replace the current finite element mesh with the updated finite element mesh to obtain the updated nonlinear static magnetic field finite element model; the material region identifier, coil excitation, boundary conditions and control point number remain unchanged, and the updated parameterized boundary and finite element mesh use the same version identifier.

[0111] Step S108, perform closed-loop iteration and output the target boundary of the padding area, including:

[0112] Step S1081: The updated parameterized boundary and the updated nonlinear static magnetic field finite element model are used as the current boundary and current model for the next round, respectively. Based on the current model, the forward state equation solution, azimuth angle Fourier decomposition, two types of error determination, multi-objective error functional construction, adjoint load generation, inverse adjoint equation solution, continuous shape derivative determination, discrete gradient formation, and boundary update are repeated sequentially to obtain the current isochronous error, the current target order harmonic error, the current discrete gradient, and the boundary for the next round. Each round of data is recorded with a round number, and only data with the same round number can be used together for gradient and termination judgment.

[0113] Step S1082: Determine whether the isochronous error meets the tolerance condition; for all radial sampling positions participating in the evaluation, multiply each isochronous deviation by itself, combine all square results and divide by the number of effective radial sampling positions, then perform square root operation on the obtained average result to obtain the isochronous root mean square error; compare the isochronous root mean square error with the tolerance band given by the magnetic field design data, if it falls into the tolerance band, determine that the isochronous error meets the tolerance condition, if it does not fall into the tolerance band, determine that the isochronous error does not meet the tolerance condition.

[0114] Step S1083: Determine whether the target order harmonic error meets the beam envelope limit; for each target harmonic order and each effective radial sampling position, compare the current harmonic amplitude error and phase error with the allowable range of the same harmonic order and the same radial position in the beam optical design data; when all effective comparison results are within the corresponding allowable range, determine that the target order harmonic error meets the beam envelope limit; when there is a comparison result that exceeds the corresponding allowable range, determine that the target order harmonic error does not meet the beam envelope limit.

[0115] Step S1084: The iteration termination condition is determined when the isochronous error meets the tolerance condition and the target order harmonic error meets the beam envelope limit. If the iteration termination condition is not met, the current discrete gradient is used to continue to determine the boundary deformation direction and boundary deformation step size, and the current boundary and the current model are updated. If the iteration termination condition is met, the current parameterized boundary is determined as the target boundary of the padding area. The output of the target boundary of the padding area includes the B-spline surface control point number, control point coordinates, parameter direction, node sequence, fixed boundary identifier, and the magnet coordinate system used. These data are used to generate pad processing data in the future. Before output, the continuity of the control point number, the consistency of the coordinate units, and the connection relationship between the target boundary and the magnetic pole reference plane are checked. After the check is passed, the target boundary version is fixed.

[0116] In the above embodiments, the isochronous error and the target order harmonic error are jointly entered into the multi-objective error functional. The accompanying load simultaneously carries the information of the reverse effect of the two types of errors on the magnetic field, and the discrete gradient simultaneously reflects the influence of the padding control parameters on the two types of errors. Since the deformation direction and the step size of the same boundary deformation are determined by the discrete gradient, the parameterized boundary update of the padding area in each round simultaneously evaluates the two types of magnetic field errors, thereby reducing the mutual interference caused by the step-by-step adjustment of the isochronous magnetic field and the target order harmonic.

[0117] like Figure 2 As shown, embodiments of the present invention also provide a cyclotron magnetic field isochronism and harmonic padding system based on the adjoint variable method, comprising:

[0118] The acquisition module is used to acquire the three-dimensional solution domain, material magnetization characteristics, coil excitation and parametric boundary of the padding region of the cyclotron, and to establish a nonlinear static magnetic field finite element model.

[0119] The decomposition module is used to solve the forward state equation based on the nonlinear static magnetic field finite element model to obtain the magnetic vector potential and the axial magnetic field of the intermediate plane; and to perform azimuth Fourier decomposition on the axial magnetic field of the intermediate plane to obtain the azimuth average magnetic field and the amplitude and phase of the target order harmonic.

[0120] The convergence module is used to determine the isochronous error and the target order harmonic error based on the azimuth-averaged magnetic field and the amplitude and phase of the target order harmonic, and to construct a multi-objective error functional; the accompanying load is obtained based on the forward state equation and the multi-objective error functional, and the inverse accompanying equation is solved by the tangent stiffness matrix when the forward state equation converges, to obtain the accompanying field.

[0121] The update module is used to determine the shape derivative of the multi-objective error functional with respect to each padding control parameter based on the magnetic vector potential, the adjoint field, and the parameterized boundary of the padding region, and obtain the discrete gradient; determine the boundary deformation step size based on the discrete gradient, adjust the parameterized boundary of the padding region according to the boundary deformation step size and smooth the finite element mesh to obtain the updated parameterized boundary;

[0122] The iterative module is used to repeatedly solve the forward state equation and the inverse adjoint equation based on the updated parameterized boundary until the isochronous error meets the tolerance condition and the target order harmonic error meets the beam envelope limit, and outputs the padding area target boundary used to generate pad processing data.

[0123] It should be noted that this system is a system corresponding to the above method. All implementation methods in the above method embodiments are applicable to this embodiment and can achieve the same technical effect.

[0124] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for compensating for the isochronous nature and harmonics of the magnetic field in a cyclotron based on the adjoint variable method, characterized in that, include: To obtain the three-dimensional solution domain, material magnetization characteristics, coil excitation, and parametric boundary of the padding region of the cyclotron, a nonlinear static magnetic field finite element model is established. The forward state equation is solved by the nonlinear static magnetic field finite element model to obtain the magnetic vector potential and the axial magnetic field of the intermediate plane. The axial magnetic field of the intermediate plane is decomposed by azimuth angle Fourier transform to obtain the azimuth average magnetic field and the amplitude and phase of the target order harmonic. Based on the azimuth-averaged magnetic field and the amplitude and phase of the target order harmonic, the isochronous error and the target order harmonic error are determined, and a multi-objective error functional is constructed. The adjoint load is obtained from the forward state equation and the multi-objective error functional. The inverse adjoint equation is solved by the tangent stiffness matrix when the forward state equation converges, and the adjoint field is obtained. The shape derivative of the multi-objective error functional with respect to each padding control parameter is determined based on the magnetic vector potential, the adjoint field, and the parameterized boundary of the padding region, and the discrete gradient is obtained. The boundary deformation step size is determined based on the discrete gradient. The parameterized boundary of the padding area is adjusted and the finite element mesh is smoothed according to the boundary deformation step size to obtain the updated parameterized boundary. Based on the updated parameterized boundary, the forward state equation and the inverse adjoint equation are repeatedly solved until the isochronous error meets the tolerance condition and the target order harmonic error meets the beam envelope limit. The target boundary of the padding area is then output to generate padding processing data.

2. The method for isochronous and harmonic compensation of cyclotron magnetic field based on the adjoint variable method according to claim 1, characterized in that, A nonlinear static magnetic field finite element model is established based on the three-dimensional solution domain, material magnetization properties, coil excitation, and parameterized boundary of the padding region, including: The three-dimensional solution domain is divided into a ferromagnetic domain, a coil conductor domain, and a nonmagnetic domain. Based on the magnetization properties of the material, nonlinear magnetic parameters are configured for the ferromagnetic domain, the coil excitation is configured as the excitation condition for the coil conductor domain, and the nonmagnetic domain is used as the solution domain to determine the magnetic field distribution in the vacuum cavity and air region, thus obtaining the magnetic field solution conditions for each domain. The parameterized boundary of the padding region is characterized by the control points of the B-spline surface, and the ferromagnetic domain, the coil conductor domain and the non-magnetic domain are meshed by finite element method to obtain a finite element mesh containing the parameterized boundary of the padding region. The magnetic field solution conditions of each domain are loaded into the finite element mesh, and the parameterized boundary of the padding region is used as the adjustable boundary of the ferromagnetic domain to obtain the nonlinear static magnetic field finite element model.

3. The method for isochronous and harmonic compensation of cyclotron magnetic field based on the adjoint variable method according to claim 2, characterized in that, Solving the forward state equations using a nonlinear static magnetic field finite element model yields the magnetic vector potential and the axial magnetic field of the intermediate plane, including: Initial values ​​are set for the magnetic vector potential in the forward state equation; the forward state equation is solved using the Newton-Krylov-Shull domain decomposition method, and the magnetic vector potential is updated using line search and adaptive relaxation based on the solution residuals. When solving for the residuals that satisfy the convergence condition, the axial magnetic field of the intermediate plane is determined based on the magnetic vector potential, and the tangent stiffness matrix when the forward state equation converges is used as the coefficient matrix of the inverse adjoint equation.

4. The method for compensating for the isochronism and harmonics of a cyclotron magnetic field based on the adjoint variable method according to claim 1, characterized in that, An azimuth Fourier decomposition of the axial magnetic field in the intermediate plane is performed, and a multi-objective error functional is constructed, including: Extract the magnetic field sequence of the axial magnetic field as a function of azimuth along the radial direction of the intermediate plane; A fast Fourier transform is performed on the magnetic field sequence to obtain the azimuth-averaged magnetic field and the amplitude and phase of the target order harmonics. The isochronous target magnetic field is determined based on the synchronization relationship between the particle cyclotron frequency and the radio frequency, and the target amplitude and target phase of the target order harmonics are determined based on the beam resonance condition. By comparing the azimuth-averaged magnetic field with the isochronous target magnetic field, the isochronous error is obtained. By comparing the amplitude and phase of the target harmonic with the target amplitude and phase, the target harmonic error is obtained. Based on the isochronous error and the target harmonic error, a multi-objective error functional is constructed.

5. The method for compensating for the isochronism and harmonics of a cyclotron magnetic field based on the adjoint variable method according to claim 4, characterized in that, The associated load is obtained based on the forward state equation and the multi-objective error functional, and the inverse associated equation is solved, including: An axial dipole source is generated in the radial annular mesh nodes of the intermediate plane based on the isochronous error; Based on the target order harmonic error, a multipole source is generated at the grid node according to the azimuth variation law determined by the target order and the target phase. By superimposing axial dipole and multipole sources, the associated load is obtained; based on the associated load and the tangent stiffness matrix at the convergence of the forward state equation, the inverse associated equation is solved to obtain the associated field.

6. The method for isochronous and harmonic compensation of cyclotron magnetic field based on the adjoint variable method according to claim 5, characterized in that, The shape derivative is determined and the discrete gradient is obtained based on the magnetic vector potential, the adjoint field, and the parameterized boundary of the padding region, including: Based on the magnetic vector potential and the associated field, the positive tangential magnetic field, positive normal magnetic flux, associated tangential magnetic field, and associated normal magnetic flux at the parameterized boundary of the padding region are determined. The shape derivatives of each padding control parameter are obtained by performing boundary integration along the parameterized boundary of the padding region with respect to the positive tangential magnetic field, positive normal magnetic flux, accompanying tangential magnetic field, and accompanying normal magnetic flux. The discrete gradient is obtained by combining the shape derivatives according to the order of the padding control parameters.

7. The method for compensating for the isochronism and harmonics of a cyclotron magnetic field based on the adjoint variable method according to claim 6, characterized in that, Determining the boundary deformation direction and step size based on the discrete gradient includes: Extract the current padding control parameters from the parameterized boundary of the padding area; Based on the current padding control parameters and discrete gradient, the update amount of each padding control parameter is obtained by using the finite memory quasi-Newton method; Based on the direction and magnitude of each update quantity, determine the boundary deformation direction and boundary deformation step size.

8. The method for compensating for the isochronism and harmonics of a cyclotron magnetic field based on the adjoint variable method according to claim 7, characterized in that, The parameterized boundary of the padding region is updated based on the boundary deformation direction and boundary deformation step size, including: The updated parameterized boundary is obtained by moving the boundary nodes of the padding area parameterized boundary according to the boundary deformation direction and boundary deformation step size. Based on the displacement of the boundary nodes, the active body mesh nodes that are directly connected to the boundary nodes are redistributed using the Laplace smoothing method to obtain the updated finite element mesh. The updated parametric boundary of the padding region in the nonlinear static magnetic field finite element model is replaced with the updated parametric boundary, and the updated finite element mesh is replaced with the updated finite element mesh to obtain the updated nonlinear static magnetic field finite element model.

9. The method for isochronous and harmonic compensation of cyclotron magnetic field based on the adjoint variable method according to claim 8, characterized in that, The target boundary of the padding region is output based on the updated parameterized boundary, including: The updated parameterized boundary and the updated nonlinear static magnetic field finite element model are used as the current boundary and the current model, respectively; Based on the current model, we perform forward solving, error determination, adjoint solution and discrete gradient determination to obtain the current isochronous error, the current target order harmonic error and the current discrete gradient. The iteration termination condition is that the current isochronous error meets the tolerance condition and the current target order harmonic error meets the beam envelope limit. If the iteration termination condition is not met, determine the boundary deformation direction and boundary deformation step size based on the current discrete gradient, update the current boundary and the current model, and enter the next iteration. When the iteration termination condition is met, the current boundary is determined and output as the target boundary of the padding area.

10. A cyclotron magnetic field isochronism and harmonic padding system based on the adjoint variable method, wherein the system implements the method as described in any one of claims 1 to 9, characterized in that, include: The acquisition module is used to acquire the three-dimensional solution domain, material magnetization characteristics, coil excitation and parametric boundary of the padding region of the cyclotron, and to establish a nonlinear static magnetic field finite element model. The decomposition module is used to solve the forward state equation based on the nonlinear static magnetic field finite element model to obtain the magnetic vector potential and the axial magnetic field of the intermediate plane. The axial magnetic field of the intermediate plane is decomposed by azimuth angle Fourier transform to obtain the azimuth average magnetic field and the amplitude and phase of the target order harmonic. The convergence module is used to determine the isochronous error and the target order harmonic error based on the azimuth-averaged magnetic field and the amplitude and phase of the target order harmonic, and to construct a multi-objective error functional; the accompanying load is obtained based on the forward state equation and the multi-objective error functional, and the inverse accompanying equation is solved by the tangent stiffness matrix when the forward state equation converges, to obtain the accompanying field. The update module is used to determine the shape derivative of the multi-objective error functional with respect to each padding control parameter based on the magnetic vector potential, the adjoint field, and the parameterized boundary of the padding region, and obtain the discrete gradient; determine the boundary deformation step size based on the discrete gradient, adjust the parameterized boundary of the padding region according to the boundary deformation step size and smooth the finite element mesh to obtain the updated parameterized boundary; The iterative module is used to repeatedly solve the forward state equation and the inverse adjoint equation based on the updated parameterized boundary until the isochronous error meets the tolerance condition and the target order harmonic error meets the beam envelope limit, and outputs the padding area target boundary used to generate pad processing data.