LCOV - code coverage report
Current view: top level - EnergyPlus - PlantValves.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 146 165 88.5 %
Date: 2024-08-24 18:31:18 Functions: 7 8 87.5 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, 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 <algorithm>
      50             : 
      51             : // ObjexxFCL Headers
      52             : #include <ObjexxFCL/Array.functions.hh>
      53             : 
      54             : // EnergyPlus Headers
      55             : #include <EnergyPlus/BranchNodeConnections.hh>
      56             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      57             : #include <EnergyPlus/DataBranchAirLoopPlant.hh>
      58             : #include <EnergyPlus/DataHVACGlobals.hh>
      59             : #include <EnergyPlus/DataIPShortCuts.hh>
      60             : #include <EnergyPlus/DataLoopNode.hh>
      61             : #include <EnergyPlus/General.hh>
      62             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      63             : #include <EnergyPlus/NodeInputManager.hh>
      64             : #include <EnergyPlus/OutputProcessor.hh>
      65             : #include <EnergyPlus/Plant/DataPlant.hh>
      66             : #include <EnergyPlus/PlantUtilities.hh>
      67             : #include <EnergyPlus/PlantValves.hh>
      68             : #include <EnergyPlus/UtilityRoutines.hh>
      69             : 
      70             : namespace EnergyPlus {
      71             : 
      72             : namespace PlantValves {
      73             : 
      74             :     // Module containing the routines dealing with the <module_name>
      75             : 
      76             :     // MODULE INFORMATION:
      77             :     //       AUTHOR         B. Griffith
      78             :     //       DATE WRITTEN   Jan, 2006
      79             :     //       MODIFIED       Nov 2010, B. Griffith, plant upgrades
      80             :     //       RE-ENGINEERED  na
      81             : 
      82             :     // PURPOSE OF THIS MODULE:
      83             :     // Collect "valve" type models for Plant loops
      84             : 
      85             :     using namespace DataLoopNode;
      86             : 
      87           2 :     PlantComponent *TemperValveData::factory(EnergyPlusData &state, std::string objectName)
      88             :     {
      89             :         // Process the input data for valves if it hasn't been done already
      90           2 :         if (state.dataPlantValves->GetTemperingValves) {
      91           2 :             GetPlantValvesInput(state);
      92           2 :             state.dataPlantValves->GetTemperingValves = false;
      93             :         }
      94             :         // Now look for this particular pipe in the list
      95           2 :         for (auto &valve : state.dataPlantValves->TemperValve) {
      96           2 :             if (valve.Name == objectName) {
      97           2 :                 return &valve;
      98             :             }
      99           4 :         }
     100             :         // If we didn't find it, fatal
     101             :         ShowFatalError(state, format("TemperValveDataFactory: Error getting inputs for valve named: {}", objectName)); // LCOV_EXCL_LINE
     102             :         // Shut up the compiler
     103             :         return nullptr; // LCOV_EXCL_LINE
     104             :     }
     105             : 
     106       32532 :     void TemperValveData::simulate(EnergyPlusData &state,
     107             :                                    [[maybe_unused]] const PlantLocation &calledFromLocation,
     108             :                                    [[maybe_unused]] bool FirstHVACIteration,
     109             :                                    [[maybe_unused]] Real64 &CurLoad,
     110             :                                    [[maybe_unused]] bool RunFlag)
     111             :     {
     112       32532 :         this->initialize(state);
     113       32532 :         this->calculate(state);
     114       32532 :         PlantUtilities::SafeCopyPlantNode(state, this->PltInletNodeNum, this->PltOutletNodeNum);
     115       32532 :         Real64 mdot = this->MixedMassFlowRate * this->FlowDivFract;
     116       32532 :         if (this->plantLoc.loopNum > 0) {
     117       32530 :             PlantUtilities::SetComponentFlowRate(state, mdot, this->PltInletNodeNum, this->PltOutletNodeNum, this->plantLoc);
     118             :         }
     119       32532 :     }
     120             : 
     121          10 :     void TemperValveData::getDesignCapacities([[maybe_unused]] EnergyPlusData &state,
     122             :                                               [[maybe_unused]] const PlantLocation &calledFromLocation,
     123             :                                               Real64 &MaxLoad,
     124             :                                               Real64 &MinLoad,
     125             :                                               Real64 &OptLoad)
     126             :     {
     127          10 :         MaxLoad = 0.0;
     128          10 :         MinLoad = 0.0;
     129          10 :         OptLoad = 0.0;
     130          10 :     }
     131             : 
     132           2 :     void GetPlantValvesInput(EnergyPlusData &state)
     133             :     {
     134             : 
     135             :         // SUBROUTINE INFORMATION:
     136             :         //       AUTHOR         Brent Griffith
     137             :         //       DATE WRITTEN   Jan. 2006
     138             :         //       MODIFIED       na
     139             :         //       RE-ENGINEERED  na
     140             : 
     141             :         // PURPOSE OF THIS SUBROUTINE:
     142             :         // get input from user
     143             : 
     144             :         // METHODOLOGY EMPLOYED:
     145             :         // usual method using InputProcessor
     146             : 
     147             :         // Using/Aliasing
     148             :         using BranchNodeConnections::TestCompSet;
     149             :         using NodeInputManager::GetOnlySingleNode;
     150             : 
     151             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     152             :         int Item;                        // Item to be "gotten"
     153           2 :         Array1D_string Alphas(6);        // Alpha items for object
     154           2 :         Array1D<Real64> Numbers(1);      // Numeric items for object
     155             :         int NumAlphas;                   // Number of Alphas for each GetObjectItem call
     156             :         int NumNumbers;                  // Number of Numbers for each GetObjectItem call
     157             :         int IOStatus;                    // Used in GetObjectItem
     158           2 :         bool ErrorsFound(false);         // Set to true if errors in input, fatal at end of routine
     159           2 :         std::string CurrentModuleObject; // for ease in renaming.
     160             : 
     161           2 :         CurrentModuleObject = "TemperingValve";
     162           2 :         state.dataPlantValves->NumTemperingValves = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     163             : 
     164           2 :         state.dataPlantValves->TemperValve.allocate(state.dataPlantValves->NumTemperingValves);
     165             : 
     166           4 :         for (Item = 1; Item <= state.dataPlantValves->NumTemperingValves; ++Item) {
     167             : 
     168           2 :             state.dataInputProcessing->inputProcessor->getObjectItem(
     169             :                 state, CurrentModuleObject, Item, Alphas, NumAlphas, Numbers, NumNumbers, IOStatus);
     170             :             //  <process, noting errors>
     171           2 :             state.dataPlantValves->TemperValve(Item).Name = Alphas(1);
     172             :             // Get Plant Inlet Node
     173           4 :             state.dataPlantValves->TemperValve(Item).PltInletNodeNum = GetOnlySingleNode(state,
     174           2 :                                                                                          Alphas(2),
     175             :                                                                                          ErrorsFound,
     176             :                                                                                          DataLoopNode::ConnectionObjectType::TemperingValve,
     177           2 :                                                                                          Alphas(1),
     178             :                                                                                          DataLoopNode::NodeFluidType::Water,
     179             :                                                                                          DataLoopNode::ConnectionType::Inlet,
     180             :                                                                                          NodeInputManager::CompFluidStream::Primary,
     181             :                                                                                          ObjectIsNotParent);
     182             :             // Get Plant Outlet Node
     183           4 :             state.dataPlantValves->TemperValve(Item).PltOutletNodeNum = GetOnlySingleNode(state,
     184           2 :                                                                                           Alphas(3),
     185             :                                                                                           ErrorsFound,
     186             :                                                                                           DataLoopNode::ConnectionObjectType::TemperingValve,
     187           2 :                                                                                           Alphas(1),
     188             :                                                                                           DataLoopNode::NodeFluidType::Water,
     189             :                                                                                           DataLoopNode::ConnectionType::Outlet,
     190             :                                                                                           NodeInputManager::CompFluidStream::Primary,
     191             :                                                                                           ObjectIsNotParent);
     192             : 
     193             :             // Get Stream 2 Source Node
     194           4 :             state.dataPlantValves->TemperValve(Item).PltStream2NodeNum = GetOnlySingleNode(state,
     195           2 :                                                                                            Alphas(4),
     196             :                                                                                            ErrorsFound,
     197             :                                                                                            DataLoopNode::ConnectionObjectType::TemperingValve,
     198           2 :                                                                                            Alphas(1),
     199             :                                                                                            DataLoopNode::NodeFluidType::Water,
     200             :                                                                                            DataLoopNode::ConnectionType::Sensor,
     201             :                                                                                            NodeInputManager::CompFluidStream::Primary,
     202             :                                                                                            ObjectIsNotParent);
     203             :             // Get Mixed water Setpoint
     204           4 :             state.dataPlantValves->TemperValve(Item).PltSetPointNodeNum = GetOnlySingleNode(state,
     205           2 :                                                                                             Alphas(5),
     206             :                                                                                             ErrorsFound,
     207             :                                                                                             DataLoopNode::ConnectionObjectType::TemperingValve,
     208           2 :                                                                                             Alphas(1),
     209             :                                                                                             DataLoopNode::NodeFluidType::Water,
     210             :                                                                                             DataLoopNode::ConnectionType::SetPoint,
     211             :                                                                                             NodeInputManager::CompFluidStream::Primary,
     212             :                                                                                             ObjectIsNotParent);
     213             : 
     214             :             // Get Pump outlet
     215           4 :             state.dataPlantValves->TemperValve(Item).PltPumpOutletNodeNum = GetOnlySingleNode(state,
     216           2 :                                                                                               Alphas(6),
     217             :                                                                                               ErrorsFound,
     218             :                                                                                               DataLoopNode::ConnectionObjectType::TemperingValve,
     219           2 :                                                                                               Alphas(1),
     220             :                                                                                               DataLoopNode::NodeFluidType::Water,
     221             :                                                                                               DataLoopNode::ConnectionType::Sensor,
     222             :                                                                                               NodeInputManager::CompFluidStream::Primary,
     223             :                                                                                               ObjectIsNotParent);
     224             : 
     225             :             // Note most checks on user input are made in second pass thru init routine
     226             : 
     227           2 :             TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(2), Alphas(3), "Supply Side Water Nodes");
     228             :         }
     229             : 
     230           4 :         for (Item = 1; Item <= state.dataPlantValves->NumTemperingValves; ++Item) {
     231             : 
     232           4 :             SetupOutputVariable(state,
     233             :                                 "Tempering Valve Flow Fraction",
     234             :                                 Constant::Units::None,
     235           2 :                                 state.dataPlantValves->TemperValve(Item).FlowDivFract,
     236             :                                 OutputProcessor::TimeStepType::System,
     237             :                                 OutputProcessor::StoreType::Average,
     238           2 :                                 state.dataPlantValves->TemperValve(Item).Name);
     239             :         }
     240             : 
     241           2 :         if (ErrorsFound) {
     242           0 :             ShowFatalError(state, format("GetPlantValvesInput: {} Errors found in input", CurrentModuleObject));
     243             :         }
     244           2 :     }
     245             : 
     246       32532 :     void TemperValveData::initialize(EnergyPlusData &state)
     247             :     {
     248             : 
     249             :         // SUBROUTINE INFORMATION:
     250             :         //       AUTHOR         B. Griffith, NREL
     251             :         //       DATE WRITTEN   Jan. 2006
     252             :         //       MODIFIED       na
     253             :         //       RE-ENGINEERED  na
     254             : 
     255             :         // PURPOSE OF THIS SUBROUTINE:
     256             :         // initialize data for valve modeling
     257             : 
     258             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     259             :         int InletNode;   // local working variable for inlet node number
     260             :         int OutletNode;  // local working variable for outlet node number
     261             :         int Strm2Node;   // local working variable for stream 2 outlet node number
     262             :         int SetPntNode;  // local working variable for setpoint node number
     263             :         int PumpOutNode; // local working variable for pump outlet node number
     264             : 
     265             :         bool InNodeOnSplitter; // input data check
     266             :         bool PumpOutNodeOkay;  // input data check
     267             :         bool ErrorsFound;      // input data check
     268             :         bool TwoBranchesBetwn; // input data check
     269             :         bool SetPointNodeOkay; // input data check
     270             :         bool Stream2NodeOkay;  // input data check
     271             :         bool IsBranchActive;   // input data check
     272             : 
     273             :         bool errFlag;
     274             : 
     275       32532 :         if (state.dataPlantValves->OneTimeInitFlag) {
     276           2 :             state.dataPlantValves->OneTimeInitFlag = false;
     277             :         } else {
     278             :             // delay checks one pass so more of plant data structure gets filled in
     279       32530 :             if (this->compDelayedInitFlag) {
     280             :                 // do some checks on input data
     281             :                 // Search thru PlantLoop Data Structure to check some things.
     282             :                 // Locate the component on the plant loops for later usage
     283           2 :                 errFlag = false;
     284           4 :                 PlantUtilities::ScanPlantLoopsForObject(
     285           2 :                     state, this->Name, DataPlant::PlantEquipmentType::ValveTempering, this->plantLoc, errFlag, _, _, _, _, _);
     286             : 
     287           2 :                 if (errFlag) {
     288           0 :                     ShowFatalError(state, "InitPlantValves: Program terminated due to previous condition(s).");
     289             :                 }
     290             :                 // init logical flags
     291           2 :                 ErrorsFound = false;
     292           2 :                 InNodeOnSplitter = false;
     293           2 :                 PumpOutNodeOkay = false;
     294           2 :                 TwoBranchesBetwn = false;
     295           2 :                 SetPointNodeOkay = false;
     296           2 :                 Stream2NodeOkay = false;
     297           2 :                 IsBranchActive = false;
     298             : 
     299             :                 // . A) find indexes of PlantLoop, Half loop, and Branch by searching CompData
     300           6 :                 for (auto &thisPlantLoop : state.dataPlnt->PlantLoop) {
     301          12 :                     for (auto &thisLoopSide : thisPlantLoop.LoopSide) {
     302           8 :                         int branchCtr = 0;
     303          40 :                         for (auto &thisBranch : thisLoopSide.Branch) {
     304          32 :                             branchCtr++;
     305          65 :                             for (auto &thisComp : thisBranch.Comp) {
     306             : 
     307          35 :                                 if ((thisComp.Type == DataPlant::PlantEquipmentType::ValveTempering) &&
     308           2 :                                     (thisComp.Name == this->Name)) { // we found it.
     309             : 
     310             :                                     // is branch control type 'Active'
     311           2 :                                     if (thisBranch.controlType == DataBranchAirLoopPlant::ControlType::Active) IsBranchActive = true;
     312             : 
     313             :                                     // is Valve inlet node an outlet node of a splitter
     314           2 :                                     if (thisLoopSide.Splitter.Exists) {
     315           2 :                                         if (allocated(thisLoopSide.Splitter.NodeNumOut)) {
     316           2 :                                             if (any_eq(thisLoopSide.Splitter.NodeNumOut, this->PltInletNodeNum)) {
     317           2 :                                                 InNodeOnSplitter = true;
     318             :                                             }
     319             :                                         } // allocated
     320             : 
     321             :                                         // are there only 2 branches between splitter and mixer?
     322           2 :                                         if (thisLoopSide.Splitter.TotalOutletNodes == 2) {
     323           2 :                                             TwoBranchesBetwn = true;
     324             :                                         }
     325             :                                     } // has splitter
     326             : 
     327             :                                     // is stream 2 node an inlet to the mixer ?
     328           2 :                                     if (thisLoopSide.Mixer.Exists) {
     329           2 :                                         if (any_eq(thisLoopSide.Mixer.NodeNumIn, this->PltStream2NodeNum)) {
     330           2 :                                             int thisInnerBranchCtr = 0;
     331          10 :                                             for (auto &thisInnerBranch : thisLoopSide.Branch) {
     332           8 :                                                 thisInnerBranchCtr++;
     333           8 :                                                 if (branchCtr == thisInnerBranchCtr) continue; // already looped into this one
     334          12 :                                                 for (auto &thisInnerComp : thisInnerBranch.Comp) {
     335           6 :                                                     if (thisInnerComp.NodeNumOut == this->PltStream2NodeNum) {
     336           2 :                                                         Stream2NodeOkay = true;
     337             :                                                     }
     338             :                                                 }
     339             :                                             }
     340             :                                         }
     341             :                                     } // has mixer
     342             : 
     343             :                                     // is pump node really the outlet of a branch with a pump?
     344          10 :                                     for (auto &thisInnerBranch : thisLoopSide.Branch) {
     345           8 :                                         if (thisInnerBranch.NodeNumOut == this->PltPumpOutletNodeNum) {
     346           4 :                                             for (auto &thisInnerComp : thisInnerBranch.Comp) {
     347           2 :                                                 if (DataPlant::PlantEquipmentTypeIsPump[static_cast<int>(thisInnerComp.Type)]) {
     348           2 :                                                     PumpOutNodeOkay = true;
     349             :                                                 }
     350             :                                             }
     351             :                                         }
     352             :                                     }
     353             : 
     354             :                                     // does sensor node agree with plant loop setpoint?
     355           2 :                                     if (thisPlantLoop.TempSetPointNodeNum == this->PltSetPointNodeNum) {
     356           2 :                                         SetPointNodeOkay = true;
     357             :                                     }
     358             : 
     359             :                                 } // found item
     360             : 
     361             :                             } // comps
     362             :                         }     // Branches
     363             :                     }         // Loop Sides
     364             :                 }             // Plant loops
     365             : 
     366           2 :                 if (!IsBranchActive) {
     367           0 :                     ShowSevereError(state, "TemperingValve object needs to be on an ACTIVE branch");
     368           0 :                     ErrorsFound = true;
     369             :                 }
     370             : 
     371           2 :                 if (!InNodeOnSplitter) {
     372           0 :                     ShowSevereError(state, "TemperingValve object needs to be between a Splitter and Mixer");
     373           0 :                     ErrorsFound = true;
     374             :                 }
     375             : 
     376           2 :                 if (!PumpOutNodeOkay) {
     377           0 :                     ShowSevereError(state, "TemperingValve object needs to reference a node that is the outlet of a pump on its loop");
     378           0 :                     ErrorsFound = true;
     379             :                 }
     380             : 
     381           2 :                 if (!TwoBranchesBetwn) {
     382           0 :                     ShowSevereError(state, "TemperingValve object needs exactly two branches between a Splitter and Mixer");
     383           0 :                     ErrorsFound = true;
     384             :                 }
     385             : 
     386           2 :                 if (!SetPointNodeOkay) {
     387           0 :                     ShowSevereError(state, "TemperingValve object setpoint node not valid.  Check Setpoint manager for Plant Loop Temp Setpoint");
     388           0 :                     ErrorsFound = true;
     389             :                 }
     390             : 
     391           2 :                 if (!Stream2NodeOkay) {
     392           0 :                     ShowSevereError(state, "TemperingValve object stream 2 source node not valid.");
     393           0 :                     ShowContinueError(state, "Check that node is a component outlet, enters a mixer, and on the other branch");
     394           0 :                     ErrorsFound = true;
     395             :                 }
     396           2 :                 if (ErrorsFound) {
     397           0 :                     ShowFatalError(state, format("Errors found in input, TemperingValve object {}", this->Name));
     398             :                 }
     399           2 :                 this->compDelayedInitFlag = false;
     400             :             } // my two time flag for input checking
     401             : 
     402             :         } // my one time flag for input checking
     403             : 
     404       32532 :         InletNode = this->PltInletNodeNum;
     405       32532 :         OutletNode = this->PltOutletNodeNum;
     406       32532 :         Strm2Node = this->PltStream2NodeNum;
     407       32532 :         SetPntNode = this->PltSetPointNodeNum;
     408       32532 :         PumpOutNode = this->PltPumpOutletNodeNum;
     409             : 
     410       32532 :         if (state.dataGlobal->BeginEnvrnFlag && this->environmentInit) {
     411             : 
     412          12 :             if ((InletNode > 0) && (OutletNode > 0)) {
     413             :                 //   Node(InletNode)%Temp = 0.0
     414          24 :                 PlantUtilities::InitComponentNodes(
     415          12 :                     state, 0.0, state.dataLoopNodes->Node(PumpOutNode).MassFlowRateMax, this->PltInletNodeNum, this->PltOutletNodeNum);
     416             :             }
     417          12 :             this->environmentInit = false;
     418             :         }
     419             : 
     420       32532 :         if (!state.dataGlobal->BeginEnvrnFlag) this->environmentInit = true;
     421             : 
     422       32532 :         if (InletNode > 0) {
     423       32532 :             this->InletTemp = state.dataLoopNodes->Node(InletNode).Temp;
     424             :         }
     425       32532 :         if (Strm2Node > 0) {
     426       32532 :             this->Stream2SourceTemp = state.dataLoopNodes->Node(Strm2Node).Temp;
     427             :         }
     428       32532 :         if (SetPntNode > 0) {
     429       32532 :             this->SetPointTemp = state.dataLoopNodes->Node(SetPntNode).TempSetPoint;
     430             :         }
     431       32532 :         if (PumpOutNode > 0) {
     432       32532 :             this->MixedMassFlowRate = state.dataLoopNodes->Node(PumpOutNode).MassFlowRate;
     433             :         }
     434       32532 :     }
     435             : 
     436       32532 :     void TemperValveData::calculate(EnergyPlusData &state)
     437             :     {
     438             : 
     439             :         // SUBROUTINE INFORMATION:
     440             :         //       AUTHOR         B. Griffith, NREL
     441             :         //       DATE WRITTEN   Jan. 2006
     442             :         //       MODIFIED       na
     443             :         //       RE-ENGINEERED  na
     444             : 
     445             :         // PURPOSE OF THIS SUBROUTINE:
     446             :         //  This routine does the calculations for Valves.
     447             :         //  Currently only one type of valve, for Tempering.
     448             : 
     449             :         // METHODOLOGY EMPLOYED:
     450             :         //   Tempering valve calculations involve computing a flow fraction
     451             :         //     that should be diverted.  See update routine for setting flow rates.
     452             : 
     453             :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     454             :         Real64 Tin;  // local working variable for Inlet Temperature (C)
     455             :         Real64 Tset; // local working variable for Setpoint Temperature (C)
     456             :         Real64 Ts2;  // local Working Variable for Stream 2 outlet Temperature (C)
     457             : 
     458       32532 :         if (state.dataGlobal->KickOffSimulation) return;
     459             : 
     460       32232 :         if (state.dataPlnt->PlantLoop(this->plantLoc.loopNum).LoopSide(this->plantLoc.loopSideNum).FlowLock == DataPlant::FlowLock::Unlocked) {
     461       16116 :             Tin = this->InletTemp;
     462       16116 :             Tset = this->SetPointTemp;
     463       16116 :             Ts2 = this->Stream2SourceTemp;
     464             : 
     465       16116 :             if (Ts2 <= Tset) {
     466       14942 :                 this->FlowDivFract = 0.0;
     467             :             } else { // Divert some or all flow
     468        1174 :                 if (Tin < Ts2) {
     469        1174 :                     this->FlowDivFract = (Ts2 - Tset) / (Ts2 - Tin);
     470             :                 } else {
     471           0 :                     this->FlowDivFract = 1.0;
     472             :                 }
     473             :             }
     474       16116 :         } else if (state.dataPlnt->PlantLoop(this->plantLoc.loopNum).LoopSide(this->plantLoc.loopSideNum).FlowLock ==
     475             :                    DataPlant::FlowLock::Locked) { // don't recalc diversion, just reuse current flows
     476       16116 :             if (this->MixedMassFlowRate > 0.0) {
     477        7784 :                 this->FlowDivFract = state.dataLoopNodes->Node(this->PltOutletNodeNum).MassFlowRate / this->MixedMassFlowRate;
     478             :             } else {
     479        8332 :                 this->FlowDivFract = 0.0;
     480             :             }
     481             :         }
     482             : 
     483       32232 :         if (this->FlowDivFract < 0.0) this->FlowDivFract = 0.0;
     484       32232 :         if (this->FlowDivFract > 1.0) this->FlowDivFract = 1.0;
     485             :     }
     486           0 :     void TemperValveData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
     487             :     {
     488           0 :     }
     489           2 :     void TemperValveData::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
     490             :     {
     491           2 :     }
     492             : 
     493             : } // namespace PlantValves
     494             : 
     495             : } // namespace EnergyPlus

Generated by: LCOV version 1.14