Skip to content

Commit

Permalink
Fix lag in updating output variables
Browse files Browse the repository at this point in the history
This addresses an issue with lag between the time of setting an input
via and actuator, and seeing the corresponding output variable change.
This commit specifically addresses the issue for output variables
related to the zone air heat balance, and for internal heat gains. Other
output variables may still suffer from the lag issue, however they can
be handled in a similar manner by simply calling their respective update
functions. In the future we will introduce an explicit list of supported
output variables, at which time we can have positive confirmation that
we have addressed the lag for all supported output variables.

close lbl-srg/modelica-buildings/#1681
  • Loading branch information
kbenne committed Mar 13, 2020
1 parent 45d1c47 commit e443d63
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions epfmi/EPComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "EnergyPlus/DataHeatBalFanSys.hh"
#include "EnergyPlus/DataRuntimeLanguage.hh"
#include "EnergyPlus/EMSManager.hh"
#include "EnergyPlus/HeatBalanceAirManager.hh"
#include "EnergyPlus/InternalHeatGains.hh"
#include "EnergyPlus/OutputProcessor.hh"
#include "EnergyPlus/ZoneTempPredictorCorrector.hh"

Expand Down Expand Up @@ -192,6 +194,7 @@ void EPComponent::exchange()
resetActuator(h);
};

// Update inputs first, then outputs so that we can do some updates within EnergyPlus
for( auto & varmap : variables ) {
auto & var = varmap.second;
auto varZoneNum = zoneNum(var.name);
Expand All @@ -203,6 +206,36 @@ void EPComponent::exchange()
EnergyPlus::DataHeatBalFanSys::MAT( varZoneNum ) = var.value;
}
break;
case VariableType::EMS_ACTUATOR:
if( var.valueset ) {
compSetActuatorValue(
var.actuatorcomponentkey,
var.actuatorcomponenttype,
var.actuatorcontroltype,
var.value
);
} else {
compResetActuator(
var.actuatorcomponentkey,
var.actuatorcomponenttype,
var.actuatorcontroltype
);
}
break;
default:
break;
}
}

// Run some internal EnergyPlus functions to update outputs
EnergyPlus::HeatBalanceAirManager::ReportZoneMeanAirTemp();
EnergyPlus::InternalHeatGains::InitInternalHeatGains();

// Now update the outputs
for( auto & varmap : variables ) {
auto & var = varmap.second;
auto varZoneNum = zoneNum(var.name);
switch ( var.type ) {
case VariableType::V:
var.value = EnergyPlus::DataHeatBalance::Zone( varZoneNum ).Volume;
var.valueset = true;
Expand All @@ -223,22 +256,6 @@ void EPComponent::exchange()
var.value = getSensorValue(var);
var.valueset = true;
break;
case VariableType::EMS_ACTUATOR:
if( var.valueset ) {
compSetActuatorValue(
var.actuatorcomponentkey,
var.actuatorcomponenttype,
var.actuatorcontroltype,
var.value
);
} else {
compResetActuator(
var.actuatorcomponentkey,
var.actuatorcomponenttype,
var.actuatorcontroltype
);
}
break;
default:
break;
}
Expand Down

0 comments on commit e443d63

Please sign in to comment.