Generation method for automatically generating circuit simulation based on large language model
Through the automatic generation circuit simulation method based on large language model, the complex and low efficiency of the circuit simulation process is solved, and the simplification and efficiency of the circuit simulation process are achieved, which is suitable for the simulation of complex circuit systems.
Patent Information
- Application Number
- CN202510556360.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-05-30
AI Technical Summary
The existing circuit simulation process is complicated and inefficient, resulting in difficulty in design optimization and problem discovery.
Automatically generated circuit simulation method based on large language models is adopted to generate simulation files through modeling discrete, sample simulation establishment, fine-tuning of large language models and language description to realize circuit simulation.
It simplifies the circuit simulation process, improves the simulation efficiency, reduces the user's operation complexity and error rate, and is suitable for building complex circuit systems.
Smart Images

Figure CN120068741A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of circuit simulation, and particularly relates to a generation method for automatically generating circuit simulation based on a large language model. Background Art
[0002] In the past few decades, the field of artificial intelligence (AI) has experienced unprecedented development and progress. Numerous innovative AI architectures have emerged continuously, marking the continuous expansion of the technological frontier. Scientific researchers are committed to deeply integrating AI technology into industrial applications, aiming to significantly improve production efficiency and effectively reduce production costs. This trend has become a key driving force for promoting industrial upgrading and transformation.
[0003] In the design of power electronic systems, circuit simulation plays an indispensable role. Through simulation technology, the performance of the designed system can be pre-tested and evaluated, potential problems can be discovered, the design scheme can be optimized, thereby reducing the development cost of products, shortening the development cycle of the system, and improving the reliability of the design. Usually, circuit simulation requires researchers to manually place electrical components and connect wires in the simulation software to build a complete circuit model, and then a series of basic simulation parameters need to be set, such as power supply parameters, switching frequencies, passive component parameters, etc. This process is not only complicated but also prone to errors, and any mistake in parameter setting may lead to the failure of the entire simulation process. Summary of the Invention
[0004] The present invention discloses a generation method for automatically generating circuit simulation based on a large language model, mainly solving the problems of complicated and low-efficiency current circuit simulation processes.
[0005] To achieve the above object, the present invention provides a generation method for automatically generating circuit simulation based on a large language model, including the following steps: Modeling and discretization: Analyze the device modeling, classify and analyze the devices, modularize the devices, and then discretize the modules; Establishment of sample simulation: Establish a training sample circuit simulation based on the selected simulation platform; Establishment of large language model: Based on the training sample circuit simulation, fine-tune and generate a customized large language model, enabling it to have the ability to recombine modules based on user input to generate a circuit, and generate a simulation that can adapt to the selected simulation platform; Language description: After obtaining the customized large language model, input the language description of the arrangement of each device in the target circuit and generate a simulation file; Operation: Run the simulation file, evaluate the generated simulation results, and dynamically adjust the process, where the dynamic adjustment process includes reverting to the language description step or completing the simulation.
[0006] Further, the device includes a power supply, an inductor, a switch, and a resistive load.
[0007] Further, the modularization of the device includes: Constructing a power supply module: For a voltage source, the input is current I S-v , and the output is voltage V S-v ; For a current source, the input voltage is V S-i , and the output current is I S-i , then the characteristic equation of the power supply module is:
[0008] where V S-v is the output of the voltage source, v v (t) is the output voltage function of the actual voltage source, I S-v is the input of the voltage source, v i (t) is the input current function of the actual voltage source; I S-i is the output of the current source, i i (t) is the output current function of the actual current source, V S-i is the input of the current source, v i (t) is the input voltage function of the actual current source; Constructing an inductor module: The input is voltage and the output is current. Let its voltage input be V L , and the output current be I L , then the characteristic equation of the inductor module is:
[0009] where L is the inductance value of the inductor, and t represents time; Constructing a capacitor module: The input is current and the output is voltage. Let its current input be I C , and the output voltage be V C , then the characteristic equation of the capacitor module is:
[0010] where C is the capacitance value, and t represents time; Construct a switching module: The inputs are the control signal of the switching transistor, current, and voltage, and the outputs are also current and voltage. Let the current input be I IN , the input voltage be V IN , the current output be I OUT , the output voltage be V OUT . This switching module does not only focus on the state of a single switching transistor, but modularly models the switching network in the circuit. The characteristic equation of the switching module is:
[0011] where s(t) is a Boolean equation representing the signal of the switching transistor in the control circuit, and t represents time; Construct a resistive load module. The input is voltage and the output is current. Let the input voltage be V R , and the output current be I R . The characteristic equation of the resistive load module is:
[0012] where R is the resistance value and t represents time.
[0013] Furthermore, the discretization of the module includes: For the power supply module, its discretization characteristic equation is:
[0014] where n represents the current moment, dv is the voltage variation of the voltage source, di is the current variation of the current source; For the inductor module, the discretization characteristic equation is:
[0015] where n represents the current moment, Ts is the switching period of the switching circuit, di L is the inductor current variation; For the capacitor module, the discretization characteristic equation is:
[0016] where n represents the current moment, Ts is the switching period of the switching circuit, dv C is the capacitor voltage variation; For the switching module, the discretization characteristic equation is:
[0017] where n represents the current moment.
[0018] For the resistive load module, the discretized characteristic equation is:
[0019] where n represents the current moment.
[0020] Furthermore, the simulation platform includes MATLAB or LTspice or PSpice.
[0021] Furthermore, the training sample circuit includes a power supply, an inductor, a capacitor, a switch, and a load circuit.
[0022] Furthermore, the method for generating a customized large language model adopts any one of retrieval augmented generation technology, large model fine-tuning technology, and prompt engineering technology.
[0023] Furthermore, the language description of the arrangement of each device includes the power supply type, the connection relationship between the power supply, the inductor, the capacitor, the switch, and the load, and also includes the power supply value, the inductance value of the inductor, the capacitance value of the capacitor, and the input and output of each device in the circuit.
[0024] Furthermore, during the simulation result evaluation process, when the evaluation result does not meet the expectation, return to the language description and adjust the description of the circuit according to the result; if the simulation result is good, output the simulation waveform, save the simulation file, and complete the simulation.
[0025] The technical solution provided by the present invention has at least the following technical effects: The method for generating circuit simulation disclosed by the present invention constructs a device model and analyzes it, and performs discretization processing on the module. Subsequently, a large language model is customized through training sample circuit simulation. Finally, the language description of the target circuit is input to obtain a circuit simulation file. The large language model generated by this method exhibits remarkable scalability. By creating a basic sample circuit simulation, the customized model can be applied to construct more complex systems, and the process of customizing the large language model is relatively simple. In addition, compared with other artificial intelligence applications, this solution has obvious advantages in terms of ease of use, interactivity, and accessibility, aiming to simplify the user's operation process and improve work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0027] Figure 1 This is the flowchart of the working process of the embodiment of the present invention.
[0028] Figure 2 This is the target circuit topology and parameter diagram of the embodiment of the present invention.
[0029] Figure 3 This is the modular schematic diagram of each device in the embodiment of the present invention.
[0030] Figure 4 This is the modular schematic diagram of the Buck converter in the embodiment of the present invention.
[0031] Figure 5 This is the modular schematic diagram of the Boost converter in the embodiment of the present invention.
[0032] Figure 6 This is the result diagram of the Boost converter simulation generated by the large language model customized in the embodiment of the present invention.
[0033] Figure 7 This is the result diagram of the traditional simulation of the Boost converter in the embodiment of the present invention.
[0034] Figure 8 These are the waveforms obtained by traditional simulation. Detailed implementation manners
[0035] The embodiments of the present invention will be described in detail below. The examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to explain the embodiments of the present invention, and should not be construed as limiting the present invention.
[0036] This embodiment discloses a MATLAB simulation method for automatically generating a Boost converter based on a large language model. The process is as Figure 1 shown, and the parameters of the target circuit are as Figure 2 shown. The method includes the following steps: Step 1: Modeling and discretization. Classify and analyze the devices and modularize them. These devices include: power supply, inductor, capacitor, switch, and resistive load, as Figure 3 shown.
[0037] Construct a power supply module: For a voltage source, the input is current I S-v , and the output is voltage V S-v ; For a current source, the input voltage is V S-i , and the output current is I S-i, the characteristic equation of the power supply module is:
[0038] where V S-v is the output of the voltage source, v v (t) is the output voltage function of the actual voltage source, I S-v is the input of the voltage source, v i (t) is the input current function of the actual voltage source; I S-i is the output of the current source, i i (t) is the output current function of the actual current source, V S-i is the input of the current source, v i (t) is the input voltage function of the actual current source.
[0039] Construct an inductor module with voltage as the input and current as the output. Let its voltage input be V L , and the output current be I L , the characteristic equation of the inductor module is:
[0040] where L is the inductance value, and t represents time.
[0041] Construct a capacitor module with current as the input and voltage as the output. Let its current input be I C , and the output voltage be V C , the characteristic equation of the capacitor module is:
[0042] where C is the capacitance value, and t represents time.
[0043] Construct a switch module with the switch tube control signal, current, and voltage as the inputs and current and voltage as the outputs. Let its current input be I IN , the input voltage be V IN , the current output be I OUT , and the output voltage be V OUT. This switch module does not only focus on the state of a single switch tube, but modularly models the switch network in the circuit. The characteristic equation of the switch module is:
[0044] where s(t) is a Boolean equation representing the signal of the switch tube in the control circuit, and t represents time.
[0045] Construct a resistive load module with voltage as the input and current as the output. Let its input voltage be V R , and the output current be I R . The characteristic equation of the resistive load module is:
[0046] where R is the resistance value, and t represents time.
[0047] Furthermore, in step one, discretize the obtained characteristic equation for the purpose of simulation, including: For the power supply module, its discretized characteristic equation is:
[0048] where n represents the current moment, dv is the change in power supply voltage, di is the change in power supply current.
[0049] For the inductor module, the discretized characteristic equation is:
[0050] where n represents the current moment, Ts is the switching period of the switching circuit, di L is the change in inductor current.
[0051] For the capacitor module, the discretized characteristic equation is:
[0052] where n represents the current moment, Ts is the switching period of the switching circuit, dv C is the change in capacitor voltage.
[0053] For the switch module, the discretized characteristic equation is:
[0054] where n represents the current moment.
[0055] For the resistive load module, the discretized characteristic equation is:
[0056] Where n represents the current moment.
[0057] Step 2: Sample simulation establishment to adapt to different simulation software; in this embodiment, the MATLAB simulation of the buck converter is used as the sample circuit simulation, and the Buck converter is simulated through the Simulink S-Function module code. The Buck converter is modularized as Figure 4 shown.
[0058] Since the Buck converter system is relatively simple, the Level-1 MATLAB S-Function module is adopted. The following is a detailed explanation of the S-Function construction of the sample Buck circuit.
[0059] 1) Initialization The system uses discrete simulation and there are no continuous variables in the simulation; let the current on the inductor and the output voltage be two discrete intermediate variables (x(1), x(2)), which need to be updated according to the simulation steps (the initial values are all 0), and finally are the two outputs; the system has one input, that is, the control signal of the switch tube; the system is a direct feedthrough system (Direct Feedthrough), that is, the system output is controlled by the system input; the simulation step is set to 1 us. So the initialization part code of the system is: sizes.NumContStates = 0; sizes.NumOutputs = 2; sizes.NumInputs = 1; sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 1; x0 = [0; 0]; str = []; Ts = 0.000001; ts = [Ts 0]; 2) Update intermediate variables Since the power supply is an independent voltage power supply, the output voltage is a constant; within the system, the voltage output is controlled by the module input (u); the update of the two intermediate variables is the value of the previous moment plus the change amount within a sampling period; so the code for the system update part is: Ts = 0.000001; Va = 15; L = 8.375e-4; C = 2.5e-4; R = 2.5; Vs = Va; Vswout = u*Va; Iswout = u*x(1); I_R = x(2) / R; I_L = x(1) + (Vswout - x(2)) / L*Ts; V_C = x(2) + (x(1) - I_R) / C*Ts; sys = [I_L ; V_C]; 3) Output The system output is the inductor current and the output voltage; the code for the output part is as follows: sys = [x(1) ; x(2)]; Step 3: Establishment of the large language model: Based on the Buck circuit S-Function module code generated in Step 2, a customized large language model is generated. In this embodiment, using single-example prompting (1 prompt engineering), the input prompt for the large language is as follows: "You are an expert in power electronics, especially proficient in converter modeling. Your main task is to generate the corresponding converter simulation based on the user's requirements. The simulation platform is MATLAB, and you need to generate the Simulink S-Function module code for it. Now I will give you an example of a Buck converter. For example, the simulation name of the Buck converter is "buck_sfunct", and the code for the main part of its simulation program is: function[sys,x0,str,ts,simStateCompliance]=boost_sfunc_PV(t,x,u,flag) switch flag, case 0, [sys,x0,str,ts,simStateCompliance] = mdlInitializeSizes; case 2, sys = mdlUpdate(t,x,u); case 3, sys = mdlOutputs(t,x,u); case 4, sys = mdlGetTimeOfNextVarHit(t,x,u); case 9, sys = mdlTerminate(t,x,u); otherwise DAStudio.error('Simulink:blocks:unhandledFlag',num2str(flag)); end In the Buck simulation, the system uses discrete simulation and there are no continuous variables in the simulation. Let the current on the inductor and the output voltage be two discrete intermediate variables (x(1), x(2)), which need to be updated according to the simulation steps (the initial values are all 0) and finally be the two outputs. The system has one input, that is, the control signal of the switch tube. The system is a direct feedthrough system, that is, the system output is controlled by the system input. The set simulation step is 1 us. So the initialization part code of the system is as follows: function [sys,x0,str,ts,simStateCompliance] = mdlInitializeSizes sizes = simsizes; sizes.NumContStates = 0; sizes.NumDiscStates = 5; sizes.NumOutputs = 4; sizes.NumInputs = 1; sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 1; sys = simsizes(sizes); x0 = [0; 0; 3.3; 0; 0]; str = []; Ts = 3e-7; ts = [Ts 0]; simStateCompliance = 'UnknownSimState'; Since the power supply is a 15V independent voltage source, the output voltage is a constant; within the system, the voltage output is controlled by the module input (u); the inductance value is 0.8375 mH; the capacitance value is 0.25 mC; the load is 2.5 Ω; the output capacitance of the capacitor is that the updates of two intermediate variables are obtained by adding the change amount within one sampling period to the value at the previous moment; therefore, the code for the system update part is as follows: function sys=mdlUpdate(t,x,u) Ts = 0.000001; Va = 15; L = 8.375e-4; C = 2.5e-4; R = 2.5; Vs = Va; Vswout = u*Va; Iswout = u*x(1); I_R = x(2) / R; I_L = x(1) + (Vswout - x(2)) / L*Ts; V_C = x(2) + (x(1) - I_R) / C*Ts; sys = [I_L ; V_C]; Among them, "Vswout = u*Va; Iswout = u*x(1);" is the simulation code for the switch, where "Va" and "x(1) (inductor current)" are the input voltage and input current of the switch, and are controlled by the input "u"; "I_R = x(2) / R;" is the simulation code for the load, where "x(2) (capacitor voltage)" is the input of the load; "I_L = x(1) + (Vswout - x(2)) / L*Ts;" is the simulation code for the inductor, where "x(2) (capacitor voltage)" is its input; "V_C = x(2) + (x(1) - I_R) / C*Ts;" is the simulation code for the capacitor, where "x(1) (inductor current)" is its input.
[0060] The system outputs the inductor current and the output voltage; the code for the output part is as follows: function sys=mdlOutputs(t,x,u) sys = [x(1) ; x(2)]; The equations for other parts are as follows: function sys=mdlGetTimeOfNextVarHit(t,x,u) sampleTime = 1; sys = t + sampleTime; function sys=mdlTerminate(t,x,u) sys = [];” Step 4: Language description: After obtaining the corresponding large language model, input the language description of the target circuit into the generated large language model and generate a simulation file. The target circuit is a Boost converter, so the input to the large language model is the description of the arrangement and connection between the components in the Boost circuit, and its modularity is as Figure 5 shown, and the input to the large language model is: "Hello, I want to use the S-Function in MATLAB to simulate a boost converter. The specifications are as follows: The simulation should be discrete. There are two discrete variables, the capacitor voltage V_C and the inductor current I_L. These two are also the outputs of the function. The S-Function has only one input. It is a direct feedthrough system. According to these requirements, generate the initialization part of the code.
[0061] Now I will explain the specific parameters. Please help me modify the code. The input voltage of the boost converter is 200V, the inductor is 400e-6H, the capacitor is 2.688e-6F, the switching frequency is 100kHz, and the output load is 104.167 ohm.
[0062] Then, I need you to change the equations in the update function. For the switch, the output current is the inductor current when the switch is off and 0 when the switch is on. The switch output voltage is the capacitor voltage when the switch is off and 0 when the switch is on. The inductor input voltage is equal to the power supply Va minus the switch output voltage, and the capacitor input current is equal to the switch output current minus the load output current.
[0063] Step 5: Run the simulation file, evaluate the generated simulation results, and dynamically adjust the process; Figure 6 is the simulation block diagram of the Boost converter; Figure 7 is the obtained operation result; Figure 8 is the waveform obtained by traditional simulation. The simulation results meet the requirements.
[0064] Step 6: Complete the simulation.
[0065] By constructing a device model and conducting analysis, discretizing the module, and then customizing a large language model through training sample circuit simulations, finally inputting the language description of the target circuit to obtain a circuit simulation file. The large language model generated by this method demonstrates remarkable scalability. By creating a basic sample circuit simulation, the customized model can be applied to build more complex systems, and the process of customizing the large language model is relatively simple. In addition, compared with other artificial intelligence applications, this solution has obvious advantages in terms of ease of use, interactivity, and accessibility, aiming to simplify the user's operation process and improve work efficiency.
[0066] The above disclosure of the embodiments is only for the better implementation of the present invention and is not used to limit the present invention. Any modifications, equivalent replacements, and improvements made on the basis and within the scope of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for automatically generating circuit simulation based on a large language model, characterized in that: The steps include: Modeling and discretization: Model and analyze the devices, classify and analyze the devices, modularize the devices, and then discretize the modules; Sample simulation establishment: Establish training sample circuit simulation based on the selected simulation platform; Large language model establishment: Based on the training sample circuit simulation, fine-tune and generate a customized large language model, so that it has the ability to generate circuits based on user input reorganization modules and generate simulations that can adapt to the selected simulation platform; Language description: After obtaining the customized large language model, input the language description of the arrangement of each device in the target circuit and generate a simulation file; Run: Run the simulation file, evaluate the generated simulation results, and dynamically adjust the process, where the dynamic adjustment of the process includes falling back to the language description step or completing the simulation.
2. The method for automatically generating circuit simulation based on a large language model according to claim 1, characterized in that: The device includes a power supply, an inductor, a switch and a resistive load.
3. The method for automatically generating circuit simulation based on a large language model according to claim 2, characterized in that: Device modularity includes: Building a power supply module: For a voltage source, the input is a current I S-v , the output is voltage V S-v ; For a current source, the input voltage is V S-i , the output current is I S-i , then the characteristic equation of the power module is: ; in V S-v is the voltage source output, v v (t) is the actual voltage source output voltage function, I S-v is the voltage source input, v i (t) is the actual voltage source input current function; I S-i is the current source output, i i (t) is the actual current source output current function, V S-i is the current source input, v i (t) is the actual current source input voltage function; Building the Inductor Module: Input is Voltage V L , the output is current I L , the characteristic equation of the inductor module is: ; in L is the inductance value, t represents the time; Building a capacitor module: Input is current I C , the output is voltage V C , the characteristic equation of the capacitor module is: ; in C is the capacitance value, t represents the time; Construct a switch module: The input is the switch control signal, current and voltage, and the output is also current and voltage. Let its current input be I IN , the input voltage is V IN , the current output is I OUT , the output voltage is V OUT , the switch module performs modular modeling on the switch network in the circuit, and the characteristic equation of the switch module is: ; Among them, s(t) is a Boolean equation, which represents the switch signal in the control circuit, and t represents time; Construct a resistive load module with voltage as input and current as output. Let its input voltage be V R , the output current is I R , the characteristic equation of the resistive load module is: ; in R is the resistance value; t represents the time.
4. The method for automatically generating circuit simulation based on a large language model according to claim 3, characterized in that: Module discretization includes: For the power module, its discretized characteristic equation is: ; Where n represents the current time, dv is the voltage change of the voltage source, d is the current change of the current source; For the inductor module, the scattered characteristic equation is: ; Where n represents the current moment, Ts is the switching cycle of the switching circuit, d L is the change of inductor current; For the capacitor module, the discrete characteristic equation is: ; Where n represents the current moment, Ts is the switching cycle of the switching circuit, dv C is the capacitance voltage change; For the switch module, the discrete characteristic equation is: ; Where n represents the current moment; For resistive load modules, the discrete characteristic equation is: ; Where n represents the current time.
5. The method for automatically generating circuit simulation based on a large language model according to claim 1, characterized in that: The simulation platform includes MATLAB or LTspice or PSpice.
6. A method for automatically generating circuit simulation based on a large language model according to claim 1 or 5, characterized in that: The training sample circuit includes a power supply, an inductor, a capacitor, a switch and a load circuit.
7. The method for automatically generating circuit simulation based on a large language model according to claim 1, characterized in that: The method for generating a customized large language model adopts any one of retrieval enhancement generation technology, large model fine-tuning technology, and usage prompt engineering technology.
8. The method for automatically generating circuit simulation based on a large language model according to claim 1, characterized in that: The language description of the arrangement of each device includes the power type, the power supply, inductance, capacitance, the connection relationship between the switch and the load, as well as the power value, inductance value, capacitance value, and the input and output of each device in the circuit.
9. The method for automatically generating circuit simulation based on a large language model according to claim 1, characterized in that: During the simulation result evaluation process, if the evaluation result does not meet expectations, fall back to the language description and adjust the circuit description based on the result; if the simulation result is good, output the simulation waveform, save the simulation file, and complete the simulation.
Citation Information
Patent Citations
Real-time simulation method for modular multilevel converter
CN110232220A
Automatic design method and device for power converter based on multi-mode large language model system
CN119129502A
DC converter controller design method and device, and medium
CN119443006A
Intelligent agent construction method and system based on large language model, medium and equipment
CN119512523A
Circuit simulation method, circuit simulation device, and circuit simulation program and computer readable storage medium onto which the program is stored
US20020156609A1