LCOV - code coverage report
Current view: top level - EnergyPlus - Pipes.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 85 87 97.7 %
Date: 2023-01-17 19:17:23 Functions: 7 8 87.5 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, 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        5370 : 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        5370 :     if (state.dataPipes->GetPipeInputFlag) {
      82         438 :         GetPipeInput(state);
      83         438 :         state.dataPipes->GetPipeInputFlag = false;
      84             :     }
      85             :     // Now look for this particular pipe in the list
      86       42008 :     for (auto &pipe : state.dataPipes->LocalPipe) {
      87       42008 :         if (pipe.Type == objectType && pipe.Name == objectName) {
      88        5370 :             return &pipe;
      89             :         }
      90             :     }
      91             :     // If we didn't find it, fatal
      92             :     ShowFatalError(state, "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   169534249 : 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   169534249 :     if (state.dataGlobal->BeginEnvrnFlag && this->EnvrnFlag) {
     105       33080 :         this->initEachEnvironment(state);
     106       33080 :         this->EnvrnFlag = false;
     107             :     }
     108             : 
     109   169534249 :     if (!state.dataGlobal->BeginEnvrnFlag) this->EnvrnFlag = true;
     110             : 
     111   169534249 :     PlantUtilities::SafeCopyPlantNode(state, this->InletNodeNum, this->OutletNodeNum, this->plantLoc.loopNum);
     112   169534249 : }
     113             : 
     114        5370 : void LocalPipeData::oneTimeInit_new(EnergyPlusData &state)
     115             : {
     116        5370 :     int FoundOnLoop = 0;
     117        5370 :     bool errFlag = false;
     118        5370 :     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        5370 :     if (FoundOnLoop == 0) {
     123             :         ShowFatalError(state, "SimPipes: Pipe=\"" + this->Name + "\" not found on a Plant Loop."); // LCOV_EXCL_LINE
     124             :     }
     125             : #pragma clang diagnostic pop
     126        5370 :     if (errFlag) {
     127             :         ShowFatalError(state, "SimPipes: Program terminated due to previous condition(s)."); // LCOV_EXCL_LINE
     128             :     }
     129        5370 : }
     130             : 
     131       33080 : void LocalPipeData::initEachEnvironment(EnergyPlusData &state) const
     132             : {
     133       33080 :     PlantUtilities::InitComponentNodes(
     134       33080 :         state, 0.0, state.dataPlnt->PlantLoop(this->plantLoc.loopNum).MaxMassFlowRate, this->InletNodeNum, this->OutletNodeNum);
     135       33080 : }
     136           0 : void LocalPipeData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
     137             : {
     138           0 : }
     139             : 
     140         438 : 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         438 :     int PipeNum = 0;
     154         438 :     int NumAlphas = 0; // Number of elements in the alpha array
     155         438 :     int NumNums = 0;   // Number of elements in the numeric array
     156         438 :     int IOStat = 0;    // IO Status when calling get input subroutine
     157         438 :     bool ErrorsFound(false);
     158             : 
     159             :     // GET NUMBER OF ALL EQUIPMENT TYPES
     160         438 :     int NumWaterPipes = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Pipe:Adiabatic");
     161         438 :     int NumSteamPipes = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Pipe:Adiabatic:Steam");
     162         438 :     int const NumLocalPipes = NumWaterPipes + NumSteamPipes;
     163         438 :     state.dataPipes->LocalPipe.allocate(NumLocalPipes);
     164         438 :     state.dataPipes->LocalPipeUniqueNames.reserve(static_cast<unsigned>(NumLocalPipes));
     165         438 :     auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject;
     166         438 :     cCurrentModuleObject = "Pipe:Adiabatic";
     167        5776 :     for (int PipeWaterNum = 1; PipeWaterNum <= NumWaterPipes; ++PipeWaterNum) {
     168        5338 :         ++PipeNum;
     169       16014 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
     170             :                                                                  cCurrentModuleObject,
     171             :                                                                  PipeWaterNum,
     172        5338 :                                                                  state.dataIPShortCut->cAlphaArgs,
     173             :                                                                  NumAlphas,
     174        5338 :                                                                  state.dataIPShortCut->rNumericArgs,
     175             :                                                                  NumNums,
     176             :                                                                  IOStat);
     177        5338 :         GlobalNames::VerifyUniqueInterObjectName(
     178        5338 :             state, state.dataPipes->LocalPipeUniqueNames, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
     179        5338 :         state.dataPipes->LocalPipe(PipeNum).Name = state.dataIPShortCut->cAlphaArgs(1);
     180        5338 :         state.dataPipes->LocalPipe(PipeNum).Type = DataPlant::PlantEquipmentType::Pipe;
     181             : 
     182        5338 :         state.dataPipes->LocalPipe(PipeNum).InletNodeNum = GetOnlySingleNode(state,
     183        5338 :                                                                              state.dataIPShortCut->cAlphaArgs(2),
     184             :                                                                              ErrorsFound,
     185             :                                                                              DataLoopNode::ConnectionObjectType::PipeAdiabatic,
     186        5338 :                                                                              state.dataIPShortCut->cAlphaArgs(1),
     187             :                                                                              DataLoopNode::NodeFluidType::Water,
     188             :                                                                              DataLoopNode::ConnectionType::Inlet,
     189             :                                                                              NodeInputManager::CompFluidStream::Primary,
     190        5338 :                                                                              DataLoopNode::ObjectIsNotParent);
     191        5338 :         state.dataPipes->LocalPipe(PipeNum).OutletNodeNum = GetOnlySingleNode(state,
     192        5338 :                                                                               state.dataIPShortCut->cAlphaArgs(3),
     193             :                                                                               ErrorsFound,
     194             :                                                                               DataLoopNode::ConnectionObjectType::PipeAdiabatic,
     195        5338 :                                                                               state.dataIPShortCut->cAlphaArgs(1),
     196             :                                                                               DataLoopNode::NodeFluidType::Water,
     197             :                                                                               DataLoopNode::ConnectionType::Outlet,
     198             :                                                                               NodeInputManager::CompFluidStream::Primary,
     199        5338 :                                                                               DataLoopNode::ObjectIsNotParent);
     200       10676 :         TestCompSet(state,
     201             :                     cCurrentModuleObject,
     202        5338 :                     state.dataIPShortCut->cAlphaArgs(1),
     203        5338 :                     state.dataIPShortCut->cAlphaArgs(2),
     204        5338 :                     state.dataIPShortCut->cAlphaArgs(3),
     205             :                     "Pipe Nodes");
     206             :     }
     207             : 
     208         438 :     PipeNum = NumWaterPipes;
     209         438 :     cCurrentModuleObject = "Pipe:Adiabatic:Steam";
     210             : 
     211         470 :     for (int PipeSteamNum = 1; PipeSteamNum <= NumSteamPipes; ++PipeSteamNum) {
     212          32 :         ++PipeNum;
     213          96 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
     214             :                                                                  cCurrentModuleObject,
     215             :                                                                  PipeSteamNum,
     216          32 :                                                                  state.dataIPShortCut->cAlphaArgs,
     217             :                                                                  NumAlphas,
     218          32 :                                                                  state.dataIPShortCut->rNumericArgs,
     219             :                                                                  NumNums,
     220             :                                                                  IOStat);
     221          32 :         GlobalNames::VerifyUniqueInterObjectName(
     222          32 :             state, state.dataPipes->LocalPipeUniqueNames, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
     223          32 :         state.dataPipes->LocalPipe(PipeNum).Name = state.dataIPShortCut->cAlphaArgs(1);
     224          32 :         state.dataPipes->LocalPipe(PipeNum).Type = DataPlant::PlantEquipmentType::PipeSteam;
     225          32 :         state.dataPipes->LocalPipe(PipeNum).InletNodeNum = GetOnlySingleNode(state,
     226          32 :                                                                              state.dataIPShortCut->cAlphaArgs(2),
     227             :                                                                              ErrorsFound,
     228             :                                                                              DataLoopNode::ConnectionObjectType::PipeAdiabaticSteam,
     229          32 :                                                                              state.dataIPShortCut->cAlphaArgs(1),
     230             :                                                                              DataLoopNode::NodeFluidType::Steam,
     231             :                                                                              DataLoopNode::ConnectionType::Inlet,
     232             :                                                                              NodeInputManager::CompFluidStream::Primary,
     233          32 :                                                                              DataLoopNode::ObjectIsNotParent);
     234          32 :         state.dataPipes->LocalPipe(PipeNum).OutletNodeNum = GetOnlySingleNode(state,
     235          32 :                                                                               state.dataIPShortCut->cAlphaArgs(3),
     236             :                                                                               ErrorsFound,
     237             :                                                                               DataLoopNode::ConnectionObjectType::PipeAdiabaticSteam,
     238          32 :                                                                               state.dataIPShortCut->cAlphaArgs(1),
     239             :                                                                               DataLoopNode::NodeFluidType::Steam,
     240             :                                                                               DataLoopNode::ConnectionType::Outlet,
     241             :                                                                               NodeInputManager::CompFluidStream::Primary,
     242          32 :                                                                               DataLoopNode::ObjectIsNotParent);
     243          64 :         TestCompSet(state,
     244             :                     cCurrentModuleObject,
     245          32 :                     state.dataIPShortCut->cAlphaArgs(1),
     246          32 :                     state.dataIPShortCut->cAlphaArgs(2),
     247          32 :                     state.dataIPShortCut->cAlphaArgs(3),
     248             :                     "Pipe Nodes");
     249             :     }
     250             : 
     251         438 :     if (ErrorsFound) {
     252             :         ShowFatalError(state, "GetPipeInput: Errors getting input for pipes"); // LCOV_EXCL_LINE
     253             :     }
     254         438 : }
     255             : 
     256        2313 : } // namespace EnergyPlus::Pipes

Generated by: LCOV version 1.13