I am just started to learn modelica and I have one (newbie) question. The problem for me is to change the way of thinking from convential programming thinking to modelica way of thinking.
I want to do simple program. I have input array with PV output values in 5 minutes resolution. I have input array with heat load values in 60 minutes resolution. I have a energy storage that stores excess energy or takes energy fro meeting the heat demand in real time.
I wrote this in 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;`
But when I c/p to dymola it gets an error on this " p=Storage+ pre(p); " part because it says pre() cannot be used for continuous model. When I delete pre() then it says it cannot devide by 0.
Can you explain me what I am doing wrong?
Thanks!