Buildings.Utilities.IO.Files
Reports package
Information
Package with models for writing data to files.
Extends from Modelica.Icons.Package (Icon for standard packages).
Package Content
Name | Description |
---|---|
CSVWriter | Model for writing results to a .csv file |
CombiTimeTableWriter | Model for writing results to a format that is readable by the model CombiTimeTable |
JSONWriter | Model for writing results to a json file |
Printer | Model that prints values to a file |
WeeklySchedule | Weekly schedule |
Examples | Examples package |
BaseClasses | Package with base classes for Buildings.Utilities.IO.Files |
Buildings.Utilities.IO.Files.CSVWriter
Model for writing results to a .csv file
Information
This model samples the model inputs u
and saves them to a .csv file,
which can be read using e.g. Excel or Python.
Typical use and important parameters
The parameter nin
defines the number of variables that are stored.
In Dymola, this parameter is updated automatically when inputs are connected to the component.
The parameter fileName
defines to what file name the results
are saved. The file is in the current working directory,
unless an absolute path is provided.
The parameter samplePeriod
defines every how many seconds
the inputs are saved to the file.
Options
The parameter delimiter
can be used to choose a custom separator.
By default the first line of the csv file consists of the file header.
The column names can be defined using parameter headerNames
.
The header can be removed by setting writeHeader=false
Dynamics
This model samples the outputs at an equidistant interval and hence disregards the simulation tool output interval settings.
Extends from Buildings.Utilities.IO.Files.BaseClasses.FileWriter (Partial model for writing results to a .csv file).
Parameters
Type | Name | Default | Description |
---|---|---|---|
String | fileName | getInstanceName() + ".csv" | File name, including extension |
Time | samplePeriod | Sample period: equidistant interval for which the inputs are saved [s] | |
Advanced | |||
String | delimiter | "\t" | Delimiter for csv file |
Boolean | writeHeader | true | =true, to write header with variable names, otherwise no header will be written |
String | headerNames[nin] | {"col" + String(i) for i in ... | Header names, indices by default |
Integer | significantDigits | 6 | Number of significant digits that are used for converting inputs into string format |
Connectors
Type | Name | Description |
---|---|---|
input RealVectorInput | u[nin] | Variables that are saved |
Modelica definition
Buildings.Utilities.IO.Files.CombiTimeTableWriter
Model for writing results to a format that is readable by the model CombiTimeTable
Information
This model samples the model inputs u
and saves them to a .csv file,
which can be read by a
Modelica.Blocks.Sources.CombiTimeTable.
The
Modelica.Blocks.Sources.CombiTimeTable
must then have tableName="csv"
, as illustrated in the example
Buildings.Utilities.IO.Files.Examples.CSVReader.
Typical use and important parameters
The parameter nin
defines the number of variables that are stored.
In Dymola, this parameter is updated automatically when inputs are connected to the component.
The parameter fileName
defines to what file name the results
are saved. The file is in the current working directory,
unless an absolute path is provided.
The parameter samplePeriod
defines every how many seconds
the inputs are saved to the file.
Options
By default the first line of the csv file consists of the file header.
The column names can be defined using parameter headerNames
or the header can be removed by setting writeHeader=false
Dynamics
This model samples the outputs at an equidistant interval and hence disregards the simulation tool output interval settings.
Extends from Buildings.Utilities.IO.Files.BaseClasses.FileWriter (Partial model for writing results to a .csv file).
Parameters
Type | Name | Default | Description |
---|---|---|---|
String | fileName | getInstanceName() + ".csv" | File name, including extension |
Time | samplePeriod | Sample period: equidistant interval for which the inputs are saved [s] | |
Advanced | |||
String | delimiter | "\t" | Delimiter for csv file |
Boolean | writeHeader | true | =true, to write header with variable names, otherwise no header will be written |
String | headerNames[nin] | {"col" + String(i) for i in ... | Header names, indices by default |
Integer | significantDigits | 6 | Number of significant digits that are used for converting inputs into string format |
Connectors
Type | Name | Description |
---|---|---|
input RealVectorInput | u[nin] | Variables that are saved |
Modelica definition
Buildings.Utilities.IO.Files.JSONWriter
Model for writing results to a json file
Information
This model samples the model inputs u
and saves them to a json file.
Typical use and important parameters
The parameter nin
defines the number of variables that are stored.
In Dymola, this parameter is updated automatically when inputs are connected to the component.
The parameter fileName
defines to what file name the results
are saved. The file is in the current working directory,
unless an absolute path is provided.
The parameter keyNames
defines the key names that are used to
store the json values corresponding to the inputs u
.
Dynamics
This model samples its inputs at the time defined by the parameter outputTime
and writes them to the file fileName
.
The model has the following options:
-
If
outputTime==OutputTime.Initial
, results are saved at initialisation. -
If
outputTime==OutputTime.Custom
, results are saved when the built-in variabletime
achievescustomTime
. -
If
outputTime==OutputTime.Terminal
, results are saved when the simulation terminates.
Extends from Modelica.Blocks.Icons.DiscreteBlock (Graphical layout of discrete block component icon).
Parameters
Type | Name | Default | Description |
---|---|---|---|
String | fileName | getInstanceName() + ".json" | File name, including extension |
String | varKeys[nin] | {"key" + String(i) for i in ... | Key names, indices by default |
OutputTime | outputTime | Buildings.Utilities.IO.Files... | Time when results are written to file |
Time | customTime | 0 | Custom time when results are stored, used if outputTime=Custom only [s] |
Connectors
Type | Name | Description |
---|---|---|
input RealVectorInput | u[nin] | Variables that are saved |
Modelica definition
Buildings.Utilities.IO.Files.Printer
Model that prints values to a file
Information
This model prints to a file or the terminal at a fixed sample interval.
The parameter configuration
controls the printing as follows:
configuration | configuration |
1 | print at sample times only |
2 | print at sample times and at end of simulation |
3 | print at end of simulation only |
Extends from Modelica.Blocks.Interfaces.DiscreteBlock (Base class of discrete control blocks).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Time | samplePeriod | Sample period of component [s] | |
Time | startTime | 0 | First sample time instant [s] |
String | header | "" | Header to be printed |
String | fileName | "" | File name (empty string is the terminal) |
Integer | nin | 1 | Number of inputs |
Integer | configuration | 1 | Index for treating final report (see documentation) |
Integer | minimumLength | 1 | Minimum length of result string |
Integer | significantDigits | 16 | Number of significant digits |
Connectors
Type | Name | Description |
---|---|---|
input RealInput | x[nin] | Value to be printed |
Modelica definition
Buildings.Utilities.IO.Files.WeeklySchedule
Weekly schedule
Information
This model interprets a schedule file and performs a weekly, cyclic extrapolation on the source data. An example for a schedule entry is
double tab1(3,2) # For week-day, output 1 between 7:00 and 19:00, and 0 otherwise mon,tue,wed,thu,fri:7:00:00 1 mon,tue,wed,thu,fri:19:00:00 0 # For week-end, output always 0 sat,sun:0:00:00 0
The first row must start with double tab1
and be followed by the number of rows (excluding comments) and number of columns, whereas
the time column is considered the first column.
Lines that start with '#' are comments.
The list of week-days is separated by a comma, and ends with a colon, after which
the time format for the start is listed in the format hour:minute:second
.
Week-day, hour, minute and second are optional fields, but if one of these fields is used,
the fields coming before it in the sequence (week-day, hour, minute, second) must be used too.
By default, schedules are read from the parameter data
but optionally schedules can be read from a file.
The parameter columns
is used to specify which columns of the table should be produced at the output y
.
The first column is time, hence for the above example, set columns = {2}
.
See Buildings/Resources/Data/schedule.txt for an example of the supported file format.
Extends from Modelica.Blocks.Icons.DiscreteBlock (Graphical layout of discrete block component icon).
Parameters
Type | Name | Default | Description |
---|---|---|---|
Integer | columns[:] | {2} | Columns of the schedule to be produced at the output y. First column is time, hence value must be 2 or larger |
Time | t_offset | 0 | Timestamp that corresponds to midnight from Sunday to Monday [s] |
Data source | |||
Boolean | tableOnFile | false | = true, if table is defined on file; false if defined through parameter data |
String | fileName | "" | Filename |
String | data | "double tab1(3,2) # For week... | String data with weekly schedule |
Connectors
Type | Name | Description |
---|---|---|
output RealOutput | y[n_columns] | Schedule values |