Skip to content

Commit

Permalink
Update Interval specification for PlugFlowPipe, and merge latest IBPS…
Browse files Browse the repository at this point in the history
…A library (#3773)

* Interval time reduced in order to speed-up the simulation during the initial phase (#3771)

* Merged IBPSA

* Removed trailing white space

---------

Co-authored-by: AndreaBartolini <[email protected]>
  • Loading branch information
mwetter and AndreaBartolini authored Apr 4, 2024
1 parent c5fd934 commit 527f606
Show file tree
Hide file tree
Showing 13 changed files with 329 additions and 99 deletions.
5 changes: 5 additions & 0 deletions Buildings/.copiedFiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1930,6 +1930,7 @@ Buildings/Resources/Data/Fluid/Geothermal/Borefields/HeatTransfer/Validation/Bei
Buildings/Resources/Data/Fluid/Geothermal/Borefields/HeatTransfer/Validation/Cimmino_Bernier_2015_SmallScale.txt
Buildings/Resources/Data/Utilities/IO/Files/Examples/CSVReader/Data.txt
Buildings/Resources/Data/schedule.txt
Buildings/Resources/Data/scheduleWindows.txt
Buildings/Resources/Documentation/userGuide/source/_static/lbl-logo.png
Buildings/Resources/Images/Airflow/Multizone/BaseClasses/windPressureLowRise.odp
Buildings/Resources/Images/Airflow/Multizone/BaseClasses/windPressureLowRise.png
Expand Down Expand Up @@ -2784,6 +2785,7 @@ Buildings/Resources/Scripts/Dymola/Utilities/IO/Files/Examples/CSVWriter.mos
Buildings/Resources/Scripts/Dymola/Utilities/IO/Files/Examples/JSONWriter.mos
Buildings/Resources/Scripts/Dymola/Utilities/IO/Files/Examples/WeeklySchedule.mos
Buildings/Resources/Scripts/Dymola/Utilities/IO/Files/Examples/WeeklySchedule7to19.mos
Buildings/Resources/Scripts/Dymola/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mos
Buildings/Resources/Scripts/Dymola/Utilities/IO/SignalExchange/Examples/FirstOrder.mos
Buildings/Resources/Scripts/Dymola/Utilities/IO/SignalExchange/Examples/WeatherStation.mos
Buildings/Resources/Scripts/Dymola/Utilities/Math/Examples/Average.mos
Expand Down Expand Up @@ -3034,6 +3036,9 @@ Buildings/Utilities/IO/Files/Examples/WeeklySchedule7to19.mo
Buildings/Utilities/IO/Files/Examples/package.mo
Buildings/Utilities/IO/Files/Examples/package.order
Buildings/Utilities/IO/Files/JSONWriter.mo
Buildings/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mo
Buildings/Utilities/IO/Files/Validation/package.mo
Buildings/Utilities/IO/Files/Validation/package.order
Buildings/Utilities/IO/Files/WeeklySchedule.mo
Buildings/Utilities/IO/Files/package.mo
Buildings/Utilities/IO/Files/package.order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ equation
annotation (
experiment(
StopTime=603900,
Interval=900,
Interval=120,
Tolerance=1e-006),
__Dymola_Commands(file="modelica://Buildings/Resources/Scripts/Dymola/Fluid/FixedResistances/Validation/PlugFlowPipes/PlugFlowAIT.mos"
"Simulate and plot"),
Expand Down
303 changes: 209 additions & 94 deletions Buildings/Resources/C-Sources/WeeklySchedule.c

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions Buildings/Resources/C-Sources/WeeklySchedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#ifndef WEEKCAL_h
#define WEEKCAL_h


typedef struct TimeDataTuple {
double time; /* Time relative to monday midnight. */
double *data; /* Corresponding column data */
Expand All @@ -26,20 +27,28 @@ typedef struct WeeklySchedule {
double t_offset; /* Time offset for monday, midnight. */
int n_rows_in; /* Number of input rows */
int n_cols_in; /* Number of input columns */
int n_rowsUnpacked; /* Number of rows: number of rows after unpacking the date */

double previousTimestamp; /* Time where the schedule was called the previous time */
int previousIndex; /* Index where the schedule was called the previous time */

struct TimeDataTuple ** schedule;
int n_allocatedRules;
int n_allocatedRulesData;
double * lastData;
char * token;
FILE* fp;
char* buff2;
struct TimeDataTuple **rules;

} WeeklySchedule;



void* weeklyScheduleInit(const int tableOnFile, const char* name, const double t_offset, char* stringData);
void* weeklyScheduleInit(const int tableOnFile, const char* name, const double t_offset, const char* stringData);

void weeklyScheduleFree(void * ID);

void weeklyScheduleFreeInit(void * ID);

double getScheduleValue(void * ID, const int column, const double time);

#endif
7 changes: 7 additions & 0 deletions Buildings/Resources/Data/scheduleWindows.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Comments start with a #
# The user is responsible for making sure that the header dimensions are correct
double tab1(3,5) # Comments can be added at the end of a line for adding local documentation
mon:0:0:10 - 3 1 -
# Comments can be added in the table too
tue,thu:20:30:59 123 - 45 -
wed 12 1 4 -
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
last-generated=2024-04-02
statistics-simulation=
{
"linear": " ",
"nonlinear": " ",
"numerical Jacobians": "0"
}
time=[-1e+04, 1e+06]
weeSchLin.y[1]=[1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.2e+01, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02, 1.23e+02]
weeSchLin.y[2]=[1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 3e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00]
weeSchLin.y[3]=[4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 4.5e+01, 4.5e+01, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4e+00, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01, 4.5e+01]
weeSchLin.y[4]=[0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
simulateModel("Buildings.Utilities.IO.Files.Validation.WeeklyScheduleWindowsLineEndings", startTime=-10000, stopTime=1000000, tolerance=1e-6, method="dassl", resultFile="WeeklyScheduleWindowsLineEndings");
createPlot(id=1, position={15, 15, 592, 364}, y={"weeSchLin.y[1]", "weeSchLin.y[2]", "weeSchLin.y[3]", "weeSchLin.y[4]"}, range={-100000.0, 1000000.0, -20.0, 140.0}, grid=true, colors={{28,108,200}, {238,46,47}, {0,140,72}, {217,67,180}}, timeUnit="s");
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compareVars :=
{
"weeSchLin.y[1]",
"weeSchLin.y[2]",
"weeSchLin.y[3]",
"weeSchLin.y[4]"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
within Buildings.Utilities.IO.Files.Validation;
model WeeklyScheduleWindowsLineEndings "Weekly schedule example"
extends Modelica.Icons.Example;
parameter String data = "double tab1(3,5) #test:
mon:0:0:10 - 3 1 -
tue,thu:20:30:59 123 - 45 -
wed 12 1 4 -" "Contents of schedule.txt";
Buildings.Utilities.IO.Files.WeeklySchedule weeSchLin(
columns={2,3,4,5},
tableOnFile=true,
fileName=Modelica.Utilities.Files.loadResource("modelica://Buildings/Resources/Data/schedule.txt"),
t_offset=1e6) "Weekly schedule example using file data source"
annotation (Placement(transformation(extent={{-10,20},{10,40}})));

Buildings.Utilities.IO.Files.WeeklySchedule weeSchWin(
columns={2,3,4,5},
tableOnFile=true,
fileName=Modelica.Utilities.Files.loadResource("modelica://Buildings/Resources/Data/scheduleWindows.txt"),
t_offset=1e6) "Weekly schedule example using parameter data source"
annotation (Placement(transformation(extent={{-10,-32},{10,-12}})));
Diagnostics.AssertEquality assEqu[4](
each startTime=-10000,
each threShold=Modelica.Constants.small)
"Trigger an assertion if the outputs differ"
annotation (Placement(transformation(extent={{40,-10},{60,10}})));
equation
connect(weeSchLin.y, assEqu.u1)
annotation (Line(points={{11,30},{24,30},{24,6},{38,6}}, color={0,0,127}));
connect(weeSchWin.y, assEqu.u2) annotation (Line(points={{11,-22},{24,-22},{24,
-6},{38,-6}}, color={0,0,127}));
annotation (
Documentation(info="<html>
<p>
Example for a weekly schedule that reads the schedule data from a file.
There are two file readers, one reading a file with Windows line endings and the other with Linux line endings.
</p>
</html>",
revisions="<html>
<ul>
<li>
April 2, 2024, by Michael Wetter:<br/>
First implementation.<br/>
This is for
<a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1860\">IBPSA, #1860</a>.
</li>
</ul>
</html>"),
experiment(
StartTime=-10000,
StopTime=1000000,
Tolerance=1e-06),
__Dymola_Commands(file=
"modelica://Buildings/Resources/Scripts/Dymola/Utilities/IO/Files/Validation/WeeklyScheduleWindowsLineEndings.mos"
"Simulate and plot"));
end WeeklyScheduleWindowsLineEndings;
12 changes: 12 additions & 0 deletions Buildings/Utilities/IO/Files/Validation/package.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
within Buildings.Utilities.IO.Files;
package Validation "Collection of models that validate the models that access files"
extends Modelica.Icons.ExamplesPackage;

annotation (preferredView="info", Documentation(info="<html>
<p>
This package contains models that validate the models that access files.
The examples plot various outputs. These model outputs are stored as reference data to
allow continuous validation whenever models in the library change.
</p>
</html>"));
end Validation;
1 change: 1 addition & 0 deletions Buildings/Utilities/IO/Files/Validation/package.order
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WeeklyScheduleWindowsLineEndings
6 changes: 5 additions & 1 deletion Buildings/Utilities/IO/Files/WeeklySchedule.mo
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ protected
revisions="<html>
<ul>
<li>
March 30 2024, by Filip Jorissen:<br/>
Avoiding memory leaks for <a href=\"https://github.com/ibpsa/modelica-ibpsa/pull/1861\">IBPSA, #1860</a>.
</li>
<li>
April 10 2022, by Filip Jorissen:<br/>
Added parameter source implementation.
</li>
Expand Down Expand Up @@ -90,7 +94,7 @@ The parameter <code>columns</code> is used to specify which columns of the table
The first column is time, hence for the above example, set <code>columns = {2}</code>.
</p>
<p>
See <a href=\"modelica://Buildings/Resources/Data/schedule.txt\">Buildings/Resources/Data/schedule.txt</a>
See <a href=\"modelica://Buildings/Resources/Data/schedule.txt\">Buildings/Resources/Data/schedule.txt</a>
for an example of the supported file format.
</p>
</html>"),
Expand Down
1 change: 1 addition & 0 deletions Buildings/Utilities/IO/Files/package.order
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ JSONWriter
Printer
WeeklySchedule
Examples
Validation
BaseClasses

0 comments on commit 527f606

Please sign in to comment.