LCOV - code coverage report
Current view: top level - EnergyPlus/GroundTemperatureModeling - SiteFCFactorMethodGroundTemperatures.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 37 56 66.1 %
Date: 2023-01-17 19:17:23 Functions: 5 6 83.3 %

          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 <memory>
      50             : 
      51             : // EnergyPlus Headers
      52             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      53             : #include <EnergyPlus/DataEnvironment.hh>
      54             : #include <EnergyPlus/DataGlobals.hh>
      55             : #include <EnergyPlus/DataIPShortCuts.hh>
      56             : #include <EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh>
      57             : #include <EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.hh>
      58             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      59             : #include <EnergyPlus/UtilityRoutines.hh>
      60             : #include <EnergyPlus/WeatherManager.hh>
      61             : 
      62             : namespace EnergyPlus {
      63             : 
      64             : //******************************************************************************
      65             : 
      66             : // Site:GroundTemperature:FCFactorMethod factory
      67         771 : std::shared_ptr<SiteFCFactorMethodGroundTemps> SiteFCFactorMethodGroundTemps::FCFactorGTMFactory(EnergyPlusData &state, std::string objectName)
      68             : {
      69             :     // SUBROUTINE INFORMATION:
      70             :     //       AUTHOR         Matt Mitchell
      71             :     //       DATE WRITTEN   Summer 2015
      72             :     //       MODIFIED       na
      73             :     //       RE-ENGINEERED  na
      74             : 
      75             :     // PURPOSE OF THIS SUBROUTINE:
      76             :     // Reads input and creates instance of Site:GroundTemperature:FCfactorMethod object
      77             : 
      78             :     // USE STATEMENTS:
      79             :     using namespace GroundTemperatureManager;
      80             : 
      81             :     // Locals
      82             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
      83         771 :     bool found = false;
      84             :     int NumNums;
      85             :     int NumAlphas;
      86             :     int IOStat;
      87         771 :     bool errorsFound = false;
      88             : 
      89             :     // New shared pointer for this model object
      90        1542 :     std::shared_ptr<SiteFCFactorMethodGroundTemps> thisModel(new SiteFCFactorMethodGroundTemps());
      91             : 
      92         771 :     GroundTempObjType objType = GroundTempObjType::SiteFCFactorMethodGroundTemp;
      93             : 
      94         771 :     std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast<int>(objType)];
      95         771 :     int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
      96             : 
      97         771 :     thisModel->objectType = objType;
      98         771 :     thisModel->objectName = objectName;
      99             : 
     100         771 :     if (numCurrObjects == 1) {
     101             : 
     102             :         // Get the object names for each construction from the input processor
     103          60 :         state.dataInputProcessing->inputProcessor->getObjectItem(
     104          40 :             state, cCurrentModuleObject, 1, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat);
     105             : 
     106          20 :         if (NumNums < 12) {
     107           0 :             ShowSevereError(
     108           0 :                 state, fmt::format("{}: Less than 12 values entered.", GroundTemperatureManager::groundTempModelNames[static_cast<int>(objType)]));
     109           0 :             errorsFound = true;
     110             :         }
     111             : 
     112             :         // overwrite values read from weather file for the 0.5m set ground temperatures
     113         260 :         for (int i = 1; i <= 12; ++i) {
     114         240 :             thisModel->fcFactorGroundTemps(i) = state.dataIPShortCut->rNumericArgs(i);
     115             :         }
     116             : 
     117          20 :         state.dataEnvrn->FCGroundTemps = true;
     118          20 :         found = true;
     119             : 
     120         751 :     } else if (numCurrObjects > 1) {
     121           0 :         ShowSevereError(state,
     122           0 :                         fmt::format("{}: Too many objects entered. Only one allowed.",
     123           0 :                                     GroundTemperatureManager::groundTempModelNames[static_cast<int>(objType)]));
     124           0 :         errorsFound = true;
     125             : 
     126         751 :     } else if (state.dataWeatherManager->wthFCGroundTemps) {
     127             : 
     128        9646 :         for (int i = 1; i <= 12; ++i) {
     129        8904 :             thisModel->fcFactorGroundTemps(i) = state.dataWeatherManager->GroundTempsFCFromEPWHeader(i);
     130             :         }
     131             : 
     132         742 :         state.dataEnvrn->FCGroundTemps = true;
     133         742 :         found = true;
     134             : 
     135             :     } else {
     136           9 :         thisModel->fcFactorGroundTemps = 0.0;
     137           9 :         found = true;
     138             :     }
     139             : 
     140             :     // Write Final Ground Temp Information to the initialization output file
     141         771 :     if (state.dataEnvrn->FCGroundTemps) {
     142         762 :         write_ground_temps(state.files.eio, "FCfactorMethod", thisModel->fcFactorGroundTemps);
     143             :     }
     144             : 
     145         771 :     if (found && !errorsFound) {
     146         771 :         state.dataGrndTempModelMgr->groundTempModels.push_back(thisModel);
     147         771 :         return thisModel;
     148             :     } else {
     149           0 :         ShowFatalError(state,
     150           0 :                        fmt::format("{}--Errors getting input for ground temperature model",
     151           0 :                                    GroundTemperatureManager::groundTempModelNames[static_cast<int>(objType)]));
     152           0 :         return nullptr;
     153             :     }
     154             : }
     155             : 
     156             : //******************************************************************************
     157             : 
     158     2661169 : Real64 SiteFCFactorMethodGroundTemps::getGroundTemp([[maybe_unused]] EnergyPlusData &state)
     159             : {
     160             :     // SUBROUTINE INFORMATION:
     161             :     //       AUTHOR         Matt Mitchell
     162             :     //       DATE WRITTEN   Summer 2015
     163             :     //       MODIFIED       na
     164             :     //       RE-ENGINEERED  na
     165             : 
     166             :     // PURPOSE OF THIS SUBROUTINE:
     167             :     // Returns the ground temperature for Site:GroundTemperature:FCFactorMethod
     168             : 
     169     2661169 :     return fcFactorGroundTemps(timeOfSimInMonths);
     170             : }
     171             : 
     172             : //******************************************************************************
     173             : 
     174           0 : Real64 SiteFCFactorMethodGroundTemps::getGroundTempAtTimeInSeconds(EnergyPlusData &state, [[maybe_unused]] Real64 const _depth, Real64 const _seconds)
     175             : {
     176             :     // SUBROUTINE INFORMATION:
     177             :     //       AUTHOR         Matt Mitchell
     178             :     //       DATE WRITTEN   Summer 2015
     179             :     //       MODIFIED       na
     180             :     //       RE-ENGINEERED  na
     181             : 
     182             :     // PURPOSE OF THIS SUBROUTINE:
     183             :     // Returns the ground temperature when input time is in seconds
     184             : 
     185             :     // USE STATEMENTS:
     186             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     187           0 :     Real64 secPerMonth = state.dataWeatherManager->NumDaysInYear * DataGlobalConstants::SecsInDay / 12;
     188             : 
     189             :     // Convert secs to months
     190           0 :     int month = ceil(_seconds / secPerMonth);
     191             : 
     192           0 :     if (month >= 1 && month <= 12) {
     193           0 :         timeOfSimInMonths = month;
     194             :     } else {
     195           0 :         timeOfSimInMonths = remainder(month, 12);
     196             :     }
     197             : 
     198             :     // Get and return ground temp
     199           0 :     return getGroundTemp(state);
     200             : }
     201             : 
     202             : //******************************************************************************
     203             : 
     204     2661169 : Real64 SiteFCFactorMethodGroundTemps::getGroundTempAtTimeInMonths(EnergyPlusData &state, [[maybe_unused]] Real64 const _depth, int const _month)
     205             : {
     206             :     // SUBROUTINE INFORMATION:
     207             :     //       AUTHOR         Matt Mitchell
     208             :     //       DATE WRITTEN   Summer 2015
     209             :     //       MODIFIED       na
     210             :     //       RE-ENGINEERED  na
     211             : 
     212             :     // PURPOSE OF THIS SUBROUTINE:
     213             :     // Returns the ground temperature when input time is in months
     214             : 
     215             :     // Set month
     216     2661169 :     if (_month >= 1 && _month <= 12) {
     217     2661169 :         timeOfSimInMonths = _month;
     218             :     } else {
     219           0 :         timeOfSimInMonths = remainder(_month, 12);
     220             :     }
     221             : 
     222             :     // Get and return ground temp
     223     2661169 :     return getGroundTemp(state);
     224             : }
     225             : 
     226             : //******************************************************************************
     227             : 
     228        2313 : } // namespace EnergyPlus

Generated by: LCOV version 1.13