Skip to content

Conversation

@jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Sep 18, 2023

Pull request overview

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

…of std::all_of)

```
[ RUN      ] EnergyPlusFixture.EconomicLifeCycleCost_GetInput_EnsureFuelTypesAllRecognized
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/EconomicLifeCycleCost.unit.cc:601: Failure
Expected equality of these values:
  numResources
    Which is: 18
  enum_values.size()
    Which is: 16
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/EconomicLifeCycleCost.unit.cc:648: Failure
Expected equality of these values:
  numResources
    Which is: 18
  state->dataEconLifeCycleCost->numUsePriceEscalation
    Which is: 16
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.hh:137: Failure
Expected: (static_cast<typename std::underlying_type_t<T>>(expected)) != (static_cast<typename std::underlying_type_t<T>>(actual)), actual: -1 vs -1
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/EconomicLifeCycleCost.unit.cc:650: Failure
Value of: compare_enums(lcc.resource, Constant::eResource::Invalid, false)
  Actual: true
Expected: false
Failed for LCCUSEPRICEESCALATION STEAM
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/EconomicLifeCycleCost.unit.cc:652: Failure
Expected equality of these values:
  numResources
    Which is: 18
  state->dataEconLifeCycleCost->numUseAdjustment
    Which is: 16
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.hh:137: Failure
Expected: (static_cast<typename std::underlying_type_t<T>>(expected)) != (static_cast<typename std::underlying_type_t<T>>(actual)), actual: -1 vs -1
/home/julien/Software/Others/EnergyPlus/tst/EnergyPlus/unit/EconomicLifeCycleCost.unit.cc:654: Failure
Value of: compare_enums(lcc.resource, Constant::eResource::Invalid, false)
  Actual: true
Expected: false
Failed for LCCUSEADJUSTMENT STEAM
```
@jmarrec jmarrec added Defect Includes code to repair a defect in EnergyPlus IDDChange Code changes impact the IDD file (cannot be merged after IO freeze) labels Sep 18, 2023
@jmarrec jmarrec self-assigned this Sep 18, 2023
Comment on lines +100943 to +100945
\key DistrictCooling
\key DistrictHeatingWater
\key DistrictHeatingSteam
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For LifeCycleCost:UsePriceEscalation and LifeCycleCost:UseAdjustment

Replace Steam with DistrictHeatingSteam like the rest of the objects

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, good catch.

Comment on lines +919 to +933
CASE('LIFECYCLECOST:USEPRICEESCALATION')
CALL GetNewObjectDefInIDD(ObjectName,NwNumArgs,NwAorN,NwReqFld,NwObjMinFlds,NwFldNames,NwFldDefaults,NwFldUnits)
nodiff=.false.
OutArgs(1:CurArgs)=InArgs(1:CurArgs)
IF (SameString(OutArgs(2), "STEAM")) THEN
OutArgs(2) = "DistrictHeatingSteam"
END IF

CASE('LIFECYCLECOST:USEADJUSTMENT')
CALL GetNewObjectDefInIDD(ObjectName,NwNumArgs,NwAorN,NwReqFld,NwObjMinFlds,NwFldNames,NwFldDefaults,NwFldUnits)
nodiff=.false.
OutArgs(1:CurArgs)=InArgs(1:CurArgs)
IF (SameString(OutArgs(2), "STEAM")) THEN
OutArgs(2) = "DistrictHeatingSteam"
END IF
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transition. See test on DevSupport: https://github.com/NREL/EnergyPlusDevSupport/blob/master/DefectFiles/10000s/10220/transition.idf

./Transition-V23-1-0-to-V23-2-0 /path/to/EnergyPlusDevSupport/DefectFiles/10000s/10220/transition.idf
gvim -d -f transition.idfold transition.idfnew

image

