我刚刚开始学习modelica,我有一个(新手)问题。对我来说,问题是要改变思维方式,从传统的程序设计思维方式转变为模型思维方式。
我想做一个简单的程序。我有5分钟分辨率PV输出值的输入阵列。我有60分钟分辨率热负荷值的输入阵列。我有一个储能装置,可以储存多余的能量,或者将能量实时地用于满足热量需求。
我在openmodelica中写了这个:
`class Add
Real PV[:] = 100:10:1000;
Real Heat[:] = 200:300:6000;
Real Storage;
Real p;
Integer j;
Integer i;
Boolean power,heat;
equation
power=sample(0,5);
heat=sample(0,60);
when power then
j=j+1;
end when;
when heat then
i=i+1;
end when;
Storage= PV[j] * 2.375-Heat[i];
p=Storage+ pre(p);
end Add;`但是,当i c/p到dymola时,它在这个“p=Storage+ pre(P)”上会出现一个错误;部分原因是它说pre()不能用于连续模型。当我删除pre()时,它说它不能偏离0。
你能解释我做错了什么吗?
谢谢!
发布于 2014-02-12 09:40:48
我希望我能正确理解你的问题。我用Dymola来解决一个简单的例子--我希望这在OpenModelica中也能奏效。
如果您试图使用输入数据的时间序列,我建议使用模型Modelica.Blocks.Sources.TimeTable。在您的例子中,表的第一列将表示每小时的时间步骤,即0,3600,7200,.;第二列可以给出kW中热量需求的值,如果它在300 kW不变,就像在您的示例中那样,这可能意味着300,300,300,.;
您可以使用TimeTable模型的RealOutput作为TimeTable.y,在方程中引用它的输出。
因此,一个非常简单的测试用例示例如下所示:
model heatStorage
Modelica.SIunits.Conversions.NonSIunits.Energy_kWh storage "Energy content of storage in kWh";
Modelica.Blocks.Sources.TimeTable solarThermal(table=[0,50; 3600,70; 7200,40; 10800,73]);
Modelica.Blocks.Sources.TimeTable heatDemand(table=[0,300; 3600,300; 7200,300; 10800,
300]);
equation
der(storage) = (solarThermal.y - heatDemand.y)/3600;
end heatStorage;我假设了太阳能集热器的时变输出。如果你用PV加热水,你可以包括另一个变量和转换方程。对于变量storage,我使用了kWh中能量的定义,因此我将给定的方程除以3600。由于Modelica是基于方程的,编写der(storage)与将方程的右侧集成在一起是一样的。因此,storage的计算值是输入和输出差的积分。
我希望这能帮到你。
https://stackoverflow.com/questions/21680262
复制相似问题