Modelica intelligent modeling optimization method based on AI-Agent

By using the AI-Agent-driven Modelica intelligent modeling optimization method, physical knowledge and mathematical equations are automatically processed to generate and verify Modelica code, solving the problems of low modeling efficiency and poor accuracy in existing technologies, and realizing efficient and fast modeling of battery cell electrical-thermal coupling systems.

CN121859718APending Publication Date: 2026-04-14BEIHANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-28
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing Modelica modeling methods rely on manual retrieval of physical knowledge and mathematical equations, resulting in low efficiency, susceptibility to human error, difficulty in handling complex multidisciplinary coupled systems, inability to optimize model accuracy and robustness in real time, long modeling cycles, and high iteration costs.

Method used

The Modelica intelligent modeling optimization method based on AI-Agent is adopted, which utilizes the RAG mechanism to realize automatic retrieval of physical knowledge, intelligent processing of mathematical equations, automatic generation and verification of Modelica code. By setting up modules for physical knowledge retrieval, mathematical equation processing, Modelica code generation, and code verification and error correction, fully automated modeling optimization is achieved.

Benefits of technology

It significantly improves Modelica modeling efficiency and accuracy, shortens model development cycle, increases model simulation speed and robustness, solves the problem of inaccurate electrical-thermal coupling of battery cells, reduces model development cycle to 1/10, and increases simulation speed by more than 10 times.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121859718A_ABST
    Figure CN121859718A_ABST
Patent Text Reader

Abstract

The invention discloses a Modelica intelligent modeling optimization method based on AI-Agent. The Modelica intelligent modeling optimization method is used for modeling an electrical-thermal coupling system of a high-dynamic and high-reliability energy system and an energy battery. The method comprises the following steps: acquiring device parameters, an equivalent circuit and an electro-thermal coupling dynamic equation set of a target energy system or a battery unit to be researched, and inputting the data and user modeling requirements into AI-Agent; the AI-Agent triggers a physical knowledge retrieval module to retrieve related physical knowledge from a knowledge base, then calls a mathematical equation processing module to process an equation set of the physical knowledge, outputs an optimized electric-thermal coupling equation set, and generates an initial Modelica model of the target based on the optimized equation set; and carrying out model code verification and error correction, and outputting a final optimized model. The model obtained through the method is more accurate and higher in robustness, the model development period is greatly shortened, and the model simulation speed is greatly increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of high dynamic and high reliability energy systems and their modeling technology, specifically to an AI-Agent-based Modelica intelligent modeling optimization method for modeling high dynamic and high reliability energy systems and the electrical-thermal coupling system of energy batteries. Background Technology

[0002] In the field of model-based systems engineering, particularly in the multidisciplinary modeling and simulation of cyber-physical systems (CPS), the Modelica modeling tool plays a crucial role. It is especially suitable for complex scenarios involving high-dynamic and high-reliability energy systems, such as the electrical-thermal coupling design of power batteries for new energy vehicles, modeling of UAV energy systems, and optimization of propulsion batteries for novel reusable rockets. It allows engineers to describe the coupled behavior of multiple physical domains (such as electrochemistry, thermal conduction, and RC dynamics) using a declarative, acausal language, enabling dynamic system simulation and parameter optimization, thereby solving nonlinear coupling problems that are difficult to handle using traditional experimental methods. For example, in the design of individual battery cells for new energy vehicles, Modelica can be used to simulate the electrical-thermal response based on equivalent circuits, predict changes in SOC (state of charge), voltage drop, and heat loss under charging / discharging conditions, improve the accuracy of the battery management system (BMS) by 10%-15%, and reduce prototype testing costs by 30%-50%. In the design of UAV energy systems, it supports multi-domain electrical-thermal simulation, verifies the stability of batteries under high loads, shortens the design iteration cycle from months to weeks, and improves energy density to cope with flight uncertainties. In the optimization of propulsion batteries for novel reusable rockets, the Modelica library can build high-fidelity RC (resistor-capacitor) network models, integrate thermal balance equations to verify the impact of temperature on open-circuit voltage, ensure a cycle life improvement of more than 10%, and reduce thermal management risks. Overall, using Modelica can significantly shorten product development cycles, reduce physical prototype testing costs, and improve system energy efficiency, safety, and reliability.

[0003] Existing technologies reveal several Modelica modeling methods, which primarily rely on manual retrieval of physical knowledge, mathematical equations, and code implementation. This design suffers from the following problems and drawbacks: the modeling process heavily depends on the engineer's expertise and experience, leading to inefficiency, susceptibility to human error, and difficulty in handling complex, multidisciplinary coupled systems; furthermore, the lack of automated knowledge retrieval and error checking mechanisms prevents real-time optimization of model accuracy and robustness, resulting in long modeling cycles and high iteration costs, especially in large-scale systems engineering applications. Specifically, in the electrical-thermal coupling design of a single battery cell in new energy vehicles, manual modeling easily overlooks SOC-temperature coupling (e.g., missing dU / dT thermodynamic coefficients leading to an open-circuit voltage (OCV) deviation >10%), and neglects or simplifies RC network dynamics, resulting in voltage drops during charge transfer. The voltage is underestimated by approximately 15%, leading to inaccurate voltage response and biased thermal predictions. For example, in thermal prediction, the Joule heat calculation term Phi_ohm=I²R_ohm ignores the contribution of entropic heat, increasing safety risks such as exceeding thermal runaway thresholds and iteration costs. In UAV energy system design, manual equation integration is cumbersome, making it difficult to handle thermo-electrical feedback in real time, extending optimization cycles and reducing robustness under high loads. In the optimization of novel reusable rocket propulsion batteries, manual processing easily introduces inconsistencies between thermal ports and the electrical system, resulting in inaccurate cyclic simulations, increased lifetime degradation rates, and amplified physical testing risks. Summary of the Invention

