2011-11-06 21 views
2

誰能給我一個提示什麼是「代數環」是指 - 我應該如何通過增加「預」 -operators這種情況應對?我認真沒有得到它...提前問題的理解一個Dymola的錯誤信息

Error: Failed to generate code for an algebraic loop 
involving when equations or algorithms with when parts. 
Unknowns: 
    pump.Hb_flow 
    pump.medium.d 
    pump.medium.h 
    pump.medium.state.melting 
    pump.medium.state.T 
    pump.V_flow 
    pump.V_flow_single 
    pump.W_single 

Equations: 
    algorithm 
    when Modelica.SIunits.Conversions.to_degC(pump.medium.state.T) < 13.9 then 
     pump.medium.state.melting := true; 
    elsewhen Modelica.SIunits.Conversions.to_degC(pump.medium.state.T) > 32.8  then 
     pump.medium.state.melting := false; 
    end when; 
    // [removed set of equations that contained no "when"] 

You may be able to cut the loop 
by putting 'pre' around some of the references to 
unknown continuous time variables in when parts or when conditions. 

感謝, 問候

TIMO。

回答

2

這個問題,一般來說,因爲當從句衝擊觸發他們條件語句中的公式。

您需要了解Modelica的一點是,解算器將使用「候選解決方案」作爲仿真過程的一部分來評估方程。這些並不一定是最終選擇的解決方案,但它仍然需要在接近最終解決方案時對其進行評估。

這是什麼關係?那麼在你的情況下,我發現你正在改變「融化」變量的價值。但是,如果該值影響介質溫度(這引發了「熔化」值的變化),那麼該工具將檢測到方程組中的不一致性。一個工具可能能夠迭代找到一個一致的候選解決方案,但Dymola只是「踢」,並說它不支持這種情況。

現在需要了解的重要一點是,基本上這通常都是不相關的。爲什麼?因爲大多數情況下,用戶在這種情況下真的不希望when子句的默認語義。大多數用戶需要的是將when子句中的條件視爲「原因」,將when子句中的方程式視爲「效果」。從這個意義上說,它們是連續的,效果不應該轉而影響原因(雖然白色條紋爲這種情況寫了一首很棒的歌曲;-))。

這裏的一般模式是隔離狀態,然後當子句中添加一個「預」運營商在其周圍。如果原來的模式是這樣的:

model Test 
... 
equation 
    when x>12.5 then 
    // equations involving y 
    end when; 
    // equations coupling x to y 
end Test; 

你只需要在模型重構弄成這個樣子:

model Test2 
... 
    Boolean cond; 
equation 
    cond = x>12.5; 
    when pre(cond) then 
    // equations involving y 
    end when; 
    // equations coupling x to y 
end Test; 

這裏最根本的區別是,涉及y中的公式只有後前來條件是真的。在這種情況下,「前」基本上說,如果在當前時間減去一些小量的條件價值爲真的,那麼(響應)的條款踢時,方程英寸

這種情況可能會導致一種稱爲「抖動」的情況,其中條件的值對於經過的每個「ε」時間翻轉,但這意味着問題不是很好。

我希望這是有道理的。我承認,在複雜情況下,很難準確檢測到代數循環的存在(雖然Dymola試圖給你一些診斷)。此外,在某些情況下,您確實需要Modelica的默認行爲,因此您並不總是希望添加無條件的「預」限定符。

如果您對此解釋有任何疑問,請告知我們。