Skip to content

Commit

Permalink
Fix #10574 - Deal with BIPVT for WaterHeater sizing and throw error i…
Browse files Browse the repository at this point in the history
…f Total Collector area found is zero
  • Loading branch information
jmarrec committed Jun 19, 2024
1 parent ed631fc commit 8bd188b
Showing 1 changed file with 77 additions and 17 deletions.
94 changes: 77 additions & 17 deletions src/EnergyPlus/WaterThermalTanks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#include <EnergyPlus/OutAirNodeManager.hh>
#include <EnergyPlus/OutputProcessor.hh>
#include <EnergyPlus/OutputReportPredefined.hh>
#include <EnergyPlus/PhotovoltaicThermalCollectors.hh>
#include <EnergyPlus/Plant/DataPlant.hh>
#include <EnergyPlus/Plant/PlantLocation.hh>
#include <EnergyPlus/PlantUtilities.hh>
Expand Down Expand Up @@ -11201,9 +11202,6 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state)

static constexpr std::string_view RoutineName("SizeTankForSupplySide");

Real64 Tstart = 14.44;
Real64 Tfinish = 57.22;

Real64 tmpTankVolume = this->Volume;
Real64 tmpMaxCapacity = this->MaxCapacity;

Expand All @@ -11221,8 +11219,11 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state)
}
if (this->MaxCapacityWasAutoSized) {
if (this->Sizing.RecoveryTime > 0.0) {
Real64 rho;
Real64 Cp;
Real64 rho = 0.0;
Real64 Cp = 0.0;
constexpr Real64 Tstart = 14.44;
constexpr Real64 Tfinish = 57.22;

if (this->SrcSidePlantLoc.loopNum > 0) {
rho = FluidProperties::GetDensityGlycol(state,
state.dataPlnt->PlantLoop(this->SrcSidePlantLoc.loopNum).FluidName,
Expand All @@ -11242,8 +11243,7 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state)
(this->Sizing.RecoveryTime * Constant::SecInHour); // m3 | kg/m3 | J/Kg/K | K | seconds
} else {
ShowFatalError(
state,
format("SizeTankForSupplySide: Tank=\"{}\", requested sizing for max capacity but entered Recovery Time is zero.", this->Name));
state, format("{}: Tank=\"{}\", requested sizing for max capacity but entered Recovery Time is zero.", RoutineName, this->Name));
}
}

Expand All @@ -11259,12 +11259,40 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state)
} else if (this->Sizing.DesignMode == SizingMode::PerSolarColArea) {

this->Sizing.TotalSolarCollectorArea = 0.0;
if (state.dataSolarCollectors->GetInputFlag) {
SolarCollectors::GetSolarCollectorInput(state);
state.dataSolarCollectors->GetInputFlag = false;
}

for (int CollectorNum = 1; CollectorNum <= state.dataSolarCollectors->NumOfCollectors; ++CollectorNum) {
this->Sizing.TotalSolarCollectorArea += state.dataSurface->Surface(state.dataSolarCollectors->Collector(CollectorNum).Surface).Area;
auto const &collector = state.dataSolarCollectors->Collector(CollectorNum);
this->Sizing.TotalSolarCollectorArea += state.dataSurface->Surface(collector.Surface).Area;
}

if (state.dataPhotovoltaicThermalCollector->GetInputFlag) {
PhotovoltaicThermalCollectors::GetPVTcollectorsInput(state);
state.dataPhotovoltaicThermalCollector->GetInputFlag = false;
}

for (int CollectorNum = 1; CollectorNum <= state.dataPhotovoltaicThermalCollector->NumPVT; ++CollectorNum) {
auto const &collector = state.dataPhotovoltaicThermalCollector->PVT(CollectorNum);
this->Sizing.TotalSolarCollectorArea += collector.AreaCol;
}

if (this->VolumeWasAutoSized) tmpTankVolume = this->Sizing.TotalSolarCollectorArea * this->Sizing.TankCapacityPerCollectorArea;
if (this->MaxCapacityWasAutoSized) tmpMaxCapacity = 0.0;
if (this->VolumeWasAutoSized) {
if (this->Sizing.TotalSolarCollectorArea > 0) {
tmpTankVolume = this->Sizing.TotalSolarCollectorArea * this->Sizing.TankCapacityPerCollectorArea;
} else {
ShowFatalError(state,
format("{}: Tank=\"{}\", requested sizing for volume with PerSolarCollectorArea but total found "
"area of Collectors is zero.",
RoutineName,
this->Name));
}
}
if (this->MaxCapacityWasAutoSized) {
tmpMaxCapacity = 0.0;
}
if (this->VolumeWasAutoSized && state.dataPlnt->PlantFirstSizesOkayToFinalize) {
this->Volume = tmpTankVolume;
if (state.dataPlnt->PlantFinalSizesOkayToReport) {
Expand All @@ -11285,7 +11313,9 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state)
}
}

