src/energyplus/ForwardTranslator/ForwardTranslateConstructionWithInternalSource.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/ConstructionWithInternalSource.hpp" | ||
| 10 | #include "../../model/ConstructionWithInternalSource_Impl.hpp" | ||
| 11 | |||
| 12 | #include "../../model/Material.hpp" | ||
| 13 | #include "../../model/Material_Impl.hpp" | ||
| 14 | |||
| 15 | #include <utilities/idd/Construction_FieldEnums.hxx> | ||
| 16 | #include <utilities/idd/ConstructionProperty_InternalHeatSource_FieldEnums.hxx> | ||
| 17 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 18 | #include <utilities/idd/IddEnums.hxx> | ||
| 19 | #include <utilities/idd/IddFactory.hxx> | ||
| 20 | |||
| 21 | using namespace openstudio::model; | ||
| 22 | |||
| 23 | using namespace std; | ||
| 24 | |||
| 25 | namespace openstudio { | ||
| 26 | |||
| 27 | namespace energyplus { | ||
| 28 | |||
| 29 | 9 | boost::optional<IdfObject> ForwardTranslator::translateConstructionWithInternalSource(model::ConstructionWithInternalSource& modelObject) { | |
| 30 | |||
| 31 | // New in E+ 9.5.0: `Construction:InternalSource` used to be a standalone object listing it's layers. | ||
| 32 | // Now it's replaced with `ConstructionProperty:InternalHeatSource` which references a `Construction` object. | ||
| 33 | // I have made the choice to keep the OS SDK API intact and handle that in the ForwardTranslator. | ||
| 34 | |||
| 35 | //Layers: starting in E+ 9.5.0, | ||
| 36 |
1/1✓ Branch 1 taken 9 times.
|
9 | MaterialVector layers = modelObject.layers(); |
| 37 | |||
| 38 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
|
9 | if (layers.empty()) { |
| 39 | ✗ | LOG(Warn, modelObject.briefDescription() << " has no layers, it will not be translated."); | |
| 40 | ✗ | return boost::none; | |
| 41 | } | ||
| 42 | |||
| 43 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | IdfObject constructionObject(openstudio::IddObjectType::Construction); |
| 44 |
1/1✓ Branch 1 taken 9 times.
|
9 | m_idfObjects.push_back(constructionObject); |
| 45 | //Name | ||
| 46 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
|
9 | constructionObject.setString(ConstructionFields::Name, modelObject.name().get()); |
| 47 | |||
| 48 | 9 | unsigned fieldIndex = 1; | |
| 49 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 2 taken 9 times.
|
27 | for (unsigned layerIndex = 0; layerIndex < layers.size(); ++layerIndex) { |
| 50 |
1/1✓ Branch 2 taken 18 times.
|
18 | Material material = layers[layerIndex]; |
| 51 |
1/1✓ Branch 1 taken 18 times.
|
18 | translateAndMapModelObject(material); |
| 52 |
3/3✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
|
18 | constructionObject.setString(fieldIndex++, material.name().get()); |
| 53 | 18 | } | |
| 54 | |||
| 55 | // And we also do the ConstructionProperty:InternalHeatSource object | ||
| 56 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | IdfObject propertyObject(openstudio::IddObjectType::ConstructionProperty_InternalHeatSource); |
| 57 |
1/1✓ Branch 1 taken 9 times.
|
9 | m_idfObjects.push_back(propertyObject); |
| 58 | |||
| 59 |
4/4✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
|
9 | propertyObject.setString(ConstructionProperty_InternalHeatSourceFields::Name, modelObject.name().get() + " InternalHeatSource Property"); |
| 60 | |||
| 61 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
|
9 | propertyObject.setString(ConstructionProperty_InternalHeatSourceFields::ConstructionName, modelObject.name().get()); |
| 62 | |||
| 63 | //Source Present After Layer Number | ||
| 64 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | propertyObject.setInt(ConstructionProperty_InternalHeatSourceFields::ThermalSourcePresentAfterLayerNumber, |
| 65 | modelObject.sourcePresentAfterLayerNumber()); | ||
| 66 | |||
| 67 | //Temperature Calculation Requested After Layer Number | ||
| 68 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | propertyObject.setInt(ConstructionProperty_InternalHeatSourceFields::TemperatureCalculationRequestedAfterLayerNumber, |
| 69 | modelObject.temperatureCalculationRequestedAfterLayerNumber()); | ||
| 70 | |||
| 71 | // Dimensions for the CTF Calculation | ||
| 72 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | propertyObject.setInt(ConstructionProperty_InternalHeatSourceFields::DimensionsfortheCTFCalculation, |
| 73 | modelObject.dimensionsForTheCTFCalculation()); | ||
| 74 | |||
| 75 | // Tube Spacing | ||
| 76 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | propertyObject.setDouble(ConstructionProperty_InternalHeatSourceFields::TubeSpacing, modelObject.tubeSpacing()); |
| 77 | |||
| 78 | // Two Dimensional Temperature Calculation Position | ||
| 79 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | propertyObject.setDouble(ConstructionProperty_InternalHeatSourceFields::TwoDimensionalTemperatureCalculationPosition, |
| 80 | modelObject.twoDimensionalTemperatureCalculationPosition()); | ||
| 81 | |||
| 82 | // What we return is the construction object, not the property object | ||
| 83 |
1/1✓ Branch 1 taken 9 times.
|
9 | return constructionObject; |
| 84 | 9 | } | |
| 85 | |||
| 86 | } // namespace energyplus | ||
| 87 | |||
| 88 | } // namespace openstudio | ||
| 89 |