Skip to content

Commit

Permalink
Merge pull request #3862 from NREL/issue-3386
Browse files Browse the repository at this point in the history
Addresses #3386, LifeCycleCost:UsePriceEscalation bad E+ IDD
  • Loading branch information
kbenne authored Feb 24, 2020
2 parents b9425a2 + 893e6c7 commit 92c9f11
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/energyplus/ProposedEnergy+.idd
Original file line number Diff line number Diff line change
Expand Up @@ -58886,7 +58886,7 @@ LifeCycleCost:UsePriceEscalation,
\memo annual supplement to NIST Handbook 135 in Tables Ca-1 to Ca-5 and are included in an
\memo EnergyPlus dataset file.
\extensible:1
A1, \field LCC Price Escalation Name
A1, \field Name
\required-field
\type alpha
\note The identifier used for the object. The name usually identifies the location (such as the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ boost::optional<IdfObject> ForwardTranslator::translateLifeCycleCostParameters(
OS_ASSERT(usePriceEscalationFile);

for (IdfObject object : usePriceEscalationFile->objects()){
std::string name = object.getString(LifeCycleCost_UsePriceEscalationFields::LCCPriceEscalationName).get();
std::string name = object.nameString();
if ((name.find(*region) == 0) &&
(name.find(*sector) != string::npos)){
m_idfObjects.push_back(object);
Expand Down
1 change: 1 addition & 0 deletions src/model/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,7 @@ set(${target_name}_test_src
test/InternalMass_GTest.cpp
## test/LoadProfilePlant_GTest.cpp
test/LifeCycleCostParameters_GTest.cpp
test/LifeCycleCostUsePriceEscalation_GTest.cpp
test/LightingDesignDay_GTest.cpp
test/LightingSimulationControl_GTest.cpp
test/LightingSimulationZone_GTest.cpp
Expand Down
100 changes: 100 additions & 0 deletions src/model/test/LifeCycleCostUsePriceEscalation_GTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2008-2019, Alliance for Sustainable Energy, LLC, and other contributors. All rights reserved.
*
* 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 copyright holder nor the names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior
* written permission from Alliance for Sustainable Energy, LLC.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY 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 HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, 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.
***********************************************************************************************************************/

#include <gtest/gtest.h>

#include "ModelFixture.hpp"

#include "../LifeCycleCostUsePriceEscalation.hpp"
#include "../LifeCycleCostUsePriceEscalation_Impl.hpp"

#include "../../utilities/time/Date.hpp"

using namespace openstudio;
using namespace openstudio::model;

TEST_F(ModelFixture, LifeCycleCostUsePriceEscalation) {

Model model;

LifeCycleCostUsePriceEscalation lifeCycleCostUsePriceEscalation(model);

// check defaults
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.name());
EXPECT_EQ("Life Cycle Cost Use Price Escalation 1", lifeCycleCostUsePriceEscalation.name().get());
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.resource());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.resource().get(), "");
EXPECT_FALSE(lifeCycleCostUsePriceEscalation.escalationStartMonth());
EXPECT_FALSE(lifeCycleCostUsePriceEscalation.escalationStartYear());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.numYears(), 0);

// check setters
EXPECT_TRUE(lifeCycleCostUsePriceEscalation.setResource("Electricity"));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.resource());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.resource().get(), "Electricity");
EXPECT_TRUE(lifeCycleCostUsePriceEscalation.setResource("NaturalGas"));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.resource());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.resource().get(), "NaturalGas");
EXPECT_FALSE(lifeCycleCostUsePriceEscalation.setResource("Natural Gas"));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.resource());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.resource().get(), "NaturalGas");

EXPECT_TRUE(lifeCycleCostUsePriceEscalation.setEscalationStartMonth("January"));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.escalationStartMonth());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.escalationStartMonth().get(), "January");
EXPECT_TRUE(lifeCycleCostUsePriceEscalation.setEscalationStartMonth("February"));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.escalationStartMonth());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.escalationStartMonth().get(), "February");
EXPECT_FALSE(lifeCycleCostUsePriceEscalation.setEscalationStartMonth("Febuary"));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.escalationStartMonth());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.escalationStartMonth().get(), "February");

EXPECT_TRUE(lifeCycleCostUsePriceEscalation.setEscalationStartYear(2020));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.escalationStartYear());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.escalationStartYear().get(), 2020);
EXPECT_TRUE(lifeCycleCostUsePriceEscalation.setEscalationStartYear(2021));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.escalationStartYear());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.escalationStartYear().get(), 2021);
EXPECT_FALSE(lifeCycleCostUsePriceEscalation.setEscalationStartYear(1899));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.escalationStartYear());
EXPECT_EQ(lifeCycleCostUsePriceEscalation.escalationStartYear().get(), 2021);

EXPECT_TRUE(lifeCycleCostUsePriceEscalation.setYearEscalation(0, 100.0));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.yearEscalation(0));
EXPECT_EQ(lifeCycleCostUsePriceEscalation.yearEscalation(0).get(), 100.0);
EXPECT_EQ(lifeCycleCostUsePriceEscalation.numYears(), 1);
EXPECT_TRUE(lifeCycleCostUsePriceEscalation.setYearEscalation(0, 200.0));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.yearEscalation(0));
EXPECT_EQ(lifeCycleCostUsePriceEscalation.yearEscalation(0).get(), 200.0);
EXPECT_EQ(lifeCycleCostUsePriceEscalation.numYears(), 1);
EXPECT_TRUE(lifeCycleCostUsePriceEscalation.setYearEscalation(1, 300.0));
ASSERT_TRUE(lifeCycleCostUsePriceEscalation.yearEscalation(1));
EXPECT_EQ(lifeCycleCostUsePriceEscalation.yearEscalation(1).get(), 300.0);
EXPECT_EQ(lifeCycleCostUsePriceEscalation.numYears(), 2);
}

0 comments on commit 92c9f11

Please sign in to comment.