modelica - 具有非参数测试的 if 方程中的所有分支必须具有相同数量的方程 - Modelica
问题描述
我在 Modelica 上收到一条错误消息:
具有非参数测试的 if 方程中的所有分支必须具有相同数量的方程
错误的来源是以下代码部分:
equation
if der(Posit2.s)<=0 then
pressure=4e5+((500e5-4e5)/0.0111)*(0.0111-Posit2.s);
end if;
你知道如何处理这个错误吗?
解决方案
你需要一个 else,所以显而易见的想法是说压力不会改变:
equation
if der(Posit2.s)<=0 then
pressure=4e5+((500e5-4e5)/0.0111)*(0.0111-Posit2.s);
else
der(pressure)=0;
end if;
但是,由于索引问题,这可能无法编译。一种可能性是手动减少索引并编写如下内容:
initial equation
if der(Posit2.s)<=0 then
pressure=4e5+((500e5-4e5)/0.0111)*(0.0111-Posit2.s);
else
pressure=4e5;
end if;
equation
if der(Posit2.s)<=0 then
der(pressure)=((500e5-4e5)/0.0111)*(-der(Posit2.s));
else
der(pressure)=0;
end if;
请注意,该等式具有der(pressure)=...*der(Posit2.s);
- 由于手动索引减少。
推荐阅读
- r - 如何将特定列与其余列分开
- c# - 为什么 EF 核心没有比较 DateTimeOffset?
- javascript - 映射对象返回 false
- php - 在 Laravel 中对数组进行排序
- matlab - matlab分层交叉验证分区中的错误“CVPARTITION最多可以有一个可选参数”
- javascript - 如何创建一个 html 表格来显示具有不同字段的对象数组?
- json - Powershell 脚本 - Azure sql db - json 文件
- c# - 如何根据组 ID 从另一个模型中过滤我的学生列表。(.NET 核心 2.2)
- ssl - 没有为 ingress-nginx 后端配置 SSL 直通
- c# - 创建动态元组