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 |
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 |