Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/NREL/EnergyPlus into NFP…
Browse files Browse the repository at this point in the history
…-Refrigerant-Migration-Decarbonization
  • Loading branch information
rraustad committed Jul 11, 2024
2 parents 2e76983 + 8a045ac commit 4bef040
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 69 deletions.
62 changes: 16 additions & 46 deletions src/EnergyPlus/ElectricPowerServiceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2017,11 +2013,6 @@ void ElectPowerLoadCenter::reinitZoneGainsAtBeginEnvironment()
}
}

std::string const &ElectPowerLoadCenter::transformerName() const
{
return transformerName_;
}

std::string const &ElectPowerLoadCenter::generatorListName() const
{
return generatorListName_;
Expand Down Expand Up @@ -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_;
Expand Down Expand Up @@ -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_;
Expand Down Expand Up @@ -3626,6 +3592,7 @@ ElectricStorage::ElectricStorage( // main constructor
),
nullptr));
ssc_lastBatteryState_ = std::make_unique<battery_state>(ssc_battery_->get_state());
ssc_lastBatteryTimeStep_ = ssc_battery_->get_params().dt_hr;
ssc_initBatteryState_ = std::make_unique<battery_state>(ssc_battery_->get_state());
}

Expand Down Expand Up @@ -3912,7 +3879,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;
}
Expand Down Expand Up @@ -3953,7 +3921,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;
}
Expand Down Expand Up @@ -4013,6 +3982,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_;
Expand Down Expand Up @@ -4366,6 +4336,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) {
Expand All @@ -4375,15 +4349,11 @@ 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);

// 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
Expand Down Expand Up @@ -4672,7 +4642,7 @@ void ElectricStorage::shift(std::vector<Real64> &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),
Expand Down Expand Up @@ -4751,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;
Expand Down Expand Up @@ -5125,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;
}
Expand Down
25 changes: 6 additions & 19 deletions src/EnergyPlus/ElectricPowerServiceManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -440,7 +430,9 @@ private: // data
// Li-ion NMC battery objects from SAM Simulation Core lib_battery
std::unique_ptr<battery_t> ssc_battery_;
std::unique_ptr<battery_state> ssc_lastBatteryState_;
Real64 ssc_lastBatteryTimeStep_ = 0.0;
std::unique_ptr<battery_state> ssc_initBatteryState_;
Real64 ssc_initBatteryTimeStep_ = 0.0;
// battery life calculation variables
int count0_;
std::vector<Real64> b10_;
Expand Down Expand Up @@ -509,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 []
Expand Down Expand Up @@ -539,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)
Expand Down Expand Up @@ -622,8 +614,6 @@ public: // Methods

void reinitZoneGainsAtBeginEnvironment();

std::string const &transformerName() const;

std::string const &generatorListName() const;

void updateLoadCenterGeneratorRecords(EnergyPlusData &state);
Expand Down Expand Up @@ -705,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
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/InternalHeatGains.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/SystemReports.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions testfiles/1ZoneDataCenterCRAC_wApproachTemp.idf
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion third_party/ssc/shared/lib_battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion third_party/ssc/shared/lib_battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_t> capacity;
Expand Down
3 changes: 3 additions & 0 deletions tst/EnergyPlus/unit/InternalHeatGains.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 31 additions & 0 deletions tst/EnergyPlus/unit/SystemReports.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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

5 comments on commit 4bef040

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NFP-Refrigerant-Migration-Decarbonization (rraustad) - Win64-Windows-10-VisualStudio-16: OK (2845 of 2845 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NFP-Refrigerant-Migration-Decarbonization (rraustad) - x86_64-MacOS-10.18-clang-15.0.0: OK (3535 of 3637 tests passed, 113 test warnings)

Messages:\n

  • 215 tests had: AUD diffs.
  • 213 tests had: RDD diffs.
  • 104 tests had: Table small diffs.
  • 102 tests had: Table big diffs.
  • 1 test had: ERR diffs.

Failures:\n

regression Test Summary

  • Passed: 689
  • Failed: 102

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NFP-Refrigerant-Migration-Decarbonization (rraustad) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3576 of 3678 tests passed, 113 test warnings)

Messages:\n

  • 215 tests had: AUD diffs.
  • 213 tests had: RDD diffs.
  • 104 tests had: Table small diffs.
  • 102 tests had: Table big diffs.
  • 1 test had: ERR diffs.

Failures:\n

regression Test Summary

  • Passed: 709
  • Failed: 102

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NFP-Refrigerant-Migration-Decarbonization (rraustad) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (795 of 795 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NFP-Refrigerant-Migration-Decarbonization (rraustad) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (2053 of 2053 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.