LCOV - code coverage report
Current view: top level - EnergyPlus - PlantValves.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 150 170 88.2 %
Date: 2023-01-17 19:17:23 Functions: 9 10 90.0 %

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

Generated by: LCOV version 1.13