Again me. Sorry for possibly stupid questions but I'm new to this so i Have this initial problems and dilemas.
I would like to optimize carbon emission using dymola optimization library on this theoretical case. There is grid and PV as means of supply and there is demand. If grid is used, it emits some carbon. Therefore PV should be always used. But sometimes there isn't enough of PV so grid has to be used. The ammount of grid and PV usage is controled by variables x1 and x2 which should be contrained from 0 to 1 (as means of percentage). If I run the following code, it says too many variables. If I set x1 as parameter with value 1, it runs but then optimization cannot be carried out because even though I set in the optimization setting that x1 can change from 0 to 1, it cannot change it because of the code.
What can I do to run this? I would like to optimize emission variable which is dependent on x1 and x2. Constraints for variables x1 and x2 should be 0<=x1<=1, 0<=x2<=1. There is one equation missing for x1 and x2. But x1 + x2 doesn't need to be 0 because solarThermal.y and electricity aren't equal. So is there a way from optimization to vary 2 variable in order to minimize 3rd variable? I can set x1 to 1 as parameter so that the code can be compiled and then I would like the optimization to varry both x1 and x2. Is it possible?
Thank you in advance!
model konacno
parameter Real electricity=999;
Real x2(start=0);
Real x1;
Real emissions(start=0);
Modelica.Blocks.Sources.TimeTable solarThermal(table = [0,300;3590,295;3600,200;7195,201;7200,300;10795,299;10800,200]);
Modelica.Blocks.Sources.TimeTable heatDemand(table = [0,300;3590,295;3600,250;7195,251;7200,300;10800,300]);
equation
0=x2*electricity+x1*solarThermal.y - heatDemand.y;
der(emissions)=0.13*x2*electricity;
end konacno;