Skip to content

Commit

Permalink
Merge pull request #10577 from NREL/10574_WaterHeater_Autosizing_NaN
Browse files Browse the repository at this point in the history
Fix #10574 - Deal with BIPVT for WaterHeater sizing and throw error if Total Collector area found is zero
  • Loading branch information
Myoldmopar authored Jul 25, 2024
2 parents f2cf440 + 4ee8bcb commit 047575a
Show file tree
Hide file tree
Showing 2 changed files with 344 additions and 17 deletions.
77 changes: 60 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,31 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state)
} else if (this->Sizing.DesignMode == SizingMode::PerSolarColArea) {

this->Sizing.TotalSolarCollectorArea = 0.0;

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;
}

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 +11304,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 +11598,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 +11820,34 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state)
break;
}
case SizingMode::PerSolarColArea: {

this->Sizing.TotalSolarCollectorArea = 0.0;

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;
}

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 +11859,9 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state)
break;
}
default:
if (this->MaxCapacityWasAutoSized) this->setBackupElementCapacity(state);
if (this->MaxCapacityWasAutoSized) {
this->setBackupElementCapacity(state);
}
break;
}
}
Expand Down
Loading

0 comments on commit 047575a

Please sign in to comment.