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