Comment on lines +592 to +656
TEST_F(EnergyPlusFixture, EconomicLifeCycleCost_GetInput_EnsureFuelTypesAllRecognized)
{
using json = nlohmann::json;
const json &lcc_useprice_props = state->dataInputProcessing->inputProcessor->getObjectSchemaProps(*state, "LifeCycleCost:UsePriceEscalation");
const json &resource_field = lcc_useprice_props.at("resource");
const json &enum_values = resource_field.at("enum");

// Should support all fuels + Water + ElectricityXXX (Purchased, Produced, SurplusSold, Net)
constexpr size_t numResources = static_cast<size_t>(Constant::eFuel::Num) + 5;
EXPECT_EQ(numResources, enum_values.size());
std::string idf_objects = delimited_string({
"LifeCycleCost:Parameters,",
" TypicalLCC, !- Name",
" EndOfYear, !- Discounting Convention",
" ConstantDollar, !- Inflation Approach",
" 0.03, !- Real Discount Rate",
" , !- Nominal Discount Rate",
" , !- Inflation",
" January, !- Base Date Month",
" 2012, !- Base Date Year",
" January, !- Service Date Month",
" 2014, !- Service Date Year",
" 100, !- Length of Study Period in Years",
" 0, !- Tax rate",
" ; !- Depreciation Method",
});
// All should be valid resources
for (const auto &enum_value : enum_values) {
const std::string enum_string = enum_value.get<std::string>();

const auto resource = static_cast<Constant::eResource>(getEnumValue(Constant::eResourceNamesUC, enum_string));
EXPECT_TRUE(compare_enums(Constant::eResource::Invalid, resource)) << "Failed for " << enum_string;

idf_objects += fmt::format(R"idf(
LifeCycleCost:UsePriceEscalation,
LCCUsePriceEscalation {0}, !- Name
{0}, !- Resource
2009, !- Escalation Start Year
January, !- Escalation Start Month
1, !- Year Escalation 1
1.01, !- Year Escalation 2
1.02; !- Year Escalation 3
LifeCycleCost:UseAdjustment,
LCCUseAdjustment {0}, !- Name
{0}, !- Resource
1, !- Year Multiplier 1
1.005, !- Year Multiplier 2
1.01; !- Year Multiplier 3
)idf",
enum_string);
}
ASSERT_TRUE(process_idf(idf_objects));

GetInputForLifeCycleCost(*state);

EXPECT_EQ(numResources, state->dataEconLifeCycleCost->numUsePriceEscalation);
for (const auto &lcc : state->dataEconLifeCycleCost->UsePriceEscalation) {
EXPECT_FALSE(compare_enums(lcc.resource, Constant::eResource::Invalid, false)) << "Failed for " << lcc.name;
}
EXPECT_EQ(numResources, state->dataEconLifeCycleCost->numUseAdjustment);
for (const auto &lcc : state->dataEconLifeCycleCost->UseAdjustment) {
EXPECT_FALSE(compare_enums(lcc.resource, Constant::eResource::Invalid, false)) << "Failed for " << lcc.name;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(meta) testing to ensure this doesn't creep back in.

@jmarrec
Copy link
Contributor Author

jmarrec commented Sep 18, 2023

Using the MCVE files on DevSupport:

  • in_ori.idf: uses Steam LCC objects, and does not include DistrictCooling, DistrictHeatingWater or it throws on input parsing
  • in.idf uses DistrictHeatingSteam, DistrictCooling, DistrictHeatingWater objects
  • Both files include LCC objects for all other fuels

Ori:

eplusout.err has a warning

   ** Warning ** The resource referenced by LifeCycleCost:UsePriceEscalation= "LCCUSEPRICEESCALATION DISTRICTHEATINGSTEAM" has no energy cost. 
   **   ~~~   ** ... It is likely that the wrong resource is used. The resource should match the meter used in Utility:Tariff.

as you can see, DistrictHeatingSteam is not changed whatsoever.

image

New:

All fuels are properly affected by the LCC objects:

image

OutArgs(1:CurArgs)=InArgs(1:CurArgs)
IF (SameString(OutArgs(2), "STEAM")) THEN
OutArgs(2) = "DistrictHeatingSteam"
END IF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, @jmarrec, thanks.

Comment on lines +100943 to +100945
\key DistrictCooling
\key DistrictHeatingWater
\key DistrictHeatingSteam
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, good catch.

@Myoldmopar
Copy link
Member

This also tests happily, and the only diff is the spurious table diff. I am going to go ahead and merge this in, thanks @jmarrec

@Myoldmopar Myoldmopar merged commit 25fac22 into develop Sep 19, 2023
@Myoldmopar Myoldmopar deleted the 10220_LifeCycleCost_Steam branch September 19, 2023 18:56
jmarrec added a commit to NatLabRockies/OpenStudio that referenced this pull request Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Defect Includes code to repair a defect in EnergyPlus IDDChange Code changes impact the IDD file (cannot be merged after IO freeze)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LifeCycleCost objects are using "Steam" not "DistrictHeatingSteam"

8 participants