簡體   English   中英

FMU輸入用於Modelica中的參數

[英]FMU inputs for parameters in Modelica

我的電路中有幾個塊“ FixedCurrent”。 我希望能夠通過FMU更改這些模塊的電流值。 我可以使用“參數”來更改值,如下面的代碼所示:

type Current = Real(unit = "A", min = 0);

parameter Current CurrentTest1(start = 50) "Test current";

PowerSystems.Generic.FixedCurrent fixedCurrent3(
    I = CurrentTest1, 
    redeclare package PhaseSystem = PhaseSystem), 
  annotation(...);

PowerSystems.Generic.FixedCurrent fixedCurrent1(
    I = 55, 
    redeclare package PhaseSystem = PhaseSystem), 
  annotation(...);

但是我不能為他們分配輸入。 例如,如果我使用輸入命令(1)或RealInput塊(2)為塊fixedCurrent3設置電流值:

// 1) 
input Real TZtest(start=50);
PowerSystems.Generic.FixedCurrent fixedCurrent3(
    I = TZtest, 
    redeclare package PhaseSystem = PhaseSystem),
  annotation(...);

// 2) 
Modelica.Blocks.Interfaces.RealInput TZTest2 annotation(...);
PowerSystems.Generic.FixedCurrent fixedCurrent3(
    I = TZtest, 
    redeclare package PhaseSystem = PhaseSystem),
  annotation(...);

我收到相應的錯誤:

1) Translation Error
Component fixedCurrent3.I of variability PARAM has binding TZtest of higher variability VAR.

2)Translation Error
Component fixedCurrent3.I of variability PARAM has binding TZTest2 of higher variability VAR.

因此,我無法通過FMU輸入來設置參數值。 我將很高興得到這個問題的任何解決方案。

簡而言之:問題在於變量的可變性。 用允許設置可變電流的模塊替換您的FixedCurrent模塊。 因此,除了參數之外,它還需要具有當前I的實際輸入。

在Modelica中,變量可以具有以下變量之一(從最低到最高):

  • 常數:用戶不可更改,整個模擬中的值相同
  • 參數:在模擬開始前可更改,但在整個模擬中該值相同
  • 離散的:僅在事件發生時(在子句中)更改其值
  • 連續:常規變量

變量只能分配給具有相同或更高可變性的其他變量。 例如,不能使用連續變量設置參數。 在示例1)和2)中,您正試圖做到這一點。

對於1),您可以使用prefix參數將輸入的可變性設置為parameter:

parameter input Real TZtest(start=50);

在情況2)中,您會遇到FMU的輸出連續的問題。 因此,您應該使用某種可變電流塊來替代FixedCurrent塊,如本答案開頭所述。

請注意,還有一種解決方法,可以從初始方程式的連續變量中設置參數(如答案中所述),但是我僅在絕對必要時才使用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM