LCOV - code coverage report
Current view: top level - EnergyPlus - ReturnAirPathManager.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 27 84 32.1 %
Date: 2023-01-17 19:17:23 Functions: 5 7 71.4 %

          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             : // ObjexxFCL Headers
      49             : #include <ObjexxFCL/Array.functions.hh>
      50             : #include <ObjexxFCL/Fmath.hh>
      51             : 
      52             : // EnergyPlus Headers
      53             : #include <AirflowNetwork/Solver.hpp>
      54             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      55             : #include <EnergyPlus/DataHVACGlobals.hh>
      56             : #include <EnergyPlus/DataIPShortCuts.hh>
      57             : #include <EnergyPlus/DataLoopNode.hh>
      58             : #include <EnergyPlus/DataZoneEquipment.hh>
      59             : #include <EnergyPlus/GeneralRoutines.hh>
      60             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      61             : #include <EnergyPlus/MixerComponent.hh>
      62             : #include <EnergyPlus/NodeInputManager.hh>
      63             : #include <EnergyPlus/ReturnAirPathManager.hh>
      64             : #include <EnergyPlus/UtilityRoutines.hh>
      65             : #include <EnergyPlus/ZonePlenum.hh>
      66             : 
      67             : namespace EnergyPlus {
      68             : 
      69             : namespace ReturnAirPathManager {
      70             :     // Module containing the routines dealing with the AirLoopHVAC:ReturnPath (formerly Return Air Path)
      71             : 
      72             :     // MODULE INFORMATION:
      73             :     //       AUTHOR         Russ Taylor
      74             :     //       DATE WRITTEN   January 1998
      75             :     //       MODIFIED       Lawrie, September 1999 -- consolidate ReturnAirPath data structure
      76             :     //       RE-ENGINEERED  na
      77             : 
      78             :     // PURPOSE OF THIS MODULE:
      79             :     // To manage the return air path.
      80             : 
      81     6050562 :     void SimReturnAirPath(EnergyPlusData &state)
      82             :     {
      83             : 
      84             :         // SUBROUTINE INFORMATION:
      85             :         //       AUTHOR:          Russ Taylor
      86             :         //       DATE WRITTEN:    Nov 1997
      87             : 
      88             :         // Locals
      89             :         int ReturnAirPathNum;
      90             : 
      91             :         // Obtains and Allocates Mixer related parameters from input file
      92     6050562 :         if (state.dataRetAirPathMrg->GetInputFlag) { // First time subroutine has been entered
      93         770 :             GetReturnAirPathInput(state);
      94         770 :             state.dataRetAirPathMrg->GetInputFlag = false;
      95             :         }
      96             : 
      97    16413337 :         for (ReturnAirPathNum = 1; ReturnAirPathNum <= state.dataZoneEquip->NumReturnAirPaths; ++ReturnAirPathNum) {
      98    10362775 :             CalcReturnAirPath(state, ReturnAirPathNum);
      99             :         }
     100     6050562 :     }
     101             : 
     102         770 :     void GetReturnAirPathInput(EnergyPlusData &state)
     103             :     {
     104             :         // SUBROUTINE INFORMATION:
     105             :         //       AUTHOR:          Russ Taylor
     106             :         //       DATE WRITTEN:    Nov 1997
     107             : 
     108             :         // PURPOSE OF THIS SUBROUTINE: This subroutine
     109             : 
     110             :         // Using/Aliasing
     111             :         using NodeInputManager::GetOnlySingleNode;
     112             :         using namespace DataLoopNode;
     113             : 
     114             :         // Locals
     115             :         int PathNum;
     116             :         int CompNum;
     117             :         int NumAlphas;
     118             :         int NumNums;
     119             :         int IOStat;
     120             :         int Counter;
     121             :         //////////// hoisted into namespace ////////////////////////////////////////////////
     122             :         // static bool ErrorsFound( false );
     123             :         ////////////////////////////////////////////////////////////////////////////////////
     124             :         bool IsNotOK; // Flag to verify name
     125             : 
     126         770 :         bool ErrorsFound = false;
     127             : 
     128         770 :         if (allocated(state.dataZoneEquip->ReturnAirPath)) {
     129         770 :             return;
     130             :         }
     131           0 :         auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject;
     132           0 :         cCurrentModuleObject = "AirLoopHVAC:ReturnPath";
     133           0 :         state.dataZoneEquip->NumReturnAirPaths = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
     134             : 
     135           0 :         if (state.dataZoneEquip->NumReturnAirPaths > 0) {
     136             : 
     137           0 :             state.dataZoneEquip->ReturnAirPath.allocate(state.dataZoneEquip->NumReturnAirPaths);
     138             : 
     139           0 :             for (PathNum = 1; PathNum <= state.dataZoneEquip->NumReturnAirPaths; ++PathNum) {
     140             : 
     141           0 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
     142             :                                                                          cCurrentModuleObject,
     143             :                                                                          PathNum,
     144           0 :                                                                          state.dataIPShortCut->cAlphaArgs,
     145             :                                                                          NumAlphas,
     146           0 :                                                                          state.dataIPShortCut->rNumericArgs,
     147             :                                                                          NumNums,
     148             :                                                                          IOStat);
     149           0 :                 UtilityRoutines::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
     150             : 
     151           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).Name = state.dataIPShortCut->cAlphaArgs(1);
     152           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents = nint((NumAlphas - 2.0) / 2.0);
     153             : 
     154           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).OutletNodeNum =
     155           0 :                     GetOnlySingleNode(state,
     156           0 :                                       state.dataIPShortCut->cAlphaArgs(2),
     157             :                                       ErrorsFound,
     158             :                                       DataLoopNode::ConnectionObjectType::AirLoopHVACReturnPath,
     159           0 :                                       state.dataIPShortCut->cAlphaArgs(1),
     160             :                                       DataLoopNode::NodeFluidType::Air,
     161             :                                       DataLoopNode::ConnectionType::Outlet,
     162             :                                       NodeInputManager::CompFluidStream::Primary,
     163           0 :                                       ObjectIsParent);
     164             : 
     165           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType.allocate(state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents);
     166           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType = "";
     167           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).ComponentTypeEnum.allocate(state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents);
     168           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).ComponentTypeEnum = DataZoneEquipment::AirLoopHVACZone::Invalid;
     169           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).ComponentName.allocate(state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents);
     170           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).ComponentName = "";
     171           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).ComponentIndex.allocate(state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents);
     172           0 :                 state.dataZoneEquip->ReturnAirPath(PathNum).ComponentIndex = 0;
     173           0 :                 Counter = 3;
     174             : 
     175           0 :                 for (CompNum = 1; CompNum <= state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents; ++CompNum) {
     176             : 
     177           0 :                     if ((UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(Counter), "AirLoopHVAC:ZoneMixer")) ||
     178           0 :                         (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(Counter), "AirLoopHVAC:ReturnPlenum"))) {
     179             : 
     180           0 :                         state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType(CompNum) = state.dataIPShortCut->cAlphaArgs(Counter);
     181           0 :                         state.dataZoneEquip->ReturnAirPath(PathNum).ComponentName(CompNum) = state.dataIPShortCut->cAlphaArgs(Counter + 1);
     182           0 :                         ValidateComponent(state,
     183           0 :                                           state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType(CompNum),
     184           0 :                                           state.dataZoneEquip->ReturnAirPath(PathNum).ComponentName(CompNum),
     185             :                                           IsNotOK,
     186             :                                           "AirLoopHVAC:ReturnPath");
     187           0 :                         if (IsNotOK) {
     188           0 :                             ShowContinueError(state, "In AirLoopHVAC:ReturnPath =" + state.dataZoneEquip->ReturnAirPath(PathNum).Name);
     189           0 :                             ErrorsFound = true;
     190             :                         }
     191           0 :                         state.dataZoneEquip->ReturnAirPath(PathNum).ComponentTypeEnum(CompNum) = static_cast<DataZoneEquipment::AirLoopHVACZone>(
     192           0 :                             getEnumerationValue(DataZoneEquipment::AirLoopHVACTypeNamesCC, state.dataIPShortCut->cAlphaArgs(Counter)));
     193             : 
     194             :                     } else {
     195           0 :                         ShowSevereError(state, "Unhandled component type in AirLoopHVAC:ReturnPath of " + state.dataIPShortCut->cAlphaArgs(Counter));
     196           0 :                         ShowContinueError(state, "Occurs in AirLoopHVAC:ReturnPath = " + state.dataZoneEquip->ReturnAirPath(PathNum).Name);
     197           0 :                         ShowContinueError(state, "Must be \"AirLoopHVAC:ZoneMixer\" or \"AirLoopHVAC:ReturnPlenum\"");
     198           0 :                         ErrorsFound = true;
     199             :                     }
     200             : 
     201           0 :                     Counter += 2;
     202             :                 }
     203             :             }
     204             :         }
     205             : 
     206           0 :         if (ErrorsFound) {
     207           0 :             ShowFatalError(state, "Errors found getting AirLoopHVAC:ReturnPath.  Preceding condition(s) causes termination.");
     208             :         }
     209             :     }
     210             : 
     211           0 :     void InitReturnAirPath([[maybe_unused]] int &ReturnAirPathNum) // unused1208
     212             :     {
     213             :         // SUBROUTINE INFORMATION:
     214             :         //       AUTHOR:          Russ Taylor
     215             :         //       DATE WRITTEN:    Nov 1997
     216             : 
     217             :         // PURPOSE OF THIS SUBROUTINE: This subroutine
     218             : 
     219             :         // METHODOLOGY EMPLOYED:
     220             : 
     221             :         // REFERENCES:
     222             : 
     223             :         // USE STATEMENTS:
     224           0 :     }
     225             : 
     226    10362775 :     void CalcReturnAirPath(EnergyPlusData &state, int &ReturnAirPathNum)
     227             :     {
     228             :         // SUBROUTINE INFORMATION:
     229             :         //       AUTHOR:          Russ Taylor
     230             :         //       DATE WRITTEN:    Nov 1997
     231             : 
     232             :         // PURPOSE OF THIS SUBROUTINE: This subroutine
     233             : 
     234             :         // METHODOLOGY EMPLOYED:
     235             : 
     236             :         // REFERENCES:
     237             : 
     238             :         // USE STATEMENTS:
     239             : 
     240             :         // Using/Aliasing
     241             :         using MixerComponent::SimAirMixer;
     242             :         using ZonePlenum::SimAirZonePlenum;
     243             : 
     244             :         // Locals
     245             :         int ComponentNum;
     246             : 
     247    22286089 :         for (ComponentNum = 1; ComponentNum <= state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).NumOfComponents; ++ComponentNum) {
     248    11923314 :             switch (state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentTypeEnum(ComponentNum)) {
     249     9398069 :             case DataZoneEquipment::AirLoopHVACZone::Mixer: // 'AirLoopHVAC:ZoneMixer'
     250             : 
     251     9398069 :                 if (!(state.afn->AirflowNetworkFanActivated && state.afn->distribution_simulated)) {
     252    18210534 :                     SimAirMixer(state,
     253     9105267 :                                 state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentName(ComponentNum),
     254     9105267 :                                 state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentIndex(ComponentNum));
     255             :                 }
     256             : 
     257     9398069 :                 break;
     258             : 
     259     2525245 :             case DataZoneEquipment::AirLoopHVACZone::ReturnPlenum: // 'AirLoopHVAC:ReturnPlenum'
     260             : 
     261     7575735 :                 SimAirZonePlenum(state,
     262     2525245 :                                  state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentName(ComponentNum),
     263             :                                  DataZoneEquipment::AirLoopHVACZone::ReturnPlenum,
     264     2525245 :                                  state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentIndex(ComponentNum));
     265     2525245 :                 break;
     266             : 
     267           0 :             default:
     268           0 :                 ShowSevereError(state,
     269           0 :                                 "Invalid AirLoopHVAC:ReturnPath Component=" +
     270           0 :                                     state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentType(ComponentNum));
     271           0 :                 ShowContinueError(state, "Occurs in AirLoopHVAC:ReturnPath =" + state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).Name);
     272           0 :                 ShowFatalError(state, "Preceding condition causes termination.");
     273           0 :                 break;
     274             :             }
     275             :         }
     276    10362775 :     }
     277             : 
     278           0 :     void ReportReturnAirPath([[maybe_unused]] int &ReturnAirPathNum) // unused1208
     279             :     {
     280             :         // SUBROUTINE INFORMATION:
     281             :         //       AUTHOR:          Russ Taylor
     282             :         //       DATE WRITTEN:    Nov 1997
     283             : 
     284             :         // PURPOSE OF THIS SUBROUTINE: This subroutine
     285             : 
     286             :         // METHODOLOGY EMPLOYED:
     287             : 
     288             :         // REFERENCES:
     289             : 
     290             :         // USE STATEMENTS:
     291           0 :     }
     292             : 
     293             : } // namespace ReturnAirPathManager
     294             : 
     295        2313 : } // namespace EnergyPlus

Generated by: LCOV version 1.13