diff --git a/src/EnergyPlus/StringUtilities.hh b/src/EnergyPlus/StringUtilities.hh index 0dec4215ca0..4d16ba5d9ea 100644 --- a/src/EnergyPlus/StringUtilities.hh +++ b/src/EnergyPlus/StringUtilities.hh @@ -49,7 +49,6 @@ #define StringUtilities_hh_INCLUDED #include -#include #include #include #include diff --git a/tst/EnergyPlus/unit/CMakeLists.txt b/tst/EnergyPlus/unit/CMakeLists.txt index 75c1fd20184..ef53b98c265 100644 --- a/tst/EnergyPlus/unit/CMakeLists.txt +++ b/tst/EnergyPlus/unit/CMakeLists.txt @@ -30,6 +30,7 @@ set(test_src AirflowNetworkHVAC.unit.cc AirflowNetworkConditions.unit.cc AirflowNetworkComponents.unit.cc + api/datatransfer.unit.cc Autosizing/All_Simple_Sizing.unit.cc Autosizing/AutosizingFixture.hh Autosizing/BaseClassSizing.unit.cc diff --git a/tst/EnergyPlus/unit/PhaseChangeModeling/HysteresisModel.unit.cc b/tst/EnergyPlus/unit/PhaseChangeModeling/HysteresisModel.unit.cc index 44e98c05404..d490e39394c 100644 --- a/tst/EnergyPlus/unit/PhaseChangeModeling/HysteresisModel.unit.cc +++ b/tst/EnergyPlus/unit/PhaseChangeModeling/HysteresisModel.unit.cc @@ -47,7 +47,6 @@ // Google Test Headers #include -#include #include #include diff --git a/tst/EnergyPlus/unit/SortAndStringUtilities.unit.cc b/tst/EnergyPlus/unit/SortAndStringUtilities.unit.cc deleted file mode 100644 index 25021d99b03..00000000000 --- a/tst/EnergyPlus/unit/SortAndStringUtilities.unit.cc +++ /dev/null @@ -1,99 +0,0 @@ -// EnergyPlus, Copyright (c) 1996-present, The Board of Trustees of the University of Illinois, -// The Regents of the University of California, through Lawrence Berkeley National Laboratory -// (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge -// National Laboratory, managed by UT-Battelle, Alliance for Energy Innovation, LLC, and other -// contributors. All rights reserved. -// -// NOTICE: This Software was developed under funding from the U.S. Department of Energy and the -// U.S. Government consequently retains certain rights. As such, the U.S. Government has been -// granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, -// worldwide license in the Software to reproduce, distribute copies to the public, prepare -// derivative works, and perform publicly and display publicly, and to permit others to do so. -// -// Redistribution and use in source and binary forms, with or without modification, are permitted -// provided that the following conditions are met: -// -// (1) Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// (2) Redistributions in binary form must reproduce the above copyright notice, this list of -// conditions and the following disclaimer in the documentation and/or other materials -// provided with the distribution. -// -// (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory, -// the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be -// used to endorse or promote products derived from this software without specific prior -// written permission. -// -// (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form -// without changes from the version obtained under this License, or (ii) Licensee makes a -// reference solely to the software portion of its product, Licensee must refer to the -// software as "EnergyPlus version X" software, where "X" is the version number Licensee -// obtained under this License and may not use a different name for the software. Except as -// specifically required in this Section (4), Licensee shall not use in a company name, a -// product name, in advertising, publicity, or other promotional activities any name, trade -// name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly -// similar designation, without the U.S. Department of Energy's prior written consent. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR -// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -// EnergyPlus::SortAndStringUtilities Unit Tests - -// Google Test Headers -#include - -// ObjexxFCL Headers -#include - -// EnergyPlus Headers -#include "Fixtures/EnergyPlusFixture.hh" -#include -#include -#include -#include - -using namespace EnergyPlus; -using namespace EnergyPlus::SortAndStringUtilities; - -TEST_F(EnergyPlusFixture, SortAndStringUtilitiesTest_Basic) -{ - Array1D_string Alphas({"ZEBRA", "LION", "RACCOON", "BOA", "LEMUR"}); - Array1D_int iAlphas(5); - SetupAndSort(Alphas, iAlphas); - EXPECT_TRUE(eq(Array1D_int({4, 5, 2, 3, 1}), iAlphas)); -} - -TEST_F(EnergyPlusFixture, SortAndStringUtilitiesTest_findItemInSortedListUnderscoreTest) -{ - static Array1D_string ListOfObjects; // stored variable names - static Array1D_int iListOfObjects; - ListOfObjects.allocate(7); - - ListOfObjects = Array1D_string({ - // list which has been incorrectly sorted - "SYSTEM NODE STANDARD DENSITY VOLUME FLOW RATE", - "SYSTEM NODE TEMPERATURE", - "SYSTEM NODE WETBULB TEMPERATURE", - "S_CCFRAC", - "T_TRIG", - "VRF HEAT PUMP CONDENSER INLET TEMPERATURE", - "VRF HEAT PUMP COOLING COP", - }); - - int NumObjectDefs = ListOfObjects.size(); - - iListOfObjects.allocate(NumObjectDefs); - SetupAndSort(ListOfObjects, iListOfObjects); // list is resorted - - auto index = Util::FindItemInSortedList("SYSTEM NODE TEMPERATURE", ListOfObjects, NumObjectDefs); - - EXPECT_EQ(3, index); -} diff --git a/tst/EnergyPlus/unit/api/datatransfer.unit.cc b/tst/EnergyPlus/unit/api/datatransfer.unit.cc index 13f756ca960..f1b00a1c0ff 100644 --- a/tst/EnergyPlus/unit/api/datatransfer.unit.cc +++ b/tst/EnergyPlus/unit/api/datatransfer.unit.cc @@ -64,6 +64,8 @@ #include #include +#include "EnergyPlus/DataEnvironment.hh" + using namespace EnergyPlus; class DataExchangeAPIUnitTestFixture : public EnergyPlusFixture @@ -145,11 +147,10 @@ class DataExchangeAPIUnitTestFixture : public EnergyPlusFixture void SetUp() override { EnergyPlusFixture::SetUp(); - Real64 timeStep = 1.0; - OutputProcessor::SetupTimePointers(*state, OutputProcessor::SOVTimeStepType::Zone, timeStep); - OutputProcessor::SetupTimePointers(*state, OutputProcessor::SOVTimeStepType::HVAC, timeStep); - *state->dataOutputProcessor->TimeValue.at(OutputProcessor::TimeStepType::Zone).TimeStep = 60; - *state->dataOutputProcessor->TimeValue.at(OutputProcessor::TimeStepType::System).TimeStep = 60; + state->dataGlobal->TimeStepZone = 1.0 / 60.0; + state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; + OutputProcessor::SetupTimePointers(*state, OutputProcessor::TimeStepType::Zone, state->dataGlobal->TimeStepZone); + OutputProcessor::SetupTimePointers(*state, OutputProcessor::TimeStepType::System, state->dataHVACGlobal->TimeStepSys); state->dataPluginManager->pluginManager = std::make_unique(*state); } @@ -180,33 +181,31 @@ class DataExchangeAPIUnitTestFixture : public EnergyPlusFixture if (val.meterType) { SetupOutputVariable(*state, val.varName, - OutputProcessor::Unit::kg_s, + Constant::Units::J, val.value, - OutputProcessor::SOVTimeStepType::Zone, - OutputProcessor::SOVStoreType::Summed, + OutputProcessor::TimeStepType::Zone, + OutputProcessor::StoreType::Sum, val.varKey, - _, - "ELECTRICITY", - "HEATING", - _, - "System"); + Constant::eResource::Electricity, + OutputProcessor::Group::HVAC, + OutputProcessor::EndUseCat::Heating); } else { SetupOutputVariable(*state, val.varName, - OutputProcessor::Unit::kg_s, + Constant::Units::kg_s, val.value, - OutputProcessor::SOVTimeStepType::Zone, - OutputProcessor::SOVStoreType::Average, + OutputProcessor::TimeStepType::Zone, + OutputProcessor::StoreType::Average, val.varKey); } } for (auto &val : this->intVariablePlaceholders) { SetupOutputVariable(*state, val.varName, - OutputProcessor::Unit::kg_s, + Constant::Units::kg_s, val.value, - OutputProcessor::SOVTimeStepType::Zone, - OutputProcessor::SOVStoreType::Average, + OutputProcessor::TimeStepType::Zone, + OutputProcessor::StoreType::Average, val.varKey); } } @@ -257,19 +256,19 @@ class DataExchangeAPIUnitTestFixture : public EnergyPlusFixture } } - void addPluginGlobal(EnergyPlus::EnergyPlusData &state, std::string const &varName) + static void addPluginGlobal(EnergyPlus::EnergyPlusData &state, std::string const &varName) { state.dataPluginManager->pluginManager->addGlobalVariable(state, varName); } - void addTrendWithNewGlobal(std::string const &newGlobalVarName, std::string const &trendName, int numTrendValues) + void addTrendWithNewGlobal(std::string const &newGlobalVarName, std::string const &trendName, int numTrendValues) const { state->dataPluginManager->pluginManager->addGlobalVariable(*state, newGlobalVarName); int i = EnergyPlus::PluginManagement::PluginManager::getGlobalVariableHandle(*state, newGlobalVarName, true); state->dataPluginManager->trends.emplace_back(*state, trendName, numTrendValues, i); } - void simulateTimeStepAndReport() + void simulateTimeStepAndReport() const { UpdateMeterReporting(*state); UpdateDataandReport(*state, OutputProcessor::TimeStepType::Zone); @@ -373,6 +372,11 @@ TEST_F(DataExchangeAPIUnitTestFixture, DataTransfer_TestGetVariableValuesRealTyp int hChillerHT = getVariableHandle((void *)this->state, "Chiller Heat Transfer", "Chiller 1"); int hZoneTemp = getVariableHandle((void *)this->state, "Zone Mean Temperature", "Zone 1"); + this->state->dataGlobal->HourOfDay = 1; + this->state->dataGlobal->MinutesInTimeStep = 1; + this->state->dataEnvrn->Month = 1; + this->state->dataEnvrn->DayOfMonth = 1; + // pretend like E+ ran a time step this->simulateTimeStepAndReport(); @@ -408,6 +412,12 @@ TEST_F(DataExchangeAPIUnitTestFixture, DataTransfer_TestGetMeterValues) this->setupVariablesOnceAllAreRequested(); int hFacilityElectricity = getMeterHandle((void *)this->state, "Electricity:Facility"); EXPECT_GT(hFacilityElectricity, -1); + + this->state->dataGlobal->HourOfDay = 1; + this->state->dataGlobal->MinutesInTimeStep = 1; + this->state->dataEnvrn->Month = 1; + this->state->dataEnvrn->DayOfMonth = 1; + // pretend like E+ ran a time step this->simulateTimeStepAndReport(); // get the value for a valid meter