# 实时仿真

实时仿真是一种计算方法：仿真器在一秒墙钟时间内产生一秒的仿真结果，并在每个时间步的持续时间之内求解该时间步。它用于将物理设备连接到虚拟模型、培训操作员，以及在被建模过程实际发生的同时验证控制器和数字孪生。<sup>[1](https://arxiv.org/pdf/1905.01848.pdf)</sup><sup> • </sup><sup>[2](https://infoscience.epfl.ch/server/api/core/bitstreams/3e2019a2-7b9c-44ce-b332-75a447f8fbe5/content)</sup> 核心约束不是固定帧率，而是截止时间：一个时间步的执行时间 \( T_{e} \) 必须低于步长 \( T_{s} \)。若一个或多个时间步出现 \( T_{e} > T_{s} \)，该次运行即构成超时，不再属于实时仿真。<sup>[1](https://arxiv.org/pdf/1905.01848.pdf)</sup><sup> • </sup><sup>[2](https://infoscience.epfl.ch/server/api/core/bitstreams/3e2019a2-7b9c-44ce-b332-75a447f8fbe5/content)</sup><sup> • </sup><sup>[3](https://blob.opal-rt.com/medias/L00161_0436.pdf)</sup> 在数字孪生实践中，阈值因应用而异：工业制造的目标响应约为100 ms或更短，而基础设施管理可接受1–5 s。<sup>[4](https://www.sciencedirect.com/science/article/pii/S0045794924000713)</sup>

| 关键事实 | 详情 |
|---|---|
| 核心约束 | 每个时间步都必须在其自身的墙钟持续时间内求解；错过截止时间即为“超时”<sup>[1](https://arxiv.org/pdf/1905.01848.pdf)</sup><sup> • </sup><sup>[3](https://blob.opal-rt.com/medias/L00161_0436.pdf)</sup> |
| 求解器要求 | 定步长、固定计算成本的求解器；变步长技术不适用<sup>[5](https://www.mathworks.com/help/simscape/ug/solvers-for-real-time-simulation.html)</sup><sup> • </sup><sup>[3](https://blob.opal-rt.com/medias/L00161_0436.pdf)</sup> |
| 典型电磁暂态步长 | 50/60 Hz电力系统约50 µs；保护硬件在环为30–60 µs<sup>[6](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/journal/J026_real-time-simulation-applications.pdf)</sup><sup> • </sup><sup>[7](https://www.mdpi.com/1996-1073/15/3/1111)</sup> |
| 最快步长 | FPGA求解器在Opal-RT 4520上达到250 ns，在HYPERSIM eHS中为90 ns–4 µs，而当前eHS工具箱可低至32 ns（eHS Gen5配置提供90 ns时间步长和625 ps采样分辨率）<sup>[8](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/conference/2019/CP163_MSCPES2019_paper_3.pdf)</sup><sup> • </sup><sup>[9](https://www.opal-rt.com/software/software-platforms/hypersim/)</sup> |
| 主要变体 | 全数字仿真、控制器硬件在环（CHIL）、功率硬件在环（PHIL）、软件在环（SIL）<sup>[6](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/journal/J026_real-time-simulation-applications.pdf)</sup><sup> • </sup><sup>[3](https://blob.opal-rt.com/medias/L00161_0436.pdf)</sup> |
| 入门硬件成本 | 一台基础NI PXI实时服务器成本约为10,000美元（2016年数据）<sup>[1](https://arxiv.org/pdf/1905.01848.pdf)</sup> |
| 关键领域 | 电力系统与电力电子测试、汽车ECU验证、结构实时混合仿真、操作员培训<sup>[10](https://www.mdpi.com/2079-9292/11/15/2462)</sup><sup> • </sup><sup>[11](https://onlinelibrary.wiley.com/doi/10.1002/eqe.2246)</sup> |

## 工作原理

实时仿真器运行定步长、固定计算成本的配置：选择求解器类型、步长和迭代次数，使每个时间步的计算都在该步的墙钟持续时间内完成。<sup>[5](https://www.mathworks.com/help/simscape/ug/solvers-for-real-time-simulation.html)</sup> 变步长求解器会缩小步长以捕捉事件，其每步计算成本可变，因此无法映射到这一时钟；正因如此，Simulink默认的梯形法和后向欧拉法变步长行为明确并非为严格实时执行而设计。<sup>[3](https://blob.opal-rt.com/medias/L00161_0436.pdf)</sup><sup> • </sup><sup>[2](https://infoscience.epfl.ch/server/api/core/bitstreams/3e2019a2-7b9c-44ce-b332-75a447f8fbe5/content)</sup>

步长由必须解析的最快动态决定。常用经验法则将步长设为最小系统时间常数的5–10%以下，因此慢速机械系统取1–10 ms，而摩擦效应重要时取100–500 µs。<sup>[3](https://blob.opal-rt.com/medias/L00161_0436.pdf)</sup> 对于50/60 Hz电网的电磁暂态（EMT）仿真，要忠实再现暂态过程，约需50 µs或更小步长；而含短馈线的配电网即使对此也构成挑战，因为其传播延迟远短于经典的50 µs步长。<sup>[2](https://infoscience.epfl.ch/server/api/core/bitstreams/3e2019a2-7b9c-44ce-b332-75a447f8fbe5/content)</sup><sup> • </sup><sup>[6](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/journal/J026_real-time-simulation-applications.pdf)</sup> 刚性驱动求解器选择：显式求解器每步成本较低，但在刚性系统上受稳定性限制；隐式求解器以更高成本处理刚性，其中L-稳定格式会有意阻尼快模态。L-稳定格式有所帮助；ARTEMiS art5求解器使用矩阵指数的L-稳定近似，可自然抑制大多数数值振荡。<sup>[5](https://www.mathworks.com/help/simscape/ug/solvers-for-real-time-simulation.html)</sup><sup> • </sup><sup>[12](https://www.ipstconf.org/papers/Proc_IPST2009/09IPST096.pdf)</sup>

## 实现方法

实践者首先简化模型，直到其固定计算成本符合预算：采用平均值元件模型，以及为每个子系统分配与其自身时间尺度相匹配的时间步长的多速率分区。<sup>[13](https://publications.rwth-aachen.de/record/843288/files/843288.pdf)</sup><sup> • </sup><sup>[14](https://www.sciencedirect.com/science/article/abs/pii/S0306261918311346)</sup> 例如，详细的变流器模型只有在每个开关周期内的仿真步数超过10，即 \( T_{s} < 1/(10 f_{sw}) \) 时，才能在基于CPU的求解器上运行；这是用于表征变流器开关频谱的安全规则。<sup>[13](https://publications.rwth-aachen.de/record/843288/files/843288.pdf)</sup>

随后将模型配置为固定计算成本执行，限制每步迭代次数以防止超时；建议从两到三次非线性迭代开始。<sup>[15](https://www.mathworks.com/company/technical-articles/real-time-simulation-of-physical-systems-using-simscape.html)</sup> 生成代码并部署到实时目标机上，与I/O耦合，并利用任务执行时间（TET）报告和执行时间裕度来验证是否发生超时。在一个已发表的示例中，一个模型在700 MHz处理器上实时运行，仅使用可用步长的62%，其结果与相同求解器设置下的桌面仿真一致。<sup>[15](https://www.mathworks.com/company/technical-articles/real-time-simulation-of-physical-systems-using-simscape.html)</sup> 在标准主机上，毫秒级步长并不苛刻，但微秒级步长需要经过调优的内核：借助[PREEMPT_RT](https://www.edgepedia.org/zh/preempt-rt)、核心隔离、FIFO调度和核心绑定，开源DPsim求解器实现了低至5 µs且与FPGA同步的步长。<sup>[16](https://dpsim.fein-aachen.org/docs/user-guide/real-time/)</sup>

## 起源

在数字计算机出现之前，电网实时仿真使用模拟实时仿真器和由实际设备按缩小尺寸构建的暂态网络分析仪，后来又加入了模拟-数字混合仿真器。<sup>[6](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/journal/J026_real-time-simulation-applications.pdf)</sup> 其算法基础是赫尔曼·多梅尔（Hermann Dommel）1969年发表于《IEEE电力设备与系统汇刊》的论文《单相与多相网络电磁暂态的数字计算机求解》<sup>[17](https://doi.org/10.1109/tpas.1969.292459)</sup>。早期数字仿真器以非实时方式运行，有时每仿真一秒需要数秒甚至数分钟；随着微处理器和DSP成熟，数字实时仿真器在20世纪80年代开始取代物理对应设备，最初用于测试HVDC项目控制设备，以替代体积大、成本高且重新配置缓慢的模拟仿真器。<sup>[1](https://arxiv.org/pdf/1905.01848.pdf)</sup><sup> • </sup><sup>[7](https://www.mdpi.com/1996-1073/15/3/1111)</sup> J.R. 马蒂（J.R. Marti）和L.R. 利纳雷斯（L.R. Linares）于1994年在《IEEE电力系统汇刊》上报道了基于EMTP的实时暂态仿真。<sup>[18](https://doi.org/10.1109/59.336135)</sup> 到20世纪90年代末，全数字仿真器已经确立，包括基于DSP的商用系统、魁北克水电公司（Hydro-Québec）在超级计算机上运行的HYPERSIM，以及后来的PC集群实现。<sup>[6](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/journal/J026_real-time-simulation-applications.pdf)</sup><sup> • </sup><sup>[1](https://arxiv.org/pdf/1905.01848.pdf)</sup><sup> • </sup><sup>[19](https://link.springer.com/rwe/10.1007/978-981-287-251-7_40)</sup> 在结构工程领域，堀内（T. Horiuchi）及其同事于1999年在《地震工程与结构动力学》上报道了一种带作动器延迟补偿的实时混合实验系统，其基础是内森·M. 纽马克（Nathan M. Newmark）1959年的结构动力学计算方法。<sup>[20](https://doi.org/10.1002/%28sici%291096-9845%28199910%2928:10<1121::aid-eqe858>3.0.co;2-o)</sup><sup> • </sup><sup>[21](https://doi.org/10.1061/jmcea3.0000098)</sup> 该领域一篇被广泛引用的综述是M. D. 奥马尔·法鲁克（M. D. Omar Faruque）及其同事2015年发表于《IEEE电力与能源技术系统杂志》的论文。<sup>[22](https://doi.org/10.1109/jpets.2015.2427370)</sup>

## 变体

电力系统工作组文献将实时仿真分为全数字仿真、控制器硬件在环（CHIL）和功率硬件在环（PHIL）；在CHIL中，物理控制器连接到虚拟被控对象，不交换真实功率；在PHIL中，功率传入或传出被测硬件。<sup>[6](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/journal/J026_real-time-simulation-applications.pdf)</sup><sup> • </sup><sup>[2](https://infoscience.epfl.ch/server/api/core/bitstreams/3e2019a2-7b9c-44ce-b332-75a447f8fbe5/content)</sup> 在软件在环（SIL）中，控制器和被控对象在同一仿真器上运行且无I/O，从而支持加速的蒙特卡洛统计测试。<sup>[3](https://blob.opal-rt.com/medias/L00161_0436.pdf)</sup> 在结构工程中，实时混合仿真（RTHS）将由作动器测试的物理试件与计算子结构耦合。分布式RTHS（dRTHS）通过互联网将地理上分离的实验室中的子结构耦合起来，并使用改进的史密斯预测器来适应不可预测的通信延迟。<sup>[23](https://ascelibrary.org/doi/10.1061/%28ASCE%29CP.1943-5487.0000654)</sup> 电磁暂态–暂态稳定协同仿真通过基于贝杰龙模型的混合线路模型，将详细的内部电网与外部相量模型连接起来。<sup>[24](https://ietresearch.onlinelibrary.wiley.com/doi/10.1049/iet-gtd.2016.1573)</sup>

商用平台包括RTDS、Opal-RT（带基于FPGA的可重构I/O的PC集群）、dSPACE、Applied Dynamics International、Typhoon HIL、国家仪器（National Instruments）和Speedgoat。<sup>[25](https://ojs.cvut.cz/ojs/index.php/ap/article/download/738/570/0)</sup><sup> • </sup><sup>[10](https://www.mdpi.com/2079-9292/11/15/2462)</sup> Opal-RT 4520达到250 ns的最小时间步长，而Typhoon HIL 603（ARM R级处理器加[Xilinx Virtex](https://www.edgepedia.org/zh/xilinx-virtex) 6 FPGA）可在1 µs最小步长下可靠运行；Typhoon采用基于变压器的解耦，而Opal-RT使用状态空间节点（SSN）求解器，后者无需缓冲器即可避免数值问题。<sup>[29](https://opal-rt.atlassian.net/wiki/spaces/PHDGD/pages/144662811/OP4520+Specifications)</sup><sup> • </sup><sup>[8](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/conference/2019/CP163_MSCPES2019_paper_3.pdf)</sup> HYPERSIM以5–100 µs运行多核CPU电磁暂态仿真，以1–10 ms运行RMS仿真，并以90 ns–4 µs运行基于FPGA的eHS电磁暂态仿真，另有专用MMC求解器从100 ns起。<sup>[9](https://www.opal-rt.com/software/software-platforms/hypersim/)</sup>

## 应用

电力系统应用在文献中占主导地位：保护继电器以及HVDC和SVC控制设备的闭环测试、变流器控制器验证，以及电力电子硬件在环。<sup>[6](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/journal/J026_real-time-simulation-applications.pdf)</sup><sup> • </sup><sup>[7](https://www.mdpi.com/1996-1073/15/3/1111)</sup> 在汽车行业，嵌入式ECU的HIL测试自20世纪90年代以来一直是事实上的开发标准，通常要求100 µs或更短的帧时间，尤其是对于一级方程式赛车所用的高性能发动机。<sup>[10](https://www.mdpi.com/2079-9292/11/15/2462)</sup><sup> • </sup><sup>[25](https://ojs.cvut.cz/ojs/index.php/ap/article/download/738/570/0)</sup> RTHS能够在真实工况下评估结构构件，比大规模振动台测试更具成本效益，同时保留物理测试部件的速率依赖性和非线性行为。<sup>[11](https://onlinelibrary.wiley.com/doi/10.1002/eqe.2246)</sup> 操作员培训仿真器以10–100 ms帧时间即可令人满意地运行，实时仿真还支持设计、快速原型制作和教学。<sup>[25](https://ojs.cvut.cz/ojs/index.php/ap/article/download/738/570/0)</sup><sup> • </sup><sup>[6](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/journal/J026_real-time-simulation-applications.pdf)</sup>

## 局限与替代方案

典型失效模式是超时：计算超过该步的截止时间。后果取决于平台。在DPsim等软实时系统中，错过截止时间会被报告，但不致命；运行继续，结果在数值上仍然正确，但它不再与任何外部过程保持同步。<sup>[16](https://dpsim.fein-aachen.org/docs/user-guide/real-time/)</sup> 其他实现将超时视为错误运行，或在CPU过载时终止；TET监测用于在错过截止时间之前发现裕度侵蚀。<sup>[1](https://arxiv.org/pdf/1905.01848.pdf)</sup><sup> • </sup><sup>[2](https://infoscience.epfl.ch/server/api/core/bitstreams/3e2019a2-7b9c-44ce-b332-75a447f8fbe5/content)</sup><sup> • </sup><sup>[15](https://www.mathworks.com/company/technical-articles/real-time-simulation-of-physical-systems-using-simscape.html)</sup> 在RTHS中，计算子结构与物理子结构之间边界条件的同步决定稳定性和精度；已有研究提出 \( H_{\infty} \) 回路整形作动器控制器以同时改善二者。<sup>[11](https://onlinelibrary.wiley.com/doi/10.1002/eqe.2246)</sup>

相对于离线仿真的精度取决于离散化和模型降阶。一个三层三跨非延性钢筋混凝土框架的RTHS（超过400个自由度，其中一根柱进行物理测试）与先前加州大学伯克利分校（UC Berkeley）的振动台试验结果相差在10%以内，作者称其结果令人鼓舞但尚未完全可接受。<sup>[26](https://ascelibrary.org/doi/10.1061/%28ASCE%29ST.1943-541X.0000813)</sup> Eurostag、DigSilent和PSS/E等暂态稳定工具使用1–20 ms步长，无法详细表征HVDC和FACTS开关过程；反过来，对具有数千个节点的系统以非常小步长进行电磁暂态仿真需要过多时间。<sup>[3](https://blob.opal-rt.com/medias/L00161_0436.pdf)</sup><sup> • </sup><sup>[2](https://infoscience.epfl.ch/server/api/core/bitstreams/3e2019a2-7b9c-44ce-b332-75a447f8fbe5/content)</sup> 在一个电磁暂态–暂态稳定协同仿真中，外部600节点、105机暂态稳定模型在1.2 ms步长下需要1个Xeon核心，而其50 µs的电磁暂态表示需要15个核心；为避免精度下降，暂态稳定步长必须保持在约2 ms以下。<sup>[24](https://ietresearch.onlinelibrary.wiley.com/doi/10.1049/iet-gtd.2016.1573)</sup> 专用硬件昂贵且难以扩展；2016年一台基础NI PXI服务器成本约为10,000美元。<sup>[1](https://arxiv.org/pdf/1905.01848.pdf)</sup>

近期工作直接针对计算瓶颈。将[物理信息神经网络](https://www.edgepedia.org/zh/physics-informed-neural-networks)（PINNs）集成到时域电力系统仿真器中，相比龙格-库塔格式，可在更大步长上给出更精确的解；在IEEE 57节点系统上，用PINNs替代发电机动态使发电机精度提高51%，整体仿真性能提高24%。<sup>[27](https://arxiv.org/pdf/2404.13325)</sup> 一种部署在Speedgoat FPGA仿真器上的混合逻辑动态（MLD）方法，与传统FPGA仿真方法相比，实现了更小的最小步长并减少了FPGA资源使用。<sup>[28](https://www.nature.com/articles/s41598-026-68087-4.pdf)</sup>

## References

1. [Real-Time Simulation in Real-Time Systems: Current Status, Research Challenges and A Way Forward](https://arxiv.org/pdf/1905.01848.pdf)
2. [Real-Time Simulation of Power Systems: State-of-the-Art (task force paper)](https://infoscience.epfl.ch/server/api/core/bitstreams/3e2019a2-7b9c-44ce-b332-75a447f8fbe5/content)
3. [The What, Where and Why of Real-Time Simulation](https://blob.opal-rt.com/medias/L00161_0436.pdf)
4. [Methods for enabling real-time analysis in digital twins: A literature review](https://www.sciencedirect.com/science/article/pii/S0045794924000713)
5. [Solvers for Real-Time Simulation - MATLAB & Simulink](https://www.mathworks.com/help/simscape/ug/solvers-for-real-time-simulation.html)
6. [Applications of Real-Time Simulation Technologies in Power and Energy Systems (IEEE PES Task Force paper)](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/journal/J026_real-time-simulation-applications.pdf)
7. [A Review of Recent Best Practices in the Development of Real-Time Power System Simulators from a Simulator Manufacturer's Perspective](https://www.mdpi.com/1996-1073/15/3/1111)
8. [Cross-Platform Comparison of Standard Power System Components in Real-Time Simulation](https://sites.ecse.rpi.edu/~vanfrl/documents/publications/conference/2019/CP163_MSCPES2019_paper_3.pdf)
9. [HYPERSIM | Real-Time Power System Modeling and Simulation (OPAL-RT product page)](https://www.opal-rt.com/software/software-platforms/hypersim/)
10. [Hardware-in-the-Loop Simulations: A Historical Overview of Engineering Challenges](https://www.mdpi.com/2079-9292/11/15/2462)
11. [Real time hybrid simulation: from dynamic system, motion control to experimental error](https://onlinelibrary.wiley.com/doi/10.1002/eqe.2246)
12. [A Modern and Open Real-Time Digital Simulation of Large-Scale Power Systems (IPST 2009)](https://www.ipstconf.org/papers/Proc_IPST2009/09IPST096.pdf)
13. [On Modeling Depths of Power Electronic Circuits for Real-Time Simulation – A Comparative Analysis for Power Systems](https://publications.rwth-aachen.de/record/843288/files/843288.pdf)
14. [Extendable multirate real-time simulation of active distribution networks based on field programmable gate arrays](https://www.sciencedirect.com/science/article/abs/pii/S0306261918311346)
15. [Real-Time Simulation of Physical Systems Using Simscape](https://www.mathworks.com/company/technical-articles/real-time-simulation-of-physical-systems-using-simscape.html)
16. [Real-Time | DPsim](https://dpsim.fein-aachen.org/docs/user-guide/real-time/)
17. [Hermann Dommel (1969). Digital Computer Solution of Electromagnetic Transients in Single-and Multiphase Networks. IEEE Transactions on Power Apparatus and Systems.](https://doi.org/10.1109/tpas.1969.292459)
18. [J.R. Marti, L.R. Linares (1994). Real-time EMTP-based transients simulation. IEEE Transactions on Power Systems.](https://doi.org/10.1109/59.336135)
19. [Real-Time Simulation Support for Real-Time Systems (Springer encyclopedia chapter)](https://link.springer.com/rwe/10.1007/978-981-287-251-7_40)
20. [Real-time hybrid experimental system with actuator delay compensation and its application to a piping system with energy absorber (Earthquake Engineering & Structural Dynamics, 1999)](https://doi.org/10.1002/%28sici%291096-9845%28199910%2928:10<1121::aid-eqe858>3.0.co;2-o)
21. [Nathan M. Newmark (1959). A Method of Computation for Structural Dynamics. Journal of the Engineering Mechanics Division.](https://doi.org/10.1061/jmcea3.0000098)
22. [M. D. Omar Faruque and colleagues (2015). Real-Time Simulation Technologies for Power Systems Design, Testing, and Analysis. IEEE Power and Energy Technology Systems Journal.](https://doi.org/10.1109/jpets.2015.2427370)
23. [Development and Verification of Distributed Real-Time Hybrid Simulation Methods](https://ascelibrary.org/doi/10.1061/%28ASCE%29CP.1943-5487.0000654)
24. [Real-time electromagnetic transient and transient stability co-simulation based on hybrid line modelling](https://ietresearch.onlinelibrary.wiley.com/doi/10.1049/iet-gtd.2016.1573)
25. [High-speed real-time simulation (Acta Polytechnica, Crosbie et al.)](https://ojs.cvut.cz/ojs/index.php/ap/article/download/738/570/0)
26. [Real-Time Hybrid Simulation of a Nonductile Reinforced Concrete Frame](https://ascelibrary.org/doi/10.1061/%28ASCE%29ST.1943-541X.0000813)
27. [Physics-Informed Neural Networks: a Plug and Play Integration into Power System Dynamic Simulations](https://arxiv.org/pdf/2404.13325)
28. [Hybrid model-based real-time simulation of switching devices: enhancing precision and resource efficiency](https://www.nature.com/articles/s41598-026-68087-4.pdf)
29. [OP4520 Specifications (opal-rt.atlassian.net)](https://opal-rt.atlassian.net/wiki/spaces/PHDGD/pages/144662811/OP4520+Specifications)

---
*Initially written Sep 29, 2026 · Reviewed: Sep 30, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Sep 30, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Algorithms and computational methods

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/real-time-simulation

English original: https://www.edgepedia.org/real-time-simulation
