Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois,
2 : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
3 : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
4 : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
5 : // contributors. All rights reserved.
6 : //
7 : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
8 : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
9 : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
10 : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
11 : // derivative works, and perform publicly and display publicly, and to permit others to do so.
12 : //
13 : // Redistribution and use in source and binary forms, with or without modification, are permitted
14 : // provided that the following conditions are met:
15 : //
16 : // (1) Redistributions of source code must retain the above copyright notice, this list of
17 : // conditions and the following disclaimer.
18 : //
19 : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
20 : // conditions and the following disclaimer in the documentation and/or other materials
21 : // provided with the distribution.
22 : //
23 : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
24 : // the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
25 : // used to endorse or promote products derived from this software without specific prior
26 : // written permission.
27 : //
28 : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
29 : // without changes from the version obtained under this License, or (ii) Licensee makes a
30 : // reference solely to the software portion of its product, Licensee must refer to the
31 : // software as "EnergyPlus version X" software, where "X" is the version number Licensee
32 : // obtained under this License and may not use a different name for the software. Except as
33 : // specifically required in this Section (4), Licensee shall not use in a company name, a
34 : // product name, in advertising, publicity, or other promotional activities any name, trade
35 : // name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
36 : // similar designation, without the U.S. Department of Energy's prior written consent.
37 : //
38 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
39 : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
40 : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
41 : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43 : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46 : // POSSIBILITY OF SUCH DAMAGE.
47 :
48 : // C++ Headers
49 : #include <memory>
50 :
51 : // EnergyPlus headers
52 : #include <EnergyPlus/Data/EnergyPlusData.hh>
53 : #include <EnergyPlus/DataGlobalConstants.hh>
54 : #include <EnergyPlus/DataGlobals.hh>
55 : #include <EnergyPlus/DataIPShortCuts.hh>
56 : #include <EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh>
57 : #include <EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.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 : // Xing model factory
67 1 : std::shared_ptr<XingGroundTempsModel> XingGroundTempsModel::XingGTMFactory(EnergyPlusData &state, std::string objectName)
68 : {
69 : // SUBROUTINE INFORMATION:
70 : // AUTHOR Matt Mitchell
71 : // DATE WRITTEN Summer 2015
72 :
73 : // PURPOSE OF THIS SUBROUTINE:
74 : // Reads input and creates instance of Xing ground temps model
75 :
76 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
77 1 : bool found = false;
78 : int NumNums;
79 : int NumAlphas;
80 : int IOStat;
81 :
82 : // New shared pointer for this model object
83 1 : std::shared_ptr<XingGroundTempsModel> thisModel(new XingGroundTempsModel());
84 :
85 1 : GroundTempObjType objType = GroundTempObjType::XingGroundTemp;
86 :
87 1 : std::string_view const cCurrentModuleObject = GroundTemperatureManager::groundTempModelNamesUC[static_cast<int>(objType)];
88 1 : int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
89 :
90 1 : for (int modelNum = 1; modelNum <= numCurrModels; ++modelNum) {
91 :
92 2 : state.dataInputProcessing->inputProcessor->getObjectItem(
93 1 : state, cCurrentModuleObject, modelNum, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat);
94 :
95 1 : if (objectName == state.dataIPShortCut->cAlphaArgs(1)) {
96 : // Read input into object here
97 :
98 1 : thisModel->objectName = state.dataIPShortCut->cAlphaArgs(1);
99 1 : thisModel->objectType = objType;
100 1 : thisModel->groundThermalDiffisivity = state.dataIPShortCut->rNumericArgs(1) /
101 1 : (state.dataIPShortCut->rNumericArgs(2) * state.dataIPShortCut->rNumericArgs(3)) *
102 : Constant::SecsInDay;
103 1 : thisModel->aveGroundTemp = state.dataIPShortCut->rNumericArgs(4);
104 1 : thisModel->surfTempAmplitude_1 = state.dataIPShortCut->rNumericArgs(5);
105 1 : thisModel->surfTempAmplitude_2 = state.dataIPShortCut->rNumericArgs(6);
106 1 : thisModel->phaseShift_1 = state.dataIPShortCut->rNumericArgs(7);
107 1 : thisModel->phaseShift_2 = state.dataIPShortCut->rNumericArgs(8);
108 :
109 1 : found = true;
110 1 : break;
111 : }
112 : }
113 :
114 1 : if (found) {
115 1 : state.dataGrndTempModelMgr->groundTempModels.push_back(thisModel);
116 1 : return thisModel;
117 : } else {
118 0 : ShowFatalError(state,
119 0 : fmt::format("{}--Errors getting input for ground temperature model",
120 0 : GroundTemperatureManager::groundTempModelNames[static_cast<int>(objType)]));
121 0 : return nullptr;
122 : }
123 1 : }
124 :
125 : //******************************************************************************
126 :
127 771816 : Real64 XingGroundTempsModel::getGroundTemp(EnergyPlusData &state)
128 : {
129 : // SUBROUTINE INFORMATION:
130 : // AUTHOR Matt Mitchell
131 : // DATE WRITTEN Summer 2015
132 :
133 : // PURPOSE OF THIS SUBROUTINE:
134 : // Returns the ground temperature for the Site:GroundTemperature:Undisturbed:Xing
135 :
136 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
137 771816 : Real64 tp = state.dataWeather->NumDaysInYear; // Period of soil temperature cycle
138 :
139 : // Inits
140 771816 : Real64 Ts_1 = surfTempAmplitude_1; // Amplitude of surface temperature
141 771816 : Real64 PL_1 = phaseShift_1; // Phase shift of surface temperature
142 771816 : Real64 Ts_2 = surfTempAmplitude_2; // Amplitude of surface temperature
143 771816 : Real64 PL_2 = phaseShift_2; // Phase shift of surface temperature
144 :
145 771816 : int n = 1;
146 771816 : Real64 gamma1 = std::sqrt((n * Constant::Pi) / (groundThermalDiffisivity * tp));
147 771816 : Real64 exp1 = -depth * gamma1;
148 771816 : Real64 cos1 = (2 * Constant::Pi * n) / tp * (simTimeInDays - PL_1) - depth * gamma1;
149 :
150 771816 : n = 2;
151 771816 : Real64 gamma2 = std::sqrt((n * Constant::Pi) / (groundThermalDiffisivity * tp));
152 771816 : Real64 exp2 = -depth * gamma2;
153 771816 : Real64 cos2 = (2 * Constant::Pi * n) / tp * (simTimeInDays - PL_2) - depth * gamma2;
154 :
155 771816 : Real64 summation = std::exp(exp1) * Ts_1 * std::cos(cos1) + std::exp(exp2) * Ts_2 * std::cos(cos2);
156 :
157 771816 : return aveGroundTemp - summation;
158 : }
159 :
160 : //******************************************************************************
161 :
162 0 : Real64 XingGroundTempsModel::getGroundTempAtTimeInMonths(EnergyPlusData &state, Real64 _depth, int _month)
163 : {
164 : // SUBROUTINE INFORMATION:
165 : // AUTHOR Matt Mitchell
166 : // DATE WRITTEN Summer 2015
167 :
168 : // PURPOSE OF THIS SUBROUTINE:
169 : // Returns ground temperature when input time is in months
170 :
171 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
172 0 : Real64 const aveDaysInMonth = state.dataWeather->NumDaysInYear / 12;
173 :
174 0 : depth = _depth;
175 :
176 : // Set month
177 0 : if (_month >= 1 && _month <= 12) {
178 0 : simTimeInDays = aveDaysInMonth * ((_month - 1) + 0.5);
179 : } else {
180 0 : int monthIndex = remainder(_month, 12);
181 0 : simTimeInDays = aveDaysInMonth * ((monthIndex - 1) + 0.5);
182 : }
183 :
184 : // Get and return ground temp
185 0 : return getGroundTemp(state);
186 : }
187 :
188 : //******************************************************************************
189 :
190 771816 : Real64 XingGroundTempsModel::getGroundTempAtTimeInSeconds(EnergyPlusData &state, Real64 _depth, Real64 seconds)
191 : {
192 : // SUBROUTINE INFORMATION:
193 : // AUTHOR Matt Mitchell
194 : // DATE WRITTEN Summer 2015
195 :
196 : // PURPOSE OF THIS SUBROUTINE:
197 : // Returns ground temperature when time is in seconds
198 :
199 771816 : depth = _depth;
200 :
201 771816 : simTimeInDays = seconds / Constant::SecsInDay;
202 :
203 771816 : if (simTimeInDays > state.dataWeather->NumDaysInYear) {
204 0 : simTimeInDays = remainder(simTimeInDays, state.dataWeather->NumDaysInYear);
205 : }
206 :
207 771816 : return getGroundTemp(state);
208 : }
209 :
210 : //******************************************************************************
211 :
212 : } // namespace EnergyPlus
|