[0004] Existing technologies using Modelica to model highly dynamic and reliable energy systems rely on manual retrieval of physical knowledge, mathematical equations, and code implementation. This approach suffers from inefficiency, susceptibility to human error, difficulty in handling complex multidisciplinary coupled systems, inability to optimize model accuracy and robustness in real time, long modeling cycles, and high iteration costs. To address these issues and avoid the problems associated with manual retrieval, this invention provides an AI-Agent-based intelligent modeling optimization method for Modelica. This method integrates a Retrieval-Augmented Generation (RAG) mechanism with the AI-Agent to achieve automated modeling optimization, including automatic retrieval of physical knowledge, intelligent processing of mathematical equations, and automatic generation and verification of Modelica code. This improves the efficiency, accuracy, and scalability of Modelica modeling for highly dynamic and reliable energy systems.

[0005] The Modelica intelligent modeling optimization method based on AI-Agent provided by this invention includes a physics knowledge retrieval module, a mathematical equation processing module, a Modelica code generation module, and a code verification and error correction module, which are invoked by the AI-Agent. The method of this invention includes the following steps:

[0006] Step 1: Take the target energy system or battery cell to be studied as the target, and obtain the target data, including the device parameters of the target energy system or battery cell, the equivalent circuit composition of the target, and the set of electro-thermal coupling dynamic equations based on the equivalent circuit; obtain the user's modeling requirements, which are described as modeling the electro-thermal coupling system of the target; write the target data and the user's modeling requirements into the input text.

[0007] Step 2: Based on the user's modeling requirements, the AI-Agent triggers the physics knowledge retrieval module. Using the RAG framework, it retrieves relevant physics knowledge from the pre-built knowledge base by matching the user's modeling requirements with the knowledge base index through semantic embedding vectors, and outputs structured physics knowledge. The knowledge base pre-adds target domain knowledge blocks, which include content describing the composition of the target equivalent circuit and the electro-thermal coupling dynamic equation set of the target equivalent circuit.

[0008] Step 3: The mathematical equation processing module obtains the set of equations of physical knowledge output by the physical knowledge retrieval module and performs mathematical equation processing, including: obtaining the unknown variables in the set of equations; performing linear independence processing to eliminate redundant equations; checking the number of equation variables. If the number of equation variables does not match the number of independent equations, RAG is triggered to supplement missing constraints to ensure the completeness and consistency of the set of equations, and the optimized electro-thermal coupling equation set is output.

[0009] Step 4: Based on the optimized electro-thermal coupling equations, the Modelica code generation module generates the electrical and thermal interfaces of the model, the device parameters of the model, the internal variables of the model, the equations and comments, and obtains the initial Modelica model code.

[0010] Step 5: The code verification and error correction module performs lexical, syntactic, semantic, and path checks on the current Modelica model code, automatically corrects errors, and outputs the final optimized Modelica model, which is the simulation model of the target electrical-thermal coupling system.

[0011] In step 1, when studying a single battery of an electric vehicle, battery device parameters are obtained from the electric vehicle's engineering test report, including: battery capacity, minimum voltage, maximum voltage, internal ohmic resistance, charge transfer RC pair, diffusion impedance and capacitance of the RC pair, temperature coefficient of open-circuit voltage, Faraday efficiency, reference temperature, and initial state of charge; the equivalent circuit composition of the battery and the electro-thermal coupling dynamic equation based on the equivalent circuit are obtained, wherein the electro-thermal coupling dynamic equation includes the battery's OCV-SOC linear relationship, the equation of the diffusion RC network, and the heat loss calculation model.

[0012] In step 2, the knowledge base pre-adds knowledge blocks of the equivalent circuit of electric vehicle batteries and the set of electro-thermal coupling dynamic equations based on the open-source Modelica library. The electro-thermal coupling dynamic equations of the equivalent circuit are physical knowledge. The semantic embedding vector of the components of the equivalent circuit of electric vehicle batteries is added to the knowledge base index as the index of the knowledge block. The semantic embedding vector of the user's requirements is compared with the index of the knowledge base using cosine similarity. Knowledge blocks with similarity exceeding a set threshold are retrieved and the corresponding physical knowledge is output.

[0013] In another aspect, the present invention provides a computer-readable storage medium having stored thereon program instructions for executing the AI-Agent-based Modelica intelligent modeling optimization method.

[0014] Compared to existing technologies, the advantages and positive effects of this invention are as follows: The method employs an AI-Agent-driven RAG-enhanced knowledge retrieval and multi-module cascaded processing structure, achieving a fully automated process from requirements to model, reducing manual intervention by over 90%. This method clearly defines the Modelica model design activities, specifying the inputs, outputs, and specific implementations of each activity. Through intelligent equation processing and error correction, it enhances the scientific rigor and robustness of the constructed high-dynamic, high-reliability energy system and the electrical-thermal coupling system model of energy batteries. This method supports multidisciplinary knowledge fusion and is applicable to complex system engineering scenarios such as the electrical-thermal coupling of electric vehicle battery units. Compared to manual modeling, the model development cycle can be shortened to 1 / 10 or even 1 / 100, and the model simulation speed can be increased by 10 to 100 times or more, demonstrating significant novelty and practical value. Experiments have shown that when the method of this invention is applied to modeling scenarios involving individual accuracy and robustness of electric vehicles, as well as long modeling cycles and high iteration costs, the method can construct a more accurate and robust Modelica battery model. It solves the problem of inaccurate electrical-thermal coupling of existing electric vehicle battery cells, and shortens the model development cycle to 1 / 10 of the original time. The model simulation speed is increased by more than 10 times. It can solve problems in existing modeling such as SOC estimation deviation >5% under charging / discharging conditions and inaccurate thermal prediction, and can improve BMS simulation accuracy by 15%. Attached Figure Description

