Buildings.Controls.OBC.CDL.Continuous.Sources

Package with blocks that generate source signals

Information

Package with blocks that generate signals.

Extends from Modelica.Icons.SourcesPackage (Icon for packages containing sources).

Package Content

Name Description
Buildings.Controls.OBC.CDL.Continuous.Sources.CalendarTime CalendarTime Computes the unix time stamp and calendar time from the simulation time
Buildings.Controls.OBC.CDL.Continuous.Sources.Constant Constant Output constant signal of type Real
Buildings.Controls.OBC.CDL.Continuous.Sources.ModelTime ModelTime Standard time
Buildings.Controls.OBC.CDL.Continuous.Sources.Pulse Pulse Generate pulse signal of type Real
Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp Ramp Generate ramp signal
Buildings.Controls.OBC.CDL.Continuous.Sources.Sine Sine Generate sine signal
Buildings.Controls.OBC.CDL.Continuous.Sources.TimeTable TimeTable Table look-up with respect to time and linear or periodic extrapolation
Buildings.Controls.OBC.CDL.Continuous.Sources.Validation Validation Collection of models that validate the continuous sources blocks of the CDL

Buildings.Controls.OBC.CDL.Continuous.Sources.CalendarTime Buildings.Controls.OBC.CDL.Continuous.Sources.CalendarTime

Computes the unix time stamp and calendar time from the simulation time

Buildings.Controls.OBC.CDL.Continuous.Sources.CalendarTime

Information

Block that outputs minute, hour, day of the month, month, year and weekday.

Assumption and limitations

The implementation only supports date computations from year 2010 up to and including 2020. Daylight saving and time zones are not supported.

Typical use and important parameters

The user must define which time and date correspond to time = 0 using the model parameters zerTim, and, if zerTim == CDL.Types.ZeroTime.Custom, the parameter yearRef. The user can choose from new year, midnight for a number of years: 2010 to 2020 and also 1970. The latter corresponds to a unix stamp of 0. Note that when choosing the reference time equal to 0 at 1970, the actual simulation time must be within the 2010-2020 range. For example, startTime = 1262304000 corresponds to the simulation starting on the 1st of January 2010 when setting zerTim = CDL.Types.ZeroTime.UnixTimeStamp. This is within the 2010-2020 range and is therefore allowed.

Parameters

TypeNameDefaultDescription
ZeroTimezerTim Enumeration for choosing how reference time (time = 0) should be defined
IntegeryearRef2016Year when time = 0, used if zerTim=Custom
Advanced
Timeoffset0Offset that is added to 'time', may be used for computing time in different time zone [s]

Connectors

TypeNameDescription
output IntegerOutputyearYear
output IntegerOutputmonthMonth of the year
output IntegerOutputdayDay of the month
output IntegerOutputhourHour of the day
output RealOutputminuteMinute of the hour
output IntegerOutputweekDayInteger output representing week day (monday = 1, sunday = 7)

Modelica definition

model CalendarTime "Computes the unix time stamp and calendar time from the simulation time" parameter Buildings.Controls.OBC.CDL.Types.ZeroTime zerTim "Enumeration for choosing how reference time (time = 0) should be defined"; parameter Integer yearRef( min=firstYear, max=lastYear) = 2016 "Year when time = 0, used if zerTim=Custom"; parameter Modelica.SIunits.Time offset=0 "Offset that is added to 'time', may be used for computing time in different time zone"; discrete Interfaces.IntegerOutput year "Year"; discrete Interfaces.IntegerOutput month "Month of the year"; Interfaces.IntegerOutput day(fixed=false) "Day of the month"; Interfaces.IntegerOutput hour(fixed=false) "Hour of the day"; Interfaces.RealOutput minute "Minute of the hour"; Interfaces.IntegerOutput weekDay(fixed=false) "Integer output representing week day (monday = 1, sunday = 7)"; protected final constant Integer firstYear=2010 "First year that is supported, i.e. the first year in timeStampsNewYear[:]"; final constant Integer lastYear=firstYear + 11 "Last year that is supported (actual building automation system need to support a larger range)"; Buildings.Utilities.Time.CalendarTime calTim( final zerTim=zerTim, final yearRef=yearRef, final offset=offset) "Calendar time"; equation connect(calTim.minute, minute); connect(calTim.hour, hour); connect(calTim.day, day); connect(calTim.month, month); connect(calTim.year, year); connect(calTim.weekDay, weekDay); end CalendarTime;

