Skip to content

Commit

Permalink
Fix view factor aggregation.
Browse files Browse the repository at this point in the history
  • Loading branch information
nealkruis committed Aug 6, 2021
1 parent 7677a1c commit f8b05c7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/EnergyPlus/DataViewFactorInformation.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace DataViewFactorInformation {
std::vector<std::string> ZoneNames; // Zone names which are part of this enclosure
std::vector<int> ZoneNums; // Zones which are part of this enclosure
int NumOfSurfaces; // Number of surfaces in the enclosure
Array2D<Real64> F; // View Factors
Array2D<Real64> F; // View Factors: F(i,j) = from surface j to surface i (counter-intuitive, but optimized for performance)
Array2D<Real64> ScriptF; // Hottel's Script F //Tuned Transposed
Array1D<Real64> Area; // Surface area
Array1D<Real64> Emissivity; // Surface emissivity
Expand Down
82 changes: 59 additions & 23 deletions src/EnergyPlus/HeatBalanceIntRadExchange.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1329,34 +1329,70 @@ namespace HeatBalanceIntRadExchange {
state.dataIPShortCut->cAlphaFieldNames,
state.dataIPShortCut->cNumericFieldNames);

if (NumNums < pow_2(N)) {
ShowWarningError(state, "GetInputViewFactors: " + cCurrentModuleObject + "=\"" + EnclosureName + "\", not enough values.");
ShowContinueError(
state,
format("...Number of input values [{}] is less than the required number=[{}] Missing surface pairs will have a zero view factor.",
NumNums,
pow_2(N)));
}
F = 0.0;
numinx1 = 0;
if (!state.dataSurface->UseRepresentativeSurfaceCalculations) {
if (NumNums < pow_2(N)) {
ShowWarningError(state, "GetInputViewFactors: " + cCurrentModuleObject + "=\"" + EnclosureName + "\", not enough values.");
ShowContinueError(
state,
format("...Number of input values [{}] is less than the required number=[{}] Missing surface pairs will have a zero view factor.",
NumNums,
pow_2(N)));
}

// TODO: Automatic Window Multipliers, throw error if view factors aren't the same for representative surfaces
for (index = 2; index <= NumAlphas; index += 2) {
inx1 = UtilityRoutines::FindItemInList(state.dataIPShortCut->cAlphaArgs(index), enclosureSurfaceNames, N);
inx2 = UtilityRoutines::FindItemInList(state.dataIPShortCut->cAlphaArgs(index + 1), enclosureSurfaceNames, N);
if (inx1 == 0) {
ShowSevereError(state, "GetInputViewFactors: " + cCurrentModuleObject + "=\"" + EnclosureName + "\", invalid surface name.");
ShowContinueError(state, "...Surface name=\"" + state.dataIPShortCut->cAlphaArgs(index) + "\", not in this zone or enclosure.");
ErrorsFound = true;
for (index = 2; index <= NumAlphas; index += 2) {
inx1 = UtilityRoutines::FindItemInList(state.dataIPShortCut->cAlphaArgs(index), enclosureSurfaceNames, N);
inx2 = UtilityRoutines::FindItemInList(state.dataIPShortCut->cAlphaArgs(index + 1), enclosureSurfaceNames, N);
if (inx1 == 0) {
ShowSevereError(state, "GetInputViewFactors: " + cCurrentModuleObject + "=\"" + EnclosureName + "\", invalid surface name.");
ShowContinueError(state, "...Surface name=\"" + state.dataIPShortCut->cAlphaArgs(index) + "\", not in this zone or enclosure.");
ErrorsFound = true;
}
if (inx2 == 0) {
ShowSevereError(state, "GetInputViewFactors: " + cCurrentModuleObject + "=\"" + EnclosureName + "\", invalid surface name.");
ShowContinueError(state,
"...Surface name=\"" + state.dataIPShortCut->cAlphaArgs(index + 2) + "\", not in this zone or enclosure.");
ErrorsFound = true;
}
++numinx1;
if (inx1 > 0 && inx2 > 0) F(inx2, inx1) = state.dataIPShortCut->rNumericArgs(numinx1);
}
if (inx2 == 0) {
ShowSevereError(state, "GetInputViewFactors: " + cCurrentModuleObject + "=\"" + EnclosureName + "\", invalid surface name.");
ShowContinueError(state,
"...Surface name=\"" + state.dataIPShortCut->cAlphaArgs(index + 2) + "\", not in this zone or enclosure.");
ErrorsFound = true;
} else {

// Aggregate view factors for representative surfaces
for (index = 2; index <= NumAlphas; index += 2) {
int fromSurfNum = UtilityRoutines::FindItemInList(state.dataIPShortCut->cAlphaArgs(index), state.dataSurface->Surface, N);
int toSurfNum = UtilityRoutines::FindItemInList(state.dataIPShortCut->cAlphaArgs(index + 1), state.dataSurface->Surface, N);
if (fromSurfNum == 0) {
ShowSevereError(state, "GetInputViewFactors: " + cCurrentModuleObject + "=\"" + EnclosureName + "\", invalid surface name.");
ShowContinueError(state, "...Surface name=\"" + state.dataIPShortCut->cAlphaArgs(index) + "\", not in this zone or enclosure.");
ErrorsFound = true;
}
if (toSurfNum == 0) {
ShowSevereError(state, "GetInputViewFactors: " + cCurrentModuleObject + "=\"" + EnclosureName + "\", invalid surface name.");
ShowContinueError(state,
"...Surface name=\"" + state.dataIPShortCut->cAlphaArgs(index + 2) + "\", not in this zone or enclosure.");
ErrorsFound = true;
}
++numinx1;
if (fromSurfNum > 0 && toSurfNum > 0) {
auto &fromSurf = state.dataSurface->Surface(fromSurfNum);
auto &toSurf = state.dataSurface->Surface(toSurfNum);
int repFromSurfNum = fromSurf.RepresentativeCalcSurfNum;
int repToSurfNum = toSurf.RepresentativeCalcSurfNum;
// "From" surfaces within a representative group should all have the same view factors to the other surfaces
// "To" surfaces within a representative group should aggregate the view factors from other surfaces
if (fromSurfNum == repFromSurfNum) {
auto &repFromSurf = state.dataSurface->Surface(repFromSurfNum);
auto &repToSurf = state.dataSurface->Surface(repToSurfNum);
int fromInx = UtilityRoutines::FindItemInList(repFromSurf.Name, enclosureSurfaceNames, N);
int toInx = UtilityRoutines::FindItemInList(repToSurf.Name, enclosureSurfaceNames, N);
F(toInx, fromInx) += state.dataIPShortCut->rNumericArgs(numinx1);
}
// TODO: Track view factors to ensure that "From" surfaces have similar view factors?
}
}
++numinx1;
if (inx1 > 0 && inx2 > 0) F(inx2, inx1) = state.dataIPShortCut->rNumericArgs(numinx1);
}
enclosureSurfaceNames.deallocate();
}
Expand Down

0 comments on commit f8b05c7

Please sign in to comment.