You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenModelica 1.24.3初始化仿真触发Assert错误求助

解决OpenModelica 1.24.3+Buildings 11.0.0重启仿真时的断言错误

问题复盘

从Day1的.mat结果文件重启仿真Day2时,触发断言错误:

LOG_ASSERT | error | [C:/Users/xxxxx/AppData/Roaming/.openmodelica/libraries/Buildings 11.0.0/BoundaryConditions/WeatherData/BaseClasses/ConvertTime.mo:22:3-26:26:writable]
| | | | The following assertion has been violated during initialization at time 86400.000000
| | | | ((weaDat.conTim.canRepeatWeatherFile or noEvent(time - weaDat.conTim.weaDatEndTim < 1800.0))) --> "In modelTwo.weaDat.conTim: Insufficient weather data provided for the desired simulation period.
| | | | The simulation time 86400 exceeds the end time 0 of the weather data file."

已知前提:

  • Day1仿真正常,直接全年仿真无异常
  • Buildings 11.0.0搭配OM1.21.0无此问题,仅OM1.24.3出现报错
  • 仅从.mat文件初始化时触发错误

解决方案

1. 确保天气数据状态变量被完整保存

OM1.24.3默认可能未保存天气数据相关状态变量(如weaDat.conTim.weaDatEndTim),导致重启时该变量被重置为0。修改Day1的仿真参数,添加-saveAll保存所有变量:

# Day1仿真修改代码
mod.setSimulationOptions(["startTime=0, stopTime=86400, stepSize=300, tolerance=1e-06, solver=dassl"])
simflags = "-lv=-LOG_STDOUT,-LOG_SUCCESS -saveAll"
mod.simulate(resultfile = RESULT_FILEPATH + "day1.mat", simflags = simflags)

使用更新后的day1.mat重启Day2仿真。

2. 绕过天气数据时间检查

设置canRepeatWeatherFile=true,让天气数据组件自动重复文件内容,避免触发断言:

# Day2仿真前添加参数设置
mod.setParameters(["weaDat.conTim.canRepeatWeatherFile=true"])
# 原Day2仿真代码
mod.setSimulationOptions(["startTime=86400, stopTime=172800, stepSize=300, tolerance=1e-06, solver=dassl"])
simflag = f"-iim=none -iif={RESULT_FILEPATH}day1.mat -iit=86400 -lv=-LOG_STDOUT,-LOG_SUCCESS"
mod.simulate(resultfile = RESULT_FILEPATH + "day2.mat", simflags = simflag)

3. 调整初始化模式

将初始化模式从-iim=none改为-iim=initial,强制重新初始化天气数据组件(注意:此操作可能影响其他状态变量的加载,需验证模型行为是否符合预期):

simflag = f"-iim=initial -iif={RESULT_FILEPATH}day1.mat -iit=86400 -lv=-LOG_STDOUT,-LOG_SUCCESS"

4. 提交OpenModelica bug报告

该问题属于OM版本回归(1.21.0正常,1.24.3异常),建议在OpenModelica GitHub仓库提交issue,附上:

  • 最小可复现模型
  • 完整仿真步骤代码
  • 错误日志与环境信息

内容的提问来源于stack exchange,提问作者Farnaz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 01:39:56