src/energyplus/ForwardTranslator/ForwardTranslateSolarCollectorFlatPlatePhotovoltaicThermal.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/PlanarSurface.hpp" | ||
| 9 | #include "../../model/PlanarSurface_Impl.hpp" | ||
| 10 | #include "../../model/Node.hpp" | ||
| 11 | #include "../../model/Node_Impl.hpp" | ||
| 12 | #include "../../model/GeneratorPhotovoltaic.hpp" | ||
| 13 | #include "../../model/SolarCollectorFlatPlatePhotovoltaicThermal.hpp" | ||
| 14 | #include "../../model/SolarCollectorFlatPlatePhotovoltaicThermal_Impl.hpp" | ||
| 15 | #include "../../model/SolarCollectorPerformancePhotovoltaicThermalSimple.hpp" | ||
| 16 | #include "../../model/SolarCollectorPerformancePhotovoltaicThermalBIPVT.hpp" | ||
| 17 | #include "../../utilities/core/Logger.hpp" | ||
| 18 | #include "../../utilities/core/Assert.hpp" | ||
| 19 | #include <utilities/idd/SolarCollector_FlatPlate_PhotovoltaicThermal_FieldEnums.hxx> | ||
| 20 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 21 | #include <utilities/idd/IddEnums.hxx> | ||
| 22 | #include <utilities/idd/IddFactory.hxx> | ||
| 23 | |||
| 24 | using namespace openstudio::model; | ||
| 25 | |||
| 26 | using namespace std; | ||
| 27 | |||
| 28 | namespace openstudio { | ||
| 29 | |||
| 30 | namespace energyplus { | ||
| 31 | |||
| 32 | boost::optional<IdfObject> | ||
| 33 | 2 | ForwardTranslator::translateSolarCollectorFlatPlatePhotovoltaicThermal(SolarCollectorFlatPlatePhotovoltaicThermal& modelObject) { | |
| 34 | 2 | boost::optional<std::string> s; | |
| 35 | 2 | boost::optional<double> value; | |
| 36 | |||
| 37 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | IdfObject idfObject(IddObjectType::SolarCollector_FlatPlate_PhotovoltaicThermal); |
| 38 | |||
| 39 |
1/1✓ Branch 1 taken 2 times.
|
2 | m_idfObjects.push_back(idfObject); |
| 40 | |||
| 41 | // Name | ||
| 42 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | std::string name = modelObject.name().get(); |
| 43 |
1/1✓ Branch 1 taken 2 times.
|
2 | idfObject.setName(name); |
| 44 | |||
| 45 | // SolarCollectorPerformanceFlatPlate | ||
| 46 | { | ||
| 47 |
1/1✓ Branch 1 taken 2 times.
|
2 | auto mo = modelObject.solarCollectorPerformance(); |
| 48 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | IdfObject performance = translateAndMapModelObject(mo).get(); |
| 49 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::PhotovoltaicThermalModelPerformanceName, performance.name().get()); |
| 50 | 2 | } | |
| 51 | |||
| 52 | // SurfaceName | ||
| 53 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalPlanarSurface surface = modelObject.surface(); |
| 54 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
|
2 | if (surface) { |
| 55 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | IdfObject surf = translateAndMapModelObject(*surface).get(); |
| 56 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::SurfaceName, surf.name().get()); |
| 57 | 1 | } else { | |
| 58 |
7/7✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
|
1 | LOG(Error, "SolarCollector:FlatPlate:PhotovoltaicThermal '" << name << "' does not reference a surface."); |
| 59 | } | ||
| 60 | |||
| 61 | // PhotovoltaicName | ||
| 62 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalGeneratorPhotovoltaic generatorPhotovoltaic = modelObject.generatorPhotovoltaic(); |
| 63 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
|
2 | if (generatorPhotovoltaic) { |
| 64 | // generator will be translated with the other generators | ||
| 65 |
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(SolarCollector_FlatPlate_PhotovoltaicThermalFields::PhotovoltaicName, generatorPhotovoltaic->name().get()); |
| 66 | } else { | ||
| 67 |
7/7✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
|
1 | LOG(Warn, "SolarCollector:FlatPlate:PhotovoltaicThermal '" << name << "' does not reference a GeneratorPhotovoltaic."); |
| 68 | } | ||
| 69 | |||
| 70 | // figure out if this is on an air loop or plant loop | ||
| 71 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<AirLoopHVAC> airLoopHVAC = modelObject.airLoopHVAC(); |
| 72 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<PlantLoop> plantLoop = modelObject.plantLoop(); |
| 73 | |||
| 74 | // ThermalWorkingFluidType | ||
| 75 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (airLoopHVAC) { |
| 76 | ✗ | idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::ThermalWorkingFluidType, "Air"); | |
| 77 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | } else if (plantLoop) { |
| 78 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::ThermalWorkingFluidType, "Water"); |
| 79 | } | ||
| 80 | |||
| 81 | // InletNodeName | ||
| 82 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (boost::optional<ModelObject> mo = modelObject.inletModelObject()) { |
| 83 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (boost::optional<Node> node = mo->optionalCast<Node>()) { |
| 84 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (airLoopHVAC) { |
| 85 | ✗ | idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::AirInletNodeName, node->name().get()); | |
| 86 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | } else if (plantLoop) { |
| 87 |
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(SolarCollector_FlatPlate_PhotovoltaicThermalFields::WaterInletNodeName, node->name().get()); |
| 88 | } | ||
| 89 | 2 | } | |
| 90 | 2 | } | |
| 91 | |||
| 92 | // OutletNodeName | ||
| 93 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (boost::optional<ModelObject> mo = modelObject.outletModelObject()) { |
| 94 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | if (boost::optional<Node> node = mo->optionalCast<Node>()) { |
| 95 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (airLoopHVAC) { |
| 96 | ✗ | idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::AirOutletNodeName, node->name().get()); | |
| 97 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | } else if (plantLoop) { |
| 98 |
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(SolarCollector_FlatPlate_PhotovoltaicThermalFields::WaterOutletNodeName, node->name().get()); |
| 99 | } | ||
| 100 | 2 | } | |
| 101 | 2 | } | |
| 102 | |||
| 103 | // DesignFlowRate | ||
| 104 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<double> designFlowRate = modelObject.designFlowRate(); |
| 105 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (designFlowRate) { |
| 106 | ✗ | idfObject.setDouble(SolarCollector_FlatPlate_PhotovoltaicThermalFields::DesignFlowRate, *designFlowRate); | |
| 107 | } | ||
| 108 | |||
| 109 |
1/1✓ Branch 1 taken 2 times.
|
4 | return idfObject; |
| 110 | 2 | } | |
| 111 | |||
| 112 | } // namespace energyplus | ||
| 113 | |||
| 114 | } // namespace openstudio | ||
| 115 |