Electromagnetic field simulation method and program
By integrating the SIMION simulation process into MATLAB, the electromagnetic field simulation operation is simplified, the problem of the complexity of SIMION operation is solved, efficiency is improved and costs are reduced.
Patent Information
- Application Number
- CN202511193462.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-25
- Publication Date
- 2025-12-05
AI Technical Summary
The existing electromagnetic field simulation software SIMION is cumbersome to operate, has a high technical threshold, and requires the collaboration of multiple software programs, resulting in low efficiency and increased costs.
The SIMION simulation process is integrated into MATLAB, and parameters are set through the MATLAB interface. SIMION is used as the calculation module to achieve a unified operation for electromagnetic field simulation.
It improves simulation efficiency, saves R&D time and personnel investment, simplifies operation procedures, and is applicable to multiple fields such as signal processing, image processing, and control design.
Smart Images

Figure CN121072147A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of scientific research and engineering application technology, and particularly relates to a new electromagnetic field simulation design process method and program. BACKGROUND
[0002] In the field of scientific research and engineering application today, the accurate simulation and control of the behavior of microscopic particles are crucial, and the simulation process will directly determine the performance of the actual device. With the in-depth study of classical theory and the rapid development of computer algorithms, the simulation work can more and more intuitively reflect the performance of the actual model, so that some device development is extremely dependent on simulation results. The motion background of microscopic particles includes electromagnetic field, fluid field, etc., and the simulation theory background is also roughly these types. For the motion state of microscopic particles in the electromagnetic field, there are many mature software such as ANSYS and SIMION that can accurately reflect it. SIMION is a professional commercial software for simulating the trajectory of particles in electric and magnetic fields, and has been widely used in many fields such as electron optics, mass spectrometry, ion beam technology, etc. It can build complex electromagnetic field models and simulate the motion of particles with high precision, providing strong support for related research and technology development, and has been widely used in related instrument development processes.
[0003] SIMION, as a mature and relatively complete electromagnetic field simulation software, has been applied to the scientific instrument development process. However, it has many setting items, high technical threshold, and needs to have certain programming technology to face the output of complex results, which will bring a series of time cost and labor cost, slow start-up time, Figure 1 The basic calculation process shown includes SIMION software simulation; and involves multiple operations, and multiple software cooperation is needed to obtain visual results. The process is complicated, the parameter setting is more, the page switching is frequent, which will greatly reduce the efficiency and increase the investment cost. On the other hand, the setting operation process of SIMION software is extremely complicated, and has a certain use threshold, Figure 2 The main interface of SIMION, the interface is simple and the calculation result is accurate, but the function position is scattered and the operation is not easy to start. Therefore, a new electromagnetic field simulation design process method and program are proposed. SUMMARY
[0004] The present application is improved as follows to solve the problem of complicated process of the above data processing steps: Figure 1The shown simulation process is integrated into MATLAB, an external calling window is made by using MATLAB, SIMION is used as a calculation module inside, corresponding results under input parameters can be obtained after setting corresponding parameters in the MATLAB interface and running, and this step does not need to open the SIMION interface, through step-by-step data processing, any required simulation results and illustrations can be realized.
[0005] The application provides a flow method and program of electromagnetic field simulation design.
[0006] The application achieves the above-mentioned purposes by adopting the following technical solutions.
[0007] A method for simulating an electromagnetic field, characterized in that it comprises the following steps:
[0008] Theoretical calculation, setting conditions and parameters, setting a theoretical model of a corresponding electromagnetic field;
[0009] Theoretical verification, substituting the theoretical model into a verification equation, if the verification is successful, entering the next step, if the verification is not passed, returning to re-perform theoretical calculation to ensure the correctness of the theoretical model;
[0010] Drawing a model, compiling and drawing the model based on MATLAB and SIMION, wherein MATLAB is used for compiling and SIMION is used for identification;
[0011] Setting parameters, setting parameters for the drawn model in the MATLAB interface, and obtaining simulation results of the electromagnetic field after execution;
[0012] Further, it comprises,
[0013] Ion trajectory calculation, using MATLAB as an external calling window and using SIMION as a calculation module inside to construct an ion trajectory calculation model, and simulating the motion trajectory of ions in an electric field and a magnetic field;
[0014] Further, it comprises,
[0015] Result output, outputting the results calculated by SIMION in the form of a data file;
[0016] Visual analysis, using visual software to visually process the output results, and converting data into intuitive graphics or charts;
[0017] Further, it comprises,
[0018] Result evaluation, the data after visual processing is evaluated, whether the simulation result meets the expectation, if the evaluation fails, the theoretical calculation step needs to be restarted to ensure the accuracy and reliability of the final result.
[0019] Further, the theoretical verification is based on the second-order focusing equation, including the following formula:
[0020]
[0021] All the obtained parameters are brought into the above-mentioned three equations of the second-order focusing to judge the difference from the theory, and the difference range can be specified.
[0022] Further, the parameters in the parameter setting step include the parameters of the electric field and the magnetic field, and the initial conditions of the particles, so as to ensure that the model can accurately simulate the actual situation.
[0023] An electromagnetic field simulation program, characterized in that the program is used to execute the method in any one of the above.
[0024] The beneficial effects of the present application are as follows:
[0025] The present application controls the whole simulation process through MATLAB externally, realizes continuous operation on a MATLAB interface through eight steps of theoretical calculation, theoretical verification, model drawing, parameter setting, ion trajectory calculation, result output, visual analysis and result evaluation, integrates the simulation process involving SIMION into the MATLAB interface, greatly improves the simulation efficiency, solves the complicated simulation process caused by the complex function, and is expected to save a large amount of time cost and personnel investment about simulation in the research and development process. Users can solve complex problems through simple codes, and can also integrate with other programming languages, which is suitable for multiple fields such as signal processing, image processing and control design. BRIEF DESCRIPTION OF DRAWINGS
[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. The drawings in the following description are some embodiments of the present application. For those skilled in the art, other drawings can also be obtained on the premise of not paying creative labor.
[0027] Figure 1 is a general scientific instrument principle simulation flowchart;
[0028] Figure 2 is the main interface of the SIMION software;
[0029] Figure 3is a simulation flowchart of the present application;
[0030] Figure 4 is a schematic diagram of a time-of-flight mass spectrometer model in an embodiment of the present application;
[0031] Figure 5 is a time-of-flight mass spectrum of ions obtained under a flow code of the present application;
[0032] Figure 6 is a graph of ion focusing curves obtained under a flow code. DETAILED DESCRIPTION
[0033] The present application will be further described below in conjunction with the accompanying drawings, of which it is apparent that the embodiments described are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.
[0034] It should be noted that the terms "first", "second", and the like are used only for the purpose of description, and should not be understood as indicating or implying relative importance or implicitly indicating the number of the technical features indicated. Therefore, the features defined as "first", "second" can explicitly or implicitly include at least one of the features. In the description of the present application, the meaning of "a plurality of" is at least two, such as two, three, etc., unless otherwise explicitly specified and limited.
[0035] In the present application, unless otherwise explicitly specified and limited, the terms "mounting", "connection", "fixing", and the like should be understood in a broad sense, for example, can be fixedly connected, or can be detachably connected, or can be integrated; can be mechanically connected, or can be electrically connected or in communication with each other; can be directly connected, or can be indirectly connected through an intermediate medium; can be the internal communication of two elements or the interaction relationship between two elements, unless otherwise explicitly limited. For those of ordinary skill in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.
[0036] In the present application, unless otherwise explicitly specified and limited, the first feature is "on" or "under" the second feature, which can be direct contact between the first and second features, or indirect contact between the first and second features through an intermediate medium. Moreover, the first feature "above", "over" and "on" the second feature can be directly above or obliquely above the first feature, or only indicate that the horizontal height of the first feature is higher than that of the second feature. The first feature "below", "under" and "under" the second feature can be directly below or obliquely below the first feature, or only indicate that the horizontal height of the first feature is less than that of the second feature.
[0037] In the above description, the description with reference to the terms "one embodiment", "some embodiments", "an example", "a specific example", or "some examples" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present specification, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any appropriate manner in any one or more embodiments or examples. In addition, the person skilled in the art can combine and combine the different embodiments or examples described in the present specification and the features of the different embodiments or examples, without contradiction.
[0038] Referring to Figures 3-6 The present application provides a flow method for electromagnetic field simulation design, comprising the following steps:
[0039] Theoretical calculation, based on relevant theoretical knowledge and mathematical model, preliminary calculation is carried out to provide basic data and theoretical basis for subsequent simulation;
[0040] Theoretical verification, the completed theory is verified to determine whether it is reasonable, if the verification is successful, the next step is entered, if the verification is not passed, the theoretical calculation is returned to ensure the correctness of the theoretical basis;
[0041] Drawing model, based on MATLAB and SIMION, the model is compiled and drawn, wherein MATLAB is used for compilation and SIMION is used for identification;
[0042] Parameter setting, the model is set in the MATLAB interface, and all the desired results can be obtained after one-key execution;
[0043] Ion trajectory calculation, MATLAB is used as external calling window, and SIMION is used as calculation module to build ion trajectory calculation model to simulate the motion trajectory of ions in electric field and magnetic field;
[0044] Result output, the results calculated by SIMION are output in the form of data file;
[0045] Visual analysis, other software is used to visually process the output results, and the data is converted into intuitive graphics or charts, so that the results can be observed and analyzed more clearly;
[0046] Result evaluation, the data after visual processing is evaluated to determine whether the simulation result meets the expectation, if the evaluation is not passed, the theoretical calculation step needs to be returned to start again to ensure the accuracy and reliability of the final result; if the result evaluation is passed, the whole process is ended, and the final simulation result is obtained.
[0047] In this embodiment, preferably, the theoretical verification is based on the second-order focusing equation, including the following formulas:
[0048]
[0049] All the obtained parameters are brought into the three equations representing the second-order focusing, and the difference from the theory is determined to define the difference range.
[0050] In this embodiment, preferably, the parameters in the parameter setting step include the parameters of the electric field and the magnetic field, and the initial conditions of the particles, so as to ensure that the model can accurately simulate the actual situation.
[0051] An electromagnetic field simulation design program, the program is used in the above method.
[0052] The working principle and use process of the present application are as follows:
[0053] Based on the basic theory of electromagnetic field and the mathematical modeling framework, the calculation ability of MATLAB and the field simulation engine of SIMION are integrated to realize efficient and accurate ion trajectory prediction, and the second-order focusing equation is used to ensure the stability of the ion beam; in MATLAB, the user-defined parameters (such as electric field gradient and magnetic field strength) are converted into instructions recognizable by SIMION, so as to drive the calculation module to perform simulation. In the use process, the user first starts the MATLAB interface and loads the pre-compiled model file; then, the initial conditions (such as particle mass, charge amount, and incident angle) are input in the parameter setting panel, and the calculation task is executed one-key. The SIMION internal engine processes the field distribution data in real time, generates the ion trajectory, and outputs the results in.dat or.csv format; the user can use third-party tools (such as Origin or Python script) for visual analysis to display the trajectory distribution, energy loss and other indicators in the form of charts. In the evaluation stage, the system automatically compares the simulation value with the theoretical threshold (such as the deviation range of formulas (1), (2), and (3)), and if it is out of limit, an alarm is triggered to guide the user to trace back the theoretical calculation steps. The whole process runs in a closed loop to ensure seamless connection from the theoretical basis to the output results, and is suitable for accelerator design, mass spectrometer optimization and other scenes.
[0054] Embodiment: Time-of-flight mass spectrometry simulation process
[0055] Time-of-flight mass spectrometer is a mass spectrometry instrument widely used for component analysis in biological, chemical and other fields. The present application can perfectly adapt to the operation process of the time-of-flight mass spectrometer, and the general time-of-flight mass spectrometer model is shown as Figure 4 .
[0056] Theoretical calculation, according to the ion flight time meets the second order aggregation conditions, plus the development process for the electrode piece voltage, electrode piece spacing and other restrictions, all conditions are written in MATLAB, can be obtained a set of flight time mass spectrometry model to meet the second order focusing effect, the following list of examples of the calculation equation, wherein the input parameters are the total length of the device L, the total length of the reflection zone or acceleration zone d, the voltage applied to the two electrode pieces U0 and U2, the equation can be obtained by inputting these parameters, the value of the parameter c and U1, and then determine the length of the entire reflection zone, for the acceleration zone, the same is true, combined together can get the entire flight time mass spectrometry model.
[0057] function[a,b,c,R,Um]=the(L,d,U0,U2)
[0058] syms b
[0059] a=d-b;
[0060] c=L-d;
[0061] m1=c-2*b;
[0062] m2=2*(c+b);
[0063] m3=3*c;
[0064] m=m1 / m2*(b+c*(m1 / m3)^1.5)-a==0;
[0065] b=double(vpasolve(m,b));
[0066] a=d-b;
[0067] c=L-d;
[0068] R=3*c / (c-2*b);
[0069] Um=-(-U0+U2) / R+U2;
[0070] End
[0071] Verify the correctness of the theoretical calculation, the results obtained by substituting into the original equation, observe the residual, the original equation, i.e. equation (1), (2), (3) is the above-mentioned second order focusing equation, written in the formula:
[0072]
[0073]
[0074] All the parameters obtained are brought into the above-mentioned three equations representing the second order focusing, and the difference from the theory is determined, and the difference range is artificially specified.
[0075] Draw the model, SIMION supports external code compiled to get the geometry file, compiled code saved as.GEM format, first need to save the.GEM template file, then based on the above two steps, the resulting pole piece parameters through MATLAB update in the.GEM file, the code listed below for the update save.GEM file, where the input parameters are.GEM file name, the parameters need to modify new_d1, new_d2, new_n, can be increased or reduced according to the actual situation the number of modified parameters, the code will be executed after the original.GEM file saved as "original name_modified.GEM".
[0076] function modify_gem_d_params(original_file, new_d1, new_d2, new_n)
[0077] % Modify the d1, d2, d3, d4, d5 parameters in the GEM file
[0078] % Input: original file path, new value of each parameter (parameters not need to modify can be empty, such as [])
[0079] % Read the original file content
[0080] fid = fopen(original_file, 'r');
[0081] if fid == -1
[0082] error('Cannot open file: %s', original_file);
[0083] end
[0084] lines = {};
[0085] while ~feof(fid)
[0086] line = fgetl(fid);
[0087] lines{end+1} = line; % Store line by line
[0088] end
[0089] fclose(fid);
[0090] % Traverse each line to modify the target parameters
[0091] for i = 1:length(lines)
[0092] line = lines{i};
[0093] % match parameter line (e.g. d1=6)
[0094] if startsWith(strtrim(line),'D1=') & ~isempty(new_d1)
[0095] lines{i} = sprintf('D1=%d',new_d1); % update d1
[0096] elseif startsWith(strtrim(line),'D2=') & ~isempty(new_d2)
[0097] lines{i} = sprintf('D2=%d',new_d2); % update d2
[0098] elseif startsWith(strtrim(line),'n=') & ~isempty(new_n)
[0099] lines{i} = sprintf('n=%d',new_n); % update d3
[0100] %elseif startsWith(strtrim(line),'d4=') & ~isempty(new_d4)
[0101] %lines{i} = sprintf('d4=%d',new_d4); % update d4
[0102] %elseif startsWith(strtrim(line),'d5=') & ~isempty(new_d5)
[0103] %lines{i} = sprintf('d5=%d',new_d5); % update d5
[0104] End
[0105] % save modified file (add _modified suffix)
[0106] [path,name,ext] = fileparts(original_file);
[0107] modified_file=fullfile(path,[name,'_modified',ext]);
[0108] fid=fopen(modified_file,'w');
[0109] for i = 1: length(lines)
[0110] fprintf(fid,'%s\n',lines{i});
[0111] End
[0112] fclose(fid);
[0113] fprintf('Modification complete! New file saved to: %s\n', modified_file);
[0114] End
[0115] By calling SIMION through MATLAB, the resulting .GEM file is saved as a pa0 electrode structure file, which can be recognized by SIMION. The corresponding code is listed below:
[0116] ! "simionpath\simion.exe"--nogui--noprompt--quiet gem2pa"D:\2025\articles\patent2\new_modified.gem""filepath\filename_modified.GEM"
[0117] %refine pa#
[0118] ! "simionpath\simion.exe"--nogui--noprompt--quiet refine"filepath\filename.pa#"
[0119] After execution, the calculated device dimensions will be saved as an electrode file (.pa0) that can be recognized by SIMION.
[0120] The model includes the initial state of the ion, the voltage value of the electrode, the flight conditions, and the recording parameters, etc. First, the pa0 file of the previous step needs to be saved in the workbench of SIMION, saved as an.iob template, and subsequent settings are modified on this basis. The ion initial state file.ION or.fly2 format, the former is a certain ion state, and the latter only gives an ion state within a range. Take the.ION file as an example, after generating it with MATLAB, name it the same as the.iob file name, and it will automatically call this ion state file when running. The following is the process of generating and modifying the.ION file, where the input parameter parameter contains all the required ion initial state parameters.
[0121] function generate_ion_parameters(parameter)
[0122] % Generate ion initial state parameters and save as a txt format similar to.fly2 conversion
[0123] % parameter is a structure containing all parameters, which needs to include the following fields:
[0124] n: number of ions
[0125] % tob: initial value of flight time
[0126] % mass: mass number
[0127] % charge: charge number
[0128] % x_min, x_max: x coordinate uniform distribution range
[0129] % y_min, y_max: y coordinate uniform distribution range
[0130] % z_mean, z_stdev: z coordinate Gaussian distribution mean and standard deviation
[0131] % ke: kinetic energy value
[0132] % az_mean, az_stdev: azimuth angle Gaussian distribution mean and standard deviation
[0133] % el: elevation angle value
[0134] % cwf: correlation weight factor
[0135] % color: color identification
[0136] % Open file to prepare for writing
[0137] fid = fopen('ion_parameters.fly2', 'w');
[0138] % Write the particle parameters structure
[0139] fprintf(fid, 'particles {\n');
[0140] fprintf(fid, 'coordinates = 0, \n');
[0141] fprintf(fid,'standard_beam {\n');
[0142] fprintf(fid,'n = %d, \n', parameter.n);
[0143] fprintf(fid,'tob = %d, \n', parameter.tob);
[0144] fprintf(fid,'mass = %d, \n', parameter.mass);
[0145] fprintf(fid,'charge = %d, \n', parameter.charge);
[0146] % Write the x coordinate uniform distribution parameters
[0147] fprintf(fid,'x = uniform_distribution {\n');
[0148] fprintf(fid,'min = %d, \n', parameter.x_min);
[0149] fprintf(fid,'max = %d\n', parameter.x_max);
[0150] fprintf(fid, '}, \n');
[0151] % Write the y coordinate uniform distribution parameters
[0152] fprintf(fid,'y = uniform_distribution {\n');
[0153] fprintf(fid,'min = %d, \n', parameter.y_min);
[0154] fprintf(fid,' max=%d\n', parameter.y_max);
[0155] fprintf(fid,'},\n');
[0156] % Write z coordinate gaussian distribution parameters
[0157] fprintf(fid,' z=gaussian_distribution{\n');
[0158] fprintf(fid,' mean=%d,\n', parameter.z_mean);
[0159] fprintf(fid,' stdev=%.1f\n', parameter.z_stdev);
[0160] fprintf(fid,'},\n');
[0161] % Write remaining parameters
[0162] fprintf(fid,' ke=%d,\n', parameter.ke);
[0163] fprintf(fid,' az=gaussian_distribution{\n');
[0164] fprintf(fid,' mean=%d,\n', parameter.az_mean);
[0165] fprintf(fid,' stdev=%d\n', parameter.az_stdev);
[0166] printf(fid,'},\n');
[0167] fprintf(fid,' el=%d,\n', parameter.el);
[0168] fprintf(fid,' cwf=%d,\n', parameter.cwf);
[0169] fprintf(fid,' color=%d\n', parameter.color);
[0170] fprintf(fid,'}\n');
[0171] fprintf(fid,'}\n');
[0172] % Close file
[0173] fclose(fid);
[0174] disp('Ion initial state parameter file has been generated: filename.ion');
[0175] End
[0176] After execution, a file named filename.ion will be generated. Next, parameters for the ion flight process will be set, including voltage settings, flight parameters, and recording. SIMION supports user-programmed .lua files to control the flight process. The necessary equations for setting and recording should be written and placed in the .lua file (note that the .lua filename must match the .iob filename for it to be accessible during flight). Modify the relevant parameters in the .lua file in MATLAB to control changes in voltage values, recording parameters, etc., during flight. Below is the code for modifying the .lua file, where the input items are the .lua file location and filename, and the parameters to be modified (para_new). These parameters can be increased or decreased.
[0177] function modify_lua_voltages(lua_file,para_new)
[0178] % Fixed V5_voltage matching issue, ensuring all four parameters can be found.
[0179] % Input: Same as before, new_Vx is the new value, empty [] indicates no modification.
[0180] %1. Check the documents
[0181] if ~exist(lua_file, 'file')
[0182] error('File does not exist: %s', lua_file);
[0183] End
[0184] %2. Read all lines (preserving the original content, including blank lines and comments).
[0185] fid = fopen(lua_file,'r');
[0186] lines = cell(1, 1000); % Pre-allocate a sufficiently large amount of space
[0187] line_idx = 1;
[0188] while ~feof(fid)
[0189] line = fgetl(fid);
[0190] lines(line_idx) = {line};
[0191] line_idx = line_idx + 1;
[0192] End
[0193] lines = lines(1:line_idx-1); % trim to actual number of lines
[0194] fclose(fid);
[0195] total_lines = length(lines);
[0196] fprintf('Read %d lines of content\n', total_lines);
[0197] % 3. Define list of parameters (mandatory match, ignore formatting details)
[0198] params = {'V1_voltage', new_V1;
[0199] 'V2_voltage', new_V2;
[0200] 'V3_voltage', new_V3;
[0201] 'd2', new_d2;
[0202] 'nm', new_nm};;
[0203] % 4. Enhance matching logic (allow arbitrary characters before and after parameter, as long as it contains "param=value")
[0204] for p = 1:5
[0205] param_name = params{p,1};
[0206] new_val = params{p,2};
[0207] if isempty(new_val)
[0208] fprintf('Skipping parameter: %s\n', param_name);
[0209] continue;
[0210] End
[0211] modified=false;
[0212] for i=1:total_lines
[0213] line=lines{i};
[0214] if isempty(line),continue;end % skip empty lines
[0215] % loose match: just check if the line contains "param_name=num_val" (ignoring leading / trailing stuff)
[0216] % e.g. match "V5_voltage=-6000" or "local V5_voltage=-6000"
[0217] pattern=sprintf('%s\\s*=%s[+-]?\\d+\\.?\\d*',param_name);
[0218] if ~isempty(strfind(line,param_name)) && regexp(line,pattern,'once')
[0219] % extract old value
[0220] old_val_str=regexp(line,sprintf('%s\\s*=%s([+-]?\\d+\\.?\\d*)',param_name),'tokens');
[0221] old_val_str=old_val_str{1}{1};
[0222] % replace with new value
[0223] new_line=regexprep(line,sprintf('(%s\\s*=%s)[+-]?\\d+\\.?\\d*',param_name),...
[0224] sprintf('$1%s',num2str(new_val)));
[0225] lines{i} = new_line;
[0226] modified = true;
[0227] fprintf('Modified %s (line %d): %s -> %g\n', param_name, i, old_val_str, new_val);
[0228] break;
[0229] End
[0230] if ~modified
[0231] % Final check: show the line containing the parameter name directly, to help troubleshoot
[0232] fprintf('Warning: no modification found for %s! Here are the lines containing the name in the file:\n', param_name);
[0233] for i = 1:total_lines
[0234] if ~isempty(strfind(lines{i}, param_name))
[0235] fprintf('Line %d: %s\n', i, lines{i});
[0236] End
[0237] % 5. Save the modifications
[0238] fid = fopen(lua_file, 'w');
[0239] for i = 1:total_lines
[0240] fprintf(fid, '%s\n', lines{i});
[0241] End
[0242] fclose(fid);
[0243] fprintf('Modifications complete, saved to file\n');
[0244] End
[0245] Running the file will directly modify the source file.
[0246] The ion trajectory calculation also uses the method of calling SIMION by MATLAB, after the setting in the fourth step is completed, the following code is run:
[0247] ! "simionpath\simion.exe" --nogui --noprompt --quiet fly "filepath\filename.iob"
[0248] After the running is completed, SIMION is called in the background, and the ion flies according to the initial state of the ion and the setting of the.lua file.
[0249] In the above process, the data recorded in the flying process is saved as a text format file (such as.txt,.csv, etc.), and subsequent data processing is directly calling these files.
[0250] The text file output above is imported into MALTAB, and the recorded data is visualized, this step is executed on the basis of the fourth step, taking the ion flight time and the initial position of the ion as an example, the ion flight time mass spectrum and the focusing curve of the model can be drawn, the code is written below, and datas.csv is the text file recorded above.
[0251] datas = readmatrix('datas.csv'); figure(1)
[0252] histogram(datas(1:200,2))
[0253] % % data processing energy focusing curve
[0254] figure(2)
[0255] scatter(Z,datas(1:200,2))
[0256] On this basis, Figure 5 and Figure 6 will be obtained.
[0257] The above only describes some embodiments of the present application. For ordinary skilled in the art, without departing from the inventive concept, several modifications and improvements can be made, which belong to the protection scope of the present application.
Claims
1. A method of electromagnetic field simulation, characterized by, Comprising the following steps: Theoretical calculation, setting conditions and parameters, setting the corresponding theoretical model of electromagnetic field; Theoretical verification, substituting the theoretical model into the verification equation, if the verification is successful, then enter the next step, if the verification is not passed, then return to re-perform theoretical calculation, to ensure the correctness of the theoretical model; Drawing model, compiling and drawing the model based on MATLAB and SIMION, wherein MATLAB is used for compiling and SIMION is used for identification; Setting parameters, setting parameters for the drawn model in the MATLAB interface, and executing the electromagnetic field simulation results.
2. A method of electromagnetic field simulation according to claim 1, characterized in that, Including, Ion trajectory calculation, using MATLAB as an external calling window and SIMION as a calculation module to build an ion trajectory calculation model to simulate the motion trajectory of ions in the electric field and magnetic field.
3. A method of electromagnetic field simulation according to claim 2, characterized in that, Including, result output, outputting the results calculated by SIMION in the form of a data file; Visual analysis, using visual software to visually process the output results, and converting data into intuitive graphs or charts.
4. A method of electromagnetic field simulation according to claim 3, characterized in that, Including, Result evaluation, evaluating the data after visual processing to determine whether the simulation results meet the expectations, if the evaluation fails, the theoretical calculation step needs to be returned to start again, to ensure the accuracy and reliability of the final results; If the result evaluation is passed, the whole process is ended, and the final simulation results are obtained.
5. The method of electromagnetic field simulation of claim 1, wherein, The theoretical verification is based on the second-order focusing equation, including the following formulas: Bring all the parameters obtained into the three equations representing the second-order focusing, judge the difference with the theory, and specify the difference range.
6. The method of electromagnetic field simulation of claim 1, wherein, The parameters in the parameter setting step include the parameters of the electric field and the magnetic field, and the initial conditions of the particles, to ensure that the model can accurately simulate the actual situation.
7. An electromagnetic field simulation program characterized by comprising: The program is used to execute the method of any one of claims 1-6.