LCOV - code coverage report
Current view: top level - EnergyPlus - Pipes.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 97.6 % 82 80
Test Date: 2025-05-22 16:09:37 Functions: 83.3 % 6 5

            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              : // C++ Headers
      49              : #include <string>
      50              : 
      51              : // EnergyPlus Headers
      52              : #include <EnergyPlus/BranchNodeConnections.hh>
      53              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      54              : #include <EnergyPlus/DataHVACGlobals.hh>
      55              : #include <EnergyPlus/DataIPShortCuts.hh>
      56              : #include <EnergyPlus/DataLoopNode.hh>
      57              : #include <EnergyPlus/General.hh>
      58              : #include <EnergyPlus/GlobalNames.hh>
      59              : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      60              : #include <EnergyPlus/NodeInputManager.hh>
      61              : #include <EnergyPlus/Pipes.hh>
      62              : #include <EnergyPlus/Plant/DataPlant.hh>
      63              : #include <EnergyPlus/Plant/PlantLocation.hh>
      64              : #include <EnergyPlus/PlantComponent.hh>
      65              : #include <EnergyPlus/PlantUtilities.hh>
      66              : #include <EnergyPlus/UtilityRoutines.hh>
      67              : 
      68              : namespace EnergyPlus::Pipes {
      69              : 
      70              : // Module containing the routines dealing with the <module_name>
      71              : 
      72              : // MODULE INFORMATION:
      73              : //       AUTHOR         <author>
      74              : //       DATE WRITTEN   <date_written>
      75              : //       MODIFIED       Rahul Chillar , Jan 2005
      76              : //       RE-ENGINEERED  na
      77              : 
      78          270 : PlantComponent *LocalPipeData::factory(EnergyPlusData &state, DataPlant::PlantEquipmentType objectType, std::string const &objectName)
      79              : {
      80              :     // Process the input data for pipes if it hasn't been done already
      81          270 :     if (state.dataPipes->GetPipeInputFlag) {
      82           43 :         GetPipeInput(state);
      83           43 :         state.dataPipes->GetPipeInputFlag = false;
      84              :     }
      85              :     // Now look for this particular pipe in the list
      86         1205 :     for (auto &pipe : state.dataPipes->LocalPipe) {
      87         1205 :         if (pipe.Type == objectType && pipe.Name == objectName) {
      88          270 :             return &pipe;
      89              :         }
      90              :     }
      91              :     // If we didn't find it, fatal
      92              :     ShowFatalError(state, format("LocalPipeDataFactory: Error getting inputs for pipe named: {}", objectName)); // LCOV_EXCL_LINE
      93              :     // Shut up the compiler
      94              :     return nullptr; // LCOV_EXCL_LINE
      95              : }
      96              : 
      97       830224 : void LocalPipeData::simulate(EnergyPlusData &state,
      98              :                              [[maybe_unused]] const PlantLocation &calledFromLocation,
      99              :                              [[maybe_unused]] bool const FirstHVACIteration,
     100              :                              [[maybe_unused]] Real64 &CurLoad,
     101              :                              [[maybe_unused]] bool const RunFlag)
     102              : {
     103              : 
     104       830224 :     if (state.dataGlobal->BeginEnvrnFlag && this->EnvrnFlag) {
     105          388 :         this->initEachEnvironment(state);
     106          388 :         this->EnvrnFlag = false;
     107              :     }
     108              : 
     109       830224 :     if (!state.dataGlobal->BeginEnvrnFlag) this->EnvrnFlag = true;
     110              : 
     111       830224 :     PlantUtilities::SafeCopyPlantNode(state, this->InletNodeNum, this->OutletNodeNum, this->plantLoc.loopNum);
     112       830224 : }
     113              : 
     114          270 : void LocalPipeData::oneTimeInit_new(EnergyPlusData &state)
     115              : {
     116          270 :     int FoundOnLoop = 0;
     117          270 :     bool errFlag = false;
     118          270 :     PlantUtilities::ScanPlantLoopsForObject(state, this->Name, this->Type, this->plantLoc, errFlag, _, _, FoundOnLoop, _, _);
     119              :     // Clang can't tell that the FoundOnLoop argument is actually passed by reference since it is an optional, so it thinks FoundOnLoop is always 0.
     120              : #pragma clang diagnostic push
     121              : #pragma ide diagnostic ignored "ConstantConditionsOC"
     122          270 :     if (FoundOnLoop == 0) {
     123              :         ShowFatalError(state, format("SimPipes: Pipe=\"{}\" not found on a Plant Loop.", this->Name)); // LCOV_EXCL_LINE
     124              :     }
     125              : #pragma clang diagnostic pop
     126          270 :     if (errFlag) {
     127              :         ShowFatalError(state, "SimPipes: Program terminated due to previous condition(s)."); // LCOV_EXCL_LINE
     128              :     }
     129          270 : }
     130              : 
     131          388 : void LocalPipeData::initEachEnvironment(EnergyPlusData &state) const
     132              : {
     133          388 :     PlantUtilities::InitComponentNodes(
     134          388 :         state, 0.0, state.dataPlnt->PlantLoop(this->plantLoc.loopNum).MaxMassFlowRate, this->InletNodeNum, this->OutletNodeNum);
     135          388 : }
     136            0 : void LocalPipeData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
     137              : {
     138            0 : }
     139              : 
     140           44 : void GetPipeInput(EnergyPlusData &state)
     141              : {
     142              :     // SUBROUTINE INFORMATION:
     143              :     //       AUTHOR:          Dan Fisher
     144              :     //       DATE WRITTEN:    April 1998
     145              :     //       MODIFIED       na
     146              :     //       RE-ENGINEERED  na
     147              : 
     148              :     // Using/Aliasing
     149              :     using BranchNodeConnections::TestCompSet;
     150              :     using NodeInputManager::GetOnlySingleNode;
     151              : 
     152              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     153           44 :     int PipeNum = 0;
     154           44 :     int NumAlphas = 0; // Number of elements in the alpha array
     155           44 :     int NumNums = 0;   // Number of elements in the numeric array
     156           44 :     int IOStat = 0;    // IO Status when calling get input subroutine
     157           44 :     bool ErrorsFound(false);
     158              : 
     159              :     // GET NUMBER OF ALL EQUIPMENT TYPES
     160           44 :     int NumWaterPipes = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Pipe:Adiabatic");
     161           44 :     int NumSteamPipes = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Pipe:Adiabatic:Steam");
     162           44 :     int const NumLocalPipes = NumWaterPipes + NumSteamPipes;
     163           44 :     state.dataPipes->LocalPipe.allocate(NumLocalPipes);
     164           44 :     state.dataPipes->LocalPipeUniqueNames.reserve(static_cast<unsigned>(NumLocalPipes));
     165           44 :     auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject;
     166           44 :     cCurrentModuleObject = "Pipe:Adiabatic";
     167          315 :     for (int PipeWaterNum = 1; PipeWaterNum <= NumWaterPipes; ++PipeWaterNum) {
     168          271 :         ++PipeNum;
     169          542 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
     170              :                                                                  cCurrentModuleObject,
     171              :                                                                  PipeWaterNum,
     172          271 :                                                                  state.dataIPShortCut->cAlphaArgs,
     173              :                                                                  NumAlphas,
     174          271 :                                                                  state.dataIPShortCut->rNumericArgs,
     175              :                                                                  NumNums,
     176              :                                                                  IOStat);
     177          271 :         GlobalNames::VerifyUniqueInterObjectName(
     178          271 :             state, state.dataPipes->LocalPipeUniqueNames, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
     179          271 :         state.dataPipes->LocalPipe(PipeNum).Name = state.dataIPShortCut->cAlphaArgs(1);
     180          271 :         state.dataPipes->LocalPipe(PipeNum).Type = DataPlant::PlantEquipmentType::Pipe;
     181              : 
     182          542 :         state.dataPipes->LocalPipe(PipeNum).InletNodeNum = GetOnlySingleNode(state,
     183          271 :                                                                              state.dataIPShortCut->cAlphaArgs(2),
     184              :                                                                              ErrorsFound,
     185              :                                                                              DataLoopNode::ConnectionObjectType::PipeAdiabatic,
     186          271 :                                                                              state.dataIPShortCut->cAlphaArgs(1),
     187              :                                                                              DataLoopNode::NodeFluidType::Water,
     188              :                                                                              DataLoopNode::ConnectionType::Inlet,
     189              :                                                                              NodeInputManager::CompFluidStream::Primary,
     190              :                                                                              DataLoopNode::ObjectIsNotParent);
     191          542 :         state.dataPipes->LocalPipe(PipeNum).OutletNodeNum = GetOnlySingleNode(state,
     192          271 :                                                                               state.dataIPShortCut->cAlphaArgs(3),
     193              :                                                                               ErrorsFound,
     194              :                                                                               DataLoopNode::ConnectionObjectType::PipeAdiabatic,
     195          271 :                                                                               state.dataIPShortCut->cAlphaArgs(1),
     196              :                                                                               DataLoopNode::NodeFluidType::Water,
     197              :                                                                               DataLoopNode::ConnectionType::Outlet,
     198              :                                                                               NodeInputManager::CompFluidStream::Primary,
     199              :                                                                               DataLoopNode::ObjectIsNotParent);
     200          813 :         TestCompSet(state,
     201              :                     cCurrentModuleObject,
     202          271 :                     state.dataIPShortCut->cAlphaArgs(1),
     203          271 :                     state.dataIPShortCut->cAlphaArgs(2),
     204          271 :                     state.dataIPShortCut->cAlphaArgs(3),
     205              :                     "Pipe Nodes");
     206              :     }
     207              : 
     208           44 :     PipeNum = NumWaterPipes;
     209           44 :     cCurrentModuleObject = "Pipe:Adiabatic:Steam";
     210              : 
     211           45 :     for (int PipeSteamNum = 1; PipeSteamNum <= NumSteamPipes; ++PipeSteamNum) {
     212            1 :         ++PipeNum;
     213            2 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
     214              :                                                                  cCurrentModuleObject,
     215              :                                                                  PipeSteamNum,
     216            1 :                                                                  state.dataIPShortCut->cAlphaArgs,
     217              :                                                                  NumAlphas,
     218            1 :                                                                  state.dataIPShortCut->rNumericArgs,
     219              :                                                                  NumNums,
     220              :                                                                  IOStat);
     221            1 :         GlobalNames::VerifyUniqueInterObjectName(
     222            1 :             state, state.dataPipes->LocalPipeUniqueNames, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
     223            1 :         state.dataPipes->LocalPipe(PipeNum).Name = state.dataIPShortCut->cAlphaArgs(1);
     224            1 :         state.dataPipes->LocalPipe(PipeNum).Type = DataPlant::PlantEquipmentType::PipeSteam;
     225            2 :         state.dataPipes->LocalPipe(PipeNum).InletNodeNum = GetOnlySingleNode(state,
     226            1 :                                                                              state.dataIPShortCut->cAlphaArgs(2),
     227              :                                                                              ErrorsFound,
     228              :                                                                              DataLoopNode::ConnectionObjectType::PipeAdiabaticSteam,
     229            1 :                                                                              state.dataIPShortCut->cAlphaArgs(1),
     230              :                                                                              DataLoopNode::NodeFluidType::Steam,
     231              :                                                                              DataLoopNode::ConnectionType::Inlet,
     232              :                                                                              NodeInputManager::CompFluidStream::Primary,
     233              :                                                                              DataLoopNode::ObjectIsNotParent);
     234            2 :         state.dataPipes->LocalPipe(PipeNum).OutletNodeNum = GetOnlySingleNode(state,
     235            1 :                                                                               state.dataIPShortCut->cAlphaArgs(3),
     236              :                                                                               ErrorsFound,
     237              :                                                                               DataLoopNode::ConnectionObjectType::PipeAdiabaticSteam,
     238            1 :                                                                               state.dataIPShortCut->cAlphaArgs(1),
     239              :                                                                               DataLoopNode::NodeFluidType::Steam,
     240              :                                                                               DataLoopNode::ConnectionType::Outlet,
     241              :                                                                               NodeInputManager::CompFluidStream::Primary,
     242              :                                                                               DataLoopNode::ObjectIsNotParent);
     243            3 :         TestCompSet(state,
     244              :                     cCurrentModuleObject,
     245            1 :                     state.dataIPShortCut->cAlphaArgs(1),
     246            1 :                     state.dataIPShortCut->cAlphaArgs(2),
     247            1 :                     state.dataIPShortCut->cAlphaArgs(3),
     248              :                     "Pipe Nodes");
     249              :     }
     250              : 
     251           44 :     if (ErrorsFound) {
     252              :         ShowFatalError(state, "GetPipeInput: Errors getting input for pipes"); // LCOV_EXCL_LINE
     253              :     }
     254           44 : }
     255              : 
     256              : } // namespace EnergyPlus::Pipes
        

Generated by: LCOV version 2.0-1