LCOV - code coverage report
Current view: top level - EnergyPlus - PlantValves.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 0.0 % 171 0
Test Date: 2025-06-02 12:03:30 Functions: 0.0 % 8 0

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : // C++ Headers
      49              : #include <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            0 :     PlantComponent *TemperValveData::factory(EnergyPlusData &state, std::string objectName)
      88              :     {
      89              :         // Process the input data for valves if it hasn't been done already
      90            0 :         if (state.dataPlantValves->GetTemperingValves) {
      91            0 :             GetPlantValvesInput(state);
      92            0 :             state.dataPlantValves->GetTemperingValves = false;
      93              :         }
      94              :         // Now look for this particular pipe in the list
      95            0 :         for (auto &valve : state.dataPlantValves->TemperValve) {
      96            0 :             if (valve.Name == objectName) {
      97            0 :                 return &valve;
      98              :             }
      99            0 :         }
     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            0 :     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            0 :         this->initialize(state);
     113            0 :         this->calculate(state);
     114            0 :         PlantUtilities::SafeCopyPlantNode(state, this->PltInletNodeNum, this->PltOutletNodeNum);
     115            0 :         Real64 mdot = this->MixedMassFlowRate * this->FlowDivFract;
     116            0 :         if (this->plantLoc.loopNum > 0) {
     117            0 :             PlantUtilities::SetComponentFlowRate(state, mdot, this->PltInletNodeNum, this->PltOutletNodeNum, this->plantLoc);
     118              :         }
     119            0 :     }
     120              : 
     121            0 :     void TemperValveData::getDesignCapacities([[maybe_unused]] EnergyPlusData &state,
     122              :                                               [[maybe_unused]] const PlantLocation &calledFromLocation,
     123              :                                               Real64 &MaxLoad,
     124              :                                               Real64 &MinLoad,
     125              :                                               Real64 &OptLoad)
     126              :     {
     127            0 :         MaxLoad = 0.0;
     128            0 :         MinLoad = 0.0;
     129            0 :         OptLoad = 0.0;
     130            0 :     }
     131              : 
     132            0 :     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            0 :         Array1D_string Alphas(6);        // Alpha items for object
     154            0 :         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            0 :         bool ErrorsFound(false);         // Set to true if errors in input, fatal at end of routine
     159            0 :         std::string CurrentModuleObject; // for ease in renaming.
     160              : 
     161            0 :         CurrentModuleObject = "TemperingValve";
     162            0 :         state.dataPlantValves->NumTemperingValves = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     163              : 
     164            0 :         state.dataPlantValves->TemperValve.allocate(state.dataPlantValves->NumTemperingValves);
     165              : 
     166            0 :         for (Item = 1; Item <= state.dataPlantValves->NumTemperingValves; ++Item) {
     167              : 
     168            0 :             state.dataInputProcessing->inputProcessor->getObjectItem(
     169              :                 state, CurrentModuleObject, Item, Alphas, NumAlphas, Numbers, NumNumbers, IOStatus);
     170              :             //  <process, noting errors>
     171            0 :             state.dataPlantValves->TemperValve(Item).Name = Alphas(1);
     172              :             // Get Plant Inlet Node
     173            0 :             state.dataPlantValves->TemperValve(Item).PltInletNodeNum = GetOnlySingleNode(state,
     174            0 :                                                                                          Alphas(2),
     175              :                                                                                          ErrorsFound,
     176              :                                                                                          DataLoopNode::ConnectionObjectType::TemperingValve,
     177            0 :                                                                                          Alphas(1),
     178              :                                                                                          DataLoopNode::NodeFluidType::Water,
     179              :                                                                                          DataLoopNode::ConnectionType::Inlet,
     180              :                                                                                          NodeInputManager::CompFluidStream::Primary,
     181              :                                                                                          ObjectIsNotParent);
     182              :             // Get Plant Outlet Node
     183            0 :             state.dataPlantValves->TemperValve(Item).PltOutletNodeNum = GetOnlySingleNode(state,
     184            0 :                                                                                           Alphas(3),
     185              :                                                                                           ErrorsFound,
     186              :                                                                                           DataLoopNode::ConnectionObjectType::TemperingValve,
     187            0 :                                                                                           Alphas(1),
     188              :                                                                                           DataLoopNode::NodeFluidType::Water,
     189              :                                                                                           DataLoopNode::ConnectionType::Outlet,
     190              :                                                                                           NodeInputManager::CompFluidStream::Primary,
     191              :                                                                                           ObjectIsNotParent);
     192              : 
     193              :             // Get Stream 2 Source Node
     194            0 :             state.dataPlantValves->TemperValve(Item).PltStream2NodeNum = GetOnlySingleNode(state,
     195            0 :                                                                                            Alphas(4),
     196              :                                                                                            ErrorsFound,
     197              :                                                                                            DataLoopNode::ConnectionObjectType::TemperingValve,
     198            0 :                                                                                            Alphas(1),
     199              :                                                                                            DataLoopNode::NodeFluidType::Water,
     200              :                                                                                            DataLoopNode::ConnectionType::Sensor,
     201              :                                                                                            NodeInputManager::CompFluidStream::Primary,
     202              :                                                                                            ObjectIsNotParent);
     203              :             // Get Mixed water Setpoint
     204            0 :             state.dataPlantValves->TemperValve(Item).PltSetPointNodeNum = GetOnlySingleNode(state,
     205            0 :                                                                                             Alphas(5),
     206              :                                                                                             ErrorsFound,
     207              :                                                                                             DataLoopNode::ConnectionObjectType::TemperingValve,
     208            0 :                                                                                             Alphas(1),
     209              :                                                                                             DataLoopNode::NodeFluidType::Water,
     210              :                                                                                             DataLoopNode::ConnectionType::SetPoint,
     211              :                                                                                             NodeInputManager::CompFluidStream::Primary,
     212              :                                                                                             ObjectIsNotParent);
     213              : 
     214              :             // Get Pump outlet
     215            0 :             state.dataPlantValves->TemperValve(Item).PltPumpOutletNodeNum = GetOnlySingleNode(state,
     216            0 :                                                                                               Alphas(6),
     217              :                                                                                               ErrorsFound,
     218              :                                                                                               DataLoopNode::ConnectionObjectType::TemperingValve,
     219            0 :                                                                                               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            0 :             TestCompSet(state, CurrentModuleObject, Alphas(1), Alphas(2), Alphas(3), "Supply Side Water Nodes");
     228              :         }
     229              : 
     230            0 :         for (Item = 1; Item <= state.dataPlantValves->NumTemperingValves; ++Item) {
     231              : 
     232            0 :             SetupOutputVariable(state,
     233              :                                 "Tempering Valve Flow Fraction",
     234              :                                 Constant::Units::None,
     235            0 :                                 state.dataPlantValves->TemperValve(Item).FlowDivFract,
     236              :                                 OutputProcessor::TimeStepType::System,
     237              :                                 OutputProcessor::StoreType::Average,
     238            0 :                                 state.dataPlantValves->TemperValve(Item).Name);
     239              :         }
     240              : 
     241            0 :         if (ErrorsFound) {
     242            0 :             ShowFatalError(state, format("GetPlantValvesInput: {} Errors found in input", CurrentModuleObject));
     243              :         }
     244            0 :     }
     245              : 
     246            0 :     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            0 :         if (state.dataPlantValves->OneTimeInitFlag) {
     276            0 :             state.dataPlantValves->OneTimeInitFlag = false;
     277              :         } else {
     278              :             // delay checks one pass so more of plant data structure gets filled in
     279            0 :             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            0 :                 errFlag = false;
     284            0 :                 PlantUtilities::ScanPlantLoopsForObject(
     285            0 :                     state, this->Name, DataPlant::PlantEquipmentType::ValveTempering, this->plantLoc, errFlag, _, _, _, _, _);
     286              : 
     287            0 :                 if (errFlag) {
     288            0 :                     ShowFatalError(state, "InitPlantValves: Program terminated due to previous condition(s).");
     289              :                 }
     290              :                 // init logical flags
     291            0 :                 ErrorsFound = false;
     292            0 :                 InNodeOnSplitter = false;
     293            0 :                 PumpOutNodeOkay = false;
     294            0 :                 TwoBranchesBetwn = false;
     295            0 :                 SetPointNodeOkay = false;
     296            0 :                 Stream2NodeOkay = false;
     297            0 :                 IsBranchActive = false;
     298              : 
     299              :                 // . A) find indexes of PlantLoop, Half loop, and Branch by searching CompData
     300            0 :                 for (auto &thisPlantLoop : state.dataPlnt->PlantLoop) {
     301            0 :                     for (auto &thisLoopSide : thisPlantLoop.LoopSide) {
     302            0 :                         int branchCtr = 0;
     303            0 :                         for (auto const &thisBranch : thisLoopSide.Branch) {
     304            0 :                             branchCtr++;
     305            0 :                             for (auto const &thisComp : thisBranch.Comp) {
     306              : 
     307            0 :                                 if ((thisComp.Type == DataPlant::PlantEquipmentType::ValveTempering) &&
     308            0 :                                     (thisComp.Name == this->Name)) { // we found it.
     309              : 
     310              :                                     // is branch control type 'Active'
     311            0 :                                     if (thisBranch.controlType == DataBranchAirLoopPlant::ControlType::Active) {
     312            0 :                                         IsBranchActive = true;
     313              :                                     }
     314              : 
     315              :                                     // is Valve inlet node an outlet node of a splitter
     316            0 :                                     if (thisLoopSide.Splitter.Exists) {
     317            0 :                                         if (allocated(thisLoopSide.Splitter.NodeNumOut)) {
     318            0 :                                             if (any_eq(thisLoopSide.Splitter.NodeNumOut, this->PltInletNodeNum)) {
     319            0 :                                                 InNodeOnSplitter = true;
     320              :                                             }
     321              :                                         } // allocated
     322              : 
     323              :                                         // are there only 2 branches between splitter and mixer?
     324            0 :                                         if (thisLoopSide.Splitter.TotalOutletNodes == 2) {
     325            0 :                                             TwoBranchesBetwn = true;
     326              :                                         }
     327              :                                     } // has splitter
     328              : 
     329              :                                     // is stream 2 node an inlet to the mixer ?
     330            0 :                                     if (thisLoopSide.Mixer.Exists) {
     331            0 :                                         if (any_eq(thisLoopSide.Mixer.NodeNumIn, this->PltStream2NodeNum)) {
     332            0 :                                             int thisInnerBranchCtr = 0;
     333            0 :                                             for (auto const &thisInnerBranch : thisLoopSide.Branch) {
     334            0 :                                                 thisInnerBranchCtr++;
     335            0 :                                                 if (branchCtr == thisInnerBranchCtr) {
     336            0 :                                                     continue; // already looped into this one
     337              :                                                 }
     338            0 :                                                 for (auto const &thisInnerComp : thisInnerBranch.Comp) {
     339            0 :                                                     if (thisInnerComp.NodeNumOut == this->PltStream2NodeNum) {
     340            0 :                                                         Stream2NodeOkay = true;
     341              :                                                     }
     342              :                                                 }
     343              :                                             }
     344              :                                         }
     345              :                                     } // has mixer
     346              : 
     347              :                                     // is pump node really the outlet of a branch with a pump?
     348            0 :                                     for (auto const &thisInnerBranch : thisLoopSide.Branch) {
     349            0 :                                         if (thisInnerBranch.NodeNumOut == this->PltPumpOutletNodeNum) {
     350            0 :                                             for (auto const &thisInnerComp : thisInnerBranch.Comp) {
     351            0 :                                                 if (DataPlant::PlantEquipmentTypeIsPump[static_cast<int>(thisInnerComp.Type)]) {
     352            0 :                                                     PumpOutNodeOkay = true;
     353              :                                                 }
     354              :                                             }
     355              :                                         }
     356              :                                     }
     357              : 
     358              :                                     // does sensor node agree with plant loop setpoint?
     359            0 :                                     if (thisPlantLoop.TempSetPointNodeNum == this->PltSetPointNodeNum) {
     360            0 :                                         SetPointNodeOkay = true;
     361              :                                     }
     362              : 
     363              :                                 } // found item
     364              : 
     365              :                             } // comps
     366              :                         } // Branches
     367              :                     } // Loop Sides
     368              :                 } // Plant loops
     369              : 
     370            0 :                 if (!IsBranchActive) {
     371            0 :                     ShowSevereError(state, "TemperingValve object needs to be on an ACTIVE branch");
     372            0 :                     ErrorsFound = true;
     373              :                 }
     374              : 
     375            0 :                 if (!InNodeOnSplitter) {
     376            0 :                     ShowSevereError(state, "TemperingValve object needs to be between a Splitter and Mixer");
     377            0 :                     ErrorsFound = true;
     378              :                 }
     379              : 
     380            0 :                 if (!PumpOutNodeOkay) {
     381            0 :                     ShowSevereError(state, "TemperingValve object needs to reference a node that is the outlet of a pump on its loop");
     382            0 :                     ErrorsFound = true;
     383              :                 }
     384              : 
     385            0 :                 if (!TwoBranchesBetwn) {
     386            0 :                     ShowSevereError(state, "TemperingValve object needs exactly two branches between a Splitter and Mixer");
     387            0 :                     ErrorsFound = true;
     388              :                 }
     389              : 
     390            0 :                 if (!SetPointNodeOkay) {
     391            0 :                     ShowSevereError(state, "TemperingValve object setpoint node not valid.  Check Setpoint manager for Plant Loop Temp Setpoint");
     392            0 :                     ErrorsFound = true;
     393              :                 }
     394              : 
     395            0 :                 if (!Stream2NodeOkay) {
     396            0 :                     ShowSevereError(state, "TemperingValve object stream 2 source node not valid.");
     397            0 :                     ShowContinueError(state, "Check that node is a component outlet, enters a mixer, and on the other branch");
     398            0 :                     ErrorsFound = true;
     399              :                 }
     400            0 :                 if (ErrorsFound) {
     401            0 :                     ShowFatalError(state, format("Errors found in input, TemperingValve object {}", this->Name));
     402              :                 }
     403            0 :                 this->compDelayedInitFlag = false;
     404              :             } // my two time flag for input checking
     405              : 
     406              :         } // my one time flag for input checking
     407              : 
     408            0 :         InletNode = this->PltInletNodeNum;
     409            0 :         OutletNode = this->PltOutletNodeNum;
     410            0 :         Strm2Node = this->PltStream2NodeNum;
     411            0 :         SetPntNode = this->PltSetPointNodeNum;
     412            0 :         PumpOutNode = this->PltPumpOutletNodeNum;
     413              : 
     414            0 :         if (state.dataGlobal->BeginEnvrnFlag && this->environmentInit) {
     415              : 
     416            0 :             if ((InletNode > 0) && (OutletNode > 0)) {
     417              :                 //   Node(InletNode)%Temp = 0.0
     418            0 :                 PlantUtilities::InitComponentNodes(
     419            0 :                     state, 0.0, state.dataLoopNodes->Node(PumpOutNode).MassFlowRateMax, this->PltInletNodeNum, this->PltOutletNodeNum);
     420              :             }
     421            0 :             this->environmentInit = false;
     422              :         }
     423              : 
     424            0 :         if (!state.dataGlobal->BeginEnvrnFlag) {
     425            0 :             this->environmentInit = true;
     426              :         }
     427              : 
     428            0 :         if (InletNode > 0) {
     429            0 :             this->InletTemp = state.dataLoopNodes->Node(InletNode).Temp;
     430              :         }
     431            0 :         if (Strm2Node > 0) {
     432            0 :             this->Stream2SourceTemp = state.dataLoopNodes->Node(Strm2Node).Temp;
     433              :         }
     434            0 :         if (SetPntNode > 0) {
     435            0 :             this->SetPointTemp = state.dataLoopNodes->Node(SetPntNode).TempSetPoint;
     436              :         }
     437            0 :         if (PumpOutNode > 0) {
     438            0 :             this->MixedMassFlowRate = state.dataLoopNodes->Node(PumpOutNode).MassFlowRate;
     439              :         }
     440            0 :     }
     441              : 
     442            0 :     void TemperValveData::calculate(EnergyPlusData &state)
     443              :     {
     444              : 
     445              :         // SUBROUTINE INFORMATION:
     446              :         //       AUTHOR         B. Griffith, NREL
     447              :         //       DATE WRITTEN   Jan. 2006
     448              :         //       MODIFIED       na
     449              :         //       RE-ENGINEERED  na
     450              : 
     451              :         // PURPOSE OF THIS SUBROUTINE:
     452              :         //  This routine does the calculations for Valves.
     453              :         //  Currently only one type of valve, for Tempering.
     454              : 
     455              :         // METHODOLOGY EMPLOYED:
     456              :         //   Tempering valve calculations involve computing a flow fraction
     457              :         //     that should be diverted.  See update routine for setting flow rates.
     458              : 
     459              :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     460              :         Real64 Tin;  // local working variable for Inlet Temperature (C)
     461              :         Real64 Tset; // local working variable for Setpoint Temperature (C)
     462              :         Real64 Ts2;  // local Working Variable for Stream 2 outlet Temperature (C)
     463              : 
     464            0 :         if (state.dataGlobal->KickOffSimulation) {
     465            0 :             return;
     466              :         }
     467              : 
     468            0 :         if (state.dataPlnt->PlantLoop(this->plantLoc.loopNum).LoopSide(this->plantLoc.loopSideNum).FlowLock == DataPlant::FlowLock::Unlocked) {
     469            0 :             Tin = this->InletTemp;
     470            0 :             Tset = this->SetPointTemp;
     471            0 :             Ts2 = this->Stream2SourceTemp;
     472              : 
     473            0 :             if (Ts2 <= Tset) {
     474            0 :                 this->FlowDivFract = 0.0;
     475              :             } else { // Divert some or all flow
     476            0 :                 if (Tin < Ts2) {
     477            0 :                     this->FlowDivFract = (Ts2 - Tset) / (Ts2 - Tin);
     478              :                 } else {
     479            0 :                     this->FlowDivFract = 1.0;
     480              :                 }
     481              :             }
     482            0 :         } else if (state.dataPlnt->PlantLoop(this->plantLoc.loopNum).LoopSide(this->plantLoc.loopSideNum).FlowLock ==
     483              :                    DataPlant::FlowLock::Locked) { // don't recalc diversion, just reuse current flows
     484            0 :             if (this->MixedMassFlowRate > 0.0) {
     485            0 :                 this->FlowDivFract = state.dataLoopNodes->Node(this->PltOutletNodeNum).MassFlowRate / this->MixedMassFlowRate;
     486              :             } else {
     487            0 :                 this->FlowDivFract = 0.0;
     488              :             }
     489              :         }
     490              : 
     491            0 :         if (this->FlowDivFract < 0.0) {
     492            0 :             this->FlowDivFract = 0.0;
     493              :         }
     494            0 :         if (this->FlowDivFract > 1.0) {
     495            0 :             this->FlowDivFract = 1.0;
     496              :         }
     497              :     }
     498            0 :     void TemperValveData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
     499              :     {
     500            0 :     }
     501            0 :     void TemperValveData::oneTimeInit_new([[maybe_unused]] EnergyPlusData &state)
     502              :     {
     503            0 :     }
     504              : 
     505              : } // namespace PlantValves
     506              : 
     507              : } // namespace EnergyPlus
        

Generated by: LCOV version 2.0-1