-
Notifications
You must be signed in to change notification settings - Fork 490
Coil API Refactor (Part III -- move GetCoilInputs to init_state())
#11548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 33 commits
52503e8
1ddc567
1ca4b76
d9ad532
c59795d
cf33963
dc338d5
0a5070f
4260454
9fc6e17
abb2299
8507a61
e11d842
3554729
8d28919
3738b27
7652af7
09e445d
d27b11e
89a5c56
dcb8b45
c75d9e1
f06cd9f
28bdcb3
36a3756
13b803c
1021a14
67efbe4
22e7b66
a0ee495
7a26972
063c08b
1a95bb0
aee7a8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12640,6 +12640,7 @@ namespace AirflowNetwork { | |
| DuctSizingSBFlag = true; | ||
| } | ||
| while (NodeNum1 != NodeSplitter) { | ||
| bool foundNextDuct = false; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this boolean as part of a trapdoor to prevent an infinite loop failure. This came up in one of the failing unit tests, it then failed more normally, but the approach itself is risky. |
||
| for (AFNLinkNum1 = 1; AFNLinkNum1 <= AirflowNetworkNumOfLinks; AFNLinkNum1++) { | ||
| if (NodeNum1 != AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[0]) { | ||
| continue; | ||
|
|
@@ -12659,10 +12660,14 @@ namespace AirflowNetwork { | |
| DynamicLoss += disSysCompDuct.TurDynCoef; | ||
| NodeNum1 = AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[1]; | ||
| DuctSizingSTFlag = true; | ||
| foundNextDuct = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (!foundNextDuct) { | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (DuctSizingSTFlag) { | ||
|
|
@@ -12761,6 +12766,7 @@ namespace AirflowNetwork { | |
| DuctSizingSBFlag = true; | ||
| } | ||
| while (NodeNum1 != NodeSplitter) { | ||
| bool foundNextDuct = false; | ||
| for (AFNLinkNum1 = 1; AFNLinkNum1 <= AirflowNetworkNumOfLinks; AFNLinkNum1++) { | ||
| if (NodeNum1 != AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[1]) { | ||
| continue; | ||
|
|
@@ -12780,10 +12786,14 @@ namespace AirflowNetwork { | |
| DynamicLoss += disSysCompDuct.TurDynCoef; | ||
| NodeNum1 = AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[0]; | ||
| DuctSizingSBFlag = true; | ||
| foundNextDuct = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (!foundNextDuct) { | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (DuctSizingSBFlag) { | ||
|
|
@@ -12886,6 +12896,7 @@ namespace AirflowNetwork { | |
| DuctSizingRTFlag = true; | ||
| } | ||
| while (NodeNum1 != NodeMixer) { | ||
| bool foundNextDuct = false; | ||
| for (AFNLinkNum1 = 1; AFNLinkNum1 <= AirflowNetworkNumOfLinks; AFNLinkNum1++) { | ||
| if (NodeNum1 != AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[1]) { | ||
| continue; | ||
|
|
@@ -12905,10 +12916,14 @@ namespace AirflowNetwork { | |
| DynamicLoss += disSysCompDuct.TurDynCoef; | ||
| NodeNum1 = AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[0]; | ||
| DuctSizingRTFlag = true; | ||
| foundNextDuct = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (!foundNextDuct) { | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (DuctSizingRTFlag) { | ||
|
|
@@ -13009,6 +13024,7 @@ namespace AirflowNetwork { | |
| DuctSizingRBFlag = true; | ||
| } | ||
| while (NodeNum1 != NodeMixer) { | ||
| bool foundNextDuct = false; | ||
| for (AFNLinkNum1 = 1; AFNLinkNum1 <= AirflowNetworkNumOfLinks; AFNLinkNum1++) { | ||
| if (NodeNum1 != AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[0]) { | ||
| continue; | ||
|
|
@@ -13028,10 +13044,14 @@ namespace AirflowNetwork { | |
| DynamicLoss += disSysCompDuct.TurDynCoef; | ||
| NodeNum1 = AirflowNetworkLinkageData(AFNLinkNum1).NodeNums[1]; | ||
| DuctSizingRBFlag = true; | ||
| foundNextDuct = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (!foundNextDuct) { | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| if (DuctSizingRBFlag) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2039,6 +2039,16 @@ void SetUpCompSets(EnergyPlusData &state, | |
| Node::ConnectionObjectType ComponentTypeEnum = static_cast<Node::ConnectionObjectType>(getEnumValue(ConnectionObjectTypeNamesUC, CompTypeUC)); | ||
| assert(ComponentTypeEnum != Node::ConnectionObjectType::Invalid); | ||
|
|
||
| auto const compSetSource = [&]() { | ||
| if (ParentTypeEnum == Node::ConnectionObjectType::Undefined) { | ||
| return Node::CompSetSource::ComponentRegistration; | ||
| } | ||
| if (ParentTypeEnum == Node::ConnectionObjectType::Branch) { | ||
| return Node::CompSetSource::BranchTopology; | ||
| } | ||
| return Node::CompSetSource::ParentChild; | ||
| }(); | ||
|
Comment on lines
+2042
to
+2053
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another helper to work out branch connections. |
||
|
|
||
| int Found = 0; | ||
|
|
||
| // See if Component-Nodes set is already there - should be unique | ||
|
|
@@ -2080,123 +2090,21 @@ void SetUpCompSets(EnergyPlusData &state, | |
| if (!Description.empty()) { | ||
| state.dataBranchNodeConnections->CompSets(Count).Description = Description; | ||
| } | ||
| state.dataBranchNodeConnections->CompSets(Count).Source = compSetSource; | ||
| Found = Count; | ||
| break; | ||
| } | ||
| } | ||
| if (Found == 0) { | ||
| for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) { | ||
| Found = 0; | ||
| // Test if inlet node has been used before as an inlet node | ||
| // If the matching node name does not belong to the parent object, then error | ||
| // For example a fan may share the same inlet node as the furnace object which is its parent | ||
| if (InletNode != state.dataBranchNodeConnections->CompSets(Count).InletNodeName) { | ||
| continue; | ||
| // If parent type is undefined then no error | ||
| } | ||
| if ((ParentTypeEnum == Node::ConnectionObjectType::Undefined) || | ||
| (state.dataBranchNodeConnections->CompSets(Count).ParentObjectType == Node::ConnectionObjectType::Undefined)) { | ||
| // If node name is undefined then no error | ||
| } else if (InletNode != undefined) { | ||
| // If the matching node name does not belong to the parent or child object, then error | ||
| // For example a fan may share the same inlet node as the furnace object which is its parent | ||
| if ((ParentTypeEnum == state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType) && | ||
| (ParentName == state.dataBranchNodeConnections->CompSets(Count).CName)) { | ||
| // OK - The duplicate inlet node belongs to this component's parent | ||
| } else if ((ComponentTypeEnum == state.dataBranchNodeConnections->CompSets(Count).ParentObjectType) && | ||
|
Comment on lines
-2095
to
-2106
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a lot of if-then-else in this block that has been removed. I think all of the paths are accounted for now, but this in particular needs a careful review. |
||
| (CompName == state.dataBranchNodeConnections->CompSets(Count).ParentCName)) { | ||
| // OK - The duplicate inlet node belongs to a child of this component | ||
| } else { | ||
| // Due to possibility of grandparents or more, if the matching node name | ||
| // belongs to a component that appears as a parent, then OK | ||
| int Found2 = 0; | ||
| for (int Count2 = 1; Count2 <= state.dataBranchNodeConnections->NumCompSets; ++Count2) { | ||
| if ((state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType == | ||
| state.dataBranchNodeConnections->CompSets(Count2).ParentObjectType) && | ||
| (state.dataBranchNodeConnections->CompSets(Count).CName == | ||
| state.dataBranchNodeConnections->CompSets(Count2).ParentCName)) { | ||
| Found2 = 1; | ||
| } | ||
| if ((ComponentTypeEnum == state.dataBranchNodeConnections->CompSets(Count2).ParentObjectType) && | ||
| (CompName == state.dataBranchNodeConnections->CompSets(Count2).ParentCName)) { | ||
| Found2 = 1; | ||
| } | ||
| } | ||
| if (Found2 == 0) { | ||
| ShowWarningError(state, std::format("Node used as an inlet more than once: {}", InletNode)); | ||
| ShowContinueError( | ||
| state, | ||
| std::format( | ||
| " Used by: {}, name={}", | ||
| ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ParentObjectType)], | ||
| state.dataBranchNodeConnections->CompSets(Count).ParentCName)); | ||
| ShowContinueError( | ||
| state, | ||
| std::format( | ||
| " as inlet for: {}, name={}", | ||
| ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)], | ||
| state.dataBranchNodeConnections->CompSets(Count).CName)); | ||
| ShowContinueError(state, std::format("{}{}{}", " and by : ", ParentTypeUC + ", name=", ParentName)); | ||
| ShowContinueError(state, std::format("{}{}{}", " as inlet for: ", CompTypeUC + ", name=", CompName)); | ||
| } | ||
| } | ||
| } | ||
| // Test if outlet node has been used before as an outlet node | ||
| // If the matching node name does not belong to the parent or child object, then error | ||
| // For example a fan may share the same outlet node as the furnace object which is its parent | ||
| if (OutletNode != state.dataBranchNodeConnections->CompSets(Count).OutletNodeName) { | ||
| continue; | ||
| // If parent type is undefined then no error | ||
| } | ||
| if ((ParentTypeEnum == Node::ConnectionObjectType::Undefined) || | ||
| (state.dataBranchNodeConnections->CompSets(Count).ParentObjectType == Node::ConnectionObjectType::Undefined)) { | ||
| // If node name is undefined then no error | ||
| } else if (OutletNode != undefined) { | ||
| if ((ParentTypeEnum == state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType) && | ||
| (ParentName == state.dataBranchNodeConnections->CompSets(Count).CName)) { | ||
| // OK - The duplicate outlet node belongs to this component's parent | ||
| } else if ((ComponentTypeEnum == state.dataBranchNodeConnections->CompSets(Count).ParentObjectType) && | ||
| (CompName == state.dataBranchNodeConnections->CompSets(Count).ParentCName)) { | ||
| // OK - The duplicate outlet node belongs to a child of this component | ||
| } else { | ||
| // Due to possibility of grandparents or more, if the matching node name | ||
| // belongs to a component that appears as a parent, then OK | ||
| int Found2 = 0; | ||
| for (int Count2 = 1; Count2 <= state.dataBranchNodeConnections->NumCompSets; ++Count2) { | ||
| if ((state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType == | ||
| state.dataBranchNodeConnections->CompSets(Count2).ParentObjectType) && | ||
| (state.dataBranchNodeConnections->CompSets(Count).CName == | ||
| state.dataBranchNodeConnections->CompSets(Count2).ParentCName)) { | ||
| Found2 = 1; | ||
| } | ||
| if ((ComponentTypeEnum == state.dataBranchNodeConnections->CompSets(Count2).ParentObjectType) && | ||
| (CompName == state.dataBranchNodeConnections->CompSets(Count2).ParentCName)) { | ||
| Found2 = 1; | ||
| } | ||
| } | ||
| // This rule is violated by dual duct units, so let it pass | ||
| if (Found2 == 0) { | ||
| std::string_view const CType = | ||
| ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)]; | ||
| if ((!has_prefixi(CType, "AirTerminal:DualDuct:")) && (!has_prefixi(CompTypeUC, "AirTerminal:DualDuct:"))) { | ||
| ShowWarningError(state, std::format("Node used as an outlet more than once: {}", OutletNode)); | ||
| ShowContinueError( | ||
| state, | ||
| std::format( | ||
| " Used by: {}, name={}", | ||
| ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ParentObjectType)], | ||
| state.dataBranchNodeConnections->CompSets(Count).ParentCName)); | ||
| ShowContinueError( | ||
| state, | ||
| std::format( | ||
| " as outlet for: {}, name={}", | ||
| ConnectionObjectTypeNames[static_cast<int>(state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType)], | ||
| state.dataBranchNodeConnections->CompSets(Count).CName)); | ||
| ShowContinueError(state, std::format("{}{}{}", " and by : ", ParentTypeUC + ", name=", ParentName)); | ||
| ShowContinueError(state, std::format("{}{}{}", " as outlet for: ", CompTypeUC + ", name=", CompName)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| if (compSetSource != state.dataBranchNodeConnections->CompSets(Count).Source) { | ||
| continue; | ||
| } | ||
| if (ComponentTypeEnum != state.dataBranchNodeConnections->CompSets(Count).ComponentObjectType && | ||
| ComponentTypeEnum != Node::ConnectionObjectType::Undefined) { | ||
|
|
@@ -2227,6 +2135,7 @@ void SetUpCompSets(EnergyPlusData &state, | |
| } else { | ||
| state.dataBranchNodeConnections->CompSets(state.dataBranchNodeConnections->NumCompSets).Description = undefined; | ||
| } | ||
| state.dataBranchNodeConnections->CompSets(state.dataBranchNodeConnections->NumCompSets).Source = compSetSource; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -2243,11 +2152,14 @@ void TestInletOutletNodes(EnergyPlusData &state) | |
|
|
||
| Array1D_bool AlreadyNoted; | ||
|
|
||
| // Test component sets created by branches | ||
| // Test component sets created by branch input only. | ||
| AlreadyNoted.dimension(state.dataBranchNodeConnections->NumCompSets, false); | ||
| for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) { | ||
| if (state.dataBranchNodeConnections->CompSets(Count).Source != Node::CompSetSource::BranchTopology) { | ||
| continue; | ||
| } | ||
| for (int Other = 1; Other <= state.dataBranchNodeConnections->NumCompSets; ++Other) { | ||
| if (Count == Other) { | ||
| if (Count == Other || state.dataBranchNodeConnections->CompSets(Other).Source != Node::CompSetSource::BranchTopology) { | ||
| continue; | ||
| } | ||
| if (state.dataBranchNodeConnections->CompSets(Count).InletNodeName != state.dataBranchNodeConnections->CompSets(Other).InletNodeName) { | ||
|
|
@@ -2290,8 +2202,11 @@ void TestInletOutletNodes(EnergyPlusData &state) | |
|
|
||
| AlreadyNoted = false; | ||
| for (int Count = 1; Count <= state.dataBranchNodeConnections->NumCompSets; ++Count) { | ||
| if (state.dataBranchNodeConnections->CompSets(Count).Source != Node::CompSetSource::BranchTopology) { | ||
| continue; | ||
| } | ||
| for (int Other = 1; Other <= state.dataBranchNodeConnections->NumCompSets; ++Other) { | ||
| if (Count == Other) { | ||
| if (Count == Other || state.dataBranchNodeConnections->CompSets(Other).Source != Node::CompSetSource::BranchTopology) { | ||
| continue; | ||
| } | ||
| if (state.dataBranchNodeConnections->CompSets(Count).OutletNodeName != state.dataBranchNodeConnections->CompSets(Other).OutletNodeName) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure where these changes came from. Most of it is formatting, but develop is merged in, and this looks like part of the
EnergyPlus::formatconversion work. Probably safe to ignore.