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

Revision history [back]

My first question would be to ask whether you actually need to do that during the simulation or not, otherwise just do it as a post processing step...

Assuming you need the current max from 0 to current timestep, at each timestep, there is a way to do it I can think of. One caveat is that it involves using a TrendVariable and TrendVariables store things at the Zone timestep, so you're going to have a few differences if you were looking for something at a detailed timestep (such as HVAC variables)

Implementation details

EnergyManagementSystem:Sensor,
  Qdot_DXCoil_Sens,        !- Name
  Main Cooling Coil 1,     !- Output:Variable or Output:Meter Index Key Name
  Cooling Coil Sensible Cooling Rate;  !- Output:Variable or Output:Meter Name

EnergyManagementSystem:GlobalVariable,
  GlobalMax;                    !- Erl Variable 1 Name

EnergyManagementSystem:TrendVariable,
   PreviousMaxTrend,   !- Name
   GlobalMax,          !- EMS Variable Name
   1;                  !- Number of Timesteps to be Logged

EnergyManagementSystem:ProgramCallingManager,
  Store Max Program Calling Mgr,  !- Name
  EndOfZoneTimestepBeforeZoneReporting,  !- EnergyPlus Model Calling Point
  StoreMaxProgram;                !- Program Name 1

EnergyManagementSystem:Program,
  StoreMaxProgram,                !- Name
  Set previousMax = @TrendValue PreviousMaxTrend 1,  !- Program Line 1
  Set GlobalMax = @Max previousMax Qdot_DXCoil_Sens; !- Program Line 2

EnergyManagementSystem:OutputVariable,
  Output Max,              !- Name
  GlobalMax,               !- EMS Variable Name
  Averaged,                !- Type of Data in Variable
  SystemTimeStep,          !- Update Frequency
  ,                        !- EMS Program or Subroutine Name
  ;                        !- Units

Output:Variable,*,Output Max,Detailed;

Output:Variable,Main Cooling Coil 1,Cooling Coil Sensible Cooling Rate,Detailed;

Proof of the Caveat I mentionned

In post processing, I'm calculating the cummulative max of the actual variables. As you can see, there IS a gap between the one I computed in the EMS with the actual one at Detailed timestep

image description


Alternative: huge trend variable with TrendMax

A resource consuming alternative (and my first intuition) was to just make a huge Trend variable, and call @TrendMax on it. https://bigladdersoftware.com/epx/docs/9-5/ems-application-guide/built-in-functions.html#table:built-in-functions-for-trend-variables-in-erl

EnergyManagementSystem:TrendVariable,
 TemptrendLog1,        !- Name
 AverageBuildingTemp,     !- EMS Variable Name
 8760;                     !- Number of Timesteps to be Logged

Then in a program

Set Max1 = @TrendMax TemptrendLog1 8760