Buildings.Controls.OBC.CDL.Continuous.Sources.Constant Buildings.Controls.OBC.CDL.Continuous.Sources.Constant

Output constant signal of type Real

Buildings.Controls.OBC.CDL.Continuous.Sources.Constant

Information

Block that outputs a constant signal y = k, where k is a real-valued parameter.

Constant.png

Parameters

TypeNameDefaultDescription
Realk Constant output value

Connectors

TypeNameDescription
output RealOutputyConnector of Real output signal

Modelica definition

block Constant "Output constant signal of type Real" parameter Real k "Constant output value"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = k; end Constant;

Buildings.Controls.OBC.CDL.Continuous.Sources.ModelTime Buildings.Controls.OBC.CDL.Continuous.Sources.ModelTime

Standard time

Buildings.Controls.OBC.CDL.Continuous.Sources.ModelTime

Information

Block that outputs the standard time.

Implementation

This block outputs the time of the model. In the case of a building automation system, the building automation system synchronizes time, and hence need to assign a value for the output of this block. Daylight saving time shall not be taken into account, e.g, the block always outputs standard time rather than daylight savings time.

If a simulation starts at t=-1, then this block outputs first t=-1, and its output is advanced at the same rate as the simulation time.

Connectors

TypeNameDescription
output RealOutputyConnector of Real output signal [s]

Modelica definition

block ModelTime "Standard time" Interfaces.RealOutput y(final unit="s") "Connector of Real output signal"; equation y = time; end ModelTime;

Buildings.Controls.OBC.CDL.Continuous.Sources.Pulse Buildings.Controls.OBC.CDL.Continuous.Sources.Pulse

Generate pulse signal of type Real

Buildings.Controls.OBC.CDL.Continuous.Sources.Pulse

Information

The Real output y is a pulse signal:

Pulse.png

Parameters

TypeNameDefaultDescription
Realamplitude1Amplitude of pulse
Realwidth0.5Width of pulse in fraction of period [1]
Timeperiod Time for one period [s]
Integernperiod-1Number of periods (< 0 means infinite number of periods)
Realoffset0Offset of output signals
TimestartTime0Output = offset for time < startTime [s]

Connectors

TypeNameDescription
output RealOutputyConnector of Pulse output signal

Modelica definition

block Pulse "Generate pulse signal of type Real" parameter Real amplitude=1 "Amplitude of pulse"; parameter Real width( final min=Constants.small, final max=1, final unit="1") = 0.5 "Width of pulse in fraction of period"; parameter Modelica.SIunits.Time period(final min=Constants.small) "Time for one period"; parameter Integer nperiod=-1 "Number of periods (< 0 means infinite number of periods)"; parameter Real offset=0 "Offset of output signals"; parameter Modelica.SIunits.Time startTime=0 "Output = offset for time < startTime"; Interfaces.RealOutput y "Connector of Pulse output signal"; protected Modelica.SIunits.Time T_width=period*width "Pulse duration time"; Modelica.SIunits.Time T_start "Start time of current period"; Integer count "Period count"; initial equation count = integer((time - startTime)/period); T_start = startTime + count*period; equation when integer((time - startTime)/period) > pre(count) then count = pre(count) + 1; T_start = time; end when; y = offset + (if (time < startTime or nperiod == 0 or (nperiod > 0 and count >= nperiod)) then 0 else if time < T_start + T_width then amplitude else 0); end Pulse;

Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp

Generate ramp signal

Buildings.Controls.OBC.CDL.Continuous.Sources.Ramp

Information

The Real output y is a ramp signal:

Ramp.png

Parameters

