我正在尝试根据电网电压控制并网光伏系统。 这个想法是这样的:当电网电压高于VMax时,我想关闭系统timeOff。当timeOff通过时,我想再次打开,但仅当电网电压低于VMax时。
我目前有两个实现;两者都创造了很多事件,我想知道是否有更有效的方式。这就是它现在的实现方式:
package Foo
model PVControl1 "Generating most events"
parameter Real VMax=253;
parameter Real timeOff=60;
input Real P_init "uncontrolled power";
input Real VGrid;
Real P_final "controlled power";
Boolean switch (start = true) "if true, system is producing";
discrete Real restartTime (start=-1, fixed=true)
"system is off until time>restartTime";
equation
when {VGrid > VMax, time > pre(restartTime)} then
if VGrid > VMax then
switch = false;
restartTime = time + timeOff;
else
switch = true;
restartTime = -1;
end if;
end when;
if pre(switch) then
P_final = P_init;
else
P_final = 0;
end if;
end PVControl1;
model PVControl2;
"Generating less events, but off-time is no multiple of timeOff"
parameter Real VMax=253;
parameter Real timeOff=60;
input Real P_init "uncontrolled power";
input Real VGrid;
Real P_final "controlled power";
discrete Real stopTime( start=-1-timeOff, fixed=true)
"system is off until time > stopTime + timeOff";
equation
when VGrid > VMax then
stopTime=time;
end when;
if noEvent(VGrid > VMax) or noEvent(time < stopTime + timeOff) then
P_final = 0;
else
P_final = P_init;
end if;
end PVControl2;
model TestPVControl;
"Simulate 1000s to get an idea"
PVControl pvControl2(P_init=4000, VGrid = 300*sin(time/100));
end TestPVControl;
end foo;
运行时,我通过PVControl1获得8个事件,使用PVControl2获得4个事件。 看看PVControl2,我实际上只需要VGrid变得比VMax大的那一刻的事件。这只会给出2个事件。当VGrid再次降至VMax以下时,将生成其他2个事件。
有没有办法进一步改进我的模型?
谢谢,
罗埃尔
答案 0 :(得分:2)
我有几点意见。我认为您正在查看事件,就像激活when子句中的方程式一样。但那不太对劲。离散变量的值发生变化时会发生事件。关键是必须在该点停止连续积分器,并将方程与新值相结合。
要了解在这种情况下这对您有何影响,您应该考虑匿名表达式(如您的when子句中的那个)可能被视为匿名离散变量。换句话说,你可以认为它等同于:
Boolean c1 = VGrid > VMax;
when c1 then
...
end when;
...需要注意的重要一点是,当c1
变得大于VGrid
并且变为VMax
时,会发生事件(即VMax
的值的变化)小于Boolean c1 = VGrid > VMax;
Boolean c2 = time > pre(restartTime);
when {c1, c2} then
...
end when;
。现在考虑一下:
{{1}}
现在你有更多的事件,因为涉及两个条件,每当其中一个更改值时就会生成事件。
所有这些都说过,你真的遇到了性能问题吗?通常情况下,这种事件只会在您“喋喋不休”时出现问题(由于集成过程中的数字噪声导致条件值发生变化)。你有没有数字来表明这些事件究竟有多少问题?它也可能有助于了解您使用什么工具来模拟这些东西。
最后,我从逻辑中理解的一件事是,如果VGrid&gt; VMax然后在timeOff之后VGrid仍然大于VMax会发生什么?
假设它正确地处理了这最后一个案例,我认为PVControl2实际上就是你想要的(并且产生我预期的事件数量和我期望的原因)。
答案 1 :(得分:1)
可能我的答案是一年半太晚了,但在这种情况下,系统似乎有可能不僵硬,在这种情况下,一个明确的集成商(如Dymola中的CERK)会让你的模拟运行时间要快得多。