src/energyplus/ForwardTranslator/ForwardTranslateCentralHeatPumpSystem.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "../ForwardTranslator.hpp" | ||
| 7 | #include "../../model/Model.hpp" | ||
| 8 | #include "../../model/CentralHeatPumpSystem.hpp" | ||
| 9 | #include "../../model/CentralHeatPumpSystem_Impl.hpp" | ||
| 10 | #include "../../model/CentralHeatPumpSystemModule.hpp" | ||
| 11 | #include "../../model/ChillerHeaterPerformanceElectricEIR.hpp" | ||
| 12 | #include "../../model/Schedule.hpp" | ||
| 13 | #include "../../model/Node.hpp" | ||
| 14 | #include "../../model/Node_Impl.hpp" | ||
| 15 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 16 | #include "../../utilities/core/Logger.hpp" | ||
| 17 | #include <utilities/idd/CentralHeatPumpSystem_FieldEnums.hxx> | ||
| 18 | #include <utilities/idd/IddEnums.hxx> | ||
| 19 | |||
| 20 | using namespace openstudio::model; | ||
| 21 | |||
| 22 | namespace openstudio { | ||
| 23 | |||
| 24 | namespace energyplus { | ||
| 25 | |||
| 26 | 7 | boost::optional<IdfObject> ForwardTranslator::translateCentralHeatPumpSystem(CentralHeatPumpSystem& modelObject) { | |
| 27 | 7 | OptionalDouble d; | |
| 28 | 7 | OptionalModelObject temp; | |
| 29 | |||
| 30 |
1/1✓ Branch 3 taken 7 times.
|
7 | auto const& modules = modelObject.getImpl<model::detail::CentralHeatPumpSystem_Impl>()->modules(); |
| 31 | |||
| 32 | // If the CentralHeatPumpSystem doesn't have at least one CentralHeatPumpSystemModule, then it shouldn't be translated | ||
| 33 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
|
7 | if (modules.empty()) { |
| 34 |
9/9✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 5 times.
✓ Branch 13 taken 5 times.
✓ Branch 16 taken 5 times.
✓ Branch 20 taken 5 times.
✓ Branch 23 taken 5 times.
✓ Branch 26 taken 5 times.
|
5 | LOG(Warn, "CentralHeatPumpSystem " << modelObject.name().get() << " has no CentralHeatPumpSystemModules, it will not be translated"); |
| 35 | 5 | return boost::none; | |
| 36 | } | ||
| 37 | |||
| 38 | // Name | ||
| 39 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::CentralHeatPumpSystem, modelObject); |
| 40 | |||
| 41 | // AncillaryPower | ||
| 42 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
4 | if ((d = modelObject.ancillaryPower())) { |
| 43 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | idfObject.setDouble(CentralHeatPumpSystemFields::AncillaryPower, d.get()); |
| 44 | } | ||
| 45 | |||
| 46 | // AncillaryOperationScheduleName | ||
| 47 | { | ||
| 48 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
|
4 | if (auto schedule = modelObject.ancillaryOperationSchedule()) { |
| 49 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
|
2 | if (auto _schedule = translateAndMapModelObject(schedule.get())) { |
| 50 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | idfObject.setString(CentralHeatPumpSystemFields::AncillaryOperationScheduleName, _schedule->name().get()); |
| 51 | 1 | } | |
| 52 | 2 | } | |
| 53 | } | ||
| 54 | |||
| 55 | // supply = Cooling Loop, demand=Source Loop, tertiary = Heating Loop | ||
| 56 | |||
| 57 | // CoolingLoopInletNodeName | ||
| 58 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (auto mo = modelObject.supplyInletModelObject()) { |
| 59 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (auto node = mo->optionalCast<Node>()) { |
| 60 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | idfObject.setString(CentralHeatPumpSystemFields::CoolingLoopInletNodeName, node->name().get()); |
| 61 | 2 | } | |
| 62 | 2 | } | |
| 63 | |||
| 64 | // CoolingLoopOutletNodeName | ||
| 65 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (auto mo = modelObject.supplyOutletModelObject()) { |
| 66 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (auto node = mo->optionalCast<Node>()) { |
| 67 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | idfObject.setString(CentralHeatPumpSystemFields::CoolingLoopOutletNodeName, node->name().get()); |
| 68 | 2 | } | |
| 69 | 2 | } | |
| 70 | |||
| 71 | // SourceLoopInletNodeName | ||
| 72 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (auto mo = modelObject.demandInletModelObject()) { |
| 73 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (auto node = mo->optionalCast<Node>()) { |
| 74 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | idfObject.setString(CentralHeatPumpSystemFields::SourceLoopInletNodeName, node->name().get()); |
| 75 | 2 | } | |
| 76 | 2 | } | |
| 77 | |||
| 78 | // SourceLoopOutletNodeName | ||
| 79 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (auto mo = modelObject.demandOutletModelObject()) { |
| 80 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (auto node = mo->optionalCast<Node>()) { |
| 81 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | idfObject.setString(CentralHeatPumpSystemFields::SourceLoopOutletNodeName, node->name().get()); |
| 82 | 2 | } | |
| 83 | 2 | } | |
| 84 | |||
| 85 | // HeatingLoopInletNodeName | ||
| 86 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (auto mo = modelObject.tertiaryInletModelObject()) { |
| 87 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (auto node = mo->optionalCast<Node>()) { |
| 88 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | idfObject.setString(CentralHeatPumpSystemFields::HeatingLoopInletNodeName, node->name().get()); |
| 89 | 2 | } | |
| 90 | 2 | } | |
| 91 | // HeatingLoopOutletNodeName | ||
| 92 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (auto mo = modelObject.tertiaryOutletModelObject()) { |
| 93 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (auto node = mo->optionalCast<Node>()) { |
| 94 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | idfObject.setString(CentralHeatPumpSystemFields::HeatingLoopOutletNodeName, node->name().get()); |
| 95 | 2 | } | |
| 96 | 2 | } | |
| 97 | |||
| 98 | // ChillerHeaterModulesPerformanceComponentObjectType1 | ||
| 99 | // ChillerHeaterModulesPerformanceComponentName1 | ||
| 100 | // ChillerHeaterModulesControlScheduleName1 | ||
| 101 | // NumberofChillerHeaterModules1 | ||
| 102 | |||
| 103 |
2/2✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2 times.
|
5 | for (auto const& module : modules) { |
| 104 |
1/1✓ Branch 1 taken 3 times.
|
3 | IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); |
| 105 | |||
| 106 |
1/1✓ Branch 1 taken 3 times.
|
3 | auto performanceComponent = module.chillerHeaterModulesPerformanceComponent(); |
| 107 |
2/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | if (auto _performanceComponent = translateAndMapModelObject(performanceComponent)) { |
| 108 |
1/1✓ Branch 1 taken 3 times.
|
3 | group.setString(CentralHeatPumpSystemExtensibleFields::ChillerHeaterModulesPerformanceComponentObjectType, |
| 109 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
6 | _performanceComponent->iddObject().name()); |
| 110 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
|
3 | group.setString(CentralHeatPumpSystemExtensibleFields::ChillerHeaterModulesPerformanceComponentName, _performanceComponent->name().get()); |
| 111 | 3 | } | |
| 112 | { | ||
| 113 |
1/1✓ Branch 1 taken 3 times.
|
3 | auto schedule = module.chillerHeaterModulesControlSchedule(); |
| 114 |
2/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
|
6 | if (auto _schedule = translateAndMapModelObject(schedule)) { |
| 115 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
|
3 | group.setString(CentralHeatPumpSystemExtensibleFields::ChillerHeaterModulesControlScheduleName, _schedule->name().get()); |
| 116 | 3 | } | |
| 117 | 3 | } | |
| 118 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | group.setInt(CentralHeatPumpSystemExtensibleFields::NumberofChillerHeaterModules, module.numberofChillerHeaterModules()); |
| 119 | 3 | } | |
| 120 | |||
| 121 |
1/1✓ Branch 1 taken 2 times.
|
2 | return idfObject; |
| 122 | 7 | } | |
| 123 | |||
| 124 | } // namespace energyplus | ||
| 125 | |||
| 126 | } // namespace openstudio | ||
| 127 |