我注意到集成脉冲输入的数值问题在Modelica中延迟了一段固定的时间(使用Wolfram System Modeler 4.3):
model PulseTest "Test FixedDelay with Pulse Input";
Modelica.Blocks.Sources.Pulse pulse(
startTime = 1,
width = 100,
period = 1/32,
amplitude = 32,
nperiod = 1
);
Modelica.Blocks.Nonlinear.FixedDelay fixedDelay( delayTime = 5 );
Modelica.Blocks.Continuous.Integrator x; // integrator for the undelayed pulse
Modelica.Blocks.Continuous.Integrator y; // integrator for the delayed pulse
equation
connect( pulse.y, fixedDelay.u );
connect( fixedDelay.y, y.u );
connect( pulse.y, x.u );
end PulseTest;
Run Code Online (Sandbox Code Playgroud)
积分脉冲周期= 1/a,幅度= a,宽度= 100%应该给出1.0.但从图中可以看出,这不是我得到的延迟脉冲:
只有未延迟的信号使用DASSL给出正确的值.将已经出现的数值积分误差周期= 1/A = 1/8和(自然)成长为一个增长.
什么是最好的补救措施?
为什么 Modelica 的非线性求解器Modelica.Math.Nonlinear.solveOneNonlinearEquation比传统的定点迭代 (FPI) 方案花费更多的时间来求解非线性方程?等式
y= arctan(1-x/1+x)-x
Run Code Online (Sandbox Code Playgroud)
求解solveOneNonlinearEquation器(基本上使用布伦特方法)求解上述方程需要 6 次迭代,而传统的迭代方法需要 111 次迭代。但是,迭代方案所用的 CPU 时间少于solveOneNonlinearEquation求解器所用的 CPU 时间(见图)。
为什么是这样?可能是由于迭代方案的计算效率,即迭代方案中较少的事件生成?

Modelica确实存储测量单位(例如,SI单位和非SI单位)作为关于变量的属性.以下是非SI单位的示例:
type Time_months = Real( quantity = "Time", unit = "mo", displayUnit = "months" )
Run Code Online (Sandbox Code Playgroud)
因为对于经济学中的模型而言,在几秒钟内给出速率是相当不利的,我想写一个相当通用的单位转换函数,它将允许转换时间单位.理想情况下,转换为另一个时基的函数应该使用三个输入和一个输出:
input Real timeValue "the value of time to be converted";
input String timeBaseA "the time base for timeValue, e.g. \"mo\" ";
input String timeBaseB "the time base to convert to, e.g. \"yr\" ";
output Real convertedTimeValue "the result of the conversion";
Run Code Online (Sandbox Code Playgroud)
如果我们假设某个时间值的变量已经具有特定的单位属性(例如"mo"),那么在模型中使用该元信息是有意义的.
问题1:如何能像元信息单元模型中进行访问?
理想情况下,以下内容会很棒:
String timeBaseA := timeValue.unit;
Run Code Online (Sandbox Code Playgroud)
要么
String timeBaseA := getUnit( timeValue ) "some function to …Run Code Online (Sandbox Code Playgroud) 我最近开始使用Modelica(OpenModelica)作为建模工具,并且在使用内部/外部功能时遇到了一个问题。我正在尝试创建一个包含环境温度和压力值的环境模型,以便其他模型可以使用该值。我尝试使用内部关键字和外部关键字来执行此操作,但始终收到以下警告:
找不到组件.Real component.T0声明为“外部”的相应“内部”声明。现有的“内部”组件是:.Real environment.T0; 范围定义:Test.Ambient。检查您是否没有拼错“外部”组件名称。请在顶部范围中声明一个具有相同名称的“内部”组件。仅考虑“外部”组件声明来继续展平。
在这些行下面,您可以看到我正在尝试简化的代码。
这些行下面的三个模型包含在一个名为Test的包中。
环境模型,其中温度T0定义为内部:
within Test;
model Ambient
inner Real T0;
equation
T0 = 300;
end Ambient;
Run Code Online (Sandbox Code Playgroud)
尝试通过外部运算符调用T0的组件的模型:
within Test;
model Component
Real T;
outer Real T0;
parameter Real k = 2;
equation
T = k * time + T0;
end Component;
Run Code Online (Sandbox Code Playgroud)
将环境模型和组件模型都拖放到组合模型中:
within Test;
model System
Test.Ambient ambient annotation(
Placement(visible = true, transformation(origin = {-30, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Test.Component component annotation(
Placement(visible = true, transformation(origin = {30, -10}, …Run Code Online (Sandbox Code Playgroud)