Hello JModelica peopel! I'm currently trying to compile a model I originally created in OpenModelica but run into a problem with arrays. Consider the following model:
model ElectricitySource
parameter Real[:] electricityPricePlan = {42,41,40,41,42,60,65,64,63,62,61,58,56,55,56,58,66,62,58,50,46,44,43,42};
parameter Real energyBaseConsumption = 0.8 "(MWh)";
Real electricityPrice;
Integer h(start = 0);
Pin p "Electricity Consumption";
output Real cost;
output Real totalCost;
output Real totalElectricityUsage;
equation
p.v = 0;
electricityPrice = electricityPricePlan[h];
cost = (energyBaseConsumption - p.i) * electricityPrice;
der(totalCost) = cost;
der(totalElectricityUsage) = energyBaseConsumption - p.i;
when sample(0, 1) then
h = pre(h) + 1;
end when;
end ElectricitySource;
When I compile the model I get the following error.
Error: in file 'ElectricitySource.mo':
Semantic error at line 12, column 43:
Array index in equation must be constant, parameter or loop index: h
I read in the docs that JModelica currently have some limitatations regarding arrays and I assume that this is one such limitation. But if anyone has a sugestions on how to get arround the problem I would be very greatful.
Just to be explicit, what I want to do is to specify the electricity price over 24h and make the model use the electricity price for the corresponding hour, i.e. assign it to the variable electricityPrice. I could also imagine to put the price plan outside the source and have the model reading some external file, if that would solve the problem.