[0015] Figure 1 This is a diagram illustrating the implementation framework of the AI-Agent-based Modelica intelligent modeling optimization method of this invention.

[0016] Figure 2 This is a sub-flowchart of the physics knowledge retrieval module of the present invention;

[0017] Figure 3 This is a sub-flowchart of the mathematical equation processing module of the present invention;

[0018] Figure 4 This is a sub-flowchart of the Modelica code generation module of the present invention;

[0019] Figure 5 This is a sub-flowchart of the code verification and error correction module of this invention;

[0020] Figure 6 This is an example diagram of an electric vehicle battery cell model generated according to an embodiment of the present invention;

[0021] Figure 7 This is an example diagram of electric vehicle battery cell testing generated according to an embodiment of the present invention;

[0022] Figure 8 This is a voltage test result diagram of a battery pack composed of electric vehicle battery cells generated according to an embodiment of the present invention;

[0023] Figure 9 This is a graph showing the test results of the battery coolant outlet temperature of an electric vehicle battery cell generated according to an embodiment of the present invention. Detailed Implementation

[0024] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.

[0025] This invention provides an AI-Agent-based Modelica intelligent modeling optimization method. The research target is a high-dynamic, high-reliability energy system or battery cell. It acquires data and modeling requirements for the research target, and optimizes the Modelica modeling process of the research target using this invention's method to obtain a Modelica model of the required electrical-thermal coupled system of the research target. Furthermore, the obtained Modelica model can be used as a digital twin model of the target. Real-time electrical and thermal parameters of the actual energy system or battery during operation are collected and transmitted to the digital model. Based on the feedback from the digital model, the future state of the target energy system or battery is predicted, energy management or battery management is optimized, fault location and analysis are performed, and energy lifetime prediction and management are conducted, etc.

[0026] This invention uses the electrical-thermal coupling modeling of a single battery cell in a new energy electric vehicle (EV) as an example to illustrate the Modelica intelligent modeling and optimization method based on AI-Agent. For example... Figure 1As shown in this embodiment, the AI-Agent-based Modelica intelligent modeling and optimization method for EV battery cells under charging / discharging conditions automatically generates a "Batterymodel.mo" model to support simulation of voltage / SOC / temperature curves using tools such as Dymola, thus verifying EV battery thermal management strategies. This embodiment includes a physics knowledge retrieval module, a mathematical equation processing module, a Modelica code generation module, and a code verification and error correction module, which are automatically invoked by the AI-Agent. Specifically, it includes the following five steps. This invention solves the practical problems of building battery models under charging / discharging conditions using Modelica, avoiding issues such as SOC integral estimation errors, inaccurate heat loss prediction, and voltage dynamic response lag. It can quickly and accurately build a high-fidelity equivalent circuit model for the battery, thereby optimizing battery parameters and thermal management strategies through high-fidelity equivalent circuit simulation, improving battery cycle life, and reducing safety hazards.

[0027] Step 1: Obtain the equivalent circuit composition and device parameters of the research target, and receive the modeling requirements input by the user. In this embodiment, the modeling requirement is: to model the electrical-thermal coupling system of a single battery cell in an electric vehicle.

[0028] This invention first obtains data on the research objective from the application scenario. This data can be extracted from EV engineering test reports (such as Excel spreadsheets or sensor logs) during the R&D or verification phase of electric vehicles. The obtained data includes battery composition and device parameters. Battery composition mainly refers to the equivalent circuit topology and the electro-thermal coupling dynamic equations based on this equivalent circuit. In this embodiment, the user's modeling requirements and the obtained data of a single battery cell in the electric vehicle are written into the input text according to a pre-defined structured format. The input text includes:

[0029] (1) The equivalent circuit topology of the battery cell and the electro-thermal coupling dynamic equation based on the equivalent circuit.

[0030] In this embodiment, the battery equivalent circuit consists of a reference branch formed by an OCV source varying with SOC and an internal ohmic resistor connected in series. A charge transfer RC pair is then connected in parallel on this branch, followed by n_RC=2 parallel RC networks of identical structure to simulate the diffusion polarization effect inside the battery. The electro-thermal coupling dynamic equations of the battery equivalent circuit need to be obtained, including the linear relationship between OCV and SOC, the equations of the diffusion RC network, and the heat loss calculation model. Based on the electro-thermal coupling dynamic equations of the equivalent circuit topology, the electrical state equations of the main physical parameters in the circuit framework are also included.

[0031] (2) Device parameters of the battery cell, including battery capacity Q, minimum voltage U_min, maximum voltage U_max, internal ohmic resistance R_ohm, charge transfer RC pair (resistor R_ct, capacitor C_ct), diffusion impedance R_diff and capacitance C_diff of the RC pair, temperature coefficient of open-circuit voltage dUdT, Faraday efficiency eta_farad, and reference temperature T_ref. And initial conditions, i.e., initial state of charge soc_init.

[0032] In this embodiment, the input text is stored as a document named "BatterymodelDocScene10Input.md". The equivalent circuit topology can be described as: OCV voltage source + R_ohm ohmic resistor + R_ct / C_ct charge transfer RC network + n_RC = 2 diffusion R_diff / C_diff RC networks. The electro-thermal coupling kinetic equations based on the equivalent circuit topology include the following:

