Skip to content

Commit

Permalink
Improve VT and VT test (name objects better, explicit test fields)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrec committed Mar 6, 2024
1 parent 4110e93 commit 3994d48
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 76 deletions.
48 changes: 27 additions & 21 deletions src/osversion/VersionTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8960,6 +8960,10 @@ namespace osversion {
IdfFile targetIdf(idd_3_8_0.iddFile());
ss << targetIdf.versionObject().get();

constexpr std::array<int, 4> hx_old_100effectiveness_idxs{4, 5, 8, 9};
constexpr std::array<int, 4> hx_new_effectiveness_curves_idxs{20, 21, 22, 23};
constexpr std::array<std::string_view, 4> hx_new_table_names{"SensHeat", "LatHeat", "SensCool", "LatCool"};

for (const IdfObject& object : idf_3_7_0.objects()) {
auto iddname = object.iddObject().name();

Expand Down Expand Up @@ -8998,30 +9002,32 @@ namespace osversion {
}
}

std::string varListHandle = toString(createUUID());
std::vector<int> e_idxs = {4, 5, 8, 9};
std::vector<int> c_idxs = {20, 21, 22, 23};
const std::string varListHandle = toString(createUUID());
bool tableAdded = false;
for (size_t i = 0; i < e_idxs.size(); ++i) {
if (auto e100 = object.getDouble(e_idxs[i])) { // Sensible/Latent Effectiveness at 100% Heating/Cooling Air Flow {dimensionless}
if (auto e75 = object.getDouble(e_idxs[i] + 2)) { // Sensible/Latent Effectiveness at 75% Heating/Cooling Air Flow {dimensionless}
for (size_t i = 0; i < hx_old_100effectiveness_idxs.size(); ++i) {
// Sensible/Latent Effectiveness at 100% Heating/Cooling Air Flow {dimensionless}
if (auto e100 = object.getDouble(hx_old_100effectiveness_idxs[i])) {
// Sensible/Latent Effectiveness at 75% Heating/Cooling Air Flow {dimensionless}

if (auto e75 = object.getDouble(hx_old_100effectiveness_idxs[i] + 2)) {
if (e100.get() != e75.get()) {
tableAdded = true;

IdfObject tableLookup(idd_3_8_0.getObject("OS:Table:Lookup").get());
std::string uuid = toString(createUUID());
tableLookup.setString(0, uuid); // Handle
tableLookup.setString(1, object.nameString() + "_" + std::to_string(i + 1)); // Name
tableLookup.setString(2, varListHandle); // Independent Variable List Name
tableLookup.setString(3, "DivisorOnly"); // Normalization Method
tableLookup.setDouble(4, e100.get()); // Normalization Divisor
tableLookup.setDouble(5, 0.0); // Minimum Output
tableLookup.setDouble(6, 10.0); // Maximum Output
tableLookup.setString(7, "Dimensionless"); // Output Unit Type
tableLookup.pushExtensibleGroup().setDouble(0, e75.get()); // Output Value 1
tableLookup.pushExtensibleGroup().setDouble(0, e100.get()); // Output Value 2

newObject.setString(c_idxs[i], uuid); // Sensible/Latent Effectiveness of Heating/Cooling Air Flow Curve Name
tableLookup.setString(0, uuid); // Handle
tableLookup.setString(1, fmt::format("{}_{}Eff", object.nameString(), hx_new_table_names[i])); // Name
tableLookup.setString(2, varListHandle); // Independent Variable List Name
tableLookup.setString(3, "DivisorOnly"); // Normalization Method
tableLookup.setDouble(4, e100.get()); // Normalization Divisor
tableLookup.setDouble(5, 0.0); // Minimum Output
tableLookup.setDouble(6, 10.0); // Maximum Output
tableLookup.setString(7, "Dimensionless"); // Output Unit Type
tableLookup.pushExtensibleGroup().setDouble(0, e75.get()); // Output Value 1
tableLookup.pushExtensibleGroup().setDouble(0, e100.get()); // Output Value 2

// Sensible/Latent Effectiveness of Heating/Cooling Air Flow Curve Name
newObject.setString(hx_new_effectiveness_curves_idxs[i], uuid);

ss << tableLookup;
m_new.push_back(tableLookup);
Expand All @@ -9030,8 +9036,8 @@ namespace osversion {
}
}

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

if (tableAdded) {
IdfObject varList(idd_3_8_0.getObject("OS:ModelObjectList").get());
Expand All @@ -9051,11 +9057,11 @@ namespace osversion {
var.pushExtensibleGroup().setDouble(0, 0.75); // Value 1
var.pushExtensibleGroup().setDouble(0, 1.0); // Value 2

m_new.push_back(varList);
ss << varList;
m_new.emplace_back(std::move(varList));

m_new.push_back(var);
ss << var;
m_new.emplace_back(std::move(var));
}

// No-op
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,159 @@

OS:Version,
{5a8dca7f-9180-4865-acc0-eac9963d8ef3}, !- Handle
{35621888-8471-4654-b196-7a10e6d60d77}, !- Handle
3.7.0; !- Version Identifier

OS:HeatExchanger:AirToAir:SensibleAndLatent,
{e04c7943-5596-465d-878a-0db9f84f6c93}, !- Handle
Heat Exchanger Air To Air Sensible And Latent 1, !- Name
{47eea206-1ff3-4b61-88b1-7bc9ead8760a}, !- Availability Schedule
{67e2de0d-3ea9-42c1-88b8-0a04128deac9}, !- Handle
ERV, !- Name
{2a77b641-92f2-4915-a135-3d358f2ed6d0}, !- Availability Schedule
autosize, !- Nominal Supply Air Flow Rate {m3/s}
0.76, !- Sensible Effectiveness at 100% Heating Air Flow {dimensionless}
0.68, !- Latent Effectiveness at 100% Heating Air Flow {dimensionless}
0.81, !- Sensible Effectiveness at 75% Heating Air Flow {dimensionless}
0.73, !- Latent Effectiveness at 75% Heating Air Flow {dimensionless}
0.76, !- Sensible Effectiveness at 100% Cooling Air Flow {dimensionless}
0.68, !- Latent Effectiveness at 100% Cooling Air Flow {dimensionless}
0.81, !- Sensible Effectiveness at 75% Cooling Air Flow {dimensionless}
0.73, !- Latent Effectiveness at 75% Cooling Air Flow {dimensionless}
, !- Supply Air Inlet Node
, !- Supply Air Outlet Node
, !- Exhaust Air Inlet Node
, !- Exhaust Air Outlet Node
0.74, !- Sensible Effectiveness at 100% Cooling Air Flow {dimensionless}
0.67, !- Latent Effectiveness at 100% Cooling Air Flow {dimensionless}
0.8, !- Sensible Effectiveness at 75% Cooling Air Flow {dimensionless}
0.72, !- Latent Effectiveness at 75% Cooling Air Flow {dimensionless}
{0a300f71-b1bc-4ad0-b33d-78538aba9f4d}, !- Supply Air Inlet Node
{d8090337-7cf3-4469-91e6-4cf247eb4a14}, !- Supply Air Outlet Node
{96f29526-15b8-419d-9d22-18e2f34655b7}, !- Exhaust Air Inlet Node
{34c68d89-61b1-4354-9845-2bcbfa55bdde}, !- Exhaust Air Outlet Node
0, !- Nominal Electric Power {W}
Yes, !- Supply Air Outlet Temperature Control
Plate, !- Heat Exchanger Type
None, !- Frost Control Type
1.7, !- Threshold Temperature {C}
, !- Initial Defrost Time Fraction {dimensionless}
, !- Rate of Defrost Time Fraction Increase {1/K}
Yes; !- Economizer Lockout
No; !- Economizer Lockout

OS:Schedule:Constant,
{47eea206-1ff3-4b61-88b1-7bc9ead8760a}, !- Handle
{2a77b641-92f2-4915-a135-3d358f2ed6d0}, !- Handle
Always On Discrete, !- Name
{f1aa0f40-39f0-4ad4-a148-2ca756a8d74f}, !- Schedule Type Limits Name
{424ab631-0001-433e-a6c6-3c9bf194df94}, !- Schedule Type Limits Name
1; !- Value

OS:ScheduleTypeLimits,
{f1aa0f40-39f0-4ad4-a148-2ca756a8d74f}, !- Handle
{424ab631-0001-433e-a6c6-3c9bf194df94}, !- Handle
OnOff, !- Name
0, !- Lower Limit Value
1, !- Upper Limit Value
Discrete, !- Numeric Type
Availability; !- Unit Type

OS:Controller:OutdoorAir,
{2f48a111-690e-4cac-a0c4-4a7daaf03f94}, !- Handle
Controller Outdoor Air 1, !- Name
, !- Relief Air Outlet Node Name
, !- Return Air Node Name
, !- Mixed Air Node Name
, !- Actuator Node Name
0, !- Minimum Outdoor Air Flow Rate {m3/s}
Autosize, !- Maximum Outdoor Air Flow Rate {m3/s}
NoEconomizer, !- Economizer Control Type
ModulateFlow, !- Economizer Control Action Type
28, !- Economizer Maximum Limit Dry-Bulb Temperature {C}
64000, !- Economizer Maximum Limit Enthalpy {J/kg}
, !- Economizer Maximum Limit Dewpoint Temperature {C}
, !- Electronic Enthalpy Limit Curve Name
-100, !- Economizer Minimum Limit Dry-Bulb Temperature {C}
NoLockout, !- Lockout Type
FixedMinimum, !- Minimum Limit Type
, !- Minimum Outdoor Air Schedule Name
, !- Minimum Fraction of Outdoor Air Schedule Name
, !- Maximum Fraction of Outdoor Air Schedule Name
{5b6f1b3f-2d43-4874-8e80-1f863931595b}, !- Controller Mechanical Ventilation
, !- Time of Day Economizer Control Schedule Name
No, !- High Humidity Control
, !- Humidistat Control Zone Name
, !- High Humidity Outdoor Air Flow Ratio
, !- Control High Indoor Humidity Based on Outdoor Humidity Ratio
BypassWhenWithinEconomizerLimits, !- Heat Recovery Bypass Control Type
InterlockedWithMechanicalCooling; !- Economizer Operation Staging

OS:Controller:MechanicalVentilation,
{5b6f1b3f-2d43-4874-8e80-1f863931595b}, !- Handle
Controller Mechanical Ventilation 1, !- Name
{2a77b641-92f2-4915-a135-3d358f2ed6d0}, !- Availability Schedule
, !- Demand Controlled Ventilation
; !- System Outdoor Air Method

OS:AirLoopHVAC:OutdoorAirSystem,
{a5b85d9c-2fc9-4b26-aa5c-da16db98efaa}, !- Handle
Air Loop HVAC Outdoor Air System 1, !- Name
{2f48a111-690e-4cac-a0c4-4a7daaf03f94}, !- Controller Name
, !- Outdoor Air Equipment List Name
, !- Availability Manager List Name
, !- Mixed Air Node Name
{d5901fbe-722e-4175-810f-d57fef602118}, !- Outdoor Air Stream Node Name
{c8a3f5a9-2e0b-43b2-abb7-d71fb91d455f}, !- Relief Air Stream Node Name
; !- Return Air Stream Node Name

OS:Node,
{97f5f18a-aef2-498e-9178-a51afbe800f2}, !- Handle
Outboard OA Node, !- Name
, !- Inlet Port
{0a300f71-b1bc-4ad0-b33d-78538aba9f4d}; !- Outlet Port

OS:Node,
{eaed6165-9257-4d9a-ae4f-acf7c2f2397f}, !- Handle
Relief Node, !- Name
{34c68d89-61b1-4354-9845-2bcbfa55bdde}, !- Inlet Port
; !- Outlet Port

OS:Node,
{90d802c8-2719-485c-a00b-a18a2e352174}, !- Handle
Node 2, !- Name
{d8090337-7cf3-4469-91e6-4cf247eb4a14}, !- Inlet Port
{d5901fbe-722e-4175-810f-d57fef602118}; !- Outlet Port

OS:Connection,
{0a300f71-b1bc-4ad0-b33d-78538aba9f4d}, !- Handle
{97f5f18a-aef2-498e-9178-a51afbe800f2}, !- Source Object
3, !- Outlet Port
{67e2de0d-3ea9-42c1-88b8-0a04128deac9}, !- Target Object
12; !- Inlet Port

OS:Connection,
{d8090337-7cf3-4469-91e6-4cf247eb4a14}, !- Handle
{67e2de0d-3ea9-42c1-88b8-0a04128deac9}, !- Source Object
13, !- Outlet Port
{90d802c8-2719-485c-a00b-a18a2e352174}, !- Target Object
2; !- Inlet Port

OS:Connection,
{d5901fbe-722e-4175-810f-d57fef602118}, !- Handle
{90d802c8-2719-485c-a00b-a18a2e352174}, !- Source Object
3, !- Outlet Port
{a5b85d9c-2fc9-4b26-aa5c-da16db98efaa}, !- Target Object
6; !- Inlet Port

OS:Node,
{381769e1-53aa-4267-abed-5d8adb16f251}, !- Handle
Node 3, !- Name
{c8a3f5a9-2e0b-43b2-abb7-d71fb91d455f}, !- Inlet Port
{96f29526-15b8-419d-9d22-18e2f34655b7}; !- Outlet Port

OS:Connection,
{c8a3f5a9-2e0b-43b2-abb7-d71fb91d455f}, !- Handle
{a5b85d9c-2fc9-4b26-aa5c-da16db98efaa}, !- Source Object
7, !- Outlet Port
{381769e1-53aa-4267-abed-5d8adb16f251}, !- Target Object
2; !- Inlet Port

OS:Connection,
{96f29526-15b8-419d-9d22-18e2f34655b7}, !- Handle
{381769e1-53aa-4267-abed-5d8adb16f251}, !- Source Object
3, !- Outlet Port
{67e2de0d-3ea9-42c1-88b8-0a04128deac9}, !- Target Object
14; !- Inlet Port

OS:Connection,
{34c68d89-61b1-4354-9845-2bcbfa55bdde}, !- Handle
{67e2de0d-3ea9-42c1-88b8-0a04128deac9}, !- Source Object
15, !- Outlet Port
{eaed6165-9257-4d9a-ae4f-acf7c2f2397f}, !- Target Object
2; !- Inlet Port

Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,28 @@
m = Model.new

hx = HeatExchangerAirToAirSensibleAndLatent.new(m)
hx.setName("ERV")

m.save('test_vt_HeatExchangerAirToAirSensibleAndLatent.osm', true)
hx.autosizeNominalSupplyAirFlowRate

hx.setSensibleEffectivenessat100HeatingAirFlow(0.76)
hx.setLatentEffectivenessat100HeatingAirFlow(0.68)

hx.setSensibleEffectivenessat75HeatingAirFlow(0.81)
hx.setLatentEffectivenessat75HeatingAirFlow(0.73)

hx.setSensibleEffectivenessat100CoolingAirFlow(0.74)
hx.setLatentEffectivenessat100CoolingAirFlow(0.67)

hx.setSensibleEffectivenessat75CoolingAirFlow(0.80)
hx.setLatentEffectivenessat75CoolingAirFlow(0.72)

# Field right after is the supply air inlet node
controller = ControllerOutdoorAir.new(m)
oaSystem = AirLoopHVACOutdoorAirSystem.new(m, controller)
hx.addToNode(oaSystem.outboardOANode.get)

# Last field
hx.setEconomizerLockout(false)

m.save('test_vt_HeatExchangerAirToAirSensibleAndLatent.osm', true)
Loading

0 comments on commit 3994d48

Please sign in to comment.