TypeNameDefaultDescription
Realheight1Height of ramps
Timeduration Duration of ramp (= 0.0 gives a Step) [s]
Realoffset0Offset of output signal
TimestartTime0Output = offset for time < startTime [s]

Connectors

TypeNameDescription
output RealOutputyConnector of Real output signal

Modelica definition

block Ramp "Generate ramp signal" parameter Real height=1 "Height of ramps"; parameter Modelica.SIunits.Time duration(min=Constants.small) "Duration of ramp (= 0.0 gives a Step)"; parameter Real offset=0 "Offset of output signal"; parameter Modelica.SIunits.Time startTime=0 "Output = offset for time < startTime"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = offset + (if time < startTime then 0 else if time < (startTime + duration) then (time - startTime)*height/duration else height); end Ramp;

Buildings.Controls.OBC.CDL.Continuous.Sources.Sine Buildings.Controls.OBC.CDL.Continuous.Sources.Sine

Generate sine signal

Buildings.Controls.OBC.CDL.Continuous.Sources.Sine

Information

Block that outputs a sine.

Sine.png

Parameters

TypeNameDefaultDescription
Realamplitude1Amplitude of sine wave
FrequencyfreqHz Frequency of sine wave [Hz]
Anglephase0Phase of sine wave [rad]
Realoffset0Offset of output signal
TimestartTime0Output = offset for time < startTime [s]

Connectors

TypeNameDescription
output RealOutputyConnector of Real output signal

Modelica definition

block Sine "Generate sine signal" parameter Real amplitude=1 "Amplitude of sine wave"; parameter Modelica.SIunits.Frequency freqHz(start=1) "Frequency of sine wave"; parameter Modelica.SIunits.Angle phase=0 "Phase of sine wave"; parameter Real offset=0 "Offset of output signal"; parameter Modelica.SIunits.Time startTime=0 "Output = offset for time < startTime"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput y "Connector of Real output signal"; equation y = offset + (if time < startTime then 0 else amplitude*Modelica.Math.sin(2* Buildings.Controls.OBC.CDL.Constants.pi*freqHz*(time - startTime) + phase)); end Sine;

Buildings.Controls.OBC.CDL.Continuous.Sources.TimeTable Buildings.Controls.OBC.CDL.Continuous.Sources.TimeTable

Table look-up with respect to time and linear or periodic extrapolation

Buildings.Controls.OBC.CDL.Continuous.Sources.TimeTable

Information

Block that outputs values of a time table.

The block takes as a parameter a time table of the format

table = [ 0*3600, 0;
          6*3600, 0;
          6*3600, 1;
         18*3600, 1;
         18*3600, 0;
         24*3600, 0];

where the first column is time in seconds, and the remaining column(s) are the table values. Any number of columns can be specified. The parameter smoothness determines how the table values are interpolated. The following settings are allowed:

smoothnessDescription
CDL.Types.LinearSegments Table points are linearly interpolated.
CDL.Types.ConstantSegments Table points are not interpolated, but the previous tabulated value is returned.

The parameter extrapolation determines how the table values are extrapolated. The following settings are allowed:

extrapolationDescription
CDL.Types.HoldLastPoint Hold the first or last table point outside of the table scope.
CDL.Types.LastTwoPoints Extrapolate by using the derivative at the first or last table points outside of the table scope.
CDL.Types.Periodic Repeat the table scope periodically with periodicity (max(table[:, 1]-min(table[:, 1]))*timeScale).

The value of the parameter offset is added to the tabulated values. The parameters timeScale is used to scale the first column of the table. For example, set timeScale = 3600 if the first column is in hour (because in CDL, the time unit is seconds).

If the table has only one row, no interpolation is performed and the table values of this row are just returned.

An interval boundary is defined by two identical time values following each other. For example

   table = [0, 0;
            1, 0;
            1, 1;
            2, 3;
            3, 5;
            3, 2;
            4, 4;
            5, 5];

