グリッド電圧に基づいてグリッド接続された太陽光発電システムを制御しようとしています。アイデアはこれです:グリッド電圧がVMaxを超えて上昇したとき、私はtimeOffのためにシステムをオフにしたいです。timeOffが経過したら、もう一度オンにしますが、グリッド電圧がVMaxよりも低い場合に限ります。
現在、2つの実装があります。どちらも多くのイベントを作成しており、もっと効率的な方法があるのではないかと思います。これが現在の実装方法です。
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つだけになります。他の2つのイベントは、VGridがVMaxを再び下回ったときに生成されます。
モデルをさらに改善する方法はありますか?
ありがとう、ロエル