LCOV - code coverage report
Current view: top level - EnergyPlus - HVACDuct.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 0.0 % 75 0
Test Date: 2025-05-22 16:09:37 Functions: 0.0 % 5 0

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : // EnergyPlus Headers
      49              : #include <EnergyPlus/BranchNodeConnections.hh>
      50              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      51              : #include <EnergyPlus/DataContaminantBalance.hh>
      52              : #include <EnergyPlus/DataIPShortCuts.hh>
      53              : #include <EnergyPlus/DataLoopNode.hh>
      54              : #include <EnergyPlus/HVACDuct.hh>
      55              : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      56              : #include <EnergyPlus/NodeInputManager.hh>
      57              : #include <EnergyPlus/UtilityRoutines.hh>
      58              : 
      59              : namespace EnergyPlus {
      60              : 
      61              : namespace HVACDuct {
      62              : 
      63              :     // Module containing the routines dealing with the Duct component
      64              :     // in forced air air conditioning systems
      65              : 
      66              :     // MODULE INFORMATION:
      67              :     //       AUTHOR         Fred Buhl
      68              :     //       DATE WRITTEN   17May2005
      69              :     //       MODIFIED       na
      70              :     //       RE-ENGINEERED  na
      71              : 
      72              :     // PURPOSE OF THIS MODULE:
      73              :     // To encapsulate the data and routines required to model duct
      74              :     // components in the EnergyPlus HVAC simulation
      75              : 
      76              :     // METHODOLOGY EMPLOYED:
      77              :     // At this point ducts are passive elements in the loop that just pass inlet node
      78              :     // conditions to the outlet node. The function of a duct component is to allow the
      79              :     // definition of a bypass branch: a branch must contain at least 1 component.
      80              : 
      81              :     // REFERENCES:
      82              :     // na
      83              : 
      84              :     // OTHER NOTES:
      85              :     // na
      86              : 
      87              :     // USE STATEMENTS:
      88              :     // <use statements for data only modules>
      89              :     // Using/Aliasing
      90              :     using namespace DataLoopNode;
      91              : 
      92              :     // <use statements for access to subroutines in other modules>
      93              : 
      94              :     // Data
      95              :     // MODULE PARAMETER DEFINITIONS:
      96              :     // na
      97              : 
      98              :     // DERIVED TYPE DEFINITIONS:
      99              : 
     100              :     // MODULE VARIABLE DECLARATIONS:
     101              : 
     102              :     // SUBROUTINE SPECIFICATIONS FOR MODULE HVACDuct:
     103              : 
     104              :     // <name Public routines, optionally name Private routines within this module>
     105              : 
     106              :     // Object Data
     107              : 
     108              :     // Functions
     109              : 
     110            0 :     void SimDuct(EnergyPlusData &state,
     111              :                  std::string_view CompName,                      // name of the duct component
     112              :                  [[maybe_unused]] bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system timestep !unused1208
     113              :                  int &CompIndex                                  // index of duct component
     114              :     )
     115              :     {
     116              : 
     117              :         // SUBROUTINE INFORMATION:
     118              :         //       AUTHOR         Fred Buhl
     119              :         //       DATE WRITTEN   17May2005
     120              :         //       MODIFIED       na
     121              :         //       RE-ENGINEERED  na
     122              : 
     123              :         // PURPOSE OF THIS SUBROUTINE:
     124              :         // Manage the simulation of a duct component
     125              : 
     126              :         // Using/Aliasing
     127              : 
     128              :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     129              :         int DuctNum; // index of duct being simulated
     130              : 
     131            0 :         if (state.dataHVACDuct->GetInputFlag) {
     132            0 :             GetDuctInput(state);
     133            0 :             state.dataHVACDuct->GetInputFlag = false;
     134              :         }
     135              : 
     136              :         // Get the duct component index
     137            0 :         if (CompIndex == 0) {
     138            0 :             DuctNum = Util::FindItemInList(CompName, state.dataHVACDuct->Duct);
     139            0 :             if (DuctNum == 0) {
     140            0 :                 ShowFatalError(state, format("SimDuct: Component not found={}", CompName));
     141              :             }
     142            0 :             CompIndex = DuctNum;
     143              :         } else {
     144            0 :             DuctNum = CompIndex;
     145            0 :             if (DuctNum > state.dataHVACDuct->NumDucts || DuctNum < 1) {
     146            0 :                 ShowFatalError(state,
     147            0 :                                format("SimDuct:  Invalid CompIndex passed={}, Number of Components={}, Entered Component name={}",
     148              :                                       DuctNum,
     149            0 :                                       state.dataHVACDuct->NumDucts,
     150              :                                       CompName));
     151              :             }
     152            0 :             if (state.dataHVACDuct->CheckEquipName(DuctNum)) {
     153            0 :                 if (CompName != state.dataHVACDuct->Duct(DuctNum).Name) {
     154            0 :                     ShowFatalError(state,
     155            0 :                                    format("SimDuct: Invalid CompIndex passed={}, Component name={}, stored Component Name for that index={}",
     156              :                                           DuctNum,
     157              :                                           CompName,
     158            0 :                                           state.dataHVACDuct->Duct(DuctNum).Name));
     159              :                 }
     160            0 :                 state.dataHVACDuct->CheckEquipName(DuctNum) = false;
     161              :             }
     162              :         }
     163              : 
     164            0 :         CalcDuct(DuctNum);
     165              : 
     166            0 :         UpdateDuct(state, DuctNum);
     167              : 
     168            0 :         ReportDuct(DuctNum);
     169            0 :     }
     170              : 
     171            0 :     void GetDuctInput(EnergyPlusData &state)
     172              :     {
     173              : 
     174              :         // SUBROUTINE INFORMATION:
     175              :         //       AUTHOR         Fred Buhl
     176              :         //       DATE WRITTEN   17May2005
     177              :         //       MODIFIED       na
     178              :         //       RE-ENGINEERED  na
     179              : 
     180              :         // PURPOSE OF THIS SUBROUTINE:
     181              :         // Obtains input data for ducts and stores it in duct data structures.
     182              : 
     183              :         // METHODOLOGY EMPLOYED:
     184              :         // Uses InputProcessor "Get" routines to obtain data.
     185              : 
     186              :         // Using/Aliasing
     187              :         using BranchNodeConnections::TestCompSet;
     188              :         using NodeInputManager::GetOnlySingleNode;
     189              : 
     190              :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     191              :         int DuctNum; // duct index
     192              :         static constexpr std::string_view RoutineName("GetDuctInput:");
     193              :         int NumAlphas;           // Number of Alphas for each GetObjectItem call
     194              :         int NumNumbers;          // Number of Numbers for each GetObjectItem call
     195              :         int IOStatus;            // Used in GetObjectItem
     196            0 :         bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine
     197            0 :         auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject;
     198            0 :         cCurrentModuleObject = "Duct";
     199            0 :         state.dataHVACDuct->NumDucts = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
     200            0 :         state.dataHVACDuct->Duct.allocate(state.dataHVACDuct->NumDucts);
     201            0 :         state.dataHVACDuct->CheckEquipName.dimension(state.dataHVACDuct->NumDucts, true);
     202              : 
     203            0 :         for (DuctNum = 1; DuctNum <= state.dataHVACDuct->NumDucts; ++DuctNum) {
     204            0 :             state.dataInputProcessing->inputProcessor->getObjectItem(state,
     205              :                                                                      cCurrentModuleObject,
     206              :                                                                      DuctNum,
     207            0 :                                                                      state.dataIPShortCut->cAlphaArgs,
     208              :                                                                      NumAlphas,
     209            0 :                                                                      state.dataIPShortCut->rNumericArgs,
     210              :                                                                      NumNumbers,
     211              :                                                                      IOStatus,
     212            0 :                                                                      state.dataIPShortCut->lNumericFieldBlanks,
     213            0 :                                                                      state.dataIPShortCut->lAlphaFieldBlanks,
     214            0 :                                                                      state.dataIPShortCut->cAlphaFieldNames,
     215            0 :                                                                      state.dataIPShortCut->cNumericFieldNames);
     216              : 
     217            0 :             state.dataHVACDuct->Duct(DuctNum).Name = state.dataIPShortCut->cAlphaArgs(1);
     218            0 :             state.dataHVACDuct->Duct(DuctNum).InletNodeNum = GetOnlySingleNode(state,
     219            0 :                                                                                state.dataIPShortCut->cAlphaArgs(2),
     220              :                                                                                ErrorsFound,
     221              :                                                                                DataLoopNode::ConnectionObjectType::Duct,
     222            0 :                                                                                state.dataIPShortCut->cAlphaArgs(1),
     223              :                                                                                DataLoopNode::NodeFluidType::Air,
     224              :                                                                                DataLoopNode::ConnectionType::Inlet,
     225              :                                                                                NodeInputManager::CompFluidStream::Primary,
     226              :                                                                                ObjectIsNotParent);
     227            0 :             state.dataHVACDuct->Duct(DuctNum).OutletNodeNum = GetOnlySingleNode(state,
     228            0 :                                                                                 state.dataIPShortCut->cAlphaArgs(3),
     229              :                                                                                 ErrorsFound,
     230              :                                                                                 DataLoopNode::ConnectionObjectType::Duct,
     231            0 :                                                                                 state.dataIPShortCut->cAlphaArgs(1),
     232              :                                                                                 DataLoopNode::NodeFluidType::Air,
     233              :                                                                                 DataLoopNode::ConnectionType::Outlet,
     234              :                                                                                 NodeInputManager::CompFluidStream::Primary,
     235              :                                                                                 ObjectIsNotParent);
     236            0 :             TestCompSet(state,
     237              :                         cCurrentModuleObject,
     238            0 :                         state.dataIPShortCut->cAlphaArgs(1),
     239            0 :                         state.dataIPShortCut->cAlphaArgs(2),
     240            0 :                         state.dataIPShortCut->cAlphaArgs(3),
     241              :                         "Air Nodes");
     242              :         }
     243              : 
     244              :         // No output variables
     245              : 
     246            0 :         if (ErrorsFound) {
     247            0 :             ShowFatalError(state, format("{} Errors found in input", RoutineName));
     248              :         }
     249            0 :     }
     250              : 
     251            0 :     void CalcDuct([[maybe_unused]] int const DuctNum) // number of the current duct being simulated !unused1208
     252              :     {
     253              : 
     254              :         // SUBROUTINE INFORMATION:
     255              :         //       AUTHOR         Fred Buhl
     256              :         //       DATE WRITTEN   17May2005
     257              :         //       MODIFIED       na
     258              :         //       RE-ENGINEERED  na
     259              : 
     260              :         // PURPOSE OF THIS SUBROUTINE:
     261              :         // na
     262              : 
     263              :         // METHODOLOGY EMPLOYED:
     264              :         // na
     265              : 
     266              :         // REFERENCES:
     267              :         // na
     268              : 
     269              :         // USE STATEMENTS:
     270              :         // na
     271              : 
     272              :         // Locals
     273              :         // SUBROUTINE ARGUMENT DEFINITIONS:
     274              : 
     275              :         // SUBROUTINE PARAMETER DEFINITIONS:
     276              :         // na
     277              : 
     278              :         // INTERFACE BLOCK SPECIFICATIONS:
     279              :         // na
     280              : 
     281              :         // DERIVED TYPE DEFINITIONS:
     282              :         // na
     283              : 
     284              :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     285              :         // na
     286            0 :     }
     287              : 
     288            0 :     void UpdateDuct(EnergyPlusData &state, int const DuctNum) // number of the current duct being simulated
     289              :     {
     290              : 
     291              :         // SUBROUTINE INFORMATION:
     292              :         //       AUTHOR         Fred Buhl
     293              :         //       DATE WRITTEN   17May2005
     294              :         //       MODIFIED       na
     295              :         //       RE-ENGINEERED  na
     296              : 
     297              :         // PURPOSE OF THIS SUBROUTINE:
     298              :         // Moves duct output to the outlet nodes
     299              : 
     300              :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     301              :         int InNode;  // inlet node number
     302              :         int OutNode; // outlet node number
     303              : 
     304            0 :         InNode = state.dataHVACDuct->Duct(DuctNum).InletNodeNum;
     305            0 :         OutNode = state.dataHVACDuct->Duct(DuctNum).OutletNodeNum;
     306              :         // Set the outlet air node conditions of the duct
     307            0 :         state.dataLoopNodes->Node(OutNode).MassFlowRate = state.dataLoopNodes->Node(InNode).MassFlowRate;
     308            0 :         state.dataLoopNodes->Node(OutNode).Temp = state.dataLoopNodes->Node(InNode).Temp;
     309            0 :         state.dataLoopNodes->Node(OutNode).HumRat = state.dataLoopNodes->Node(InNode).HumRat;
     310            0 :         state.dataLoopNodes->Node(OutNode).Enthalpy = state.dataLoopNodes->Node(InNode).Enthalpy;
     311            0 :         state.dataLoopNodes->Node(OutNode).Quality = state.dataLoopNodes->Node(InNode).Quality;
     312            0 :         state.dataLoopNodes->Node(OutNode).Press = state.dataLoopNodes->Node(InNode).Press;
     313            0 :         state.dataLoopNodes->Node(OutNode).MassFlowRateMin = state.dataLoopNodes->Node(InNode).MassFlowRateMin;
     314            0 :         state.dataLoopNodes->Node(OutNode).MassFlowRateMax = state.dataLoopNodes->Node(InNode).MassFlowRateMax;
     315            0 :         state.dataLoopNodes->Node(OutNode).MassFlowRateMinAvail = state.dataLoopNodes->Node(InNode).MassFlowRateMinAvail;
     316            0 :         state.dataLoopNodes->Node(OutNode).MassFlowRateMaxAvail = state.dataLoopNodes->Node(InNode).MassFlowRateMaxAvail;
     317              : 
     318            0 :         if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
     319            0 :             state.dataLoopNodes->Node(OutNode).CO2 = state.dataLoopNodes->Node(InNode).CO2;
     320              :         }
     321              : 
     322            0 :         if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
     323            0 :             state.dataLoopNodes->Node(OutNode).GenContam = state.dataLoopNodes->Node(InNode).GenContam;
     324              :         }
     325            0 :     }
     326              : 
     327            0 :     void ReportDuct([[maybe_unused]] int const DuctNum) // number of the current duct being simulated !unused1208
     328              :     {
     329              : 
     330              :         // SUBROUTINE INFORMATION:
     331              :         //       AUTHOR         Fred Buhl
     332              :         //       DATE WRITTEN   17May2005
     333              :         //       MODIFIED       na
     334              :         //       RE-ENGINEERED  na
     335              : 
     336              :         // PURPOSE OF THIS SUBROUTINE:
     337              :         // Fill remaining report variables
     338              : 
     339              :         // METHODOLOGY EMPLOYED:
     340              :         // na
     341              : 
     342              :         // REFERENCES:
     343              :         // na
     344              : 
     345              :         // USE STATEMENTS:
     346              :         // na
     347              : 
     348              :         // Locals
     349              :         // SUBROUTINE ARGUMENT DEFINITIONS:
     350              : 
     351              :         // SUBROUTINE PARAMETER DEFINITIONS:
     352              :         // na
     353              : 
     354              :         // INTERFACE BLOCK SPECIFICATIONS:
     355              :         // na
     356              : 
     357              :         // DERIVED TYPE DEFINITIONS:
     358              :         // na
     359              : 
     360              :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     361              :         // na
     362            0 :     }
     363              : 
     364              : } // namespace HVACDuct
     365              : 
     366              : } // namespace EnergyPlus
        

Generated by: LCOV version 2.0-1