src/model/DistrictHeatingWater.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 "DistrictHeatingWater.hpp" | ||
| 7 | #include "DistrictHeatingWater_Impl.hpp" | ||
| 8 | #include "Model.hpp" | ||
| 9 | #include "Node.hpp" | ||
| 10 | #include "Node_Impl.hpp" | ||
| 11 | #include "Schedule.hpp" | ||
| 12 | #include "Schedule_Impl.hpp" | ||
| 13 | |||
| 14 | #include "../utilities/core/Assert.hpp" | ||
| 15 | #include "../utilities/data/DataEnums.hpp" | ||
| 16 | |||
| 17 | #include <utilities/idd/OS_DistrictHeating_Water_FieldEnums.hxx> | ||
| 18 | #include <utilities/idd/IddEnums.hxx> | ||
| 19 | |||
| 20 | namespace openstudio { | ||
| 21 | namespace model { | ||
| 22 | |||
| 23 | namespace detail { | ||
| 24 | |||
| 25 | 9 | DistrictHeatingWater_Impl::DistrictHeatingWater_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 26 | 9 | : StraightComponent_Impl(idfObject, model, keepHandle) { | |
| 27 |
4/6✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 9 times.
✗ Branch 13 not taken.
|
9 | OS_ASSERT(idfObject.iddObject().type() == DistrictHeatingWater::iddObjectType()); |
| 28 | 9 | } | |
| 29 | |||
| 30 | 3 | DistrictHeatingWater_Impl::DistrictHeatingWater_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 31 | 3 | : StraightComponent_Impl(other, model, keepHandle) { | |
| 32 |
4/6✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 13 not taken.
|
3 | OS_ASSERT(other.iddObject().type() == DistrictHeatingWater::iddObjectType()); |
| 33 | 3 | } | |
| 34 | |||
| 35 | 6 | DistrictHeatingWater_Impl::DistrictHeatingWater_Impl(const DistrictHeatingWater_Impl& other, Model_Impl* model, bool keepHandle) | |
| 36 | 6 | : StraightComponent_Impl(other, model, keepHandle) {} | |
| 37 | |||
| 38 | ✗ | const std::vector<std::string>& DistrictHeatingWater_Impl::outputVariableNames() const { | |
| 39 | static const std::vector<std::string> result{ | ||
| 40 | "District Heating Water Energy", | ||
| 41 | "District Heating Water Rate", | ||
| 42 | "District Heating Water Inlet Temperature", | ||
| 43 | "District Heating Water Outlet Temperature", | ||
| 44 | "District Heating Water Mass Flow Rate", | ||
| 45 | ✗ | }; | |
| 46 | ✗ | return result; | |
| 47 | ✗ | } | |
| 48 | |||
| 49 | ✗ | IddObjectType DistrictHeatingWater_Impl::iddObjectType() const { | |
| 50 | ✗ | return DistrictHeatingWater::iddObjectType(); | |
| 51 | } | ||
| 52 | |||
| 53 | ✗ | std::vector<ScheduleTypeKey> DistrictHeatingWater_Impl::getScheduleTypeKeys(const Schedule& schedule) const { | |
| 54 | ✗ | std::vector<ScheduleTypeKey> result; | |
| 55 | ✗ | const UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); | |
| 56 | ✗ | if (std::find(fieldIndices.cbegin(), fieldIndices.cend(), OS_DistrictHeating_WaterFields::CapacityFractionSchedule) != fieldIndices.cend()) { | |
| 57 | ✗ | result.emplace_back("DistrictHeatingWater", "Capacity Fraction Schedule"); | |
| 58 | } | ||
| 59 | ✗ | return result; | |
| 60 | ✗ | } | |
| 61 | |||
| 62 | 9 | unsigned DistrictHeatingWater_Impl::inletPort() const { | |
| 63 | 9 | return OS_DistrictHeating_WaterFields::HotWaterInletNodeName; | |
| 64 | } | ||
| 65 | |||
| 66 | 19 | unsigned DistrictHeatingWater_Impl::outletPort() const { | |
| 67 | 19 | return OS_DistrictHeating_WaterFields::HotWaterOutletNodeName; | |
| 68 | } | ||
| 69 | |||
| 70 | 7 | bool DistrictHeatingWater_Impl::addToNode(Node& node) { | |
| 71 |
3/3✓ Branch 1 taken 7 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 3 times.
|
14 | if (boost::optional<PlantLoop> plant = node.plantLoop()) { |
| 72 |
5/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 1 time.
|
8 | if (plant->supplyComponent(node.handle())) { |
| 73 |
1/1✓ Branch 1 taken 3 times.
|
3 | return StraightComponent_Impl::addToNode(node); |
| 74 | } | ||
| 75 | 7 | } | |
| 76 | |||
| 77 | 4 | return false; | |
| 78 | } | ||
| 79 | |||
| 80 | 6 | boost::optional<double> DistrictHeatingWater_Impl::nominalCapacity() const { | |
| 81 | 6 | return getDouble(OS_DistrictHeating_WaterFields::NominalCapacity, true); | |
| 82 | } | ||
| 83 | |||
| 84 | 3 | bool DistrictHeatingWater_Impl::isNominalCapacityAutosized() const { | |
| 85 | 3 | bool result = false; | |
| 86 |
1/1✓ Branch 1 taken 3 times.
|
3 | boost::optional<std::string> value = getString(OS_DistrictHeating_WaterFields::NominalCapacity, true); |
| 87 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (value) { |
| 88 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
|
6 | result = openstudio::istringEqual(value.get(), "autosize"); |
| 89 | } | ||
| 90 | 3 | return result; | |
| 91 | 3 | } | |
| 92 | |||
| 93 | 2 | bool DistrictHeatingWater_Impl::setNominalCapacity(double nominalCapacity) { | |
| 94 | 2 | return setDouble(OS_DistrictHeating_WaterFields::NominalCapacity, nominalCapacity); | |
| 95 | } | ||
| 96 | |||
| 97 | 7 | void DistrictHeatingWater_Impl::autosizeNominalCapacity() { | |
| 98 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
14 | const bool result = setString(OS_DistrictHeating_WaterFields::NominalCapacity, "autosize"); |
| 99 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
|
7 | OS_ASSERT(result); |
| 100 | 7 | } | |
| 101 | |||
| 102 | 2 | Schedule DistrictHeatingWater_Impl::capacityFractionSchedule() const { | |
| 103 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | auto sch_ = getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_DistrictHeating_WaterFields::CapacityFractionSchedule); |
| 104 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(sch_); |
| 105 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | return *sch_; |
| 106 | 2 | } | |
| 107 | |||
| 108 | 7 | bool DistrictHeatingWater_Impl::setCapacityFractionSchedule(Schedule& schedule) { | |
| 109 | const bool result = | ||
| 110 |
3/3✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
|
28 | setSchedule(OS_DistrictHeating_WaterFields::CapacityFractionSchedule, "DistrictHeatingWater", "Capacity Fraction", schedule); |
| 111 | 7 | return result; | |
| 112 | } | ||
| 113 | |||
| 114 | ✗ | boost::optional<double> DistrictHeatingWater_Impl::autosizedNominalCapacity() const { | |
| 115 | ✗ | return getAutosizedValue("Design Size Nominal Capacity", "W"); | |
| 116 | } | ||
| 117 | |||
| 118 | ✗ | void DistrictHeatingWater_Impl::autosize() { | |
| 119 | ✗ | autosizeNominalCapacity(); | |
| 120 | ✗ | } | |
| 121 | |||
| 122 | ✗ | void DistrictHeatingWater_Impl::applySizingValues() { | |
| 123 | ✗ | boost::optional<double> val; | |
| 124 | ✗ | val = autosizedNominalCapacity(); | |
| 125 | ✗ | if (val) { | |
| 126 | ✗ | setNominalCapacity(val.get()); | |
| 127 | } | ||
| 128 | ✗ | } | |
| 129 | |||
| 130 | 1 | ComponentType DistrictHeatingWater_Impl::componentType() const { | |
| 131 |
1/1✓ Branch 1 taken 1 time.
|
1 | return ComponentType::Heating; |
| 132 | } | ||
| 133 | |||
| 134 | ✗ | std::vector<FuelType> DistrictHeatingWater_Impl::coolingFuelTypes() const { | |
| 135 | ✗ | return {}; | |
| 136 | } | ||
| 137 | |||
| 138 | ✗ | std::vector<FuelType> DistrictHeatingWater_Impl::heatingFuelTypes() const { | |
| 139 | ✗ | return {FuelType::DistrictHeating}; | |
| 140 | } | ||
| 141 | |||
| 142 | ✗ | std::vector<AppGFuelType> DistrictHeatingWater_Impl::appGHeatingFuelTypes() const { | |
| 143 | ✗ | return {AppGFuelType::District}; | |
| 144 | } | ||
| 145 | |||
| 146 | } // namespace detail | ||
| 147 | |||
| 148 | 6 | DistrictHeatingWater::DistrictHeatingWater(const Model& model) : StraightComponent(DistrictHeatingWater::iddObjectType(), model) { | |
| 149 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 5 not taken.
|
6 | OS_ASSERT(getImpl<detail::DistrictHeatingWater_Impl>()); |
| 150 |
1/1✓ Branch 1 taken 6 times.
|
6 | autosizeNominalCapacity(); |
| 151 | |||
| 152 | { | ||
| 153 |
1/1✓ Branch 1 taken 6 times.
|
6 | auto schedule = model.alwaysOnContinuousSchedule(); |
| 154 |
1/1✓ Branch 1 taken 6 times.
|
6 | const bool ok = setCapacityFractionSchedule(schedule); |
| 155 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 3 not taken.
|
6 | OS_ASSERT(ok); |
| 156 | 6 | } | |
| 157 | 6 | } | |
| 158 | |||
| 159 | 7618 | IddObjectType DistrictHeatingWater::iddObjectType() { | |
| 160 |
1/1✓ Branch 1 taken 7618 times.
|
7618 | IddObjectType result(IddObjectType::OS_DistrictHeating_Water); |
| 161 | 7618 | return result; | |
| 162 | } | ||
| 163 | |||
| 164 | 6 | boost::optional<double> DistrictHeatingWater::nominalCapacity() const { | |
| 165 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::DistrictHeatingWater_Impl>()->nominalCapacity(); |
| 166 | } | ||
| 167 | |||
| 168 | 3 | bool DistrictHeatingWater::isNominalCapacityAutosized() const { | |
| 169 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::DistrictHeatingWater_Impl>()->isNominalCapacityAutosized(); |
| 170 | } | ||
| 171 | |||
| 172 | 2 | bool DistrictHeatingWater::setNominalCapacity(double nominalCapacity) { | |
| 173 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::DistrictHeatingWater_Impl>()->setNominalCapacity(nominalCapacity); |
| 174 | } | ||
| 175 | |||
| 176 | 7 | void DistrictHeatingWater::autosizeNominalCapacity() { | |
| 177 |
1/1✓ Branch 3 taken 7 times.
|
7 | getImpl<detail::DistrictHeatingWater_Impl>()->autosizeNominalCapacity(); |
| 178 | 7 | } | |
| 179 | |||
| 180 | 2 | Schedule DistrictHeatingWater::capacityFractionSchedule() const { | |
| 181 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::DistrictHeatingWater_Impl>()->capacityFractionSchedule(); |
| 182 | } | ||
| 183 | |||
| 184 | 7 | bool DistrictHeatingWater::setCapacityFractionSchedule(Schedule& schedule) { | |
| 185 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::DistrictHeatingWater_Impl>()->setCapacityFractionSchedule(schedule); |
| 186 | } | ||
| 187 | |||
| 188 | /// @cond | ||
| 189 | |||
| 190 |
1/1✓ Branch 3 taken 3 times.
|
3 | DistrictHeatingWater::DistrictHeatingWater(std::shared_ptr<detail::DistrictHeatingWater_Impl> impl) : StraightComponent(std::move(impl)) {} |
| 191 | /// @endcond | ||
| 192 | |||
| 193 | ✗ | boost::optional<double> DistrictHeatingWater::autosizedNominalCapacity() const { | |
| 194 | ✗ | return getImpl<detail::DistrictHeatingWater_Impl>()->autosizedNominalCapacity(); | |
| 195 | } | ||
| 196 | |||
| 197 | } // namespace model | ||
| 198 | |||
| 199 | } // namespace openstudio | ||
| 200 |