From 004bf9bb97b7830d8f4245909509a3ac75714b0d Mon Sep 17 00:00:00 2001 From: Darice Date: Wed, 5 Jun 2024 10:39:06 -0600 Subject: [PATCH 1/8] fix batt state updates --- src/EnergyPlus/ElectricPowerServiceManager.cc | 16 +++++++++++----- src/EnergyPlus/ElectricPowerServiceManager.hh | 2 ++ third_party/ssc/shared/lib_battery.cpp | 4 +++- third_party/ssc/shared/lib_battery.h | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 208727ccb5d..6fa69d77a8d 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -3626,6 +3626,7 @@ ElectricStorage::ElectricStorage( // main constructor ), nullptr)); ssc_lastBatteryState_ = std::make_unique(ssc_battery_->get_state()); + ssc_lastBatteryTimeStep_ = ssc_battery_->get_params().dt_hr; ssc_initBatteryState_ = std::make_unique(ssc_battery_->get_state()); } @@ -3912,7 +3913,8 @@ void ElectricStorage::reinitAtBeginEnvironment() } else if (storageModelMode_ == StorageModelType::LiIonNmcBattery) { // Copy the initial battery state to the last battery state *ssc_lastBatteryState_ = *ssc_initBatteryState_; - ssc_battery_->set_state(*ssc_lastBatteryState_); + ssc_lastBatteryTimeStep_ = ssc_initBatteryTimeStep_; + ssc_battery_->set_state(*ssc_lastBatteryState_, ssc_initBatteryTimeStep_); } myWarmUpFlag_ = true; } @@ -3953,7 +3955,8 @@ void ElectricStorage::reinitAtEndWarmup() } else if (storageModelMode_ == StorageModelType::LiIonNmcBattery) { // Copy the initial battery state to the last battery state *ssc_lastBatteryState_ = *ssc_initBatteryState_; - ssc_battery_->set_state(*ssc_lastBatteryState_); + ssc_lastBatteryTimeStep_ = ssc_initBatteryTimeStep_; + ssc_battery_->set_state(*ssc_lastBatteryState_, ssc_lastBatteryTimeStep_); } myWarmUpFlag_ = false; } @@ -4013,6 +4016,7 @@ void ElectricStorage::timeCheckAndUpdate(EnergyPlusData &state) } } else if (storageModelMode_ == StorageModelType::LiIonNmcBattery) { *ssc_lastBatteryState_ = ssc_battery_->get_state(); + ssc_lastBatteryTimeStep_ = ssc_battery_->get_params().dt_hr; } lastTimeStepStateOfCharge_ = thisTimeStepStateOfCharge_; @@ -4366,6 +4370,10 @@ void ElectricStorage::simulateLiIonNmcBatteryModel(EnergyPlusData &state, // Copy the battery state from the end of last timestep battery_state battState = *ssc_lastBatteryState_; + ssc_battery_->set_state(battState, ssc_lastBatteryTimeStep_); + if (std::lround(ssc_battery_->get_params().dt_hr * 60.0) != std::lround(state.dataHVACGlobal->TimeStepSys * 60.0)) { + ssc_battery_->ChangeTimestep(state.dataHVACGlobal->TimeStepSys); + } // Set the temperature the battery sees if (zoneNum_ > 0) { @@ -4381,9 +4389,7 @@ void ElectricStorage::simulateLiIonNmcBatteryModel(EnergyPlusData &state, ssc_battery_->changeSOCLimits(controlSOCMinFracLimit * 100.0, controlSOCMaxFracLimit * 100.0); // Set the current timestep length - if (std::lround(ssc_battery_->get_params().dt_hr * 60.0) != std::lround(state.dataHVACGlobal->TimeStepSys * 60.0)) { - ssc_battery_->ChangeTimestep(state.dataHVACGlobal->TimeStepSys); - } + // Run the battery // SAM uses negative values for charging, positive for discharging diff --git a/src/EnergyPlus/ElectricPowerServiceManager.hh b/src/EnergyPlus/ElectricPowerServiceManager.hh index 2b91a2cfc13..445d9e72e0e 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.hh +++ b/src/EnergyPlus/ElectricPowerServiceManager.hh @@ -440,7 +440,9 @@ private: // data // Li-ion NMC battery objects from SAM Simulation Core lib_battery std::unique_ptr ssc_battery_; std::unique_ptr ssc_lastBatteryState_; + Real64 ssc_lastBatteryTimeStep_; std::unique_ptr ssc_initBatteryState_; + Real64 ssc_initBatteryTimeStep_; // battery life calculation variables int count0_; std::vector b10_; diff --git a/third_party/ssc/shared/lib_battery.cpp b/third_party/ssc/shared/lib_battery.cpp index 976830ce592..8b4874fe7cd 100644 --- a/third_party/ssc/shared/lib_battery.cpp +++ b/third_party/ssc/shared/lib_battery.cpp @@ -772,8 +772,10 @@ battery_state battery_t::get_state() { return *state; } battery_params battery_t::get_params() { return *params; } -void battery_t::set_state(const battery_state& tmp_state) { +void battery_t::set_state(const battery_state& tmp_state, double dt_hr) { *state = tmp_state; + if (dt_hr > 0 && dt_hr <= 1) + params->dt_hr = dt_hr; } void battery_t::update_state(double I) { diff --git a/third_party/ssc/shared/lib_battery.h b/third_party/ssc/shared/lib_battery.h index 8cb92d6aaf6..608f0389f43 100644 --- a/third_party/ssc/shared/lib_battery.h +++ b/third_party/ssc/shared/lib_battery.h @@ -402,7 +402,7 @@ class battery_t { battery_params get_params(); - void set_state(const battery_state& state); + void set_state(const battery_state& state, double dt_hr=0.0); private: std::unique_ptr capacity; From de7f3fd8fbed8f4b7cba9882804c901cde3623d4 Mon Sep 17 00:00:00 2001 From: Darice L Guittet Date: Wed, 5 Jun 2024 10:53:08 -0600 Subject: [PATCH 2/8] Update ElectricPowerServiceManager.cc --- src/EnergyPlus/ElectricPowerServiceManager.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 6fa69d77a8d..2d361babf71 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -4383,7 +4383,6 @@ void ElectricStorage::simulateLiIonNmcBatteryModel(EnergyPlusData &state, // If outside, use outdoor temperature battState.thermal->T_room = state.dataEnvrn->OutDryBulbTemp; } - ssc_battery_->set_state(battState); // Set the SOC limits ssc_battery_->changeSOCLimits(controlSOCMinFracLimit * 100.0, controlSOCMaxFracLimit * 100.0); From 73444f8d5214fff22913b2b294e0be5ae31f8ec7 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Wed, 5 Jun 2024 12:19:48 -0500 Subject: [PATCH 3/8] Initialize init var, and apply clang format --- src/EnergyPlus/ElectricPowerServiceManager.cc | 1 - src/EnergyPlus/ElectricPowerServiceManager.hh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 2d361babf71..6c5bbc4edea 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -4389,7 +4389,6 @@ void ElectricStorage::simulateLiIonNmcBatteryModel(EnergyPlusData &state, // Set the current timestep length - // Run the battery // SAM uses negative values for charging, positive for discharging // E+ power/energy outputs are positive diff --git a/src/EnergyPlus/ElectricPowerServiceManager.hh b/src/EnergyPlus/ElectricPowerServiceManager.hh index 445d9e72e0e..6d6cc4c03fd 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.hh +++ b/src/EnergyPlus/ElectricPowerServiceManager.hh @@ -442,7 +442,7 @@ private: // data std::unique_ptr ssc_lastBatteryState_; Real64 ssc_lastBatteryTimeStep_; std::unique_ptr ssc_initBatteryState_; - Real64 ssc_initBatteryTimeStep_; + Real64 ssc_initBatteryTimeStep_ = 0.0; // battery life calculation variables int count0_; std::vector b10_; From a98ff1f30b1782ca1d041e37220ed96f8851e345 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Mon, 10 Jun 2024 13:58:59 -0500 Subject: [PATCH 4/8] Add init to one var, cleanup unused stuff --- src/EnergyPlus/ElectricPowerServiceManager.cc | 46 +++---------------- src/EnergyPlus/ElectricPowerServiceManager.hh | 25 ++-------- 2 files changed, 11 insertions(+), 60 deletions(-) diff --git a/src/EnergyPlus/ElectricPowerServiceManager.cc b/src/EnergyPlus/ElectricPowerServiceManager.cc index 6c5bbc4edea..76069c342d1 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.cc +++ b/src/EnergyPlus/ElectricPowerServiceManager.cc @@ -678,10 +678,9 @@ ElectPowerLoadCenter::ElectPowerLoadCenter(EnergyPlusData &state, int const obje subpanelFeedInRequest(0.0), subpanelFeedInRate(0.0), subpanelDrawRate(0.0), genElectricProd(0.0), genElectProdRate(0.0), storOpCVDrawRate(0.0), storOpCVFeedInRate(0.0), storOpCVChargeRate(0.0), storOpCVDischargeRate(0.0), storOpIsCharging(false), storOpIsDischarging(false), genOperationScheme_(GeneratorOpScheme::Invalid), demandMeterPtr_(0), generatorsPresent_(false), myCoGenSetupFlag_(true), demandLimit_(0.0), - trackSchedPtr_(0), dCElectricityProd_(0.0), dCElectProdRate_(0.0), dCpowerConditionLosses_(0.0), storagePresent_(false), - transformerPresent_(false), totalPowerRequest_(0.0), totalThermalPowerRequest_(0.0), storageScheme_(StorageOpScheme::Invalid), - trackStorageOpMeterIndex_(0), converterPresent_(false), maxStorageSOCFraction_(1.0), minStorageSOCFraction_(0.0), - designStorageChargePower_(0.0), designStorageChargePowerWasSet_(false), designStorageDischargePower_(0.0), + trackSchedPtr_(0), storagePresent_(false), transformerPresent_(false), totalPowerRequest_(0.0), totalThermalPowerRequest_(0.0), + storageScheme_(StorageOpScheme::Invalid), trackStorageOpMeterIndex_(0), converterPresent_(false), maxStorageSOCFraction_(1.0), + minStorageSOCFraction_(0.0), designStorageChargePower_(0.0), designStorageChargePowerWasSet_(false), designStorageDischargePower_(0.0), designStorageDischargePowerWasSet_(false), storageChargeModSchedIndex_(0), storageDischargeModSchedIndex_(0), facilityDemandTarget_(0.0), facilityDemandTargetModSchedIndex_(0), eMSOverridePelFromStorage_(false), // if true, EMS calling for override eMSValuePelFromStorage_(0.0), // value EMS is directing to use, power from storage [W] @@ -1959,9 +1958,6 @@ void ElectPowerLoadCenter::setupLoadCenterMeterIndices(EnergyPlusData &state) void ElectPowerLoadCenter::reinitAtBeginEnvironment() { - dCElectricityProd_ = 0.0; - dCElectProdRate_ = 0.0; - dCpowerConditionLosses_ = 0.0; genElectricProd = 0.0; genElectProdRate = 0.0; thermalProd = 0.0; @@ -2017,11 +2013,6 @@ void ElectPowerLoadCenter::reinitZoneGainsAtBeginEnvironment() } } -std::string const &ElectPowerLoadCenter::transformerName() const -{ - return transformerName_; -} - std::string const &ElectPowerLoadCenter::generatorListName() const { return generatorListName_; @@ -2794,21 +2785,11 @@ Real64 DCtoACInverter::pvWattsDCtoACSizeRatio() return pvWattsDCtoACSizeRatio_; } -Real64 DCtoACInverter::thermLossRate() const -{ - return thermLossRate_; -} - Real64 DCtoACInverter::aCPowerOut() const { return aCPowerOut_; } -Real64 DCtoACInverter::aCEnergyOut() const -{ - return aCEnergyOut_; -} - DCtoACInverter::InverterModelType DCtoACInverter::modelType() const { return modelType_; @@ -3194,21 +3175,6 @@ void ACtoDCConverter::reinitZoneGainsAtBeginEnvironment() qdotRadZone_ = 0.0; } -Real64 ACtoDCConverter::thermLossRate() const -{ - return thermLossRate_; -} - -Real64 ACtoDCConverter::dCPowerOut() const -{ - return dCPowerOut_; -} - -Real64 ACtoDCConverter::dCEnergyOut() const -{ - return dCEnergyOut_; -} - Real64 ACtoDCConverter::aCPowerIn() const { return aCPowerIn_; @@ -4676,7 +4642,7 @@ void ElectricStorage::shift(std::vector &A, int const m, int const n, st // constructor ElectricTransformer::ElectricTransformer(EnergyPlusData &state, std::string const &objectName) : myOneTimeFlag_(true), availSchedPtr_(0), usageMode_(TransformerUse::Invalid), heatLossesDestination_(ThermalLossDestination::Invalid), - zoneNum_(0), zoneRadFrac_(0.0), ratedCapacity_(0.0), phase_(0), factorTempCoeff_(0.0), tempRise_(0.0), eddyFrac_(0.0), + zoneNum_(0), zoneRadFrac_(0.0), ratedCapacity_(0.0), factorTempCoeff_(0.0), tempRise_(0.0), eddyFrac_(0.0), performanceInputMode_(TransformerPerformanceInput::Invalid), ratedEfficiency_(0.0), ratedPUL_(0.0), ratedTemp_(0.0), maxPUL_(0.0), considerLosses_(true), ratedNL_(0.0), ratedLL_(0.0), overloadErrorIndex_(0), efficiency_(0.0), powerIn_(0.0), energyIn_(0.0), powerOut_(0.0), energyOut_(0.0), noLoadLossRate_(0.0), noLoadLossEnergy_(0.0), loadLossRate_(0.0), loadLossEnergy_(0.0), thermalLossRate_(0.0), @@ -4755,7 +4721,7 @@ ElectricTransformer::ElectricTransformer(EnergyPlusData &state, std::string cons } zoneRadFrac_ = state.dataIPShortCut->rNumericArgs(1); ratedCapacity_ = state.dataIPShortCut->rNumericArgs(2); - phase_ = state.dataIPShortCut->rNumericArgs(3); + // unused phase_ = state.dataIPShortCut->rNumericArgs(3); if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), "Copper")) { factorTempCoeff_ = 234.5; @@ -5129,7 +5095,7 @@ void ElectricTransformer::manageTransformers(EnergyPlusData &state, Real64 const // Transformer has two modes.If it works in one mode, the variable for meter output in the other mode // is assigned 0 - totalLossEnergy_ = totalLossRate_ * state.dataHVACGlobal->TimeStepSysSec; + // unused totalLossEnergy_ = totalLossRate_ * state.dataHVACGlobal->TimeStepSysSec; break; } diff --git a/src/EnergyPlus/ElectricPowerServiceManager.hh b/src/EnergyPlus/ElectricPowerServiceManager.hh index 6d6cc4c03fd..ca22a5f4c65 100644 --- a/src/EnergyPlus/ElectricPowerServiceManager.hh +++ b/src/EnergyPlus/ElectricPowerServiceManager.hh @@ -144,14 +144,10 @@ public: // Methods Real64 pvWattsDCtoACSizeRatio(); - Real64 thermLossRate() const; - Real64 getLossRateForOutputPower(EnergyPlusData &state, Real64 const powerOutOfInverter); Real64 aCPowerOut() const; - Real64 aCEnergyOut() const; - InverterModelType modelType() const; std::string const &name() const; @@ -209,12 +205,6 @@ public: // Methods void reinitZoneGainsAtBeginEnvironment(); - Real64 thermLossRate() const; - - Real64 dCPowerOut() const; - - Real64 dCEnergyOut() const; - Real64 aCPowerIn() const; Real64 getLossRateForInputPower(EnergyPlusData &state, Real64 const powerIntoConverter); // AC power going into inverter @@ -440,7 +430,7 @@ private: // data // Li-ion NMC battery objects from SAM Simulation Core lib_battery std::unique_ptr ssc_battery_; std::unique_ptr ssc_lastBatteryState_; - Real64 ssc_lastBatteryTimeStep_; + Real64 ssc_lastBatteryTimeStep_ = 0.0; std::unique_ptr ssc_initBatteryState_; Real64 ssc_initBatteryTimeStep_ = 0.0; // battery life calculation variables @@ -511,7 +501,7 @@ private: // data int zoneNum_; // destination zone for heat losses from inverter. Real64 zoneRadFrac_; // radiative fraction for thermal losses to zone Real64 ratedCapacity_; // rated capacity [VA] - int phase_; // phase + // int phase_; // phase Real64 factorTempCoeff_; // thermal coefficient of resistance for winding material Real64 tempRise_; // full load temperature rise [C] Real64 eddyFrac_; // fraction of eddy current losses [] @@ -541,7 +531,7 @@ private: // data Real64 loadLossRate_; // [W] Real64 loadLossEnergy_; // [J] Real64 totalLossRate_; // [W] - Real64 totalLossEnergy_; // [J] + // Real64 totalLossEnergy_; // [J] Real64 thermalLossRate_; // [W] Real64 thermalLossEnergy_; // [J] Real64 elecUseMeteredUtilityLosses_; // [J] Energy consumption for a utility transformer (power in) @@ -624,8 +614,6 @@ public: // Methods void reinitZoneGainsAtBeginEnvironment(); - std::string const &transformerName() const; - std::string const &generatorListName() const; void updateLoadCenterGeneratorRecords(EnergyPlusData &state); @@ -707,11 +695,8 @@ private: // data std::string generationMeterName_; // Name of Generated Energy Meter for "on demand" operation bool generatorsPresent_; // true if any generators bool myCoGenSetupFlag_; - Real64 demandLimit_; // Demand Limit in Watts(W) which the generator will operate above - int trackSchedPtr_; // "pointer" to schedule for electrical demand to meet. - Real64 dCElectricityProd_; // Current DC Elect produced (J) (if buss type DCbussInverter) - Real64 dCElectProdRate_; // Current DC Elect power produced (W) (if buss type DCbussInverter) - Real64 dCpowerConditionLosses_; // current DC to AC inverter losses (W) (if DCbussInverter) + Real64 demandLimit_; // Demand Limit in Watts(W) which the generator will operate above + int trackSchedPtr_; // "pointer" to schedule for electrical demand to meet. bool storagePresent_; std::string storageName_; // hold name for verificaton and error messages bool transformerPresent_; // should only be transformers for on-site load center, not facility service From 200e17c8a413d55dd5e18a2ac9bf7d98f2d40e02 Mon Sep 17 00:00:00 2001 From: Yujie Xu Date: Tue, 25 Jun 2024 14:07:45 -0700 Subject: [PATCH 5/8] fix AirVolFlowStdDensity: should be massFlow / density --- src/EnergyPlus/InternalHeatGains.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/InternalHeatGains.cc b/src/EnergyPlus/InternalHeatGains.cc index 28be848bb73..b7c816e8803 100644 --- a/src/EnergyPlus/InternalHeatGains.cc +++ b/src/EnergyPlus/InternalHeatGains.cc @@ -8217,7 +8217,7 @@ namespace InternalHeatGains { state.dataHeatBal->spaceRpt(spaceNum).EnergyRpt[i] += state.dataHeatBal->ZoneITEq(Loop).EnergyRpt[i]; } - state.dataHeatBal->ZoneITEq(Loop).AirVolFlowStdDensity = AirMassFlowRate * state.dataEnvrn->StdRhoAir; + state.dataHeatBal->ZoneITEq(Loop).AirVolFlowStdDensity = AirMassFlowRate / state.dataEnvrn->StdRhoAir; state.dataHeatBal->ZoneITEq(Loop).AirVolFlowCurDensity = AirVolFlowRate; state.dataHeatBal->ZoneITEq(Loop).AirMassFlow = AirMassFlowRate; state.dataHeatBal->ZoneITEq(Loop).AirInletDryBulbT = TAirIn; From 628db9b6c7d9a9a708fd94581a4168a5692aca1f Mon Sep 17 00:00:00 2001 From: Yujie Xu Date: Tue, 25 Jun 2024 16:34:21 -0700 Subject: [PATCH 6/8] test idf with zone ITE Standard Densit Air Vol Flow Rate output --- testfiles/1ZoneDataCenterCRAC_wApproachTemp.idf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testfiles/1ZoneDataCenterCRAC_wApproachTemp.idf b/testfiles/1ZoneDataCenterCRAC_wApproachTemp.idf index 3a6943b2651..ca320551b7d 100644 --- a/testfiles/1ZoneDataCenterCRAC_wApproachTemp.idf +++ b/testfiles/1ZoneDataCenterCRAC_wApproachTemp.idf @@ -1050,6 +1050,8 @@ Output:Variable,*,ITE Standard Density Air Volume Flow Rate,Hourly; Output:Variable,*,ITE Air Mass Flow Rate,Hourly; + Output:Variable,*,Zone ITE Standard Density Air Volume Flow Rate,Hourly; + Output:Variable,*,Zone ITE Air Mass Flow Rate,Hourly; Output:Variable,*,ITE Air Inlet Dry-Bulb Temperature,Hourly; From 0cc8d2c75beceb63a42ab4315e6154c3170d494e Mon Sep 17 00:00:00 2001 From: Yujie Xu Date: Tue, 25 Jun 2024 16:40:12 -0700 Subject: [PATCH 7/8] fix mechVentFlow (mass), should be OAFlow (vol) / air density --- src/EnergyPlus/SystemReports.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/SystemReports.cc b/src/EnergyPlus/SystemReports.cc index 23f1096dc3f..2599970f7a6 100644 --- a/src/EnergyPlus/SystemReports.cc +++ b/src/EnergyPlus/SystemReports.cc @@ -4284,7 +4284,7 @@ void ReportVentilationLoads(EnergyPlusData &state) for (int sysNum = 1; sysNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++sysNum) { auto &thisSysVentRepVars = state.dataSysRpts->SysVentRepVars(sysNum); auto &thisSysPreDefRep = state.dataSysRpts->SysPreDefRep(sysNum); - Real64 mechVentFlow = state.dataAirLoop->AirLoopFlow(sysNum).OAFlow * state.dataEnvrn->StdRhoAir; + Real64 mechVentFlow = state.dataAirLoop->AirLoopFlow(sysNum).OAFlow / state.dataEnvrn->StdRhoAir; thisSysVentRepVars.MechVentFlow = mechVentFlow; thisSysPreDefRep.MechVentTotal += mechVentFlow * TimeStepSysSec; thisSysPreDefRep.NatVentTotal += thisSysVentRepVars.NatVentFlow * TimeStepSysSec; From ad0c3e374da10b99a640d8974272be42634ea4f3 Mon Sep 17 00:00:00 2001 From: Yujie Xu Date: Mon, 1 Jul 2024 15:34:48 -0700 Subject: [PATCH 8/8] Add unit test for mechVentFlow, ITE standard density vol flow --- tst/EnergyPlus/unit/InternalHeatGains.unit.cc | 3 ++ tst/EnergyPlus/unit/SystemReports.unit.cc | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/tst/EnergyPlus/unit/InternalHeatGains.unit.cc b/tst/EnergyPlus/unit/InternalHeatGains.unit.cc index 623f453dbbb..ed81d6a42a2 100644 --- a/tst/EnergyPlus/unit/InternalHeatGains.unit.cc +++ b/tst/EnergyPlus/unit/InternalHeatGains.unit.cc @@ -3296,7 +3296,10 @@ TEST_F(EnergyPlusFixture, ITE_Env_Class_Update_Class_H1) // Test the processing results of the Environmental Class H1 input EXPECT_TRUE(thisZoneITEq.Class == DataHeatBalance::ITEClass::H1); + state->dataEnvrn->StdRhoAir = 0.8; InternalHeatGains::CalcZoneITEq(*state); + // add a test to verify the standard density air volume flow rate calculation + EXPECT_NEAR(state->dataHeatBal->ZoneITEq(1).AirVolFlowStdDensity, 0.2469055, 1e-6); int NZ = 1; int spaceNum = 1; diff --git a/tst/EnergyPlus/unit/SystemReports.unit.cc b/tst/EnergyPlus/unit/SystemReports.unit.cc index aec4c498976..813000f144c 100644 --- a/tst/EnergyPlus/unit/SystemReports.unit.cc +++ b/tst/EnergyPlus/unit/SystemReports.unit.cc @@ -340,4 +340,35 @@ TEST_F(EnergyPlusFixture, ReportVentilationLoads_ZoneEquip) EXPECT_NEAR(state->dataSysRpts->ZoneVentRepVars(1).TargetVentilationFlowVoz, expectedVoz, 0.001); EXPECT_NEAR(state->dataSysRpts->ZoneVentRepVars(1).OAMassFlow, 98765432.1, 0.001); } + +TEST_F(EnergyPlusFixture, ReportVentilationLoads_MechVent) +{ + // Test the correction of mechenical ventilation flow rate calculation + // Should be volume = mass / density + state->dataHVACGlobal->TimeStepSys = 1.0; + state->dataEnvrn->StdRhoAir = 1.2; + state->dataHVACGlobal->NumPrimaryAirSys = 1; + state->dataAirSystemsData->PrimaryAirSystems.allocate(state->dataHVACGlobal->NumPrimaryAirSys); + state->dataSysRpts->SysVentRepVars.allocate(1); + state->dataSysRpts->SysPreDefRep.allocate(1); + state->dataGlobal->NumOfZones = 1; + state->dataHeatBal->Zone.allocate(state->dataGlobal->NumOfZones); + state->dataHeatBal->ZonePreDefRep.allocate(state->dataGlobal->NumOfZones); + state->dataHeatBal->ZnAirRpt.allocate(state->dataGlobal->NumOfZones); + state->dataZoneEquip->ZoneEquipConfig.allocate(state->dataGlobal->NumOfZones); + state->dataZoneEquip->ZoneEquipList.allocate(state->dataGlobal->NumOfZones); + state->dataAirLoop->AirLoopFlow.allocate(1); + state->dataAirLoop->AirLoopFlow(1).OAFlow = 1.6; + state->dataEnvrn->StdRhoAir = 0.8; + HeatBalanceManager::AllocateHeatBalArrays(*state); + SystemReports::AllocateAndSetUpVentReports(*state); + ZoneTempPredictorCorrector::InitZoneAirSetPoints(*state); + state->dataSysRpts->VentReportStructureCreated = true; + state->dataSysRpts->VentLoadsReportEnabled = true; + state->dataAirLoop->AirLoopControlInfo.allocate(1); + state->dataAirLoop->AirLoopControlInfo(1).OACtrlNum = 0; + SystemReports::ReportVentilationLoads(*state); + EXPECT_NEAR(state->dataSysRpts->SysVentRepVars(1).MechVentFlow, 2.0, 1e-6); +} + } // namespace EnergyPlus