我正在为heatingSystem编写一个控制器,它对供暖系统所在电网的状态做出响应。我正在尝试几个控制器,但给我带来问题的是下一个控制器。
我正在尝试编写一个考虑到电网中产生的可再生能源的数量的模型。当满足外部能量的某一阈值时,供暖系统应开启(以便在本地使用能量)。它是需求侧管理的一种形式。我遇到的问题是当treshold的暖气系统打开的时候。这反过来意味着不再满足treshold,因为能量是在本地使用的。控制器由布尔值表示。如果满足treshold,则为true,否则为false。
这是代码中我认为有问题的部分:
算法
if CurrentGoingExternal > 5 then SwitchOn :=true;
elseif CurrentGoingExternal < 5 and pre(SwitchOn) then SwitchOn :=true;
elseif CurrentGoingExternal < 1 then SwitchOn :=false;
else SwitchOn :=false;
end if;在模拟时,我得到了布尔值无法计算出的错误,因为满足treshold可以确保加热开关打开,从而确保布尔值在相同的时间段内变为false。因此,我正在寻找一种方法来“设置或锁定”布尔值为真,从满足treshold的那一刻开始,直到下一个应该再次检查它的时间段的开始。即使在这段时间内,由于供暖系统在一开始就开启了,也不会达到阈值。
我尝试过像noEvent这样的东西,但它似乎不适用于持续不断的问题。
感谢您的帮助。
发布于 2014-11-11 14:36:18
您可以随时对系统进行采样:
model M
Real currentGoingExternal = time;
Boolean switch(start=true);
equation
when sample(0, 0.01) then
switch = pre(currentGoingExternal) < 0.5;
end when;
end M;也可以设置下一次检查条件的时间:
model M
Real currentGoingExternal = time + (if time>0.6001 then -2*time else 0);
Boolean switch(start=true);
Real checkTime(start=0.01);
equation
when currentGoingExternal < 0.5 and not pre(switch) and time>pre(checkTime) then
switch = true;
checkTime = time+0.1;
elsewhen currentGoingExternal > 0.6 and pre(switch) and time>pre(checkTime) then
switch = false;
checkTime = time+0.1;
end when;
end M;发布于 2014-11-12 00:45:20
如果我没理解错你的问题,我认为你真正想要的是滞后。您可以在this chapter of Modelica by Example中查看详细讨论。
https://stackoverflow.com/questions/26852169
复制相似问题