src/model/SolarCollectorFlatPlateWater.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 "SolarCollectorFlatPlateWater.hpp" | ||
| 7 | #include "SolarCollectorFlatPlateWater_Impl.hpp" | ||
| 8 | |||
| 9 | #include "SolarCollectorPerformanceFlatPlate.hpp" | ||
| 10 | #include "SolarCollectorPerformanceFlatPlate_Impl.hpp" | ||
| 11 | #include "Surface.hpp" | ||
| 12 | #include "Surface_Impl.hpp" | ||
| 13 | #include "ShadingSurface.hpp" | ||
| 14 | #include "ShadingSurface_Impl.hpp" | ||
| 15 | #include "Connection.hpp" | ||
| 16 | #include "Connection_Impl.hpp" | ||
| 17 | #include "ModelObject.hpp" | ||
| 18 | #include "ModelObject_Impl.hpp" | ||
| 19 | #include "PlantLoop.hpp" | ||
| 20 | #include "PlantLoop_Impl.hpp" | ||
| 21 | #include "Node.hpp" | ||
| 22 | #include "Model.hpp" | ||
| 23 | |||
| 24 | #include "../utilities/core/Assert.hpp" | ||
| 25 | #include "../utilities/data/DataEnums.hpp" | ||
| 26 | |||
| 27 | #include <utilities/idd/OS_SolarCollector_FlatPlate_Water_FieldEnums.hxx> | ||
| 28 | #include <utilities/idd/IddEnums.hxx> | ||
| 29 | |||
| 30 | namespace openstudio { | ||
| 31 | namespace model { | ||
| 32 | |||
| 33 | namespace detail { | ||
| 34 | |||
| 35 | 6 | SolarCollectorFlatPlateWater_Impl::SolarCollectorFlatPlateWater_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 36 | 6 | : StraightComponent_Impl(idfObject, model, keepHandle) { | |
| 37 |
4/6✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 6 times.
✗ Branch 13 not taken.
|
6 | OS_ASSERT(idfObject.iddObject().type() == SolarCollectorFlatPlateWater::iddObjectType()); |
| 38 | 6 | } | |
| 39 | |||
| 40 | ✗ | SolarCollectorFlatPlateWater_Impl::SolarCollectorFlatPlateWater_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, | |
| 41 | ✗ | bool keepHandle) | |
| 42 | ✗ | : StraightComponent_Impl(other, model, keepHandle) { | |
| 43 | ✗ | OS_ASSERT(other.iddObject().type() == SolarCollectorFlatPlateWater::iddObjectType()); | |
| 44 | ✗ | } | |
| 45 | |||
| 46 | 5 | SolarCollectorFlatPlateWater_Impl::SolarCollectorFlatPlateWater_Impl(const SolarCollectorFlatPlateWater_Impl& other, Model_Impl* model, | |
| 47 | 5 | bool keepHandle) | |
| 48 | 5 | : StraightComponent_Impl(other, model, keepHandle) {} | |
| 49 | |||
| 50 | 2 | ModelObject SolarCollectorFlatPlateWater_Impl::clone(Model model) const { | |
| 51 | |||
| 52 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | auto result = StraightComponent_Impl::clone(model).cast<SolarCollectorFlatPlateWater>(); |
| 53 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | result.setSolarCollectorPerformance(this->solarCollectorPerformance()); |
| 54 | |||
| 55 | // do not want to point to any surface after cloning | ||
| 56 |
1/1✓ Branch 1 taken 2 times.
|
2 | result.resetSurface(); |
| 57 | |||
| 58 | 4 | return std::move(result); | |
| 59 | 2 | } | |
| 60 | |||
| 61 | 1 | std::vector<IdfObject> SolarCollectorFlatPlateWater_Impl::remove() { | |
| 62 | // DLM: will remove performance object due to parent/child relationship | ||
| 63 | 1 | return StraightComponent_Impl::remove(); | |
| 64 | } | ||
| 65 | |||
| 66 | ✗ | const std::vector<std::string>& SolarCollectorFlatPlateWater_Impl::outputVariableNames() const { | |
| 67 | static const std::vector<std::string> result{"Solar Collector Incident Angle Modifier", "Solar Collector Efficiency", | ||
| 68 | "Solar Collector Heat Transfer Rate", "Solar Collector Heat Gain Rate", | ||
| 69 | ✗ | "Solar Collector Heat Loss Rate", "Solar Collector Heat Transfer Energy"}; | |
| 70 | ✗ | return result; | |
| 71 | ✗ | } | |
| 72 | |||
| 73 | 3 | IddObjectType SolarCollectorFlatPlateWater_Impl::iddObjectType() const { | |
| 74 | 3 | return SolarCollectorFlatPlateWater::iddObjectType(); | |
| 75 | } | ||
| 76 | |||
| 77 | 2 | std::vector<ModelObject> SolarCollectorFlatPlateWater_Impl::children() const { | |
| 78 | 2 | std::vector<ModelObject> result; | |
| 79 | |||
| 80 |
1/1✓ Branch 1 taken 2 times.
|
2 | SolarCollectorPerformanceFlatPlate solarCollectorPerformance = this->solarCollectorPerformance(); |
| 81 |
1/1✓ Branch 1 taken 2 times.
|
2 | result.push_back(solarCollectorPerformance); |
| 82 | |||
| 83 | 4 | return result; | |
| 84 | 2 | } | |
| 85 | |||
| 86 | 7 | unsigned SolarCollectorFlatPlateWater_Impl::inletPort() const { | |
| 87 | 7 | return OS_SolarCollector_FlatPlate_WaterFields::InletNodeName; | |
| 88 | } | ||
| 89 | |||
| 90 | 29 | unsigned SolarCollectorFlatPlateWater_Impl::outletPort() const { | |
| 91 | 29 | return OS_SolarCollector_FlatPlate_WaterFields::OutletNodeName; | |
| 92 | } | ||
| 93 | |||
| 94 | 2 | bool SolarCollectorFlatPlateWater_Impl::addToNode(Node& node) { | |
| 95 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
4 | if (boost::optional<PlantLoop> plantLoop = node.plantLoop()) { |
| 96 |
4/5✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
4 | if (plantLoop->supplyComponent(node.handle())) { |
| 97 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | if (StraightComponent_Impl::addToNode(node)) { |
| 98 | 2 | return true; | |
| 99 | } | ||
| 100 | } | ||
| 101 | 2 | } | |
| 102 | |||
| 103 | ✗ | return false; | |
| 104 | } | ||
| 105 | |||
| 106 | 11 | SolarCollectorPerformanceFlatPlate SolarCollectorFlatPlateWater_Impl::solarCollectorPerformance() const { | |
| 107 |
1/1✓ Branch 1 taken 11 times.
|
22 | boost::optional<SolarCollectorPerformanceFlatPlate> value = getObject<ModelObject>().getModelObjectTarget<SolarCollectorPerformanceFlatPlate>( |
| 108 |
1/1✓ Branch 1 taken 11 times.
|
11 | OS_SolarCollector_FlatPlate_WaterFields::SolarCollectorPerformanceName); |
| 109 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
|
11 | if (!value) { |
| 110 | // DLM: could default construct one here? | ||
| 111 | ✗ | LOG_AND_THROW(briefDescription() << " does not have an Solar Collector Performance attached."); | |
| 112 | } | ||
| 113 |
2/2✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
|
22 | return value.get(); |
| 114 | 11 | } | |
| 115 | |||
| 116 | 4 | boost::optional<PlanarSurface> SolarCollectorFlatPlateWater_Impl::surface() const { | |
| 117 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | return getObject<ModelObject>().getModelObjectTarget<PlanarSurface>(OS_SolarCollector_FlatPlate_WaterFields::SurfaceName); |
| 118 | } | ||
| 119 | |||
| 120 | 1 | boost::optional<double> SolarCollectorFlatPlateWater_Impl::maximumFlowRate() const { | |
| 121 | 1 | return getDouble(OS_SolarCollector_FlatPlate_WaterFields::MaximumFlowRate, true); | |
| 122 | } | ||
| 123 | |||
| 124 | bool | ||
| 125 | 2 | SolarCollectorFlatPlateWater_Impl::setSolarCollectorPerformance(const SolarCollectorPerformanceFlatPlate& solarCollectorPerformanceFlatPlate) { | |
| 126 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | ModelObject clone = solarCollectorPerformanceFlatPlate.clone(this->model()); |
| 127 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | return setSolarCollectorPerformanceNoClone(clone.cast<SolarCollectorPerformanceFlatPlate>()); |
| 128 | 2 | } | |
| 129 | |||
| 130 | ✗ | void SolarCollectorFlatPlateWater_Impl::resetSolarCollectorPerformance() { | |
| 131 | boost::optional<SolarCollectorPerformanceFlatPlate> oldPerformance = | ||
| 132 | ✗ | getObject<ModelObject>().getModelObjectTarget<SolarCollectorPerformanceFlatPlate>( | |
| 133 | ✗ | OS_SolarCollector_FlatPlate_WaterFields::SolarCollectorPerformanceName); | |
| 134 | ✗ | if (oldPerformance) { | |
| 135 | ✗ | oldPerformance->remove(); | |
| 136 | } | ||
| 137 | |||
| 138 | ✗ | SolarCollectorPerformanceFlatPlate performance(this->model()); | |
| 139 | ✗ | bool ok = setSolarCollectorPerformanceNoClone(performance); | |
| 140 | ✗ | OS_ASSERT(ok); | |
| 141 | ✗ | } | |
| 142 | |||
| 143 | 1 | bool SolarCollectorFlatPlateWater_Impl::setSurface(const PlanarSurface& surface) { | |
| 144 | 1 | bool result(false); | |
| 145 | |||
| 146 | // DLM: check for existing solar collectors or photovoltaic generators? | ||
| 147 | |||
| 148 |
2/3✓ Branch 1 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
|
2 | if (surface.optionalCast<Surface>()) { |
| 149 | ✗ | result = setPointer(OS_SolarCollector_FlatPlate_WaterFields::SurfaceName, surface.handle()); | |
| 150 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
|
2 | } else if (surface.optionalCast<ShadingSurface>()) { |
| 151 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | result = setPointer(OS_SolarCollector_FlatPlate_WaterFields::SurfaceName, surface.handle()); |
| 152 | } | ||
| 153 | |||
| 154 | 1 | return result; | |
| 155 | } | ||
| 156 | |||
| 157 | 2 | void SolarCollectorFlatPlateWater_Impl::resetSurface() { | |
| 158 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | bool result = setString(OS_SolarCollector_FlatPlate_WaterFields::SurfaceName, ""); |
| 159 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | OS_ASSERT(result); |
| 160 | 2 | } | |
| 161 | |||
| 162 | ✗ | bool SolarCollectorFlatPlateWater_Impl::setMaximumFlowRate(double maximumFlowRate) { | |
| 163 | ✗ | return setDouble(OS_SolarCollector_FlatPlate_WaterFields::MaximumFlowRate, maximumFlowRate); | |
| 164 | } | ||
| 165 | |||
| 166 | ✗ | void SolarCollectorFlatPlateWater_Impl::resetMaximumFlowRate() { | |
| 167 | ✗ | bool result = setString(OS_SolarCollector_FlatPlate_WaterFields::MaximumFlowRate, ""); | |
| 168 | ✗ | OS_ASSERT(result); | |
| 169 | ✗ | } | |
| 170 | |||
| 171 | 8 | bool SolarCollectorFlatPlateWater_Impl::setSolarCollectorPerformanceNoClone( | |
| 172 | const SolarCollectorPerformanceFlatPlate& solarCollectorPerformanceFlatPlate) { | ||
| 173 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
8 | return setPointer(OS_SolarCollector_FlatPlate_WaterFields::SolarCollectorPerformanceName, solarCollectorPerformanceFlatPlate.handle()); |
| 174 | } | ||
| 175 | |||
| 176 | 4 | ComponentType SolarCollectorFlatPlateWater_Impl::componentType() const { | |
| 177 |
1/1✓ Branch 1 taken 4 times.
|
4 | return ComponentType::Heating; |
| 178 | } | ||
| 179 | |||
| 180 | ✗ | std::vector<FuelType> SolarCollectorFlatPlateWater_Impl::coolingFuelTypes() const { | |
| 181 | ✗ | return {}; | |
| 182 | } | ||
| 183 | |||
| 184 | ✗ | std::vector<FuelType> SolarCollectorFlatPlateWater_Impl::heatingFuelTypes() const { | |
| 185 | ✗ | return {FuelType::Solar}; | |
| 186 | } | ||
| 187 | |||
| 188 | ✗ | std::vector<AppGFuelType> SolarCollectorFlatPlateWater_Impl::appGHeatingFuelTypes() const { | |
| 189 | ✗ | return {AppGFuelType::Solar}; | |
| 190 | } | ||
| 191 | |||
| 192 | } // namespace detail | ||
| 193 | |||
| 194 | 6 | SolarCollectorFlatPlateWater::SolarCollectorFlatPlateWater(const Model& model) | |
| 195 | 6 | : StraightComponent(SolarCollectorFlatPlateWater::iddObjectType(), model) { | |
| 196 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 5 not taken.
|
6 | OS_ASSERT(getImpl<detail::SolarCollectorFlatPlateWater_Impl>()); |
| 197 | |||
| 198 |
1/1✓ Branch 1 taken 6 times.
|
6 | SolarCollectorPerformanceFlatPlate performance(model); |
| 199 | |||
| 200 | 6 | bool ok = true; | |
| 201 |
1/1✓ Branch 3 taken 6 times.
|
6 | ok = getImpl<detail::SolarCollectorFlatPlateWater_Impl>()->setSolarCollectorPerformanceNoClone(performance); |
| 202 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 3 not taken.
|
6 | OS_ASSERT(ok); |
| 203 | 6 | } | |
| 204 | |||
| 205 | 7619 | IddObjectType SolarCollectorFlatPlateWater::iddObjectType() { | |
| 206 |
1/1✓ Branch 1 taken 7619 times.
|
7619 | return {IddObjectType::OS_SolarCollector_FlatPlate_Water}; |
| 207 | } | ||
| 208 | |||
| 209 | 7 | SolarCollectorPerformanceFlatPlate SolarCollectorFlatPlateWater::solarCollectorPerformance() const { | |
| 210 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::SolarCollectorFlatPlateWater_Impl>()->solarCollectorPerformance(); |
| 211 | } | ||
| 212 | |||
| 213 | 4 | boost::optional<PlanarSurface> SolarCollectorFlatPlateWater::surface() const { | |
| 214 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::SolarCollectorFlatPlateWater_Impl>()->surface(); |
| 215 | } | ||
| 216 | |||
| 217 | 1 | boost::optional<double> SolarCollectorFlatPlateWater::maximumFlowRate() const { | |
| 218 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::SolarCollectorFlatPlateWater_Impl>()->maximumFlowRate(); |
| 219 | } | ||
| 220 | |||
| 221 | 2 | bool SolarCollectorFlatPlateWater::setSolarCollectorPerformance(const SolarCollectorPerformanceFlatPlate& solarCollectorPerformanceFlatPlate) { | |
| 222 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::SolarCollectorFlatPlateWater_Impl>()->setSolarCollectorPerformance(solarCollectorPerformanceFlatPlate); |
| 223 | } | ||
| 224 | |||
| 225 | ✗ | void SolarCollectorFlatPlateWater::resetSolarCollectorPerformance() { | |
| 226 | ✗ | getImpl<detail::SolarCollectorFlatPlateWater_Impl>()->resetSolarCollectorPerformance(); | |
| 227 | ✗ | } | |
| 228 | |||
| 229 | 1 | bool SolarCollectorFlatPlateWater::setSurface(const PlanarSurface& surface) { | |
| 230 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::SolarCollectorFlatPlateWater_Impl>()->setSurface(surface); |
| 231 | } | ||
| 232 | |||
| 233 | 2 | void SolarCollectorFlatPlateWater::resetSurface() { | |
| 234 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::SolarCollectorFlatPlateWater_Impl>()->resetSurface(); |
| 235 | } | ||
| 236 | |||
| 237 | ✗ | bool SolarCollectorFlatPlateWater::setMaximumFlowRate(double maximumFlowRate) { | |
| 238 | ✗ | return getImpl<detail::SolarCollectorFlatPlateWater_Impl>()->setMaximumFlowRate(maximumFlowRate); | |
| 239 | } | ||
| 240 | |||
| 241 | ✗ | void SolarCollectorFlatPlateWater::resetMaximumFlowRate() { | |
| 242 | ✗ | getImpl<detail::SolarCollectorFlatPlateWater_Impl>()->resetMaximumFlowRate(); | |
| 243 | ✗ | } | |
| 244 | |||
| 245 | /// @cond | ||
| 246 | 7 | SolarCollectorFlatPlateWater::SolarCollectorFlatPlateWater(std::shared_ptr<detail::SolarCollectorFlatPlateWater_Impl> impl) | |
| 247 |
1/1✓ Branch 3 taken 7 times.
|
7 | : StraightComponent(std::move(impl)) {} |
| 248 | /// @endcond | ||
| 249 | |||
| 250 | } // namespace model | ||
| 251 | } // namespace openstudio | ||
| 252 |