ExternalInterfaces_Application_Guide
ExternalInterfaces_Application_Guide
External Interface(s)
Application Guide
COPYRIGHT © 1996-2013 The Board of Trustees of the University of Illinois and the Regents of the University of California through
the Ernest Orlando Lawrence Berkeley National Laboratory pending approval of the US Department of Energy.
All Rights Reserved. No part of this material may be reproduced or transmitted in any form or by any means without the prior written
permission of the University of Illinois or the Ernest Orlando Lawrence Berkeley National Laboratory.
EnergyPlus is a Trademark of the US Department of Energy.
TABLE OF CONTENTS
External Interface(s).........................................................................................................................1
Introduction ..................................................................................................................... 1
9/27/13 i
TABLE OF CONTENTS
Table 2: Use cases with different system configurations ..................................... 14
Requirements .......................................................................................................... 16
FMU Examples.............................................................................................................. 16
References.....................................................................................................................................25
9/27/13 ii
External Interface(s) Introduction
External Interface(s)
Introduction
The ExternalInterface allows coupling EnergyPlus to the Building Controls Virtual Test Bed
(BCVTB). It supports the import of Functional Mock-up Units (FMUs) for co-simulation as well
as the export of EnergyPlus as a FMU for co-simulation. BCVTB is a software environment
that allows expert users to couple different simulation programs for distributed simulation or
for a real-time simulation that is connected to a building control system. For example, the
BCVTB allows simulation of the building envelope and HVAC system in EnergyPlus and the
control logic in MATLAB/Simulink, while exchanging data between the two programs as they
simulate. The BCVTB can be downloaded from http://simulationresearch.lbl.gov/bcvtb. A
FMU is a component which implements the Functional Mock-up Interface (FMI) standard
(http://www.modelisar.com).
dx /dt = h (x ),
9/27/13 1
External Interface(s) BCVTB Examples
x (0) = x 0,
BCVTB Examples
Architecture of System
The figure below shows the architecture of the connection between EnergyPlus and the
BCVTB. The black objects are explained in this application guide, whereas the grey items are
not specific to EnergyPlus and are explained in the BCVTB documentation. The BCVTB
connects to the external interface in EnergyPlus. In the external interface, the input/output
signals that are exchanged between the BCVTB and EnergyPlus are mapped to EnergyPlus
objects. The subject of this External Interface Application Guide is how to configure this
mapping and how to use these objects. For a detailed explanation of the grey items, we refer
to the BCVTB documentation.
9/27/13 2
External Interface(s) BCVTB Examples
Figure 1: Architecture of the BCVTB with the EnergyPlus client (black) and other clients (grey).
The external interface can map to three EnergyPlus input objects called
ExternalInterface:Schedule, ExternalInterface:Actuator and ExternalInterface:Variable. The
ExternalInterface:Schedule can be used to overwrite schedules, and the other two objects
can be used in place of Energy Management System (EMS) actuators and EMS variables.
The objects have similar functionality as the objects Schedule:Compact,
EnergyManagementSystem:Actuator and EnergyManagementSystem:GlobalVariable, except
that their numerical value is obtained from the external interface at the beginning of each
zone time step, and will remain constant during this zone time step.
Compared to EnergyManagementSystem:Actuator, the object ExternalInterface:Actuator has
an optional field called “initial value.” If a value is specified for this field, then this value will be
used during the warm-up period and the system sizing. If unspecified, then the numerical
value for this object will only be used during the time stepping. Since actuators always
overwrite other objects (such as a schedule), all these objects have values that are defined
during the warm-up and the system sizing even if no initial value is specified. For the objects
ExternalInterface:Schedule and ExternalInterface:Variable, the field “initial value” is required,
and its value will be used during the warm-up period and the system-sizing.
ExternalInterface:Variable is a global variable from the point of view of the EMS language.
Thus, it can be used within any EnergyManagementSystem:Program in the same way as an
EnergyManagementSystem:GlobalVariable or an EnergyManagementSystem:Sensor can be
used.
Although variables of type ExternalInterface:Variable can be assigned to
EnergyManagmentSystem:Actuator objects, for convenience, there is also an object called
ExternalInterface:Actuator. This object behaves identically to
EnergyManagmentSystem:Actuator, with the following exceptions:
Its value is assigned by the external interface.
Its value is fixed during the zone time step because this is the synchronization time step
for the external interface.
The external interface can also map to the EnergyPlus objects Output:Variable and
EnergyManagementSystem:OutputVariable. These objects can be used to send data from
EnergyPlus to the BCVTB at each zone time step.
We will now present examples that use all of these objects. The following table shows which
EnergyPlus features are used in the examples, which are all distributed with the BCVTB
installation that can be obtained from the LBNL web site. Note – these examples are NOT
distributed with EnergyPlus installation because you need the special software to make them
work.
9/27/13 3
External Interface(s) BCVTB Examples
</BCVTB-variables>
This element will contain child elements that define the variable mapping. In between the
element tags, a user needs to specify how the exchanged data is mapped to EnergyPlus
objects. Hence, the order of these elements matter, and it need to be the same as the order
of the elements in the input and output signal vector of the BCVTB actor that calls
EnergyPlus. The exchanged variables are declared in elements that are called “variable” and
have an attribute “source.” As described above, the external interface can send data to
ExternalInterface:Schedule, ExternalInterface:Actuator, ExternalInterface:Variable. For these
objects, the “source” attribute needs to be set to “Ptolemy,” because they are computed in
Ptolemy. The xml elements for these objects look as follows:
For ExternalInterface:Schedule, use
<variable source="Ptolemy">
<EnergyPlus schedule="NAME"/>
</variable>
where NAME needs to be the EnergyPlus schedule name. For ExternalInterface:Actuator,
use
<variable source="Ptolemy">
<EnergyPlus actuator="NAME" />
</variable>
where NAME needs to be the EnergyPlus actuator name. For ExternalInterface:Variable, use
<variable source="Ptolemy">
<EnergyPlus variable="NAME"/>
9/27/13 4
External Interface(s) BCVTB Examples
</variable>
where NAME needs to be the EnergyPlus Energy Runtime Language (Erl) variable name.
The external interface can also read data from any Output:Variable and
EnergyManagementSystem:OutputVariable. For these objects, set the “source” attribute to
“EnergyPlus,” because they are computed by EnergyPlus. The read an Output:Variable, use
<variable source="EnergyPlus">
<EnergyPlus name="NAME" type="TYPE"/>
</variable>
where NAME needs to be the EnergyPlus “Variable Name” (such as ZONE/SYS AIR TEMP)
and TYPE needs to be the EnergyPlus “Key Value” (such as ZONE ONE). To read an
EnergyManagementSystem:OutputVariable, use
<variable source="EnergyPlus">
<EnergyPlus name="EMS" type="TYPE"/>
</variable>
i.e., the attribute “name” must be EMS, and the attribute “type” must be set to the EMS
variable name.
Complete examples of these xml files are presented below.
Example 1: Interface using ExternalInterface:Schedule
In this example, a controller that is implemented in the BCVTB computes the room
temperature set points for cooling and heating. The example can be found in the BCVTB
distribution in the folder examples/ePlusX-schedule, where X stands for the EnergyPlus
version number.
Suppose we need to send from the BCVTB to EnergyPlus a schedule value, and from
EnergyPlus to the BCVTB an output variable at each zone time step. This can be
accomplished by using an object of type ExternalInterface:Schedule and an object of type
Output:Variable.
To interface EnergyPlus using the EMS feature, the following three items are needed:
An object that instructs EnergyPlus to activate the external interface.
EnergyPlus objects that write data from the external interface to the EMS.
A configuration file to configure the data exchange.
9/27/13 5
External Interface(s) BCVTB Examples
Output:Variable,
TSetCoo, !- Key Value
Schedule Value, !- Variable Name
TimeStep; !- Reporting Frequency
To specify that data should be exchanged every 15 minutes of simulation time, enter in the idf
file the section
Timestep,
4; !- Number of Timesteps per Hour
9/27/13 6
External Interface(s) BCVTB Examples
<variable source="EnergyPlus">
<EnergyPlus name="TSetCoo" type="Schedule Value"/>
</variable>
</BCVTB-variables>
This file specifies that the actor in the BCVTB that calls EnergyPlus has an input vector
with two elements that are computed by Ptolemy (Ptolemy is the name of the software on
which the BCVTB is based) and sent to EnergyPlus, and that it has an output vector with
four elements that are computed by EnergyPlus and sent to Ptolemy. The order of the
elements in each vector is determined by the order in the above XML file. Hence, the
input vector that contains the signals sent to EnergyPlus has elements
TSetHea
TSetCoo
and the output vector that contains values computed by EnergyPlus has elements
Environment (Site Outdoor Air Drybulb Temperature)
ZSF1 (ZONE AIR TEMPERATURE)
TSetHea (Schedule Value)
TSetCoo (Schedule Value)
In this model, the Simulator actor that calls EnergyPlus is configured for Windows as
follows:
9/27/13 7
External Interface(s) BCVTB Examples
Figure 4: Configuration of the Simulator actor that calls EnergyPlus on Mac OS X and on Linux.
9/27/13 8
External Interface(s) BCVTB Examples
Output:Variable,
*, !- Key Value
Zone Mean Air Temperature, !- Variable Name
timestep; !- Reporting Frequency
Output:Variable,
Zn001:Wall001:Win001, !- Key Value
Surface Outside Face Incident Solar Radiation Rate per Area, !- Var Name
timestep; !- Reporting Frequency
Output:Variable,
*, !- Key Value
Surface Shading Device Is On Time Fraction, !- Variable Name
timestep; !- Reporting Frequency
To specify that data should be exchanged every 10 minutes of simulation time, we enter
in the idf file the section
Timestep,
6; !- Number of Timesteps per Hour
9/27/13 9
External Interface(s) BCVTB Examples
ExternalInterface:Variable,
yShade, !- Name of Erl variable
1; !- Initial value
9/27/13 10
External Interface(s) BCVTB Examples
During the warm-up period and the system-sizing, the variable will be set to its initial
value. Afterwards, the value will be assigned from the external interface at each
beginning of a zone time step and kept constant during the zone time step. From the
point of view of the EMS language, ExternalInterface:Variable can be used like any global
variable. Thus, it can be used within any EnergyManagementSystem:Program in the
same way as an EnergyManagementSystem:GlobalVariable or an
EnergyManagementSystem:Sensor.
This idf section above activates the external interface and declares a variable with name
yShade that can be used in an Erl program to actuate the shading control of the window
“Zn001:Wall001:Win001” as follows:
! EMS program. The first assignments sets the shading status and converts it
into the
! EnergyPlus signal (i.e., replace 1 by 6).
! The second assignment sets yShade to
! an EnergyManagementSystem:OutputVariable
! which will be read by the external interface.
EnergyManagementSystem:Program,
Set_Shade_Control_State, !- Name
Set Shade_Signal = 6*yShade, !- Program Line 1
Set Shade_Signal_01 = yShade+0.1; !- Program Line 2
We want to read from EnergyPlus the outdoor temperature, the zone air temperature and
the solar radiation that is incident on the window. Thus, we declare
Output:Variable,
Environment, !- Key Value
Site Outdoor Air Drybulb Temperature, !- Variable Name
timestep; !- Reporting Frequency
Output:Variable,
*, !- Key Value
Zone Mean Air Temperature, !- Variable Name
timestep; !- Reporting Frequency
Output:Variable,
Zn001:Wall001:Win001, !- Key Value
Surface Outside Face Incident Solar Radiation Rate per Area, !- Var Name
timestep; !- Reporting Frequency
In addition, we want to output the variable “Erl Shading Control Status” that has been set
up as
! Declare an output variable. This variable is equal to the shading signal +
0.1
! It will be read by the external interface to demonstrate how to receive
variables.
EnergyManagementSystem:OutputVariable,
Erl Shading Control Status, !- Name
Shade_Signal_01, !- EMS Variable Name
Averaged, !- Type of Data in Variable
9/27/13 11
External Interface(s) Coupling EnergyPlus with Functional Mock-up Units for co-simulation
The Functional Mock-up Unit (FMU) for co-simulation import for EnergyPlus allows
EnergyPlus to conduct co-simulation with various programs that are packaged as FMUs. A
FMU is a component which implements the Functional Mock-up Interface (FMI) standard
(http://www.modelisar.com).
A FMU is distributed in the form of a zip file that may contain physical models, model
descriptions, source code, and executable programs for various platforms. The FMU for co-
simulation import provides EnergyPlus with a standard interface to conduct and control co-
9/27/13 12
External Interface(s) Coupling EnergyPlus with Functional Mock-up Units for co-simulation
simulation with an arbitrary number of FMUs without any middle-ware, such as the Building
Controls Virtual Test Bed (BCVTB Documentation, 2011).
The FMU for co-simulation import allows coupling of continuous-time and discrete-time
models exported from different simulation programs. In the current implementation,
EnergyPlus is implemented as the co-simulation master. It controls the data exchange
between the subsystems and the synchronization of all slave simulation programs.
The FMU for co-simulation import enables the direct link between the EnergyPlus kernel and
other simulation tools. It will make the co-simulation easier to conduct as no middle-ware is
involved. This direct link will decrease run-time by eliminating the transaction layer. In
addition, by separating the co-simulation interface from the EnergyPlus kernel, the FMU
interface is reusable when EnergyPlus is updated. Furthermore, the FMU contains
executable files that have the same interface to EnergyPlus regardless of their original
programming environment. Some commercial tools allow running their FMU without licensing
requirement.
Notes:
1) The current implementation of FMU for co-simulation is only supported on Windows and
Linux.
2) FMUs must be in a folder to which the user has wri
te access.
Data exchange between EnergyPlus and FMUs
Prior to describing the data exchange between EnergyPlus and FMUs, some definitions and
terminologies used in the remainder of this document will be introduced.
A variable of a system described by a system of differential algebraic equations (DAE) is
defined as differential variable if its derivatives are present in the DAE. A variable of a system
described by a system of DAE is defined as algebraic if its derivatives do not appear explicitly
in the DAE (Fabian et al., 2008).
Figure 5: System with two variables that could be either differential or algebraic variables.
9/27/13 13
External Interface(s) Coupling EnergyPlus with Functional Mock-up Units for co-simulation
I ( x1 , x2 , u, t ) 0 with I: ℝn x ℝm x ℝq x ℝ → ℝn+m.
Figure 6 shows a case where a FMU is linked to an EnergyPlus model for co-simulation. The
FMU and EnergyPlus could be linked through differential or algebraic variables.
9/27/13 14
External Interface(s) Coupling EnergyPlus with Functional Mock-up Units for co-simulation
Let N N denote the number of time steps and let tk with k {1, , N } denote the time
steps. We will use the subscripts 1 and 2 to denote the variables and the functions that
compute the next state variable of the simulator 1 and 2, respectively.
The first system computes, for k {0, ... , N 1} and some F1 : ℝn x ℝm x ℝ x ℝ → ℝn, the
sequence
and, similarly, the simulator 2 computes for some F2 : ℝ x ℝ x ℝ x ℝ → ℝ the sequence
m n m
with initial conditions x 1(0) = x 1,0 and x 2(0) = x 2,0. F1 (.,.,.,.) and F2 (.,.,.,.) are the functions
that are used to compute the value of the state variables at the new time step
To advance from time tk to tk+1, each system uses its own time integration algorithm. At the
end of the time step, EnergyPlus sends the new state x 1(tk+1) to the FMU and it receives the
state x 2(tk+1) from the FMU. The same procedure is done with the FMU.
Case 2: Linking two systems through algebraic and differential variables
This case could be for an application where a fan is modeled in a FMU and is linked to a
room model in EnergyPlus. The room temperature is the differential variable in EnergyPlus
and the pressure difference of the fan is the algebraic variable in the FMU. For simplicity, we
assume that y 1(.) = x 1(.) and y 2(.) = x 2(.). In this application, the systems are described by the
following equations
0 = g2(x2, x1).
Let N N denote the number of time steps and let tk with k {1, , N } denote the time
steps. We use the same subscripts 1 and 2 as for the first case to denote the variable and the
function that computes the next variable of the simulator 1 and 2, respectively.
~
The first system computes, for k {0,, N 1} and some G1 : ℝ x ℝ x ℝ x ℝ → ℝ , the
n m n
sequence
9/27/13 15
External Interface(s) FMU Examples
~
and, similarly, the simulator 2 computes for some G 2 : ℝ x ℝ x ℝ → ℝ the sequence
m n m
with initial condition x 1(0) = x 1,0. G1 (.,.,.,.) and G 2 (.,.,.) are the functions that compute the
value of the variables at the new time step.
To advance from time tk to tk+1, each system uses its own time integration algorithm. At the
end of the time step, EnergyPlus sends the new value x 1(tk+1) to the FMU and it receives the
value x 2(tk+1) from the FMU. The same procedure is done with the FMU.
Requirements
The current implementation for linking EnergyPlus with the FMUs has the following
requirements:
The data exchange between EnergyPlus and the FMUs is done at the zone time step of
EnergyPlus.
Each FMU is linked to EnergyPlus only through a differential variable in EnergyPlus (see
Figure 7 for one FMU).
Two or multiple FMUs are linked together only through differential variables in
EnergyPlus (see Figure 8 for two FMUs).
FMU Examples
9/27/13 16
External Interface(s) FMU Examples
subject of this External Interface Application Guide is how to configure this mapping and how
to use these objects.
The external interface can map to three EnergyPlus input objects called
ExternalInterface:FunctionalMockupUnitImport:To:Schedule
ExternalInterface:FunctionalMockupUnitImport:To:Actuator
ExternalInterface:FunctionalMockupUnitImport:To:Variable.
The ExternalInterface:FunctionalMockupUnitImport:To:Schedule can be used to overwrite
schedules, and the other two objects can be used in place of Energy Management System
(EMS) actuators and EMS variables. The objects have similar functionality as the objects
Schedule:Compact, EnergyManagementSystem:Actuator and
EnergyManagementSystem:GlobalVariable, except that their numerical value is obtained
from the external interface at the beginning of each zone time step, and will remain constant
during this zone time step.
The external interface also uses the
ExternalInterface:FunctionalMockupUnitImport:From:Variable object which maps to
EnergyPlus objects Output:Variable and EnergyManagementSystem:OutputVariable to send
data from EnergyPlus to FMUs at each zone time step.
We will now present examples that use all of these objects. The following table shows which
EnergyPlus features are used in the examples.
Table 3. Overview of the EnergyPlus objects used in Examples
9/27/13 17
External Interface(s) FMU Examples
input and output variables for both EnergyPlus and FMUs. The co-simulation step performs
co-simulation.
Figure 10 shows the work flow for pre-processing. First, a FMU Parser parses the FMU files
(i.e. xxx.fmu) and generates a temporary EnergyPlus input file (i.e. xxxtmp.idf). The
temporary EnergyPlus input file is not complete as it just contains information related to the
FMU, such as names of the FMU and properties of each FMU variable including variable
name, associated FMU name, input/output type, data type, units and definitions. The user will
need to manually copy the FMU information from xxxtmp.idf into the EnergyPlus input file
xxx.idf. The user then needs to modify the xxx.idf file to link the FMU variables with
EnergyPlus variables.
xxx.fmu
FMU Pars er
p ars
e r[op ti
ons]x x x .fm u
xxxtmp.idf
xxx.idf
FMU Parser
The FMU parser is a code written in C. It includes Expat (Expat XML Parser, 2011) which
is a XML parser library written in C. The low level implementation of the function (p arse r)
that is used to process a FMU is p arse r[op ti ons]x x x .fm u, where op ti
onsare as follows:
--p ri nti
df, prints a temporary xxxtmp.idf with FMU information to be printed,
--unp ack, unpacks a FMU to be unpacked, and
--de le te , deletes temporary files related to FMUs.
A FMU is a zip file which may contain executable programs for specific platforms,
description files and source code. In the pre-processing step, the FMU Parser will be
called with the command option --p ri ntidf. This will cause the parser to parse the XML file
with the model description of the FMU and write the FMU information in a format of the
EnergyPlus input file (*.idf). The parser will check if all the required fields from FMU (see
next section for details) in the *.idf file are correctly specified. If the check succeeds, the
parser will successfully close. If the check fails, the parser will close with an error
message. After the EnergyPlus executable (such as EnergyPlus.exe) terminates, the
EnergyPlus batch file will delete all the temporary files that may have been generated.
The FMU Parser is distributed with EnergyPlus and can be found in the PreProcess
folder (FMUParser) of the EnergyPlus installation.
9/27/13 18
External Interface(s) FMU Examples
The code below shows how the objects will be in the idf.
To activate the external interface, we use:
ExternalInterface, !- Object to activate the external interface
FunctionalMockupUnitImport; !- Name of external interface
To define the FMU that will be linked to EnergyPlus, we use:
ExternalInterface:FunctionalMockupUnitImport,
9/27/13 19
External Interface(s) FMU Examples
ExternalInterface:FunctionalMockupUnitImport:From:Variable,
ZONE ONE, !- EnergyPlus Key Value
Zone Mean Air Temperature, !- EnergyPlus Variable Name
MoistAir.fmu, !- FMU Filename
Model1, !- FMU Model Name
TRooMea; !- FMU Model Variable Name
ExternalInterface:FunctionalMockupUnitImport:From:Variable,
Environment, !- EnergyPlus Key Value
Site Outdoor Air Relative Humidity, !- EnergyPlus Variable Name
MoistAir.fmu, !- FMU Filename
Model1, !- FMU Model Name
outRelHum; !- FMU Model Variable Name
ExternalInterface:FunctionalMockupUnitImport:From:Variable,
ZONE ONE, !- EnergyPlus Key Value
Zone Air Relative Humidity, !- EnergyPlus Variable Name
MoistAir.fmu, !- FMU Filename
Model1, !- FMU Model Name
rooRelHum; !- FMU Model Variable Name
These output variables need to be specified in the idf file:
Output:Variable,
Environment, !- Key Value
Site Outdoor Air Drybulb Temperature, !- Variable Name
TimeStep; !- Reporting Frequency
Output:Variable,
ZONE ONE, !- Key Value
Zone Mean Air Temperature, !- Variable Name
TimeStep; !- Reporting Frequency
Output:Variable,
Environment, !- Key Value
Site Outdoor Air Relative Humidity, !- Variable Name
TimeStep; !- Reporting Frequency
Output:Variable,
ZONE ONE, !- Key Value
Zone Air Relative Humidity, !- Variable Name
TimeStep; !- Reporting Frequency
To enter schedules to which the external interface writes, we use:
ExternalInterface:FunctionalMockupUnitImport:To:Schedule,
FMU_OthEquSen_ZoneOne, !- EnergyPlus Variable Name
Any Number, !- Schedule Type Limits Names
MoistAir.fmu, !- FMU Filename
Model1, !- FMU Model Name
QSensible, !- FMU Model Variable Name
0; !- Initial Value
9/27/13 20
External Interface(s) FMU Examples
ExternalInterface:FunctionalMockupUnitImport:To:Schedule,
FMU_OthEquLat_ZoneOne, !- EnergyPlus Variable Name
Any Number, !- Schedule Type Limits Names
MoistAir.fmu, !- FMU Filename
Model1, !- FMU Model Name
QLatent, !- FMU Model Variable Name
0; !- Initial Value
This completes the configuration that is required to simulate EnergyPlus with the FMU.
Example 2: Interface using
ExternalInterface:FunctionalMockupUnitImport:To:Actuator
In this example, a shading controller with a finite state machine is implemented in a FMU
(ShadingController.fmu). Inputs of the FMU are the outside temperature (TRoo) and the solar
irradiation (ISolExt) that is incident on the window. The output of the FMU is the shading
actuation signal (yShade).This example describes how to set up EnergyPlus to exchange
data between the FMU and EnergyPlus, using an Energy Management System (EMS)
actuator.
To interface EnergyPlus using the EMS feature, the following four items are needed:
An object that instructs EnergyPlus to activate the external interface.
An object that specifies the FMU and its instances.
EnergyPlus objects that read data from EnergyPlus and send to FMU.
EnergyPlus objects that read data from FMU and send to EnergyPlus.
ExternalInterface:FunctionalMockupUnitImport:From:Variable,
WEST ZONE, !- EnergyPlus Key Value
Zone Mean Air Temperature, !- EnergyPlus Variable Name
ShadingController.fmu, !- FMU Filename
Model1, !- FMU Model Name
TRoo; !- FMU Model Variable Name
9/27/13 21
External Interface(s) FMU Examples
Output:Variable,
WEST ZONE, !- Key Value
Zone Mean Air Temperature, !- Variable Name
TimeStep; !- Reporting Frequency
To enter the actuator that changes the control status of the window with name
“Zn001:Wall001:Win001”, we use:
ExternalInterface:FunctionalMockupUnitImport:To:Actuator,
Zn001_Wall001_Win001_Shading_Deploy_Status, !- EnergyPlus Variable Name
Zn001:Wall001:Win001, !- Actuated Component Unique Name
Window Shading Control, !- Actuated Component Type
Control Status, !- Actuated Component Control Type
ShadingController.fmu, !- FMU Filename
Model1, !- FMU Model Name
yShade, !- FMU Model Variable Name
6; !- Initial Value
This completes the configuration that is required to simulate EnergyPlus with the FMU.
Example 3: Interface using
ExternalInterface:FunctionalMockupUnitImport:To:Variable
This example implements the same controller as the Example 2. However, the interface with
EnergyPlus is done using an external interface variable instead of an external interface
actuator. Inputs of the FMU are the outside temperature (TRoo) and the solar irradiation
(ISolExt) that is incident on the window. The output of the FMU is the shading actuation
signal (yShade).
To interface EnergyPlus using an external interface variable, the following items are needed:
An object that instructs EnergyPlus to activate the external interface.
An object that specifies the FMU and its instances.
EnergyPlus objects that read data from EnergyPlus and send to FMU.
EnergyPlus objects that read data from FMU and send to EnergyPlus.
9/27/13 22
External Interface(s) FMU Examples
To enter the two output variables from which the external interface read from and send to
FMUs, we use:
ExternalInterface:FunctionalMockupUnitImport:From:Variable,
Zn001:Wall001:Win001, !- EnergyPlus Key Value
Surface Outside Face Incident Solar Radiation Rate per Area,
ShadingController.fmu, !- FMU Filename
Model1, !- FMU Model Name
ISolExt; !- FMU Model Variable Name
ExternalInterface:FunctionalMockupUnitImport:From:Variable,
WEST ZONE, !- EnergyPlus Key Value
Zone Mean Air Temperature, !- EnergyPlus Variable Name
ShadingController.fmu, !- FMU Filename
Model1, !- FMU Model Name
TRoo; !- FMU Model Variable Name
These output variables need to be specified in the idf file:
Output:Variable,
Zn001:Wall001:Win001, !- Key Value
Surface Outside Face Incident Solar Radiation Rate per Area, !- Var Name
TimeStep; !- Reporting Frequency
Output:Variable,
WEST ZONE, !- Key Value
Zone Mean Air Temperature, !- Variable Name
TimeStep; !- Reporting Frequency
To write data from the external interface to an EnergyPlus EMS variable, we use the
following item in idf file:
ExternalInterface:FunctionalMockupUnitImport:To:Variable,
Shade_Signal, !- EnergyPlus Variable Name
ShadingController.fmu, !- FMU Filename
Model1, !- FMU Model Name
yShade, !- FMU Model Variable Name
1; !- Initial Value
which declares a variable with name yShade that can be used in an Erl program to
actuate the shading control of the window “Zn001:Wall001:Win001” as follows:
! EMS program. The first assignments sets the shading status and converts it
into the
! EnergyPlus signal (i.e., replace 1 by 6).
! The second assignment sets yShade to
! an EnergyManagementSystem:OutputVariable
! which will be read by the external interface.
EnergyManagementSystem:Program,
Set_Shade_Control_State, !- Name
Set Shade_Signal = 6*yShade, !- Program Line 1
Set Shade_Signal_01 = yShade+0.1; !- Program Line 2
9/27/13 23
External Interface(s) Exporting EnergyPlus as a Functional Mock-up Unit for co-simulation
The FMU export of EnergyPlus allows EnergyPlus to be accessed from other simulation
environments, as a FMU for co-simulation.
FMUs are formally specified in the Functional Mock-up Interface (FMI) standard, an open
standard designed to enable links between disparate simulation programs. The standard is
available from http://www.functional-mockup-interface.org/.
To export EnergyPlus as a FMU for co-simulation, the Lawrence Berkeley National
Laboratory has developed a utility which exports EnergyPlus as a FMU for co-simulation.
This utility is freely available from http://SimulationResearch.lbl.gov.
9/27/13 24
References Exporting EnergyPlus as a Functional Mock-up Unit for co-simulation
References
Hensen, Jan L. M. 1999. “A comparison of coupled and de-coupled solutions for temperature
and air flow in a building.” ASHRAE Transacti ons105 (2): 962–969.
Zhai, Zhiqiang John, and Qingyan Yan Chen. 2005. “Performance of coupled building energy
and CFD simulations.” Ene rgy and Bui ldi
ngs37 (4): 333–344.
BCVTB Documentation. 2011. Online available at:
http://simulationresearch.lbl.gov/bcvtb/releases/1.0.0/doc/manual/index.xhtml [last accessed:
06/13/2011].
Expat XML Parser. 2011. http://sourceforge.net/projects/expat/ [Last acce sse d: 06/20/2011].
G. Fábián, D.A. van Beek, J.E. Rooda. 2008. Substitute equations for index reduction and
discontinuity handling. In Proc. of the Third International Symposium on Mathematical
Modeling, Vienna, Austria.
Modelisar. 2010. “Functional Mock-up Interface for Co-Simulation.”
h ttp ://www.m ode li
sar.com /sp e ci
fi
cati
ons/FMI_for_CoSi m ulation_v1.0.p df [Last acce sse d:
06/06/2011].
9/27/13 25