Description: "Package with base classes"

- Home > Modelica

## Buildings.Controls.Predictors.BaseClasses

Package with base classes

### Information

This package contains base classes that are used to construct the models in Buildings.Controls.Predictors.

Extends from Modelica.Icons.BasesPackage (Icon for packages containing base classes).

### Package Content

Name | Description
--- | ---
average | Average of past 10 days
partialBaselinePrediction | Partial function for baseline load prediction
sampleStart | Start time for sampling
weatherRegression | Linear weather regression model
Examples | Collection of models that illustrate model use and test models

## Buildings.Controls.Predictors.BaseClasses.average

Average of past 10 days

### Information

Function that predicts the current load using the average of the previous loads. The argument k determines how many data points will be used to compute the average. This is needed as during the start of the simulation, the complete history is not yet built up.

Extends from partialBaselinePrediction (Partial function for baseline load prediction).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
Power | P[:] |  | Vector of power consumed in each interval of the current time of day [W]
Integer | k |  | Number of history terms that have already been stored

### Outputs

Type | Name | Description
--- | --- | ---
Power | y | Baseline power consumption [W]

### Modelica definition

function average "Average of past 10 days" extends partialBaselinePrediction; algorithm if k == 0 then y := 0; else y :=sum(P[i] for i in 1:k)/k; end if; end average;

## Buildings.Controls.Predictors.BaseClasses.partialBaselinePrediction

Partial function for baseline load prediction

### Information

Partial function that defines the input and output arguments for the base load predictions.

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
Power | P[:] |  | Vector of power consumed in each interval of the current time of day [W]
Integer | k |  | Number of history terms that have already been stored

### Outputs

Type | Name | Description
--- | --- | ---
Power | y | Baseline power consumption [W]

### Modelica definition

partial function partialBaselinePrediction "Partial function for baseline load prediction" input Modelica.SIunits.Power P[:] "Vector of power consumed in each interval of the current time of day"; input Integer k "Number of history terms that have already been stored"; output Modelica.SIunits.Power y "Baseline power consumption"; end partialBaselinePrediction;

## Buildings.Controls.Predictors.BaseClasses.sampleStart

Start time for sampling

### Information

Function that returns the time at which the sampling needs to start.

This function takes as arguments the sampling interval and the current time. It returns the time at which the sampling will start. The start of the sampling will be such that a sample instant coincides with t=0.

Extends from Modelica.Icons.Function (Icon for functions).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
Time | t |  | Simulation time [s]
Time | samplePeriod |  | Sample Period [s]

### Outputs

Type | Name | Description
--- | --- | ---
Time | sampleStart | Time at which first sample happens [s]

### Modelica definition

function sampleStart "Start time for sampling" extends Modelica.Icons.Function; input Modelica.SIunits.Time t "Simulation time"; input Modelica.SIunits.Time samplePeriod "Sample Period"; output Modelica.SIunits.Time sampleStart "Time at which first sample happens"; algorithm sampleStart :=ceil(t/samplePeriod)*samplePeriod; end sampleStart;

## Buildings.Controls.Predictors.BaseClasses.weatherRegression

Linear weather regression model

### Information

Function that predicts the current load using a linear regression model. The load is assumed to be linear in the temperature. The argument k determines how many data points will be used for the regression. This is needed as during the start of the simulation, the complete history is not yet built up.

Extends from partialBaselinePrediction (Partial function for baseline load prediction).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
Power | P[:] |  | Vector of power consumed in each interval of the current time of day [W]
Integer | k |  | Number of history terms that have already been stored
Temperature | TCur |  | Current temperature [K]
Temperature | T[:] |  | Vector of temperatures of each interval of the current time of day [K]

### Outputs

Type | Name | Description
--- | --- | ---
Power | y | Baseline power consumption [W]

### Modelica definition

function weatherRegression "Linear weather regression model" extends partialBaselinePrediction; input Modelica.SIunits.Temperature TCur "Current temperature"; input Modelica.SIunits.Temperature T[:] "Vector of temperatures of each interval of the current time of day"; protected Modelica.SIunits.Temperature TAve "Average temperature"; Modelica.SIunits.Power PAve "Average power"; Real den(unit="K2") "Denominator"; Real a "Intercept"; Real b "Slope"; algorithm if k == 0 then y := 0; else TAve :=sum(T[i] for i in 1:k)/k; PAve :=sum(P[i] for i in 1:k)/k; den := sum((T[i]-TAve)^2 for i in 1:k); if den > Modelica.Constants.eps then b := sum((T[i]-TAve)*(P[i]-PAve) for i in 1:k)/den; else b := 0; end if; a := PAve - b * TAve; y := a + b*TCur; end if; end weatherRegression;