lbl-srg / modelica-buildings

Modelica Buildings library
253 stars 157 forks source link

Wang2005Occupancy is held constant at true, if simulation start time != 0 #2590

Closed FelixNienaber closed 3 years ago

FelixNienaber commented 3 years ago

The Buildings.Occupants.Office.Occupancy.Wang2005Occupancy model works well if your simulation starts at 0, but if you want to simulate other time ranges (e.g. only simulating a summer week based on an annual weather file), the occupancy is constantly true.

This seems to be because of the initial equation

initial equation 
  tNext = 0;

if the initial equation is set to

initial equation 
  tNext = time;

it seems to work.

Tested it for a standalone simulation of the Buildings.Occupants.Office.Occupancy.Wang2005Occupancy Outputs of StartTime=0, StopTime=100000, are identical for both tNext inital equations. The Output of StartTime=100000, StopTime=200000, is identical to the first two for tNext = time; but remains constantly true for tNext = 0;

model OccTest
  Buildings.Occupants.Office.Occupancy.Wang2005Occupancy occ
    annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
  annotation (
    Icon(coordinateSystem(preserveAspectRatio=false)),
    Diagram(coordinateSystem(preserveAspectRatio=false)),
    uses(Buildings(version="8.0.0")),
    experiment(
      StartTime=0,
      StopTime=100000,
      Tolerance=1e-06,
      __Dymola_Algorithm="Dassl"));
end OccTest;
mwetter commented 3 years ago

@FelixNienaber : Thanks, this is indeed a bug. I will correct it through https://github.com/lbl-srg/modelica-buildings/pull/2591