if (this->MaxCapacityWasAutoSized) this->setBackupElementCapacity(state);
if (this->MaxCapacityWasAutoSized) {
this->setBackupElementCapacity(state);
}

if ((this->VolumeWasAutoSized) && (this->WaterThermalTankType == DataPlant::PlantEquipmentType::WtrHeaterStratified) &&
state.dataPlnt->PlantFirstSizesOkayToFinalize) { // might set height
Expand Down Expand Up @@ -11577,8 +11607,7 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state)
} else {
ShowFatalError(
state,
format("SizeStandAloneWaterHeater: Tank=\"{}\", requested sizing for max capacity but entered Recovery Time is zero.",
this->Name));
format("{}: Tank=\"{}\", requested sizing for max capacity but entered Recovery Time is zero.", RoutineName, this->Name));
}
this->MaxCapacity = tmpMaxCapacity;
BaseSizer::reportSizerOutput(state, this->Type, this->Name, "Maximum Heater Capacity [W]", this->MaxCapacity);
Expand Down Expand Up @@ -11800,13 +11829,42 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state)
break;
}
case SizingMode::PerSolarColArea: {

this->Sizing.TotalSolarCollectorArea = 0.0;
if (state.dataSolarCollectors->GetInputFlag) {
SolarCollectors::GetSolarCollectorInput(state);
state.dataSolarCollectors->GetInputFlag = false;
}

for (int CollectorNum = 1; CollectorNum <= state.dataSolarCollectors->NumOfCollectors; ++CollectorNum) {
this->Sizing.TotalSolarCollectorArea += state.dataSurface->Surface(state.dataSolarCollectors->Collector(CollectorNum).Surface).Area;
auto const &collector = state.dataSolarCollectors->Collector(CollectorNum);
this->Sizing.TotalSolarCollectorArea += state.dataSurface->Surface(collector.Surface).Area;
}

if (state.dataPhotovoltaicThermalCollector->GetInputFlag) {
PhotovoltaicThermalCollectors::GetPVTcollectorsInput(state);
state.dataPhotovoltaicThermalCollector->GetInputFlag = false;
}

for (int CollectorNum = 1; CollectorNum <= state.dataPhotovoltaicThermalCollector->NumPVT; ++CollectorNum) {
auto const &collector = state.dataPhotovoltaicThermalCollector->PVT(CollectorNum);
this->Sizing.TotalSolarCollectorArea += collector.AreaCol;

if (this->VolumeWasAutoSized) {
if (this->Sizing.TotalSolarCollectorArea > 0) {
tmpTankVolume = this->Sizing.TotalSolarCollectorArea * this->Sizing.TankCapacityPerCollectorArea;
} else {
ShowFatalError(state,
format("{}: Tank=\"{}\", requested sizing for volume with PerSolarCollectorArea but total found "
"area of Collectors is zero.",
RoutineName,
this->Name));
}
}
if (this->MaxCapacityWasAutoSized) {
tmpMaxCapacity = 0.0;
}

if (this->VolumeWasAutoSized) tmpTankVolume = this->Sizing.TotalSolarCollectorArea * this->Sizing.TankCapacityPerCollectorArea;
if (this->MaxCapacityWasAutoSized) tmpMaxCapacity = 0.0;
if (this->VolumeWasAutoSized) {
this->Volume = tmpTankVolume;
BaseSizer::reportSizerOutput(state, this->Type, this->Name, "Tank Volume [m3]", this->Volume);
Expand All @@ -11818,7 +11876,9 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state)
break;
}
default:
if (this->MaxCapacityWasAutoSized) this->setBackupElementCapacity(state);
if (this->MaxCapacityWasAutoSized) {
this->setBackupElementCapacity(state);
}
break;
}
}
Expand Down

3 comments on commit 8bd188b

@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.

10574_WaterHeater_Autosizing_NaN (jmarrec) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: Build Failed

Failures:\n

API Test Summary

  • Failed: 10
  • notrun: 5

Build Badge Test Badge Coverage 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.

10574_WaterHeater_Autosizing_NaN (jmarrec) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: Build Failed

Failures:\n

integration Test Summary

  • Passed: 2
  • Failed: 790

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.

10574_WaterHeater_Autosizing_NaN (jmarrec) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: Tests Failed (0 of 0 tests passed, 0 test warnings)

Build Badge Test Badge

Please sign in to comment.