[0033] Terminal voltage U = OCV - deltaU_ohm - deltaU_ct - sum(deltaU_diff); deltaU_ohm is the voltage change caused by the current flowing through the ohmic internal resistance, deltaU_ct is the polarization overpotential caused by the current during charge transfer, deltaU_diff is the polarization overpotential caused by the current during diffusion, and sum() represents summation;

[0034] SOC dynamic equation: der(soc)=-I / Q*eta_farad; I represents current, der() represents derivative, and soc is the state of charge.

[0035] Open-circuit voltage relationship: OCV=U_min+(U_max-U_min)*soc+dUdT*(T-T_ref); This equation describes the linear relationship between OCV-SOC-T, where dUdT is the temperature coefficient of the open-circuit voltage and T is the current temperature of the battery;

[0036] Total heat loss Phi_total = Phi_ohm + Phi_ct + Phi_diff + Phi_entropy; Phi_ohm is ohmic heat, Phi_ct is charge transfer heat, Phi_diff is diffusion heat, and Phi_entropy is entropy heat caused by the battery reaction itself.

[0037] Specific device parameters: Capacitance Q = 103600As (Amperes-seconds), minimum voltage U_min = 3.0V, maximum voltage U_max = 4.2V, internal ohmic resistance R_ohm = 0.001Ω, charge transfer resistance R_ct = 0.002Ω, capacitance C_ct = 2000F, diffusion impedance array R_diff = {0.005, 0.01}Ω, capacitance array C_diff = {10000, 20000}F, voltage temperature coefficient dUdT = 0.0001V / K, Faraday efficiency eta_farad = 0.95, reference temperature T_ref = 298.15K, initial state of charge soc_init = 0.8.

[0038] The above data can be provided by uploading an Excel / JSON file of the EV engineering test report, via API interface, or by embedding a Markdown document, rather than just abstract requirements. If parameters are missing, the equations will be incomplete and a simulateable model cannot be generated. This input data ensures the physical authenticity of the model and the completeness of the dynamic simulation boundary conditions, thus laying the foundation for the subsequent automation process.

[0039] Step 2: The AI-Agent activates the physics knowledge retrieval module and uses the RAG framework to retrieve physics knowledge from the knowledge base, ensuring that the retrieval results cover the core principles and equations of relevant multidisciplinary fields, including control, dynamics, kinematics, electricity, and thermodynamics. For example, this embodiment of the invention includes: the SOC dynamic equation and open-circuit voltage relationship in electrochemistry, the charge transfer process equation, the diffusion RC network equation, and ohmic heat loss and total heat loss in thermodynamics, as follows: SOC dynamic equation: der(soc)=-I / Q*eta_farad; Open-circuit voltage relationship: OCV=U_min+(U_max-U_min)soc+dUdT(T-T_ref); Charge transfer process equation: der(deltaU_ct)=(I-deltaU_ct / R_ct) / C_ct; Diffusion RC network equation: for i in 1:n_RC: der(deltaU_diff[i])=(I-deltaU_diff[i] / R_diff[i]) / C_diff[i]; Ohmic heat in thermal engineering: Phi_ohm=I^2*R_ohm; Total heat loss: Phi_total=Phi_ohm+Phi_ct+Phi_diff+Phi_entropy; where Phi_entropy=I*dUdT*T, Phi_ct=deltaU_ct^2 / R_ct, Phi_diff=sum(deltaU_diff[i]^2 / R_diff[i]).

[0040] This knowledge pertains to the electrical-thermal coupling system of a single battery cell in an electric vehicle, enabling accurate simulation of terminal voltage and thermal port response, heatPort.Q_flow = -Phi_total, providing a rigorous multiphysics foundation for subsequent equation construction.

[0041] like Figure 2As shown, the specific implementation of the physical knowledge retrieval module of this invention is as follows: The AI-Agent matches the user's modeling needs with the knowledge base index through semantic embedding vectors, and outputs structured knowledge blocks. The knowledge base of this invention is based on existing open-source Modelica libraries such as Modelica.Electrical.Analog.Battery and Thermal libraries, with enhancements and modifications, adding domain-specific extensions. For example, in this embodiment, the equivalent circuit composition and electro-thermal coupling dynamic equation set of electric vehicle batteries are pre-added, including the Bernardi thermal generation model and experimentally verified OCV-SOC-T table data, and stored as knowledge blocks in the knowledge base to support RAG context-enhanced generation and improve retrieval targeting. In this embodiment, knowledge blocks about electric vehicle batteries are pre-added. These knowledge blocks contain the content of the equivalent circuit composition of electric vehicle batteries and the sets of electro-thermal coupling dynamic equations for each battery equivalent circuit. The electro-thermal coupling dynamic equations of the equivalent circuit are used as physical knowledge, and the semantic embedding vector of the content of the equivalent circuit composition of electric vehicle batteries is used as the index of this knowledge block. The index of the knowledge base is the semantic embedding vector of the knowledge block content, stored in a vector database such as the FAISS index. By calculating the cosine similarity between the knowledge base index and the semantic embedding vector of user needs, knowledge blocks with similarity exceeding a set threshold are output, such as a threshold > 0.85, thereby efficiently retrieving relevant physical knowledge for user need modeling.For the electro-thermal coupling system of a single battery cell in an electric vehicle, the retrieved physical knowledge includes: (a) electrochemical knowledge, such as the SOC dynamic equation der(soc)=-I / Q*eta_farad, and the linear function of open-circuit voltage OCV with soc and T, OCV=U_min+(U_max-U_min)soc+dUdT(T-T_ref); (b) polarization kinetics knowledge, such as the charge transfer RC equation der(deltaU_ct)=(I-deltaU_ct / R_ct) / C_ct, and the diffusion RC network equation der(d eltaU_diff[i])=(I-deltaU_diff[i] / R_diff[i]) / C_diff[i]; (c) Thermal knowledge, such as ohmic heat Phi_ohm=I^2*R_ohm, charge transfer heat Phi_ct=deltaU_ct^2 / R_ct, diffusion heat Phi_diff=sum(deltaU_diff[i]^2 / R_diff[i]), entropy heat Phi_entropy=IdUdT*T; (d) Interface knowledge, such as electrical interface declaration PositivePin p / NegativePin n for electrical, thermal interface declaration HeatPort_a heatPort for thermal, PositivePin, NegativePin and HeatPort_a are interface types, p, n and heatPort are variables in the instance.