defines three intervalls: 0..1, 1..3, 3..5. Within an interval the defined interpolation method is applied (so the table outputs within an interval are continuous if smoothness = CDL.Types.LinearSegments.

Example:

  table = [0, 0;
           1, 0;
           1, 1;
           2, 4;
           3, 9;
           4, 16];
  smoothness = CDL.Types.LinearSegments;

If, e.g., time = 1.0, the output y =  0.0 (before event), 1.0 (after event)
    e.g., time = 1.5, the output y =  2.5,
    e.g., time = 2.0, the output y =  4.0,
    e.g., time = 5.0, the output y = 23.0 (i.e., extrapolation via last 2 points).

Implementation

For simulation, no time events are generated within an interval in order that also intervals with many points do not reduce the simulation efficiency. If the table points are largely changing, it is adviseable to force time events by duplicating every time point (especially, if the model in which the table is present allows the variable step integrator to make large integrator steps). For example, if a sawtooth signal is defined with the table, it is more reliable to define the table as:

   table = [0, 0;
            1, 2;
            1, 2;
            2, 0;
            2, 0;
            3, 2;
            3, 2];

instead of

   table = [0, 0;
            1, 2;
            2, 0;
            3, 2];

because time events are then generated at every time point.

Building automation systems typically have discrete time semantics with fixed sampling times, and no notion of superdense time (in which a tabulated value can change without advancing time). Therefore, to implement a table with two equal time stamps, a CDL translator may parameterize a table in the building automation in such a way that the step change happens at the time indicated in the first column, whereas previous sampling times output the tabulated value at the last transition. For example,

table = [0, 0;
         1, 0;
         1, 1];
smoothness = CDL.Types.ConstantSegments;

may be converted such that a building automation system with a sampling time of 0.5 seconds outputs

  t = 0, 0.5, 1, ...
  y = 0, 0  , 1, ...

Parameters

TypeNameDefaultDescription
Realtable[:, :] Table matrix (time = first column is time in seconds, unless timeScale <> 1)
SmoothnesssmoothnessCDL.Types.Smoothness.LinearS...Smoothness of table interpolation
ExtrapolationextrapolationCDL.Types.Extrapolation.Peri...Extrapolation of data outside the definition range
Realoffset[:]{0}Offsets of output signals
TimetimeScale1Time scale of first table column. Set to 3600 if time in table is in hours [s]

Connectors

TypeNameDescription
output RealOutputy[nout]Output of the table

Modelica definition

block TimeTable "Table look-up with respect to time and linear or periodic extrapolation" parameter Real table[:, :] "Table matrix (time = first column is time in seconds, unless timeScale <> 1)"; parameter CDL.Types.Smoothness smoothness=CDL.Types.Smoothness.LinearSegments "Smoothness of table interpolation"; parameter CDL.Types.Extrapolation extrapolation=CDL.Types.Extrapolation.Periodic "Extrapolation of data outside the definition range"; parameter Real offset[:]={0} "Offsets of output signals"; parameter Modelica.SIunits.Time timeScale=1 "Time scale of first table column. Set to 3600 if time in table is in hours"; Interfaces.RealOutput y[nout] "Output of the table"; protected final parameter Integer nout=size(table, 2) - 1 "Dimension of output vector"; // CDL uses different enumerations for smoothness and for extrapolation // than the Modelica Standard Library. Hence, we cast the CDL // enumeration to the MSL enumaration. Modelica.Blocks.Sources.CombiTimeTable tab( final tableOnFile=false, final table=table, final columns=2:size(tab.table, 2), final smoothness=if smoothness == CDL.Types.Smoothness.LinearSegments then Modelica.Blocks.Types.Smoothness.LinearSegments else Modelica.Blocks.Types.Smoothness.ConstantSegments, final extrapolation=if extrapolation == CDL.Types.Extrapolation.HoldLastPoint then Modelica.Blocks.Types.Extrapolation.HoldLastPoint elseif extrapolation == CDL.Types.Extrapolation.LastTwoPoints then Modelica.Blocks.Types.Extrapolation.LastTwoPoints else Modelica.Blocks.Types.Extrapolation.Periodic, final offset=offset, final startTime=0, final timeScale=timeScale) "Time table"; equation connect(tab.y, y); end TimeTable;