src/energyplus/ForwardTranslator/ForwardTranslateGasEquipment.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 | |||
| 8 | #include "../../model/Model.hpp" | ||
| 9 | #include "../../model/GasEquipment.hpp" | ||
| 10 | #include "../../model/GasEquipment_Impl.hpp" | ||
| 11 | #include "../../model/GasEquipmentDefinition.hpp" | ||
| 12 | #include "../../model/GasEquipmentDefinition_Impl.hpp" | ||
| 13 | #include "../../model/Space.hpp" | ||
| 14 | #include "../../model/Space_Impl.hpp" | ||
| 15 | #include "../../model/SpaceType.hpp" | ||
| 16 | #include "../../model/SpaceType_Impl.hpp" | ||
| 17 | #include "../../model/ThermalZone.hpp" | ||
| 18 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 19 | #include "../../model/Schedule.hpp" | ||
| 20 | #include "../../model/Schedule_Impl.hpp" | ||
| 21 | #include "../../model/LifeCycleCost.hpp" | ||
| 22 | |||
| 23 | #include <utilities/idd/GasEquipment_FieldEnums.hxx> | ||
| 24 | #include <utilities/idd/GasEquipment_Instance_FieldEnums.hxx> | ||
| 25 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 26 | #include <utilities/idd/IddEnums.hxx> | ||
| 27 | |||
| 28 | using namespace openstudio::model; | ||
| 29 | |||
| 30 | using namespace std; | ||
| 31 | |||
| 32 | namespace openstudio { | ||
| 33 | |||
| 34 | namespace energyplus { | ||
| 35 | |||
| 36 | 7 | boost::optional<IdfObject> ForwardTranslator::translateGasEquipment(GasEquipment& modelObject) { | |
| 37 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 6 times.
|
7 | if (m_forwardTranslatorOptions.excludeSpaceLoadInstances()) { |
| 38 | 1 | return translateGasEquipmentLegacy(modelObject); | |
| 39 | } | ||
| 40 | 6 | return translateGasEquipmentInstance(modelObject); | |
| 41 | } | ||
| 42 | |||
| 43 | 1 | boost::optional<IdfObject> ForwardTranslator::translateGasEquipmentLegacy(GasEquipment& modelObject) { | |
| 44 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | IdfObject idfObject(openstudio::IddObjectType::GasEquipment); |
| 45 |
1/1✓ Branch 1 taken 1 time.
|
1 | m_idfObjects.push_back(idfObject); |
| 46 | |||
| 47 |
2/4✓ Branch 1 taken 1 time.
✗ Branch 7 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
|
1 | for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()) { |
| 48 | ✗ | translateAndMapModelObject(lifeCycleCost); | |
| 49 | 1 | } | |
| 50 | |||
| 51 |
1/1✓ Branch 1 taken 1 time.
|
1 | GasEquipmentDefinition definition = modelObject.gasEquipmentDefinition(); |
| 52 | |||
| 53 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | idfObject.setString(GasEquipmentFields::Name, modelObject.name().get()); |
| 54 | |||
| 55 |
1/1✓ Branch 1 taken 1 time.
|
1 | IdfObject parentIdfObject = getSpaceLoadParent(modelObject); |
| 56 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setString(GasEquipmentFields::ZoneorZoneListorSpaceorSpaceListName, parentIdfObject.nameString()); |
| 57 | |||
| 58 |
2/3✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
|
2 | if (boost::optional<Schedule> schedule = modelObject.schedule()) { |
| 59 | ✗ | auto idf_schedule_ = translateAndMapModelObject(*schedule); | |
| 60 | ✗ | OS_ASSERT(idf_schedule_); | |
| 61 | ✗ | idfObject.setString(GasEquipmentFields::ScheduleName, idf_schedule_->nameString()); | |
| 62 | 1 | } | |
| 63 | |||
| 64 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setString(GasEquipmentFields::DesignLevelCalculationMethod, definition.designLevelCalculationMethod()); |
| 65 | |||
| 66 |
1/1✓ Branch 1 taken 1 time.
|
1 | double multiplier = modelObject.multiplier(); |
| 67 | |||
| 68 |
1/1✓ Branch 1 taken 1 time.
|
1 | OptionalDouble d = definition.designLevel(); |
| 69 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (d) { |
| 70 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setDouble(GasEquipmentFields::DesignLevel, (*d) * multiplier); |
| 71 | } | ||
| 72 | |||
| 73 |
1/1✓ Branch 1 taken 1 time.
|
1 | d = definition.wattsperSpaceFloorArea(); |
| 74 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (d) { |
| 75 | ✗ | idfObject.setDouble(GasEquipmentFields::PowerperFloorArea, (*d) * multiplier); | |
| 76 | } | ||
| 77 | |||
| 78 |
1/1✓ Branch 1 taken 1 time.
|
1 | d = definition.wattsperPerson(); |
| 79 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
|
1 | if (d) { |
| 80 | ✗ | idfObject.setDouble(GasEquipmentFields::PowerperPerson, (*d) * multiplier); | |
| 81 | } | ||
| 82 | |||
| 83 |
2/3✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
|
1 | if (!definition.isFractionLatentDefaulted()) { |
| 84 | ✗ | idfObject.setDouble(GasEquipmentFields::FractionLatent, definition.fractionLatent()); | |
| 85 | } | ||
| 86 | |||
| 87 |
2/3✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
|
1 | if (!definition.isFractionRadiantDefaulted()) { |
| 88 | ✗ | idfObject.setDouble(GasEquipmentFields::FractionRadiant, definition.fractionRadiant()); | |
| 89 | } | ||
| 90 | |||
| 91 |
2/3✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
|
1 | if (!definition.isFractionLostDefaulted()) { |
| 92 | ✗ | idfObject.setDouble(GasEquipmentFields::FractionLost, definition.fractionLost()); | |
| 93 | } | ||
| 94 | |||
| 95 |
2/3✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
|
1 | if (!definition.isCarbonDioxideGenerationRateDefaulted()) { |
| 96 | ✗ | idfObject.setDouble(GasEquipmentFields::CarbonDioxideGenerationRate, definition.carbonDioxideGenerationRate()); | |
| 97 | } | ||
| 98 | |||
| 99 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
1 | if (!modelObject.isEndUseSubcategoryDefaulted()) { |
| 100 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | idfObject.setString(GasEquipmentFields::EndUseSubcategory, modelObject.endUseSubcategory()); |
| 101 | } | ||
| 102 | |||
| 103 |
1/1✓ Branch 1 taken 1 time.
|
2 | return idfObject; |
| 104 | 1 | } | |
| 105 | |||
| 106 | 6 | boost::optional<IdfObject> ForwardTranslator::translateGasEquipmentInstance(GasEquipment& modelObject) { | |
| 107 | |||
| 108 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::GasEquipment_Instance, modelObject); |
| 109 | |||
| 110 |
2/4✓ Branch 1 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
|
6 | for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()) { |
| 111 | ✗ | translateAndMapModelObject(lifeCycleCost); | |
| 112 | 6 | } | |
| 113 | |||
| 114 |
1/1✓ Branch 1 taken 6 times.
|
6 | GasEquipmentDefinition definition = modelObject.gasEquipmentDefinition(); |
| 115 |
1/1✓ Branch 1 taken 6 times.
|
6 | auto definitionIdfObject_ = translateAndMapModelObject(definition); |
| 116 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 4 not taken.
|
6 | OS_ASSERT(definitionIdfObject_); |
| 117 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
6 | idfObject.setString(GasEquipment_InstanceFields::GasEquipmentDefinitionName, definitionIdfObject_->nameString()); |
| 118 | |||
| 119 |
1/1✓ Branch 1 taken 6 times.
|
6 | IdfObject parentIdfObject = getSpaceLoadParent(modelObject); |
| 120 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | idfObject.setString(GasEquipment_InstanceFields::ZoneorZoneListorSpaceorSpaceListName, parentIdfObject.nameString()); |
| 121 | |||
| 122 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 5 times.
|
12 | if (boost::optional<Schedule> schedule = modelObject.schedule()) { |
| 123 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | auto idf_schedule_ = translateAndMapModelObject(*schedule); |
| 124 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
|
1 | OS_ASSERT(idf_schedule_); |
| 125 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | idfObject.setString(GasEquipment_InstanceFields::ScheduleName, idf_schedule_->nameString()); |
| 126 | 7 | } | |
| 127 | |||
| 128 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | idfObject.setDouble(GasEquipment_InstanceFields::Multiplier, modelObject.multiplier()); |
| 129 | |||
| 130 |
2/3✓ Branch 1 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
|
6 | if (!modelObject.isEndUseSubcategoryDefaulted()) { |
| 131 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | idfObject.setString(GasEquipment_InstanceFields::EndUseSubcategory, modelObject.endUseSubcategory()); |
| 132 | } | ||
| 133 | |||
| 134 |
1/1✓ Branch 1 taken 6 times.
|
12 | return idfObject; |
| 135 | 6 | } | |
| 136 | |||
| 137 | } // namespace energyplus | ||
| 138 | |||
| 139 | } // namespace openstudio | ||
| 140 |