- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在Modelica模型中,我们经常会用到外部组件,比如系统设置等常用变量,但是如果我正在读取一个新的模型,有没有什么简单的方法可以让我找到哪个组件使用了外部组件?
例如,以下屏幕截图是 Modelica.Fluid.Examples.HeatingSystem,我怎么知道哪个组件使用“系统”作为外部组件?
我可以逐行阅读代码,但是有更简单的方法吗?
最佳答案
Dymola 在 gui 中没有提供这样的功能。但随着 ModelManagement
图书馆有可能获得此类信息。该库可通过标准 Dymola 许可证获得并已预安装。
您可以在下面找到函数 SO.printComponents()
它使用 ModelManagement 库来获取符合给定条件的类中的所有组件。
对于您的模型,打印输出为:
Components in Modelica.Fluid.Examples.HeatingSystem using Modelica.Fluid.System as outer:
tank<Modelica.Fluid.Vessels.BaseClasses.PartialLumpedVessel>.heatTransfer<Modelica.Fluid.Interfaces.PartialHeatTransfer>.system
tank<Modelica.Fluid.Interfaces.PartialLumpedVolume>.system
pump<Modelica.Fluid.Machines.BaseClasses.PartialPump>.heatTransfer<Modelica.Fluid.Interfaces.PartialHeatTransfer>.system
...
valve<Modelica.Fluid.Interfaces.PartialTwoPort>.system
...
您可以在
Modelica.Fluid.Examples.HeatingSystem
中看到所有组件其中包含
Modelica.Fluid.System
的实例带有前缀外部。
extends
从基类继承系统实例, 基类以
<base-class>
形式在尖括号之间给出.
tank
组件正在扩展
PartialLumpedVessel
类,其中包含一个组件
heatTransfer
它扩展了
PartialHeatTransfer
其中包含我们正在寻找的系统实例。
PartialTwoPort
继承系统实例通过
PartialValve
和
PartialTwoPortTransport
.
ModelManagement.Structure
包中具有一些有趣的功能。它允许获取有关 Modelica 类的信息。
ModelManagement.Structure.Instantiated.UsedModels
似乎是一个很好的起点。但它的文档说:
Optionally disabled components, base-classes, and called functions are not included.
Testing.Utilities.Class.getExtendedClasses
.另外
ModelManagement.Structure.AST.ComponentsInClassAttributes
允许我们检索给定类的所有组件(但不是继承的)。
Modelica.Fluid.System
的外部实例)package SO
function getComponentsUsingClass "Get all components in class c1 which use class c2 as local component"
import ModelManagement.Structure.AST;
import Testing.Utilities.Class.getExtendedClasses;
import Testing.Utilities.Vectors.catStrings;
input String c1 "Full path of class of which components are retrieved";
input String c2 "Full path of class which must be used in the components";
input Boolean isOuter=false "Return only components where c2 is used as an outer instance";
output String cmp[:] "All components in c1 using c2";
protected
String sub[:] "Sub-components";
Boolean baseClass "True if current class is a baseClass of c1 (c1 extends it)";
String prefix "Used to give base classe";
algorithm
cmp :=fill("", 0);
// loop over class c1 and all its base classes
for c in cat(1,{c1}, getExtendedClasses(c1)) loop
baseClass :=c <> c1;
prefix :=if baseClass then "<" + c + ">." else ".";
// loop over all components in the current class
for cmpa in AST.ComponentsInClassAttributes(c) loop
if cmpa.fullTypeName==c2 and cmpa.isOuter==isOuter then
cmp :=cat(1, cmp, {prefix+cmpa.name});
end if;
// if the current component is a Modelica class, obtain all sub-components using c2
// (Mon-Modelica classes would e.g. be the attributes min, max, stateSelect etc. of built in classes)
if cmpa.fullTypeName<>"" then
sub := getComponentsUsingClass(cmpa.fullTypeName, c2, isOuter);
sub :=catStrings(fill(prefix+cmpa.name, size(sub, 1)), sub);
cmp :=cat(1, cmp, sub);
end if;
end for;
end for;
end getComponentsUsingClass;
function printComponents
import Modelica.Utilities.Streams.print;
import DymolaModels.Utilities.Strings.stripLeft;
input String c1="Modelica.Fluid.Examples.HeatingSystem" "Full path of class of which components are retrieved";
input String c2="Modelica.Fluid.System" "Full path of class which must be used in the components";
input Boolean isOuter=true "Return only components where c2 is used as an outer instance";
algorithm
print("Components in " + c1 + " using " + c2 + (if isOuter then " as outer" else "") + ":");
for c in getComponentsUsingClass(c1, c2,isOuter) loop
print(" " + stripLeft(c, "."));
end for;
end printComponents;
annotation (uses(
Modelica(version="4.0.0"),
Testing(version="1.3.1"),
ModelManagement(version="1.2.0"),
DymolaModels(version="1.2")));
end SO;
关于modelica - 如何在 Dymola 中查找哪个组件正在使用外部组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65857118/
我正在寻找一种更好的方法在 Dymola 中进行模拟后进行数据后处理,我可以使用 Dymola 安装附带的 MATLAB 脚本,但是是否有更多用户友好的后处理工具?比如我想获取10s到100s之间的数
Dymola 中的某些设置可以通过在“命令”窗口中设置标志来更改: 标志的一些示例是: 高级自动格式化 Advanced.PedanticModelica Advanced.LogStartValue
我正在寻找一种更好的方法在 Dymola 中进行模拟后进行数据后处理,我可以使用 Dymola 安装附带的 MATLAB 脚本,但是是否有更多用户友好的后处理工具?比如我想获取10s到100s之间的数
在 dymola 中,错误消息会使用行号来显示错误来源,但文本编辑器没有显示行号,我如何在 dymola 中启用此功能? 最佳答案 Dymola 在右下角的状态栏中显示当前行号。 在 Dymola 2
我需要从 dymola 的建模对象中获得相当好的图像。由于模型的大小,截屏/使用截图工具会导致图片质量很差。 有没有办法导出我在 dymola 中绘制的“图片”? 最佳答案 您可以将模型导出为可缩放和
在 https://trac.modelica.org/Modelica/ticket/2229#comment:2据称,当对库进行更改时,Dymola 能够自动更新转换脚本。我正在搜索 Dymola
我在使用 Dymola 2020 转换 Modelica 模型时遇到问题:当我尝试转换模型时,出现以下错误消息: "unknown internal error in Dymola". 模型前几天正在
我们正在尝试测试 Dymola 的联合仿真选项并创建了一个 fmu 文件。我们从 www.fmi-standard.org 安装/构建了 FMILibrary-2.0b2 和 FMUChecker-2
我经常遇到如下所示的初始化问题,它说某种非线性求解器会尝试处理这个问题。据我所知,Dymola在得到原始DAE系统的BLT形式后,使用牛顿法求解方程,那么这个非线性求解器到底是什么? 最佳答案 一般来
我正在使用 Dymola 构建动态模型,但根据我的经验,dymola 经常崩溃,尤其是在使用它几个小时后,有时当我将 View 更改为模拟或模型时,它会崩溃而没有任何迹象。我每天可以遇到这个问题 3-
Dymola 中是否有命令集或引用手册?例如,如果我想知道当前的工作目录,我应该使用哪个命令?我尝试了 pwd 和 dir,但它们不起作用。 最佳答案 有多个来源可以找到我检查的命令 - 没有特殊顺序
我一直在 Dymola 中对许多简单的区域供热网络进行建模和仿真,并且在初始化过程中经常遇到错误。 我们模拟的系统包括 生产者:两个压力边界 - 源和汇。源头压力通过 PI 进行控制,确保源头压力使得
是否有指定模拟的标志/脚本方式: Store variable at events,同Simulation Setup\Output\Store variables at events 等距时间网格,
我在 Dymola 中打开了一个 Modelica 库,更改了一行,关闭了 Dymola 并单击了“全部保存”,现在 TortoiseSVN 显示了数百个更改的文件,而不是我打算更改一行的一个文件。所
在 Dymola2020x 中使用多核功能是否总能加快求解速度?我的观察是将 Advanced.ParallelizeCode=true 用于 DOF~23k 的模型;编译时间与单线程相当,但默认求解
使用 dymola 模拟模型,根据所选的集成方法,我会得到不同的结果。所以我的问题是:为什么选择哪种方法? 最佳答案 理想情况下,方法的选择应基于哪种方法能够最快地给出足够接近准确结果的结果。 但我们
在 Dymola 中,我经常遇到非线性系统初始化失败,或者可能是大型热流体系统中难以求解的刚性系统,但对于简单的系统,不会出现此类问题。我的问题是: 所以我想知道求解非线性系统模型的最大能力是多少?例
我所在的一个团队使用 Dymola 并在很长一段时间内使用它来模拟一个相当复杂的模型。 他们最终得到大约 150gb 的大输出文件 (.mat),因此在后期处理时会出现问题。 我从事 IT 工作,毕业
我所在的一个团队使用 Dymola 并在很长一段时间内使用它来模拟一个相当复杂的模型。 他们最终得到大约 150gb 的大输出文件 (.mat),因此在后期处理时会出现问题。 我从事 IT 工作,毕业
我在 Dymola 中遇到函数调用错误,因此我尝试查找原因以及在模型中调用该函数的位置。下面是错误信息: 原因是焓为负。 根据报错信息,可以找到参数的定义,但是找不到模型调用函数的地方。 所以如果我想
我是一名优秀的程序员,十分优秀!