[0042] This provides a rigorous physical basis for the construction of subsequent equations, supporting the equivalent circuit dynamics described in "BatterymodelDoc Scene 10 Input.md".

[0043] Step 3: After receiving the physical knowledge output by the physical knowledge retrieval module, the mathematical equation processing module processes the mathematical equations, including acquiring unknown variables, performing linear independence processing, and checking the number of equation variables. Acquired unknown variables include soc, U, I, OCV, deltaU_ohm, deltaU_ct, deltaU_diff[1:2], T, Phi_ohm, Phi_ct, Phi_diff, Phi_entropy, and Phi_total. Linear independence processing is performed, such as eliminating redundant coupling terms like redundant local RC voltage drops using Gaussian elimination. The number of equation variables is checked, ensuring n_eq ≈ n_var ≈ 15. If a mismatch occurs, RAG is triggered to supplement missing constraints, such as initially deltaU_ct=0, where n_eq is the number of independent equations in the model, and n_var is the number of unknown variables in the model.

[0044] For the electric-thermal coupling system of a single battery cell in an electric vehicle according to the present invention, based on the physical knowledge of the retrieved electric-thermal coupling equations, it is optimized into an algebraic differential hybrid set after processing, which supports Modelica acausal solution. The variables include soc (start=0.8), T=heatPort.T, etc. The final set of equations includes the following core coupling equations: (1) Electrical interface equation: current I = pi, I>0 during discharge; current conservation equation pi + ni = 0; pv - nv = U; p is the defined electrical interface variable; (2) SOC dynamic equation: der(soc)=-I / Q*eta_farad, Q=103600 As, eta_farad=0.95; (3) Open circuit voltage equation: OCV=U_min+(U_max-U_min)*soc+dUdT*(T-T_ref), U_min=3.0 V, U_max=4.2 V, dUdT=0.0001 V / K, T_ref=298.15 K; (4) Ohmic voltage drop equation: deltaU_ohm=I*R_ohm, R_ohm=0.001 Ω; (5) Charge transfer RC equation: der(deltaU_ct)=(I-deltaU_ct / R_ct) / C_ct, R_ct=0.002 Ω, C_ct=2000 F, initial deltaU_ct=0; (6) Diffusion RC network equation: for i in 1:n_RC: der(deltaU_diff[i])=(I-deltaU_diff[i] / R_diff[i]) / C_diff[i], n_RC=2, R_diff={0.005, 0.01}Ω, C_diff={10000, 20000}F, initial deltaU_diff[i]=0; (7) Total voltage drop equation: deltaU_diff_total=deltaU_ohm+deltaU_ct+sum(deltaU_diff), i=1:n_RC; (8) Terminal voltage equation: U=OCV-deltaU_diff_total (Kirchhoff voltage law); (9) Heat loss equation: Ohmic heat Phi_ohm=I^2*R_ohm , Charge transfer heat Phi_ct=deltaU_ct^2 / R_ct, Diffusion heat Phi_diff=sum(deltaU_diff[i]^2 / R_diff[i]), i=1:n_RC, Entropy heat Phi_entropy=I*dUdT*T; (10) Total heat loss equation: Phi_total=Phi_ohm+Phi_ct+Phi_diff+Phi_entropy; Heat port equation: heatPort.Q_flow = -Phi_total, heatPort. Q_flow represents the heat outflow; a positive value indicates that the battery is releasing heat.

[0045] These equations, after processing, ensure completeness and consistency, providing a rigorous foundation for code generation and supporting dynamic simulation in "Batterymodel.mo".

[0046] like Figure 3 As shown, the specific implementation of the mathematical equation processing module of this invention is as follows: Obtain the list of unknown variables in the equation set, such as soc, deltaU_ct, and Phi_total; apply Gaussian elimination to perform linear independence processing, eliminating redundant equations, such as simplifying redundant RC initial condition terms; check whether the number of equation variables matches, and if not, trigger RAG to supplement missing constraints, such as additionally setting a thermal boundary T=heatPort.T, to ensure that the equation set satisfies the uniqueness and stability of the solution, thereby outputting the optimized electro-thermal coupling equation set, supporting the voltage / thermal response evaluation of the battery cell model, such as the calculation of terminal voltage and total heat flow in "BatterymodelDoc Scene 10 Input.md".

[0047] Step 4: The Modelica code generation module generates initial Modelica code based on the processed knowledge, namely the mathematical equations output from Step 3.

[0048] The knowledge processed in this embodiment mainly refers to the set of coupled equations (1)-(10) obtained in step 3. This knowledge is mapped to the Modelica model interface through semantic mapping. For example, electrical knowledge (I / U / OCV equations) corresponds to the electrical port of the Modelica model, Modelica.Electrical.Analog.Interfaces.PositivePin p / NegativePin n, which is used to describe the causal / non-causal input and output of current I and voltage U; thermal knowledge (T / Phi_total equations) corresponds to the thermal port of the Modelica model, Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a heatPort, which is used to describe the exchange of temperature T and heat flow Q_flow; polarization knowledge (RC der equations) corresponds to internal variables such as SIunits.VoltagedeltaU_ct and device parameters such as R_ct=0.002; the coupling between physical modules is achieved through equation blocks, which can realize non-causal (acausal) modeling; add annotations (such as Placement for interface position) to explain the physical meaning of the code. For the electric-thermal coupling system of a single battery cell in an electric vehicle in this embodiment, the generated code example is as follows:

