Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V23.2.0-IOFreeze - wrap DistrictHeating:Steam and rename DistrictHeating to DistrictHeatingWater #4972

Merged
merged 31 commits into from
Sep 20, 2023

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Sep 19, 2023

Pull request overview

Supersedes #4954

Additionally, rename the class DistrictHeating to DistrictHeatingWater (and IDD too) and provide an alias and model getters for backward compat, issuing a deprecation warning.

  • A Swig macro was used to provide this in a reusable fashion

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • 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

joseph-robertson and others added 23 commits August 30, 2023 09:20
….2.0-IOFreeze-RenameDistrictHeating

Resolve conflicts manually
Add python docstrings for methods we dynamically add
use a helper macro to define an alias with a deprecation warning for a class, mapping to old one
@jmarrec jmarrec changed the title V23.2.0 io freeze rename district heating V23.2.0-IOFreeze - wrap DistrictHeating:Steam and rename DistrictHeating to DistrictHeatingWater Sep 19, 2023
```ruby
w = OpenStudio::Workspace.load('in.idf').get()
w.save('in.idf', true)
```
```shell
$os_build_rel2/Products/openstudio generate.rb
```
@jmarrec jmarrec added the Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. label Sep 19, 2023
@jmarrec jmarrec self-assigned this Sep 19, 2023
Comment on lines +85 to +86
* [#4972](https://github.com/NREL/OpenStudio/pull/4972) - V23.2.0-IOFreeze - wrap `DistrictHeating:Steam` and rename `DistrictHeating` to `DistrictHeatingWater`
* The `DistrictHeating` class (and related Model getters such as `Model::getDistrictHeatings`) are deprecated but kept for backward Compatibility for now.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add to release notes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Update deprecated_methods.csv, including stuff already done on other branches / PRs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Re-regenerate allFuelTypes/in.idf. I did this in two commits: reformat, then re-regeneate. See the actual changes in 6a402c4


OS:DistrictHeating,
OS:DistrictHeating:Water,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed IDD object

Comment on lines +525 to +533
%define MODELOBJECT_ALIAS_CLASS_DEPRECATED_AT(_oldName, _newName, _deprecatedAtVersionMajor, _deprecatedAtVersionMinor, _deprecatedAtVersionPatch)
#if defined SWIGRUBY
MODELOBJECT_ALIAS_CLASS_DEPRECATED_AT_EXTENSION(_oldName, _newName, _deprecatedAtVersionMajor, _deprecatedAtVersionMinor, _deprecatedAtVersionPatch)
#endif

#if defined SWIGPYTHON
MODELOBJECT_ALIAS_CLASS_DEPRECATED_AT_EXTENSION(_oldName, _newName, _deprecatedAtVersionMajor, _deprecatedAtVersionMinor, _deprecatedAtVersionPatch)
#endif
%enddef
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New macro. Uses two extensions: one for ruby, one for python.

case openstudio::IddObjectType::OS_DistrictHeating_Water: {
return PlantSizingType::HOTWATER;
}
case openstudio::IddObjectType::OS_DistrictHeating_Steam: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That was missing from #4954. Same in FTPlantEquipmentOperationSchemes

Comment on lines 27 to 54
// Name
IdfObject idfObject = createRegisterAndNameIdfObject(IddObjectType::DistrictHeating_Water, modelObject);

// Inlet Node Name
if (auto node_ = modelObject.inletModelObject()) {
idfObject.setString(DistrictHeating_WaterFields::HotWaterInletNodeName, node_->nameString());
}

// Outlet Node Name
if (auto node_ = modelObject.outletModelObject()) {
idfObject.setString(DistrictHeating_WaterFields::HotWaterOutletNodeName, node_->nameString());
}

// Nominal Capacity
if (modelObject.isNominalCapacityAutosized()) {
idfObject.setString(DistrictHeating_WaterFields::NominalCapacity, "Autosize");
} else if (auto value_ = modelObject.nominalCapacity()) {
idfObject.setDouble(DistrictHeating_WaterFields::NominalCapacity, *value_);
}

// Capacity Fraction Schedule Name
if (auto capacityFractionSchedule_ = modelObject.capacityFractionSchedule()) {
if (auto sch_ = translateAndMapModelObject(*capacityFractionSchedule_)) {
idfObject.setString(DistrictHeating_WaterFields::CapacityFractionScheduleName, sch_->nameString());
}
}

return idfObject;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I cleaned up the FTs too

Comment on lines +3 to +13
include OpenStudio::Model

m = Model.new

dh = DistrictHeating.new(m)
dh.setName("My DistrictHeating")
p = PlantLoop.new(m)
p.addSupplyBranchForComponent(dh)
dh.inletModelObject.get.setName("DH Inlet")
dh.outletModelObject.get.setName("DH Outlet")
dh.setNominalCapacity(1000.0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

VT test file

Comment on lines +3604 to +3622
TEST_F(OSVersionFixture, update_3_6_1_to_3_7_0_DistrictHeating) {
openstudio::path osmPath = resourcesPath() / toPath("osversion/3_7_0/test_vt_RenameDistrictHeating.osm");
osversion::VersionTranslator vt;
boost::optional<model::Model> model_ = vt.loadModel(osmPath);
ASSERT_TRUE(model_) << "Failed to load " << osmPath;

openstudio::path outPath = osmPath.parent_path() / toPath(osmPath.stem().string() + "_updated" + osmPath.extension().string());
model_->save(outPath, true);

std::vector<WorkspaceObject> dhs = model_->getObjectsByType("OS:DistrictHeating:Water");
ASSERT_EQ(1u, dhs.size());
const auto& dh = dhs.front();

EXPECT_EQ("My DistrictHeating", dh.nameString());
ASSERT_TRUE(dh.getTarget(2));
EXPECT_EQ("DH Inlet", dh.getTarget(2)->getTarget(OS_ConnectionFields::SourceObject)->nameString());
ASSERT_TRUE(dh.getTarget(3));
EXPECT_EQ("DH Outlet", dh.getTarget(3)->getTarget(OS_ConnectionFields::TargetObject)->nameString());
EXPECT_EQ(1000.0, dh.getDouble(4).get());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

VT test

Comment on lines +78 to +86
if (energyPlusBuildSHA() == "c854ba6bfe") {
GTEST_SKIP() << "\nFIXME: Skip the checks for DistrictHeatingSteam pending new E+ package after https://github.com/NREL/EnergyPlus/pull/10212\n";
} else {
EXPECT_TRUE(false) << "Please come remove the special check now that a new E+ package is out";
EXPECT_NEAR(346.90, *(sqlFile3.districtHeatingSteamExteriorEquipment()), 2);
EXPECT_NEAR(346.90, *(sqlFile3.districtHeatingSteamTotalEndUses()), 2);
EXPECT_NEAR(725.33, *(sqlFile3.districtHeatingExteriorEquipment()), 2);
EXPECT_NEAR(725.33, *(sqlFile3.districtHeatingTotalEndUses()), 2);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Skip a portion of the test. With a check that will fail as soon as a new E+ package is out, so we don't forget to remove the special check here.

…edule)

The grand protector of the API has spoken! cf @kbenne 's comment here: #4954 (comment)
I got pwned by making the `discreteSchHandleStr` a static string inside the lambda: try to VT two models with the same VersionTranslator instance and you're screwed. Thanks tests!
@jmarrec jmarrec force-pushed the v23.2.0-IOFreeze-RenameDistrictHeating branch from 4c61f9e to 57fea8f Compare September 20, 2023 11:34
@jmarrec
Copy link
Collaborator Author

jmarrec commented Sep 20, 2023

@kbenne @joseph-robertson I'm going to merge this one to the V23-2-0IOFreeze branch now, but would still welcome a review, any problems can be fixed on the main IOFreeze branch.

Why merging now?

  • This fixes the SQL tests and will make our life easier
  • I'd like to move to the V23-2-0IOFreeze ASAP to start running regression tests
    • Given the sheer amount of VT we've had to do, and model API changes, I do expect a lot of issues and I want to catch these early on (especially if it requires changes to E+)

@jmarrec jmarrec merged commit 830ad7e into v23.2.0-IOFreeze Sep 20, 2023
2 of 4 checks passed
@jmarrec jmarrec deleted the v23.2.0-IOFreeze-RenameDistrictHeating branch September 20, 2023 12:43
@joseph-robertson joseph-robertson mentioned this pull request Sep 27, 2023
26 tasks
@joseph-robertson joseph-robertson linked an issue Sep 27, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - IDF Translation component - Model IDDChange Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E+ 23.2.0: Wrap DistrictHeating:Steam
3 participants