I hope I understand your problem correctly. And I used Dymola to solve a simple example - I hope this works in OpenModelica, too.
If you are trying to use a time series of input data I would suggest using the model Modelica.Blocks.Sources.TimeTable
. In your case the table's first column would denote hourly timesteps, i.e. 0, 3600, 7200, ...; the second column could give values for the heat demand in kW, if it is constant at 300 kW like in your example this could mean 300, 300, 300, ...;
You can reference the output of the TimeTable model in equations using its RealOutput as TimeTable.y
.
A very simple example for your test case could thus look like this:
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;
I assumed time-varying output of a solar thermal collector. If you use PV to heat water you could include another variable and conversion equation. For the variable storage
I used the definition of energy in kWh, therefore I divide the given equation by 3600. As Modelica is equation-based, writing der(storage)
is the same as having the right side of the equation integrated. Thus, the calculated value for storage
is the integral of the difference between input and output.
I hope this helps.