[0049] within EV_AI.ElectricStorage.Components;

[0050] The BatteryModel model is a battery model based on electrical equations, encompassing both electrical and thermal characteristics.

[0051] import Modelica.Electrical.Analog.Interfaces.PositivePin;

[0052] import Modelica.Electrical.Analog.Interfaces.NegativePin;

[0053] import Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a;

[0054] import Modelica.SIunits;

[0055] / / Electrical interface (corresponding to the I / U equation in electrical knowledge)

[0056] PositivePin p "positive interface" annotation(Placement(transformation(extent={{90,-10},{110,10}})));

[0057] NegativePin n "Negative interface" annotation(Placement(transformation(extent={{-110,-10},{-90,10}})));

[0058] / / Thermal interface (corresponding to the thermal equation T / Phi_total)

[0059] HeatPort_a heatPort "heatport" annotation(Placement(transformation(extent={{-10,-110},{10,-90}})));

[0060] / / Parameters (generated from input data, corresponding to device parameters)

[0061] parameter SIunits.ElectricCharge Q = 10*3600 "Battery capacity [As]";

[0062] parameter SIunits.Resistance R_ohm = 0.001 "Ohm resistance [Ω]";

[0063] parameter SIunits.Resistance R_ct = 0.002 "charge transfer resistance [Ω]";

[0064] parameter SIunits.Capacitance C_ct = 2000 "charge transfer capacitance [F]";

[0065] parameter Integer n_RC = 2 "Number of diffusion RC networks";

[0066] parameter SIunits.Resistance R_diff[n_RC] = {0.005, 0.01} "Diffusion resistance array [Ω]";

[0067] parameter SIunits.Capacitance C_diff[n_RC] = {10000, 20000} "Diffusion capacitor array [F]";

[0068] parameter SIunits.SpecificHeatCapacity dUdT = 0.0001 "Voltage temperature coefficient [V / K]";

[0069] parameter SIunits.Temperature T_ref = 298.15 "Reference temperature [K]";

[0070] parameter SIunits.Voltage U_min = 3.0 "Minimum voltage [V]";

[0071] parameter SIunits.Voltage U_max = 4.2 "Maximum voltage [V]";

[0072] parameter SIunits.PerUnit soc_init = 0.8 "Initial charge state [0-1]";

[0073] parameter Real eta_farad = 0.95 "Faraday efficiency";

[0074] / / Variables (corresponding to unknown variables, such as soc / U / I / OCV / deltaU, etc.)

[0075] SIunits.PerUnit soc(start = soc_init) "Charged state[0-1]";

[0076] SIunits.Voltage U "Battery terminal voltage [V]";

[0077] SIunits.Current I "Battery current [A] (positive for discharging, negative for charging)";

[0078] SIunits.Voltage OCV "Open circuit voltage [V]";

[0079] SIunits.Voltage deltaU_ohm "Ohm resistance voltage drop [V]";

[0080] SIunits.Voltage deltaU_ct "charge transfer voltage drop [V]";

[0081] SIunits.Voltage deltaU_diff[n_RC] "Voltage drop[V] of each diffused RC network";

[0082] SIunits.HeatFlowRate Phi_ohm "Ohmic heat loss [W]";

[0083] SIunits.HeatFlowRate Phi_ct "charge transfer heat loss [W]";

[0084] SIunits.HeatFlowRate Phi_diff "Diffusion heat loss [W]";

[0085] SIunits.HeatFlowRate Phi_entropy "Entropy Heat[W]";

[0086] SIunits.HeatFlowRate Phi_total "Total heat flow [W]";

[0087] SIunits.Temperature T "Battery temperature [K]";

[0088] SIunits.Voltage deltaU_diff_total;

[0089] initial equation

[0090] / / Initialization (corresponding to initial conditions)

[0091] deltaU_ct = 0;

[0092] for i in 1:n_RC loop

[0093] deltaU_diff[i] = 0;

[0094] end for;

[0095] equation

[0096] / / Interface equations (corresponding interface knowledge)

[0097] I = pi; pi + ni = 0; pv - nv = U;

[0098] / / Temperature equation (corresponding to thermal interface knowledge)

[0099] T = heatPort.T;

[0100] / / SOC equation (corresponding electrochemical knowledge)

[0101] der(soc) = -I / (Q)*eta_farad;

[0102] / / OCV equation (corresponding to open-circuit voltage knowledge)

[0103] OCV = U_min + (U_max - U_min)*soc + dUdT*(T - T_ref);

[0104] / / Pressure drop equation (corresponding to polarization knowledge)

[0105] deltaU_ohm = I*R_ohm;

[0106] der(deltaU_ct) = (I - deltaU_ct / R_ct) / C_ct;

[0107] for i in 1:n_RC loop

[0108] der(deltaU_diff[i]) = (I - deltaU_diff[i] / R_diff[i]) / C_diff[i];

[0109] end for;

[0110] deltaU_diff_total = deltaU_ohm + deltaU_ct + sum(deltaU_diff);

[0111] U = OCV - deltaU_diff_total;

[0112] / / Heat equation (corresponding to thermodynamics)

[0113] Phi_ohm = I^2*R_ohm;

[0114] Phi_ct = deltaU_ct^2 / R_ct;

