Skip to content

Commit

Permalink
Hotfix #4962 - Add VT for HeatPump:PlantLoop:EIR new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrec committed Sep 28, 2023
1 parent 28252a8 commit bad90b7
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 0 deletions.
76 changes: 76 additions & 0 deletions src/osversion/VersionTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8863,6 +8863,82 @@ namespace osversion {
ss << newObject;
m_refactored.emplace_back(std::move(object), std::move(newObject));

} else if (iddname == "OS:HeatPump:PlantLoop:EIR:Cooling") {

// Fields that have been added from 3.6.1 to 3.7.0:
// ------------------------------------------------
// * Control Type * 16
// * Flow Mode * 17
// * Minimum Part Load Ratio * 18
// * Minimum Source Inlet Temperature * 19
// * Maximum Source Inlet Temperature * 20
// * Minimum Supply Water Temperature Curve Name * 21 --- Optional
// * Maximum Supply Water Temperature Curve Name * 22 --- Optional

auto iddObject = idd_3_7_0.getObject(iddname);
IdfObject newObject(iddObject.get());

for (size_t i = 0; i < object.numFields(); ++i) {
if ((value = object.getString(i))) {
newObject.setString(i, value.get());
}
}

newObject.setString(16, "Load");
newObject.setString(17, "ConstantFlow");
newObject.setDouble(18, 0.0);
newObject.setDouble(19, -100.0);
newObject.setDouble(20, 100.0);

ss << newObject;
m_refactored.emplace_back(std::move(object), std::move(newObject));

} else if (iddname == "OS:HeatPump:PlantLoop:EIR:Heating") {

// Fields that have been added from 3.6.1 to 3.7.0:
// ------------------------------------------------
// * Heating To Cooling Capacity Sizing Ratio * 16
// * Heat Pump Sizing Method * 17
// * Control Type * 18
// * Flow Mode * 19
// * Minimum Part Load Ratio * 20
// * Minimum Source Inlet Temperature * 21
// * Maximum Source Inlet Temperature * 22
// * Minimum Supply Water Temperature Curve Name * 23 --- Optional
// * Maximum Supply Water Temperature Curve Name * 24 --- Optional
// * Dry Outdoor Correction Factor Curve Name * 25
// * Maximum Outdoor Dry Bulb Temperature For Defrost Operation * 26
// * Heat Pump Defrost Control * 27
// * Heat Pump Defrost Time Period Fraction * 28
// * Defrost Energy Input Ratio Function of Temperature Curve Name * 29 --- Optional
// * Timed Empirical Defrost Frequency Curve Name * 30 --- Optional
// * Timed Empirical Defrost Heat Load Penalty Curve Name * 31 --- Optional
// * Timed Empirical Defrost Heat Input Energy Fraction Curve Name * 32 --- Optional

auto iddObject = idd_3_7_0.getObject(iddname);
IdfObject newObject(iddObject.get());

for (size_t i = 0; i < object.numFields(); ++i) {
if ((value = object.getString(i))) {
newObject.setString(i, value.get());
}
}
newObject.setDouble(16, 1.0);
newObject.setString(17, "CoolingCapacity");
newObject.setString(18, "Load");
newObject.setString(19, "ConstantFlow");

newObject.setDouble(20, 0.0);
newObject.setDouble(21, -100.0);
newObject.setDouble(22, 100.0);

newObject.setDouble(26, 10.0);
newObject.setString(27, "None");
newObject.setDouble(28, 0.058333);

ss << newObject;
m_refactored.emplace_back(std::move(object), std::move(newObject));

// No-op
} else {
ss << object;
Expand Down
131 changes: 131 additions & 0 deletions src/osversion/test/3_7_0/test_vt_HeatPumpPlantLoopEIR.osm
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@

OS:Version,
{33071ded-2315-4908-99af-ab183bb0c205}, !- Handle
3.6.1; !- Version Identifier

OS:HeatPump:PlantLoop:EIR:Heating,
{a44033ba-0e68-4b7f-96b1-070c5072cdbc}, !- Handle
Heat Pump Plant Loop EIR Heating 1, !- Name
, !- Load Side Inlet Node Name
, !- Load Side Outlet Node Name
AirSource, !- Condenser Type
, !- Source Side Inlet Node Name
, !- Source Side Outlet Node Name
, !- Companion Heat Pump Name
Autosize, !- Load Side Reference Flow Rate {m3/s}
Autosize, !- Source Side Reference Flow Rate {m3/s}
Autosize, !- Reference Capacity {W}
7.5, !- Reference Coefficient of Performance {W/W}
1, !- Sizing Factor
{0532b92b-8926-4477-885d-c8e094088ed1}, !- Capacity Modifier Function of Temperature Curve Name
{1e69a32e-47fd-4dc8-a960-70a19d98cb92}, !- Electric Input to Output Ratio Modifier Function of Temperature Curve Name
{20c68188-c744-4f92-b7a3-e744e67b4eae}; !- Electric Input to Output Ratio Modifier Function of Part Load Ratio Curve Name

OS:Curve:Biquadratic,
{0532b92b-8926-4477-885d-c8e094088ed1}, !- Handle
Curve Biquadratic 1, !- Name
1, !- Coefficient1 Constant
0, !- Coefficient2 x
0, !- Coefficient3 x**2
0, !- Coefficient4 y
0, !- Coefficient5 y**2
0, !- Coefficient6 x*y
5, !- Minimum Value of x
10, !- Maximum Value of x
24, !- Minimum Value of y
35, !- Maximum Value of y
, !- Minimum Curve Output
, !- Maximum Curve Output
Temperature, !- Input Unit Type for X
Temperature; !- Input Unit Type for Y

OS:Curve:Biquadratic,
{1e69a32e-47fd-4dc8-a960-70a19d98cb92}, !- Handle
Curve Biquadratic 2, !- Name
1, !- Coefficient1 Constant
0, !- Coefficient2 x
0, !- Coefficient3 x**2
0, !- Coefficient4 y
0, !- Coefficient5 y**2
0, !- Coefficient6 x*y
5, !- Minimum Value of x
10, !- Maximum Value of x
24, !- Minimum Value of y
35, !- Maximum Value of y
, !- Minimum Curve Output
, !- Maximum Curve Output
Temperature, !- Input Unit Type for X
Temperature; !- Input Unit Type for Y

OS:Curve:Quadratic,
{20c68188-c744-4f92-b7a3-e744e67b4eae}, !- Handle
HeatEIRfPLR, !- Name
1, !- Coefficient1 Constant
0, !- Coefficient2 x
0, !- Coefficient3 x**2
0, !- Minimum Value of x
1; !- Maximum Value of x

OS:HeatPump:PlantLoop:EIR:Cooling,
{42986a97-3f97-4537-a758-720c86b7a317}, !- Handle
Heat Pump Plant Loop EIR Cooling 1, !- Name
, !- Load Side Inlet Node Name
, !- Load Side Outlet Node Name
AirSource, !- Condenser Type
, !- Source Side Inlet Node Name
, !- Source Side Outlet Node Name
, !- Companion Heat Pump Name
Autosize, !- Load Side Reference Flow Rate {m3/s}
Autosize, !- Source Side Reference Flow Rate {m3/s}
Autosize, !- Reference Capacity {W}
7.5, !- Reference Coefficient of Performance {W/W}
1, !- Sizing Factor
{a60237b3-76b8-4399-a7a4-d2a8e55b6d03}, !- Capacity Modifier Function of Temperature Curve Name
{691e3725-6804-4c01-91c5-853bdb27d116}, !- Electric Input to Output Ratio Modifier Function of Temperature Curve Name
{6467d34e-e8fe-4bf7-a42b-bf4a51585284}; !- Electric Input to Output Ratio Modifier Function of Part Load Ratio Curve Name

OS:Curve:Biquadratic,
{a60237b3-76b8-4399-a7a4-d2a8e55b6d03}, !- Handle
Curve Biquadratic 3, !- Name
1, !- Coefficient1 Constant
0, !- Coefficient2 x
0, !- Coefficient3 x**2
0, !- Coefficient4 y
0, !- Coefficient5 y**2
0, !- Coefficient6 x*y
5, !- Minimum Value of x
10, !- Maximum Value of x
24, !- Minimum Value of y
35, !- Maximum Value of y
, !- Minimum Curve Output
, !- Maximum Curve Output
Temperature, !- Input Unit Type for X
Temperature; !- Input Unit Type for Y

OS:Curve:Biquadratic,
{691e3725-6804-4c01-91c5-853bdb27d116}, !- Handle
Curve Biquadratic 4, !- Name
1, !- Coefficient1 Constant
0, !- Coefficient2 x
0, !- Coefficient3 x**2
0, !- Coefficient4 y
0, !- Coefficient5 y**2
0, !- Coefficient6 x*y
5, !- Minimum Value of x
10, !- Maximum Value of x
24, !- Minimum Value of y
35, !- Maximum Value of y
, !- Minimum Curve Output
, !- Maximum Curve Output
Temperature, !- Input Unit Type for X
Temperature; !- Input Unit Type for Y

OS:Curve:Quadratic,
{6467d34e-e8fe-4bf7-a42b-bf4a51585284}, !- Handle
CoolEIRfPLR, !- Name
1, !- Coefficient1 Constant
0, !- Coefficient2 x
0, !- Coefficient3 x**2
0, !- Minimum Value of x
1; !- Maximum Value of x

13 changes: 13 additions & 0 deletions src/osversion/test/3_7_0/test_vt_HeatPumpPlantLoopEIR.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#require '/usr/local/openstudio-3.6.1/Ruby/openstudio'

include OpenStudio::Model

m = Model.new

hp_heating = HeatPumpPlantLoopEIRHeating.new(m)
hp_heating.electricInputtoOutputRatioModifierFunctionofPartLoadRatioCurve.setName("HeatEIRfPLR")

hp_cooling = HeatPumpPlantLoopEIRCooling.new(m)
hp_cooling.electricInputtoOutputRatioModifierFunctionofPartLoadRatioCurve.setName("CoolEIRfPLR")

m.save('test_vt_HeatPumpPlantLoopEIR.osm', true)
58 changes: 58 additions & 0 deletions src/osversion/test/VersionTranslator_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3962,3 +3962,61 @@ TEST_F(OSVersionFixture, update_3_6_1_to_3_7_0_LoadProfilePlant) {
EXPECT_EQ(5.0, lp.getDouble(8).get()); // Degree of SubCooling {C}
EXPECT_EQ(20.0, lp.getDouble(9).get()); // Degree of Loop SubCooling {C}
}

TEST_F(OSVersionFixture, update_3_6_1_to_3_7_0_HeatPumpPlantLoopEIR) {
openstudio::path osmPath = resourcesPath() / toPath("osversion/3_7_0/test_vt_HeatPumpPlantLoopEIR.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> hps = model_->getObjectsByType("OS:HeatPump:PlantLoop:EIR:Cooling");
ASSERT_EQ(1u, hps.size());
const auto& hp = hps.front();

// Previous last field
ASSERT_TRUE(hp.getTarget(15));
EXPECT_EQ("CoolEIRfPLR", hp.getTarget(15)->nameString());

int insertionIndex = 16;
EXPECT_EQ("Load", hp.getString(insertionIndex++).get()); // ControlType
EXPECT_EQ("ConstantFlow", hp.getString(insertionIndex++).get()); // FlowMode
EXPECT_EQ(0.0, hp.getDouble(insertionIndex++).get()); // MinimumPartLoadRatio
EXPECT_EQ(-100.0, hp.getDouble(insertionIndex++).get()); // MinimumSourceInletTemperature
EXPECT_EQ(100.0, hp.getDouble(insertionIndex++).get()); // MaximumSourceInletTemperature
EXPECT_TRUE(hp.isEmpty(insertionIndex++)); // MinimumSupplyWaterTemperatureCurveName
EXPECT_TRUE(hp.isEmpty(insertionIndex++)); // MaximumSupplyWaterTemperatureCurveName
}

{
std::vector<WorkspaceObject> hps = model_->getObjectsByType("OS:HeatPump:PlantLoop:EIR:Heating");
ASSERT_EQ(1u, hps.size());
const auto& hp = hps.front();

// Previous last field
ASSERT_TRUE(hp.getTarget(15));
EXPECT_EQ("HeatEIRfPLR", hp.getTarget(15)->nameString());

int insertionIndex = 16;
EXPECT_EQ(1.0, hp.getDouble(insertionIndex++).get()); // HeatingToCoolingCapacitySizingRatio
EXPECT_EQ("CoolingCapacity", hp.getString(insertionIndex++).get()); // HeatPumpSizingMethod
EXPECT_EQ("Load", hp.getString(insertionIndex++).get()); // ControlType
EXPECT_EQ("ConstantFlow", hp.getString(insertionIndex++).get()); // FlowMode
EXPECT_EQ(0.0, hp.getDouble(insertionIndex++).get()); // MinimumPartLoadRatio
EXPECT_EQ(-100.0, hp.getDouble(insertionIndex++).get()); // MinimumSourceInletTemperature
EXPECT_EQ(100.0, hp.getDouble(insertionIndex++).get()); // MaximumSourceInletTemperature
EXPECT_TRUE(hp.isEmpty(insertionIndex++)); // MinimumSupplyWaterTemperatureCurveName
EXPECT_TRUE(hp.isEmpty(insertionIndex++)); // MaximumSupplyWaterTemperatureCurveName
EXPECT_TRUE(hp.isEmpty(insertionIndex++)); // DryOutdoorCorrectionFactorCurveName
EXPECT_EQ(10.0, hp.getDouble(insertionIndex++).get()); // MaximumOutdoorDryBulbTemperatureForDefrostOperation
EXPECT_EQ("None", hp.getString(insertionIndex++).get()); // HeatPumpDefrostControl
EXPECT_EQ(0.058333, hp.getDouble(insertionIndex++).get()); // HeatPumpDefrostTimePeriodFraction
EXPECT_TRUE(hp.isEmpty(insertionIndex++)); // DefrostEnergyInputRatioFunctionofTemperatureCurveName
EXPECT_TRUE(hp.isEmpty(insertionIndex++)); // TimedEmpiricalDefrostFrequencyCurveName
EXPECT_TRUE(hp.isEmpty(insertionIndex++)); // TimedEmpiricalDefrostHeatLoadPenaltyCurveName
EXPECT_TRUE(hp.isEmpty(insertionIndex++)); // TimedEmpiricalDefrostHeatInputEnergyFractionCurveName
}
}

0 comments on commit bad90b7

Please sign in to comment.