具有複雜連接器時,我想只修改變量集中的一個變量,而不必明確寫入其他變量的所有等式方程。Modelica - 只更改複雜類型連接器的一個參數
理想將是一個連接語句和只是一個特定變量的覆蓋。
class FluidClass
String name(start="name")"name";
Real fl(start=1000)"flow [l/h]";
Real p(start=1)"pressure [bar]";
Real T(start=25)"temperature [degC]";
Real DS(start=80)"dry substance [%]";
Real rho(start=100)"viscosity [mPas]";
end FluidClass;
connector fl "flow"
extends FluidClass;
end fl;
model setParam "set parameter"
fl fli annotation(Placement(
transformation(extent={{-5,-5},{5,5}}),
iconTransformation(extent={{-105,-5},{-95,5}})));
fl flo "flow output" annotation(Placement(
transformation(extent={{-50,0},{-40,10}}),
iconTransformation(extent={{95,-5},{105,5}})));
input Modelica.Blocks.Interfaces.RealInput u "set value";
parameter EnumType1 var "variable to change";
type EnumType1 = enumeration(
fl "Flow rate",
p "Pressure",
T "Temperature",
DS "Dry substance",
rho "Viscosity");
equation
// enter your equations here
if var ==1 then //flow
flo.name=fli.name;
flo.fl=u;
flo.p=fli.p;
flo.T=fli.T;
flo.DS=fli.DS;
flo.rho=fli.rho;
end if;
if var ==2 then //pressure
flo.name=fli.name;
flo.fl=fli.fl;
flo.p=u;
flo.T=fli.T;
flo.DS=fli.DS;
flo.rho=fli.rho;
end if;
if var ==3 then //temperature
flo.name=fli.name;
flo.fl=fli.fl;
flo.p=fli.p;
flo.T=u;
flo.DS=fli.DS;
flo.rho=fli.rho;
end if;
if var ==4 then //DS
flo.name=fli.name;
flo.fl=fli.fl;
flo.p=fli.p;
flo.T=fli.T;
flo.DS=u;
flo.rho=fli.rho;
end if;
if var ==5 then //viscosity
flo.name=fli.name;
flo.fl=fli.fl;
flo.p=fli.p;
flo.T=fli.T;
flo.DS=fli.DS;
flo.rho=u;
end if;
end setParam;
我非常感謝您的幫助。
嗨邁克爾,我很高興你回答我的回答我的問題,因爲我看到你的許多貢獻,並通過網絡閱讀你的一些作品。 – Geronimo
實際上,我對流體文獻進行了一些研究,但只是不知所措,或者沒有理解它們的正確使用,或者沒有讓它們運行。 我正在做的是試圖讓我的同事遠離excel,使用我發現的更適合於OO方法和動態組件的工具,它允許對模型進行更深入的檢查。 – Geronimo
我希望能夠在Modelica中找到它,爲了在主題中獲得「更平滑」的介紹,我試圖建立自己的「圖書館」,但沒有用太多準確的事實來重載它。真的要在第一步中將其限制在我們現在正在做的excel中。 不幸的是,對於「主流」軟件沒有那麼多的幫助,所以學習曲線比其他軟件工具更平坦。 但是,再次非常感謝您,我會盡力遵循您的建議。 – Geronimo