diff --git a/IBPSA/BoundaryConditions/WeatherData/BaseClasses/PartialConvertTime.mo b/IBPSA/BoundaryConditions/WeatherData/BaseClasses/PartialConvertTime.mo index 0c6ab731b0..a4f185ebf6 100644 --- a/IBPSA/BoundaryConditions/WeatherData/BaseClasses/PartialConvertTime.mo +++ b/IBPSA/BoundaryConditions/WeatherData/BaseClasses/PartialConvertTime.mo @@ -16,17 +16,24 @@ protected parameter Boolean canRepeatWeatherFile = abs(mod(lenWea, 365*24*3600)) < 1E-2 "=true, if the weather file can be repeated, since it has the length of a year or a multiple of it"; - discrete Modelica.Units.SI.Time tNext(start=0, fixed=true) + discrete Modelica.Units.SI.Time tNext "Start time of next period"; + Integer k "Period index"; + +initial equation + k = integer(modTimAux/lenWea)+1; + tNext = if canRepeatWeatherFile then k * lenWea else time; + equation - when {initial(), canRepeatWeatherFile and modTimAux > pre(tNext)} then - // simulation time stamp went over the end time of the weather file - //(last time stamp of the weather file + average increment) - tNext = if canRepeatWeatherFile then integer(modTimAux/lenWea)*lenWea + lenWea else time; + // simulation time stamp went over the end time of the weather file + // (last time stamp of the weather file + average increment) + when (canRepeatWeatherFile and modTimAux > pre(tNext)) then + k = pre(k) + 1; + tNext = k * lenWea; end when; - calTimAux = if canRepeatWeatherFile then modTimAux - tNext + lenWea else modTimAux; + calTimAux = if canRepeatWeatherFile then modTimAux - tNext + lenWea else modTimAux; annotation ( defaultComponentName="conTim", @@ -38,6 +45,12 @@ or a multiple of it, if this is the length of the weather file. ", revisions="