Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
1

How to get trend data from seperate days in the past

asked 2021-02-26 06:54:07 -0500

Bimi's avatar

updated 2021-02-26 08:44:11 -0500

With the help of EMS, I am trying to calculate the running average weighted outside temperature.

The formula is as following:

Running average weighted outside temp = ((Ttoday1)+(Tyesterday0.8)+(Tdaybeforeyesterday*0.3))/2.1

In which: Ttoday is the outside temperature between 0 and 24 hours ago Tyesterday is the average outside temperature between 24 and 48 hour ago. Tdaybeforeyesterday is the average outside temperature between 48 and 72 hour ago.

My question is, how can I do calculate Tyesterday and Tdaybeforeyesterday? I initially thought of using trend variables, but with trendvariables, one can only store the data from now to a certain point in the past, but not from a point in the past (yesterday) to a point further in the past (the day before yesterday) (as far as I am aware).

Does anybody know how I can calculate the Tyesterday and Tdaybeforeyesterday on an hourly level? The running average will later be used in EMS to determine thermostat setpoint on an hourly basis.

Thank you

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-03-07 18:09:58 -0500

TL;DR Use the @TrendSum trend variable function to sum up temperatures from now to different periods in the past and subtract the sums from more recent periods to calculate "in the past" averages.

If all three average temperatures focus on the same parameter (outside temperature), then you can use the @TrendSum EMS trend variable function to get the sum from now to different points in the past. Borrowing the example from this post:

EnergyManagementSystem:Sensor,
  OAT_sensor,             !- Name
  OutdoorAirNodeName,   !- Output:Variable or Output:Meter Index Key Name
  System Node Temperature; !- Output:Variable or Output:Meter Name

EnergyManagementSystem:TrendVariable,
  Trend_24hr,                          !- Name
  OAT_sensor,  !- EMS Variable Name
  24; !- Number of Timesteps to be logged

EnergyManagementSystem:TrendVariable,
  Trend_48hr,                          !- Name
  OAT_sensor,  !- EMS Variable Name
  48; !- Number of Timesteps to be logged

EnergyManagementSystem:TrendVariable,
  Trend_72hr,                          !- Name
  OAT_sensor,  !- EMS Variable Name
  72; !- Number of Timesteps to be logged

This is assuming that you're using hourly timesteps, if it's a different timestep frequency you'll need to update the last Number of Timesteps to be logged input fields for each EnergyManagementSystem:TrendVariable objects above.

Then in the EMS program sum each trend variable over the total number of time steps they have logged the sensor data.

EnergyManagementSystem:Program,
  SET T_24hr = @TrendSum Trend_24hr 24, !- sum of temp over last 24 hours
  SET T_48hr = @TrendSum Trend_48hr 48, !- sum of temp over last 48 hours
  SET T_72hr = @TrendSum Trend_72hr 72, !- sum of temp over last 72 hours

Then, to get the average over just the 24-hour period you want, subtract the appropriate temperature variables from the program lines above and divide by the number of timesteps that have been logged.

  SET T_today = T_24hr / 24, !- Divide sum by 24 hour timesteps to calculate average over last 24 hours
  SET T_yesterday = (T_48hr - T_24hr) / 24, !- Calculate average over past 25 to 48 hours
  SET T_day_before_yesterday = (T_72hr - T_48hr) / 24; !- Calculate average over past 49 to 72 hours

You could also use the ZoneTimeStep built-in variable within your program to automate the number of timesteps that the trend variables are logging and the numerators used to calculate the averages. I don't believe that this built-in variable could be used for the Number of Timesteps to be logged input fields of the EnergyManagementSystem:TrendVariable objects.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2021-02-26 06:24:50 -0500

Seen: 77 times

Last updated: Mar 07 '21