[0115] Phi_diff = sum(deltaU_diff[i]^2 / R_diff[i] for i in 1:n_RC);

[0116] Phi_entropy = I*dUdT*T;

[0117] Phi_total = Phi_ohm + Phi_ct + Phi_diff + Phi_entropy;

[0118] heatPort.Q_flow = -Phi_total; / / Hotport output

[0119] annotation(Icon(...), Documentation(...)); / / Annotation generation, corresponding to physical meaning

[0120] end BatteryModel;

[0121] The code above is an initial Modelica code framework fragment directly based on the requirements and equations of "BatterymodelDoc Scene 10 Input.md". This framework automatically builds interfaces (e.g., p for I input), parameters (e.g., Q from input data) and equations (directly embedding processed knowledge, such as der(soc)) to form a simulateable model, supporting battery cell expansion and the complete implementation of "Batterymodel.mo".

[0122] like Figure 4 As shown, the specific implementation of the Modelica code generation module of this invention is as follows: Based on the processed knowledge, the model interface is automatically generated, such as the interface PositivePin p / NegativePin n / HeatPort_a heatPort, causal / non-causal definitions, corresponding to electrical / thermal knowledge; parameter generation, such as constant initialization of Q=103600 As, R_ohm=0.001 Ω, etc., obtained from user input text; variable generation, such as Real type / physical dimension declarations such as SIunits.PerUnit soc(unit="1", start=0.8), SIunits.Voltage U; equation generation, such as algebraic differential form of der(soc)=-I / Qeta_farad / U=OCV - deltaU_diff_total; annotation generation, such as "state of charge [0-1]" / "battery model based on electrical equations" automatically adds physical meaning descriptions, forming the code framework of the initial Modelica model, supporting subsequent verification and battery electrical-thermal dynamic simulation such as simulating the terminal voltage U and total heat flow Phi_total curves.

[0123] Step 5: The code verification and error correction module performs lexical, syntactic, semantic, and path checks on the current Modelica model code, automatically corrects errors, and outputs the final optimized Modelica model.

[0124] This embodiment focuses on the electrical-thermal coupling system of a single battery cell in an electric vehicle. The Modelica model to be constructed is the complete multiphysics model of this system. For example, if a semantic error is detected, such as the thermal balance equation Phi_total not being fully coupled with entropy Phi_entropy=IdUdTT, resulting in an incomplete Q_flow conservation closure, or if a path error is detected, such as not importing Modelica.SIunits, the AI-Agent generates a correction strategy based on the error message until the model outputs without errors. This ensures that in a simulation environment such as OpenModelica, the Modelica model achieves an accuracy >95% and an error <3%, which is, for example, the voltage response deviation of the corresponding model <0.05V and the heat flow prediction <1W.

