- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试精简一个非常复杂的模型以提高性能,并注意到当我在信号总线中添加或删除变量时,性能会发生很大的变化,尤其是多体框架。
我想知道是否有任何设置可以消除不涉及从模型生成输出的代码。
我尝试将总线连接器设置为“ protected ”,以确保它不会成为输出,但计算它们的代码仍在生成。
我也尝试了这些标志,但它并没有消除死代码:
Advanced.Embedded.OptimizeForOutputs=true;
Advanced.SubstituteVariablesUsedOnce=true;
Evaluate=true;
Advanced.EvaluateAlsoTop=true;
Advanced.SubstituteVariablesUsedOnce=true;
这是一个复制场景的简单模型:
model TestBusConnector
extends Modelica.Icons.Example;
protected
Modelica.Blocks.Examples.BusUsage_Utilities.Interfaces.ControlBus controlBus
annotation (Placement(transformation(extent={{-20,-20},{20,20}})));
public
Modelica.Blocks.Sources.Sine sine(freqHz=1)
annotation (Placement(transformation(extent={{-40,-50},{-20,-30}})));
Modelica.Blocks.Sources.Constant const(k=0)
annotation (Placement(transformation(extent={{-10,50},{10,70}})));
Modelica.Blocks.Interfaces.RealOutput y
annotation (Placement(transformation(extent={{90,-10},{110,10}})));
equation
connect(y, const.y) annotation (Line(points={{100,0},{60,0},{60,60},{11,60}}, color={0,0,127}));
connect(sine.y, controlBus.testBusVariable)
annotation (Line(points={{-19,-40},{0,-40},{0,0}}, color={0,0,127}));
annotation (experiment(__Dymola_fixedstepsize=0.001, __Dymola_Algorithm="Euler"),
__Dymola_experimentFlags(Advanced(
InlineMethod=0,
InlineOrder=2,
InlineFixedStep=0.001)),
__Dymola_experimentSetupOutput(
states=false,
derivatives=false,
inputs=false,
outputs=false,
auxiliaries=false,
equidistant=false,
events=false));
end TestBusConnector;
从 Dymola 2019 FD01 生成的代码如下所示:
include <dsblock6.c>
PreNonAliasNew(0)
StartNonAlias(0)
DeclareVariable("sine.amplitude", "Amplitude of sine wave", 1, 0.0,0.0,0.0,0,513)
DeclareVariable("sine.freqHz", "Frequency of sine wave [Hz]", 1, 0.0,0.0,0.0,0,513)
DeclareVariable("sine.phase", "Phase of sine wave [rad|deg]", 0, 0.0,0.0,0.0,0,513)
DeclareVariable("sine.offset", "Offset of output signal", 0, 0.0,0.0,0.0,0,513)
DeclareVariable("sine.startTime", "Output = offset for time < startTime [s]", 0,\
0.0,0.0,0.0,0,513)
DeclareVariable("sine.y", "Connector of Real output signal", 0.0, 0.0,0.0,0.0,0,512)
DeclareVariable("const.k", "Constant output value", 0, 0.0,0.0,0.0,0,513)
DeclareVariable("const.y", "Connector of Real output signal", 0, 0.0,0.0,0.0,0,513)
DeclareOutput("y", "", 0, 0.0, 0.0,0.0,0.0,0,513)
DeclareAlias2("controlBus.testBusVariable", "Connector of Real output signal", \
"sine.y", 1, 5, 5, 1028)
EndNonAlias(0)
#define DymolaHaveUpdateInitVars 1
#include <dsblock5.c>
DYMOLA_STATIC void UpdateInitVars(double*time, double* X_, double* XD_, double* U_, double* DP_, int IP_[], Dymola_bool LP_[], double* F_, double* Y_, double* W_, double QZ_[], double duser_[], int iuser_[], void*cuser_[],struct DYNInstanceData*did_,int initialCall) {
}
StartDataBlock
EndDataBlock
翻译后的 modelica 代码 (dsmodel.mof) 仍然包含正弦 block 的计算。
// Translated Modelica model generated by Dymola from Modelica model
// TEMP.TEST.TestBusConnector
// -----------------------------------------------------------------------------
// Initial Section
sine.amplitude := 1;
sine.freqHz := 1;
sine.phase := 0;
sine.offset := 0;
sine.startTime := 0;
const.k := 0;
const.y := 0;
y := 0.0;
// -----------------------------------------------------------------------------
// Conditionally Accepted Section
sine.y := (if time < 0 then 0 else sin(6.283185307179586*time));
// -----------------------------------------------------------------------------
// Eliminated alias variables
// To have eliminated alias variables listed, set
// Advanced.OutputModelicaCodeWithAliasVariables = true
// before translation. May give much output.
理想情况下,我希望模型转换为:
y := 0.0;
最佳答案
其他答案不起作用的原因是您的模型与您的问题不一致:“我想知道是否有任何设置可以消除不涉及从模型生成输出的代码。”
通过将控制总线连接到 sine.y,您隐式地创建了一个输出,因此 sine.y 参与从模型生成输出。
可以通过以下方式之一来避免这种情况:
关于modelica - 如何消除 Dymola/Modelica 中的死代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57152661/
我正在寻找一种更好的方法在 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 中遇到函数调用错误,因此我尝试查找原因以及在模型中调用该函数的位置。下面是错误信息: 原因是焓为负。 根据报错信息,可以找到参数的定义,但是找不到模型调用函数的地方。 所以如果我想
我是一名优秀的程序员,十分优秀!