从 CombiTimeTable 加载的时间序列的最大值

发布于 2025-01-12 12:14:41 字数 345 浏览 3 评论 0原文

有没有办法从 CombiTimeTable (tableOnFile==true) 获取最大值并将其用作参数?

我希望能够在方程中使用最大值,而无需为每个组件设置最大值。想想其他人是如何处理这个问题的,我很确定这是不可能的,但在我看来应该是这样。

时间表文档没有任何迹象表明我想做的事情是可能的,但也许有人知道如何在不设置最大值参数的情况下处理这个问题。

Is there a way to get the maximum value from a CombiTimeTable (tableOnFile==true) and use it as a parameter?

I want to be able to use the max value in an equation without the need to set the Max Value for each component. Thinking about how others have handled this I'm pretty sure it's not possible, but should be in my opinion.

The Time table Docs doesn't have any indication that what I'd like to do is possible, but maybe someone has an idea how to handle this without setting a parameter for the max value.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玉环 2025-01-19 12:14:41

支持最小/最大次数,但对于 x 值,我想您需要编写如下内容:

block CombiTimeTableWithMax
  import Modelica.Blocks.Tables.Internal;
  extends Modelica.Blocks.Sources.CombiTimeTable;
  // The min/max for time are t_minScaled etc
  final parameter Real xMin[nout](each fixed=false),xMax[nout](each fixed=false);
  function getMinMax
    input Modelica.Blocks.Types.ExternalCombiTimeTable tableID;
    input Integer nout;
    input Real p_offset[nout];
    output Real xMin[nout],xMax[nout];
  protected 
    Real t;
    Real x[nout];
  algorithm 
    t:=Internal.getTimeTableTmin(tableID);
    x:=p_offset+Internal.getTimeTableValue(tableID, 1:nout, t, t, t);
    xMin:=x;
    xMax:=x;
    while t<Internal.getTimeTableTmax(tableID) loop
      t:=Internal.getNextTimeEvent(tableID, t);
      x:=p_offset+Internal.getTimeTableValue(tableID, 1:nout, t, t, t);
      for i in 1:nout loop
        if x[i]<xMin[i] then xMin[i]:=x[i]; end if;
        if x[i]>xMax[i] then xMax[i]:=x[i]; end if;
      end for;
    end while;
  end getMinMax;
initial equation 
  (xMin,xMax)=getMinMax(tableID, nout, p_offset);
  annotation (uses(Modelica(version="4.0.0")));
end CombiTimeTableWithMax;

There is support for min/max of times, but for x-values I guess you would need to write something like:

block CombiTimeTableWithMax
  import Modelica.Blocks.Tables.Internal;
  extends Modelica.Blocks.Sources.CombiTimeTable;
  // The min/max for time are t_minScaled etc
  final parameter Real xMin[nout](each fixed=false),xMax[nout](each fixed=false);
  function getMinMax
    input Modelica.Blocks.Types.ExternalCombiTimeTable tableID;
    input Integer nout;
    input Real p_offset[nout];
    output Real xMin[nout],xMax[nout];
  protected 
    Real t;
    Real x[nout];
  algorithm 
    t:=Internal.getTimeTableTmin(tableID);
    x:=p_offset+Internal.getTimeTableValue(tableID, 1:nout, t, t, t);
    xMin:=x;
    xMax:=x;
    while t<Internal.getTimeTableTmax(tableID) loop
      t:=Internal.getNextTimeEvent(tableID, t);
      x:=p_offset+Internal.getTimeTableValue(tableID, 1:nout, t, t, t);
      for i in 1:nout loop
        if x[i]<xMin[i] then xMin[i]:=x[i]; end if;
        if x[i]>xMax[i] then xMax[i]:=x[i]; end if;
      end for;
    end while;
  end getMinMax;
initial equation 
  (xMin,xMax)=getMinMax(tableID, nout, p_offset);
  annotation (uses(Modelica(version="4.0.0")));
end CombiTimeTableWithMax;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文