[0125] like Figure 5 As shown, the specific implementation of the code verification and error correction module of this invention is as follows: A Modelica compiler, such as OpenModelica, is used to perform lexical and syntactic checks on the current Modelica model code, identifying syntax errors such as an undefined deltaU_diff array; semantic checks are performed to verify variable type consistency (e.g., SIunits.Voltage U) and equation balance (e.g., Kirchhoff's law U=OCV-deltaU_diff_total conservation); path checks are performed to ensure complete library dependencies (e.g., importing Modelica.Electrical.Analog.Interfaces and Thermal.HeatTransfer); if an error is detected, the AI-Agent returns the error information by calling a tool and corrects the model, such as replacing invalid syntax or supplementing missing import statements, and iteratively verifies until an error-free final Modelica model is output, supporting robust simulation of battery cell scenarios.

[0126] Accordingly, the present invention can also implement a readable storage medium storing a computer program that implements the AI-Agent-based Modelica intelligent modeling optimization method of the present invention. When the program is executed by a processor, it implements the Modelica model construction of a target energy system or battery cell using the AI-Agent-based Modelica intelligent modeling optimization method of the present invention.

[0127] For the input text "BatterymodelDoc Scene 10 Input.md" in this embodiment of the invention, the fully automated process of physical knowledge retrieval, mathematical equation processing, Modelica code generation, and code verification and error correction of this invention is executed, and finally the optimized Modelica model Batterymodel.mo is output. This model includes the BatteryModel class as shown in the code above, integrates interfaces PositivePin p / NegativePin n / HeatPort_a heatPort, variables soc / U / I / OCV / deltaU_ohm, etc., equations such as der(soc)=-I / Qeta_farad and heatPort.Q_flow=-Phi_total. Figure 6 The image shows the generated EV battery cell model. Figure 7 As shown, multiple generated EV battery cell models are used to form a battery pack for testing. This can be used in BMS dynamic simulation to predict voltage / SOC / temperature curve responses, verify cooling strategies such as adjusting airflow rate to reduce temperature rise by 5°C, solve multi-physical coupling problems in real-world scenarios, avoid the cost and iteration failure of physical prototype testing, and save 30%-50% of costs by using Modelica model testing. Figure 8 It is done through the simulation tool Dymola, such as... Figure 7 The results of battery pack voltage testing on the assembled battery pack model. Figure 9 This involves conducting cooling strategy verification tests and monitoring the battery coolant outlet temperature of the battery cell model. Experiments verify that the battery Modelica model implemented using the method of this invention supports accurate simulation of electrical voltage drop and thermal flow response. The model contains equations deltaU_ohm=I*R_ohm and heatPort.Q_flow=-Phi_total, enabling real-time response to charging / discharging conditions. For example, experiments with SOC decay and T rising to 40°C under constant current charging of I=200A validate thermal management strategies, such as optimizing R_ct / C_ct to reduce deltaU_ct by 10%.

[0128] This invention employs an AI-Agent-driven RAG enhanced knowledge retrieval and multi-module cascaded processing structure to achieve a fully automated, self-closing process from requirements to model, reducing manual intervention by over 90%. However, this invention is not simply about computers replacing manual execution. Its innovation lies in the clear division of Modelica model design activities, the explicit inputs and outputs of each design activity, the specific steps of each activity, domain-oriented RAG knowledge retrieval (existing RAG technologies generally have limited effectiveness in Modelica model development), and tool-based multi-round error iteration correction (passing after 3-5 rounds of checks). This solves the coupling inaccuracy problem in multidisciplinary model modeling techniques such as the electrical-thermal coupling scenario of battery cells, demonstrating significant innovation. Using this method, the model development cycle is shortened to 1 / 10, and simulation speed is increased by more than 10 times.

[0129] The AI-Agent of this invention integrates a large language model and a RAG module to achieve context-enhanced knowledge retrieval and automatic parsing of user requirements. Through a cascaded pipeline of knowledge, equations, code, and verification, it iteratively optimizes and obtains the target Modelica model, ensuring that the model meets rigorous verification of physical laws such as current conservation and negative heat flux in a simulation environment. This method can be widely applied in model-based cyber-physics systems engineering fields such as electric vehicle BMS development, drone battery optimization, and rocket energy systems.

[0130] Except for the technical features described in the specification, all other technologies are known to those skilled in the art. Descriptions of well-known components and technologies are omitted in this invention to avoid redundancy and unnecessary limitation. The embodiments described above do not represent all embodiments consistent with this application. Various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of this invention are still within the protection scope of this invention.

Claims

1. A Modelica intelligent modeling optimization method based on AI-Agent, characterized in that, This method includes a physics knowledge retrieval module, a mathematical equation processing module, a Modelica code generation module, and a code verification and error correction module, and utilizes an AI-Agent. The method takes the target energy system or battery cell as the objective and performs the following steps: Step 1: Obtain target data, including device parameters of the target energy system or battery cell, the equivalent circuit composition of the target, and the set of electro-thermal coupling dynamic equations based on the equivalent circuit; Obtain user modeling requirements, which are described as modeling the electro-thermal coupling system of the target; Write the target data and user modeling requirements into the input text. Step 2: Based on the user's modeling requirements in the input text, the AI-Agent triggers the physics knowledge retrieval module. Using the RAG framework, it matches the user's modeling requirements with the knowledge base index through semantic embedding vectors, and retrieves and outputs structured physics knowledge from the knowledge base. The knowledge base pre-adds target domain knowledge blocks, which include content describing the composition of the target equivalent circuit and the electro-thermal coupling dynamic equation set of the target equivalent circuit. RAG stands for retrieval enhancement generation. Step 3: The mathematical equation processing module obtains the set of equations of physical knowledge output by the physical knowledge retrieval module, obtains the unknown variables in the set of equations, performs linear independence processing to eliminate redundant equations, checks the number of equation variables, and if the number of equation variables does not match the number of independent equations, triggers RAG to supplement missing constraints to ensure that the set of equations satisfies the uniqueness and stability of the solution, and outputs the optimized electro-thermal coupling equation set. Step 4: Based on the optimized electro-thermal coupling equations, the Modelica code generation module generates the electrical and thermal interfaces of the model, the device parameters of the model, the internal variables of the model, the equations and comments, and obtains the initial Modelica model code. Step 5: The code verification and error correction module performs lexical, syntactic, semantic, and path checks on the current Modelica model code, automatically corrects errors, and outputs the final optimized Modelica model, which is the simulation model of the target electrical-thermal coupling system.

2. The method according to claim 1, characterized in that, In step 1, when modeling a single battery of an electric vehicle, battery device parameters are obtained from the electric vehicle's engineering test report, including: battery capacity, minimum voltage, maximum voltage, internal ohmic resistance, charge transfer resistor-capacitor pair, diffusion impedance and capacitance of the RC pair, temperature coefficient of open-circuit voltage, Faraday efficiency, reference temperature, and initial state of charge; the equivalent circuit composition of the battery and the electro-thermal coupling dynamic equation based on the equivalent circuit are obtained. The electro-thermal coupling dynamic equation includes the linear relationship between the battery's OCV and SOC, the equation of the diffused RC network, and the heat loss calculation model; OCV represents open-circuit voltage, SOC represents the battery's state of charge, and RC represents resistor-capacitor.

3. The method according to claim 1 or 2, characterized in that, In step 2, the knowledge base pre-adds knowledge blocks of the equivalent circuit of electric vehicle batteries and the set of electro-thermal coupling dynamic equations based on the open-source Modelica library. The electro-thermal coupling dynamic equations of the equivalent circuit are physical knowledge. The semantic embedding vector of the components of the equivalent circuit of electric vehicle batteries is added to the knowledge base index as the index of the knowledge block. The semantic embedding vector of the user's requirements is compared with the index of the knowledge base using cosine similarity. Knowledge blocks with similarity exceeding a set threshold are retrieved and the corresponding physical knowledge is output.

4. The method according to claim 1 or 2, characterized in that, In step 4, the Modelica code generation module generates electrical and thermal interfaces based on the electrical and thermal knowledge in the equation set, generates device parameters and sets the values ​​of device parameters according to the input text, generates internal variables of the model based on the polarization knowledge of the RC network, and generates equations.

5. The method according to claim 2, characterized in that, In step 5, a Modelica model of a single battery of an electric vehicle is obtained, and multiple Modelica models of single batteries are combined to form a battery pack, which is then used for testing.

6. A computer-readable storage medium, characterized in that, The medium stores program instructions for executing the AI-Agent-based Modelica intelligent modeling optimization method as described in claim 1, 2, or 5.