Skip to content

Commit e99e042

Browse files
authored
Merge pull request #4486 from lbl-srg/maint_12.x_issue4480_integerRounding
improved ill-posed integer rounding (maint_12.x)
2 parents 520fee0 + 3afdd4a commit e99e042

25 files changed

Lines changed: 65 additions & 53 deletions

File tree

Buildings/BoundaryConditions/WeatherData/BaseClasses/PartialConvertTime.mo

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,24 @@ protected
1616
parameter Boolean canRepeatWeatherFile = abs(mod(lenWea, 365*24*3600)) < 1E-2
1717
"=true, if the weather file can be repeated, since it has the length of a year or a multiple of it";
1818

19-
discrete Modelica.Units.SI.Time tNext(start=0, fixed=true)
19+
discrete Modelica.Units.SI.Time tNext
2020
"Start time of next period";
2121

22+
Integer k "Period index";
23+
24+
initial equation
25+
k = integer(modTimAux/lenWea) + 1;
26+
tNext = if canRepeatWeatherFile then k * lenWea else time;
27+
2228
equation
23-
when {initial(), canRepeatWeatherFile and modTimAux > pre(tNext)} then
24-
// simulation time stamp went over the end time of the weather file
25-
//(last time stamp of the weather file + average increment)
26-
tNext = if canRepeatWeatherFile then integer(modTimAux/lenWea)*lenWea + lenWea else time;
29+
// simulation time stamp went over the end time of the weather file
30+
// (last time stamp of the weather file + average increment)
31+
when (canRepeatWeatherFile and modTimAux > pre(tNext)) then
32+
k = pre(k) + 1;
33+
tNext = k * lenWea;
2734
end when;
28-
calTimAux = if canRepeatWeatherFile then modTimAux - tNext + lenWea else modTimAux;
2935

36+
calTimAux = if canRepeatWeatherFile then modTimAux - tNext + lenWea else modTimAux;
3037

3138
annotation (
3239
defaultComponentName="conTim",
@@ -38,6 +45,11 @@ or a multiple of it, if this is the length of the weather file.
3845
</html>", revisions="<html>
3946
<ul>
4047
<li>
48+
February 18, 2026, by Jianjun Hu:<br/>
49+
Improved ill-posed integer rounding.<br/>
50+
This is for <a href=\"https://github.com/lbl-srg/modelica-buildings/issues/4480\">#4480</a>.
51+
</li>
52+
<li>
4153
March 27, 2023, by Ettore Zanetti:<br/>
4254
Added partial class for conversion from simulation time to calendar time, to be
4355
used by solar models that require calendar time for calculations.<br/>

Buildings/Resources/ReferenceResults/Dymola/Buildings_Air_Systems_SingleZone_VAV_Examples_ChillerDXHeatingEconomizer.txt

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

Buildings/Resources/ReferenceResults/Dymola/Buildings_Air_Systems_SingleZone_VAV_Examples_Guideline36.txt

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

Buildings/Resources/ReferenceResults/Dymola/Buildings_Controls_Predictors_Examples_BESTEST.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
last-generated=2024-06-27
1+
last-generated=2026-03-18
22
statistics-initialization=
33
{
44
"nonlinear": "1, 1, 1, 1, 1, 1, 13",

Buildings/Resources/ReferenceResults/Dymola/Buildings_ThermalZones_Detailed_Validation_BESTEST_Cases6xx_Case600.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
last-generated=2024-06-27
1+
last-generated=2026-03-18
22
statistics-initialization=
33
{
44
"nonlinear": "1, 1, 1, 1, 1, 1, 13",

Buildings/Resources/ReferenceResults/Dymola/Buildings_ThermalZones_Detailed_Validation_BESTEST_Cases6xx_Case610.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
last-generated=2024-06-27
1+
last-generated=2026-03-18
22
statistics-initialization=
33
{
44
"nonlinear": "1, 1, 1, 1, 1, 1, 13",

Buildings/Resources/ReferenceResults/Dymola/Buildings_ThermalZones_Detailed_Validation_BESTEST_Cases6xx_Case620.txt

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.

Buildings/Resources/ReferenceResults/Dymola/Buildings_ThermalZones_Detailed_Validation_BESTEST_Cases6xx_Case630.txt

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.

Buildings/Resources/ReferenceResults/Dymola/Buildings_ThermalZones_Detailed_Validation_BESTEST_Cases6xx_Case640.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
last-generated=2024-06-27
1+
last-generated=2026-03-18
22
statistics-initialization=
33
{
44
"nonlinear": "1, 1, 1, 1, 1, 1, 13",

Buildings/Resources/ReferenceResults/Dymola/Buildings_ThermalZones_Detailed_Validation_BESTEST_Cases6xx_Case650.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
last-generated=2024-06-27
1+
last-generated=2026-03-18
22
statistics-initialization=
33
{
44
"nonlinear": "1, 1, 1, 1, 1, 1, 13",

0 commit comments

Comments
 (0)