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