src/model/UtilityBill.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 "UtilityBill.hpp" | ||
| 7 | #include "UtilityBill_Impl.hpp" | ||
| 8 | #include "OutputMeter.hpp" | ||
| 9 | #include "OutputMeter_Impl.hpp" | ||
| 10 | #include "RunPeriod.hpp" | ||
| 11 | #include "RunPeriod_Impl.hpp" | ||
| 12 | #include "YearDescription.hpp" | ||
| 13 | #include "YearDescription_Impl.hpp" | ||
| 14 | #include "Building.hpp" | ||
| 15 | #include "Building_Impl.hpp" | ||
| 16 | #include "Facility.hpp" | ||
| 17 | #include "Facility_Impl.hpp" | ||
| 18 | #include "Timestep.hpp" | ||
| 19 | #include "Timestep_Impl.hpp" | ||
| 20 | |||
| 21 | #include "Model.hpp" | ||
| 22 | |||
| 23 | #include <utilities/idd/IddFactory.hxx> | ||
| 24 | |||
| 25 | #include <utilities/idd/OS_UtilityBill_FieldEnums.hxx> | ||
| 26 | #include <utilities/idd/IddEnums.hxx> | ||
| 27 | |||
| 28 | #include "../utilities/data/DataEnums.hpp" | ||
| 29 | #include "../utilities/data/TimeSeries.hpp" | ||
| 30 | |||
| 31 | #include "../utilities/time/Date.hpp" | ||
| 32 | |||
| 33 | #include "../utilities/core/Assert.hpp" | ||
| 34 | |||
| 35 | namespace openstudio { | ||
| 36 | namespace model { | ||
| 37 | |||
| 38 | namespace detail { | ||
| 39 | |||
| 40 | 42 | UtilityBill_Impl::UtilityBill_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 41 | 42 | : ModelObject_Impl(idfObject, model, keepHandle) { | |
| 42 |
4/6✓ Branch 1 taken 42 times.
✓ Branch 4 taken 42 times.
✓ Branch 7 taken 42 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 42 times.
✗ Branch 13 not taken.
|
42 | OS_ASSERT(idfObject.iddObject().type() == UtilityBill::iddObjectType()); |
| 43 | 42 | } | |
| 44 | |||
| 45 | 22 | UtilityBill_Impl::UtilityBill_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 46 | 22 | : ModelObject_Impl(other, model, keepHandle) { | |
| 47 |
4/6✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 7 taken 22 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 22 times.
✗ Branch 13 not taken.
|
22 | OS_ASSERT(other.iddObject().type() == UtilityBill::iddObjectType()); |
| 48 | 22 | } | |
| 49 | |||
| 50 | 90 | UtilityBill_Impl::UtilityBill_Impl(const UtilityBill_Impl& other, Model_Impl* model, bool keepHandle) | |
| 51 | 90 | : ModelObject_Impl(other, model, keepHandle) {} | |
| 52 | |||
| 53 | ✗ | const std::vector<std::string>& UtilityBill_Impl::outputVariableNames() const { | |
| 54 | ✗ | static const std::vector<std::string> result; | |
| 55 | ✗ | return result; | |
| 56 | } | ||
| 57 | |||
| 58 | ✗ | IddObjectType UtilityBill_Impl::iddObjectType() const { | |
| 59 | ✗ | return UtilityBill::iddObjectType(); | |
| 60 | } | ||
| 61 | |||
| 62 | 580 | FuelType UtilityBill_Impl::fuelType() const { | |
| 63 |
1/1✓ Branch 1 taken 580 times.
|
580 | boost::optional<std::string> value = getString(OS_UtilityBillFields::FuelType, true); |
| 64 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 580 times.
✗ Branch 4 not taken.
|
580 | OS_ASSERT(value); |
| 65 |
2/2✓ Branch 1 taken 580 times.
✓ Branch 4 taken 580 times.
|
1160 | return FuelType(value.get()); |
| 66 | 580 | } | |
| 67 | |||
| 68 | 138 | InstallLocationType UtilityBill_Impl::meterInstallLocation() const { | |
| 69 |
1/1✓ Branch 1 taken 138 times.
|
138 | boost::optional<std::string> value = getString(OS_UtilityBillFields::MeterInstallLocation, true); |
| 70 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 138 times.
✗ Branch 4 not taken.
|
138 | OS_ASSERT(value); |
| 71 |
2/2✓ Branch 1 taken 138 times.
✓ Branch 4 taken 138 times.
|
276 | return InstallLocationType(value.get()); |
| 72 | 138 | } | |
| 73 | |||
| 74 | 18 | bool UtilityBill_Impl::isMeterInstallLocationDefaulted() const { | |
| 75 | 18 | return isEmpty(OS_UtilityBillFields::MeterInstallLocation); | |
| 76 | } | ||
| 77 | |||
| 78 | 138 | boost::optional<std::string> UtilityBill_Impl::meterSpecificInstallLocation() const { | |
| 79 | 138 | return getString(OS_UtilityBillFields::MeterSpecificInstallLocation, true, true); | |
| 80 | } | ||
| 81 | |||
| 82 | 138 | boost::optional<EndUseCategoryType> UtilityBill_Impl::meterEndUseCategory() const { | |
| 83 | 138 | boost::optional<EndUseCategoryType> result; | |
| 84 |
1/1✓ Branch 1 taken 138 times.
|
138 | boost::optional<std::string> tmp = getString(OS_UtilityBillFields::MeterEndUseCategory, true, true); |
| 85 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
|
138 | if (tmp) { |
| 86 | ✗ | result = EndUseCategoryType(tmp.get()); | |
| 87 | } | ||
| 88 | 276 | return result; | |
| 89 | 138 | } | |
| 90 | |||
| 91 | 138 | boost::optional<std::string> UtilityBill_Impl::meterSpecificEndUse() const { | |
| 92 | 138 | return getString(OS_UtilityBillFields::MeterSpecificEndUse, true, true); | |
| 93 | } | ||
| 94 | |||
| 95 | 290 | std::string UtilityBill_Impl::consumptionUnit() const { | |
| 96 |
1/1✓ Branch 1 taken 290 times.
|
290 | boost::optional<std::string> value = getString(OS_UtilityBillFields::ConsumptionUnit, true); |
| 97 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 290 times.
✗ Branch 4 not taken.
|
290 | OS_ASSERT(value); |
| 98 |
2/2✓ Branch 1 taken 290 times.
✓ Branch 4 taken 290 times.
|
580 | return value.get(); |
| 99 | 290 | } | |
| 100 | |||
| 101 | 59 | boost::optional<std::string> UtilityBill_Impl::consumptionUnitDescription() const { | |
| 102 | 59 | boost::optional<std::string> result; | |
| 103 | |||
| 104 |
1/1✓ Branch 1 taken 59 times.
|
59 | FuelType fuelType = this->fuelType(); |
| 105 | |||
| 106 |
1/1✓ Branch 1 taken 59 times.
|
59 | std::string consumptionUnit = this->consumptionUnit(); |
| 107 | |||
| 108 |
3/3✓ Branch 1 taken 59 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 45 times.
|
59 | if (consumptionUnit == "kBtu") { |
| 109 |
1/1✓ Branch 1 taken 14 times.
|
14 | result = "thousand Btu"; |
| 110 |
3/3✓ Branch 1 taken 45 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 31 times.
|
45 | } else if (consumptionUnit == "MBtu") { |
| 111 |
1/1✓ Branch 1 taken 14 times.
|
14 | result = "million Btu"; |
| 112 |
3/3✓ Branch 1 taken 31 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 30 times.
|
31 | } else if (consumptionUnit == "kWh") { |
| 113 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = "thousand Watt hours"; |
| 114 |
3/3✓ Branch 1 taken 30 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 29 times.
|
30 | } else if (consumptionUnit == "MWh") { |
| 115 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = "million Watt hours"; |
| 116 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 26 times.
|
29 | } else if (consumptionUnit == "therms") { |
| 117 |
1/1✓ Branch 1 taken 3 times.
|
3 | result = "hundred thousand Btu"; |
| 118 |
3/3✓ Branch 1 taken 26 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 25 times.
|
26 | } else if (consumptionUnit == "RTh") { |
| 119 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = "refrigeration ton hours"; |
| 120 |
2/3✓ Branch 1 taken 25 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25 times.
|
25 | } else if (consumptionUnit == "tons") { |
| 121 | ✗ | result = "two thousand pounds"; | |
| 122 |
3/3✓ Branch 1 taken 25 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 24 times.
|
25 | } else if (consumptionUnit == "lbs") { |
| 123 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = "pounds"; |
| 124 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 23 times.
|
24 | } else if (consumptionUnit == "kLbs") { |
| 125 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = "thousand pounds"; |
| 126 |
3/3✓ Branch 1 taken 23 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 22 times.
|
23 | } else if (consumptionUnit == "MLbs") { |
| 127 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = "million pounds"; |
| 128 |
3/3✓ Branch 1 taken 22 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 16 times.
|
22 | } else if (consumptionUnit == "gal") { |
| 129 |
1/1✓ Branch 1 taken 6 times.
|
6 | result = "gallons"; |
| 130 |
3/3✓ Branch 1 taken 16 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 10 times.
|
16 | } else if (consumptionUnit == "L") { |
| 131 |
1/1✓ Branch 1 taken 6 times.
|
6 | result = "liters"; |
| 132 |
3/3✓ Branch 1 taken 10 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 8 times.
|
10 | } else if (consumptionUnit == "cf") { |
| 133 |
1/1✓ Branch 1 taken 2 times.
|
2 | result = "cubic feet"; |
| 134 |
3/3✓ Branch 1 taken 8 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 6 times.
|
8 | } else if (consumptionUnit == "m3") { |
| 135 |
1/1✓ Branch 1 taken 2 times.
|
2 | result = "cubic meters"; |
| 136 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 4 times.
|
6 | } else if (consumptionUnit == "Ccf") { |
| 137 |
1/1✓ Branch 1 taken 2 times.
|
2 | result = "hundred cubic feet"; |
| 138 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | } else if (consumptionUnit == "Mcf") { |
| 139 |
1/1✓ Branch 1 taken 2 times.
|
2 | result = "thousand cubic feet"; |
| 140 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | } else if (consumptionUnit == "MMcf") { |
| 141 |
1/1✓ Branch 1 taken 2 times.
|
2 | result = "million cubic feet"; |
| 142 | } | ||
| 143 | |||
| 144 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
|
59 | if (!result) { |
| 145 | ✗ | LOG(Error, "Unknown consumption unit '" << consumptionUnit << "' for fuel type '" << fuelType.valueDescription() << "'"); | |
| 146 | } | ||
| 147 | |||
| 148 | 118 | return result; | |
| 149 | 59 | } | |
| 150 | |||
| 151 | 77 | double UtilityBill_Impl::consumptionUnitConversionFactor() const { | |
| 152 |
1/1✓ Branch 1 taken 77 times.
|
77 | boost::optional<double> value = getDouble(OS_UtilityBillFields::ConsumptionUnitConversionFactor, true); |
| 153 | |||
| 154 | // if value not set, use a smart default | ||
| 155 |
1/2✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
|
77 | if (!value) { |
| 156 |
1/1✓ Branch 1 taken 77 times.
|
77 | FuelType fuelType = this->fuelType(); |
| 157 |
1/1✓ Branch 1 taken 77 times.
|
77 | bool isEnergy = (fuelType != FuelType::Water); |
| 158 | |||
| 159 | // DLM: Energy conversion factors come from https://www.energystar.gov/ia/business/tools_resources/target_finder/help/Energy_Units_Conversion_Table.htm | ||
| 160 | // Thermal Energy Conversions, Technical Reference, July 2013 | ||
| 161 | // Portfolio Manager uses these to convert to kBtu | ||
| 162 | // | ||
| 163 | // Original source: | ||
| 164 | // TABLE C-1 TO SUBPART C OF PART 98-DEFAULT CO2 EMISSION FACTORS AND HIGH HEAT VALUES FOR VARIOUS TYPES OF FUEL | ||
| 165 | 77 | boost::optional<double> unitToKBtu; | |
| 166 | 77 | boost::optional<double> unitToM3; | |
| 167 | |||
| 168 |
1/1✓ Branch 1 taken 77 times.
|
77 | std::string consumptionUnit = this->consumptionUnit(); |
| 169 | |||
| 170 |
3/3✓ Branch 1 taken 77 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 59 times.
|
77 | if (consumptionUnit == "kBtu") { |
| 171 |
1/1✓ Branch 1 taken 18 times.
|
18 | unitToKBtu = 1; |
| 172 |
3/3✓ Branch 1 taken 59 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 45 times.
|
59 | } else if (consumptionUnit == "MBtu") { |
| 173 |
1/1✓ Branch 1 taken 14 times.
|
14 | unitToKBtu = 1000; |
| 174 |
3/3✓ Branch 1 taken 45 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 41 times.
|
45 | } else if (consumptionUnit == "kWh") { |
| 175 |
1/1✓ Branch 1 taken 4 times.
|
4 | unitToKBtu = 3.4121416331; |
| 176 |
3/3✓ Branch 1 taken 41 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 40 times.
|
41 | } else if (consumptionUnit == "MWh") { |
| 177 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 3412.1416331; |
| 178 |
3/3✓ Branch 1 taken 40 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 34 times.
|
40 | } else if (consumptionUnit == "therms") { |
| 179 |
1/1✓ Branch 1 taken 6 times.
|
6 | unitToKBtu = 100; |
| 180 |
3/3✓ Branch 1 taken 34 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 32 times.
|
34 | } else if (consumptionUnit == "RTh") { |
| 181 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | switch (fuelType.value()) { |
| 182 | 2 | case FuelType::DistrictCooling: | |
| 183 |
1/1✓ Branch 1 taken 2 times.
|
2 | unitToKBtu = 12; |
| 184 | 2 | break; | |
| 185 | 2 | default:; | |
| 186 | } | ||
| 187 |
2/3✓ Branch 1 taken 32 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
|
32 | } else if (consumptionUnit == "tons") { |
| 188 | //switch (fuelType.value()){ | ||
| 189 | //case FuelType::Coal: | ||
| 190 | // //unitToKBtu = 25090.0; // anthracite | ||
| 191 | // unitToKBtu = 24930.0; // bituminous | ||
| 192 | // break; | ||
| 193 | //default: | ||
| 194 | // ; | ||
| 195 | //} | ||
| 196 |
3/3✓ Branch 1 taken 32 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 30 times.
|
32 | } else if (consumptionUnit == "lbs") { |
| 197 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | switch (fuelType.value()) { |
| 198 | //case FuelType::Coal: | ||
| 199 | // //unitToKBtu = 12.545; // anthracite | ||
| 200 | // unitToKBtu = 12.465; // bituminous | ||
| 201 | // break; | ||
| 202 | 2 | case FuelType::Steam: | |
| 203 |
1/1✓ Branch 1 taken 2 times.
|
2 | unitToKBtu = 1.194; |
| 204 | 2 | break; | |
| 205 | 2 | default:; | |
| 206 | } | ||
| 207 |
3/3✓ Branch 1 taken 30 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 29 times.
|
30 | } else if (consumptionUnit == "kLbs") { |
| 208 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
1 | switch (fuelType.value()) { |
| 209 | //case FuelType::Coal: | ||
| 210 | // //unitToKBtu = 12545; // anthracite | ||
| 211 | // unitToKBtu = 12465; // bituminous | ||
| 212 | // break; | ||
| 213 | 1 | case FuelType::Steam: | |
| 214 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 1194; |
| 215 | 1 | break; | |
| 216 | 1 | default:; | |
| 217 | } | ||
| 218 |
3/3✓ Branch 1 taken 29 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 28 times.
|
29 | } else if (consumptionUnit == "MLbs") { |
| 219 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
1 | switch (fuelType.value()) { |
| 220 | //case FuelType::Coal: | ||
| 221 | // //unitToKBtu = 12545000; // anthracite | ||
| 222 | // unitToKBtu = 12465000; // bituminous | ||
| 223 | // break; | ||
| 224 | 1 | case FuelType::Steam: | |
| 225 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 1194000; |
| 226 | 1 | break; | |
| 227 | 1 | default:; | |
| 228 | } | ||
| 229 |
3/3✓ Branch 1 taken 28 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 17 times.
|
28 | } else if (consumptionUnit == "gal") { |
| 230 |
7/8✓ Branch 1 taken 11 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
11 | switch (fuelType.value()) { |
| 231 | 2 | case FuelType::Gasoline: | |
| 232 |
1/1✓ Branch 1 taken 2 times.
|
2 | unitToKBtu = 125; |
| 233 | 2 | break; | |
| 234 | 2 | case FuelType::Diesel: | |
| 235 |
1/1✓ Branch 1 taken 2 times.
|
2 | unitToKBtu = 138; |
| 236 | 2 | break; | |
| 237 | 2 | case FuelType::FuelOil_1: | |
| 238 |
1/1✓ Branch 1 taken 2 times.
|
2 | unitToKBtu = 139; |
| 239 | 2 | break; | |
| 240 | 2 | case FuelType::FuelOil_2: | |
| 241 |
1/1✓ Branch 1 taken 2 times.
|
2 | unitToKBtu = 138; |
| 242 | 2 | break; | |
| 243 | 1 | case FuelType::Propane: | |
| 244 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 91; |
| 245 | 1 | break; | |
| 246 | 2 | case FuelType::Water: | |
| 247 |
1/1✓ Branch 1 taken 2 times.
|
2 | unitToM3 = 0.00378541; |
| 248 | 2 | break; | |
| 249 | 11 | default:; | |
| 250 | } | ||
| 251 |
3/3✓ Branch 1 taken 17 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 11 times.
|
17 | } else if (consumptionUnit == "L") { |
| 252 |
7/8✓ Branch 1 taken 6 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
|
6 | switch (fuelType.value()) { |
| 253 | 1 | case FuelType::Gasoline: | |
| 254 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 33.0217; |
| 255 | 1 | break; | |
| 256 | 1 | case FuelType::Diesel: | |
| 257 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 36.456; |
| 258 | 1 | break; | |
| 259 | 1 | case FuelType::FuelOil_1: | |
| 260 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 36.720; |
| 261 | 1 | break; | |
| 262 | 1 | case FuelType::FuelOil_2: | |
| 263 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 36.456; |
| 264 | 1 | break; | |
| 265 | 1 | case FuelType::Propane: | |
| 266 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 24.040; |
| 267 | 1 | break; | |
| 268 | 1 | case FuelType::Water: | |
| 269 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToM3 = 0.001; |
| 270 | 1 | break; | |
| 271 | 6 | default:; | |
| 272 | } | ||
| 273 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 8 times.
|
11 | } else if (consumptionUnit == "cf") { |
| 274 |
3/5✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
3 | switch (fuelType.value()) { |
| 275 | 1 | case FuelType::Gas: | |
| 276 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 1.028; |
| 277 | 1 | break; | |
| 278 | 2 | case FuelType::Propane: | |
| 279 |
1/1✓ Branch 1 taken 2 times.
|
2 | unitToKBtu = 0.680; |
| 280 | 2 | break; | |
| 281 | ✗ | case FuelType::Water: | |
| 282 | ✗ | unitToM3 = 0.0283168; | |
| 283 | ✗ | break; | |
| 284 | 3 | default:; | |
| 285 | } | ||
| 286 |
3/3✓ Branch 1 taken 8 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 6 times.
|
8 | } else if (consumptionUnit == "m3") { |
| 287 |
3/5✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
2 | switch (fuelType.value()) { |
| 288 | 1 | case FuelType::Gas: | |
| 289 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 36.303; |
| 290 | 1 | break; | |
| 291 | 1 | case FuelType::Propane: | |
| 292 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 24.0137; |
| 293 | 1 | break; | |
| 294 | ✗ | case FuelType::Water: | |
| 295 | ✗ | unitToM3 = 1; | |
| 296 | ✗ | break; | |
| 297 | 2 | default:; | |
| 298 | } | ||
| 299 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 4 times.
|
6 | } else if (consumptionUnit == "Ccf") { |
| 300 |
3/5✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
2 | switch (fuelType.value()) { |
| 301 | 1 | case FuelType::Gas: | |
| 302 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 102.8; |
| 303 | 1 | break; | |
| 304 | 1 | case FuelType::Propane: | |
| 305 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 68; |
| 306 | 1 | break; | |
| 307 | ✗ | case FuelType::Water: | |
| 308 | ✗ | unitToM3 = 2.83168; | |
| 309 | ✗ | break; | |
| 310 | 2 | default:; | |
| 311 | } | ||
| 312 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | } else if (consumptionUnit == "Mcf") { |
| 313 |
3/5✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
2 | switch (fuelType.value()) { |
| 314 | 1 | case FuelType::Gas: | |
| 315 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 1028; |
| 316 | 1 | break; | |
| 317 | 1 | case FuelType::Propane: | |
| 318 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 680; |
| 319 | 1 | break; | |
| 320 | ✗ | case FuelType::Water: | |
| 321 | ✗ | unitToM3 = 28.3168; | |
| 322 | ✗ | break; | |
| 323 | 2 | default:; | |
| 324 | } | ||
| 325 |
2/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
|
2 | } else if (consumptionUnit == "MMcf") { |
| 326 |
3/5✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
2 | switch (fuelType.value()) { |
| 327 | 1 | case FuelType::Gas: | |
| 328 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 1028000; |
| 329 | 1 | break; | |
| 330 | 1 | case FuelType::Propane: | |
| 331 |
1/1✓ Branch 1 taken 1 time.
|
1 | unitToKBtu = 680000; |
| 332 | 1 | break; | |
| 333 | ✗ | case FuelType::Water: | |
| 334 | ✗ | unitToM3 = 28316.8; | |
| 335 | ✗ | break; | |
| 336 | 2 | default:; | |
| 337 | } | ||
| 338 | } | ||
| 339 | |||
| 340 |
2/2✓ Branch 0 taken 74 times.
✓ Branch 1 taken 3 times.
|
77 | if (isEnergy) { |
| 341 |
1/2✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
|
74 | if (unitToKBtu) { |
| 342 |
2/2✓ Branch 1 taken 74 times.
✓ Branch 4 taken 74 times.
|
74 | value = 1055055.85 * unitToKBtu.get(); |
| 343 | } | ||
| 344 | } else { | ||
| 345 | 3 | value = unitToM3; | |
| 346 | } | ||
| 347 | |||
| 348 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
|
77 | if (!value) { |
| 349 | ✗ | LOG(Error, "Unknown consumption unit '" << consumptionUnit << "' for fuel type '" << fuelType.valueDescription() << "'"); | |
| 350 | } | ||
| 351 | 77 | } | |
| 352 | |||
| 353 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 4 not taken.
|
77 | OS_ASSERT(value); |
| 354 |
1/1✓ Branch 1 taken 77 times.
|
154 | return value.get(); |
| 355 | } | ||
| 356 | |||
| 357 | ✗ | bool UtilityBill_Impl::isConsumptionUnitConversionFactorDefaulted() const { | |
| 358 | ✗ | return isEmpty(OS_UtilityBillFields::PeakDemandUnit); | |
| 359 | } | ||
| 360 | |||
| 361 | 65 | boost::optional<std::string> UtilityBill_Impl::peakDemandUnit() const { | |
| 362 |
4/4✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 7 taken 64 times.
✓ Branch 8 taken 1 time.
|
65 | if (this->fuelType() == FuelType::Electricity) { |
| 363 | 64 | return getString(OS_UtilityBillFields::PeakDemandUnit, true, true); | |
| 364 | } | ||
| 365 | 1 | return boost::none; | |
| 366 | } | ||
| 367 | |||
| 368 | 12 | boost::optional<std::string> UtilityBill_Impl::peakDemandUnitDescription() const { | |
| 369 | 12 | boost::optional<std::string> result; | |
| 370 |
1/1✓ Branch 1 taken 12 times.
|
12 | boost::optional<std::string> peakDemandUnit = this->peakDemandUnit(); |
| 371 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | if (peakDemandUnit) { |
| 372 |
4/4✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 8 times.
|
12 | if (peakDemandUnit.get() == "kW") { |
| 373 |
1/1✓ Branch 1 taken 4 times.
|
4 | result = "thousand Watts"; |
| 374 |
4/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
|
8 | } else if (peakDemandUnit.get() == "MW") { |
| 375 |
1/1✓ Branch 1 taken 4 times.
|
4 | result = "million Watts"; |
| 376 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
|
4 | } else if (peakDemandUnit.get() == "W") { |
| 377 |
1/1✓ Branch 1 taken 4 times.
|
4 | result = "Watts"; |
| 378 | } else { | ||
| 379 | ✗ | LOG(Error, "Unknown peak demand unit '" << peakDemandUnit.get() << "' for fuel type '" << this->fuelType().valueDescription() << "'"); | |
| 380 | } | ||
| 381 | } | ||
| 382 | 24 | return result; | |
| 383 | 12 | } | |
| 384 | |||
| 385 | 24 | boost::optional<double> UtilityBill_Impl::peakDemandUnitConversionFactor() const { | |
| 386 | 24 | boost::optional<double> result; | |
| 387 |
1/1✓ Branch 1 taken 24 times.
|
24 | boost::optional<std::string> peakDemandUnit = this->peakDemandUnit(); |
| 388 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | if (peakDemandUnit) { |
| 389 |
1/1✓ Branch 1 taken 24 times.
|
24 | FuelType fuelType = this->fuelType(); |
| 390 | |||
| 391 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 16 times.
|
24 | if (peakDemandUnit.get() == "kW") { |
| 392 |
1/1✓ Branch 1 taken 8 times.
|
8 | result = 1000; |
| 393 |
4/4✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 8 times.
|
16 | } else if (peakDemandUnit.get() == "MW") { |
| 394 |
1/1✓ Branch 1 taken 8 times.
|
8 | result = 1000000; |
| 395 |
3/4✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
|
8 | } else if (peakDemandUnit.get() == "W") { |
| 396 |
1/1✓ Branch 1 taken 8 times.
|
8 | result = 1; |
| 397 | } else { | ||
| 398 | ✗ | LOG(Error, "Unknown peak demand unit '" << peakDemandUnit.get() << "' for fuel type '" << fuelType.valueDescription() << "'"); | |
| 399 | } | ||
| 400 | } | ||
| 401 | 24 | return result; | |
| 402 | 24 | } | |
| 403 | |||
| 404 | ✗ | boost::optional<unsigned> UtilityBill_Impl::timestepsInPeakDemandWindow() const { | |
| 405 | ✗ | if (this->fuelType() == FuelType::Electricity) { | |
| 406 | ✗ | return getUnsigned(OS_UtilityBillFields::TimestepsinPeakDemandWindow, true); | |
| 407 | } | ||
| 408 | ✗ | return boost::none; | |
| 409 | } | ||
| 410 | |||
| 411 | ✗ | bool UtilityBill_Impl::isTimestepsInPeakDemandWindowDefaulted() const { | |
| 412 | ✗ | return isEmpty(OS_UtilityBillFields::TimestepsinPeakDemandWindow); | |
| 413 | } | ||
| 414 | |||
| 415 | ✗ | boost::optional<double> UtilityBill_Impl::minutesInPeakDemandWindow() const { | |
| 416 | ✗ | boost::optional<double> result; | |
| 417 | ✗ | boost::optional<unsigned> timestepsInPeakDemandWindow = this->timestepsInPeakDemandWindow(); | |
| 418 | ✗ | if (timestepsInPeakDemandWindow) { | |
| 419 | ✗ | auto timestep = this->model().getUniqueModelObject<Timestep>(); | |
| 420 | ✗ | result = (60.0 * timestepsInPeakDemandWindow.get()) / timestep.numberOfTimestepsPerHour(); | |
| 421 | ✗ | } | |
| 422 | ✗ | return result; | |
| 423 | } | ||
| 424 | |||
| 425 | ✗ | bool UtilityBill_Impl::setMeterInstallLocation(const InstallLocationType& meterInstallLocation) { | |
| 426 | ✗ | bool result = setString(OS_UtilityBillFields::MeterInstallLocation, meterInstallLocation.valueName()); | |
| 427 | ✗ | return result; | |
| 428 | } | ||
| 429 | |||
| 430 | ✗ | void UtilityBill_Impl::resetMeterInstallLocation() { | |
| 431 | ✗ | bool result = setString(OS_UtilityBillFields::MeterInstallLocation, ""); | |
| 432 | ✗ | OS_ASSERT(result); | |
| 433 | ✗ | } | |
| 434 | |||
| 435 | ✗ | bool UtilityBill_Impl::setMeterSpecificInstallLocation(const std::string& meterSpecificInstallLocation) { | |
| 436 | ✗ | bool result = setString(OS_UtilityBillFields::MeterSpecificInstallLocation, meterSpecificInstallLocation); | |
| 437 | ✗ | return result; | |
| 438 | } | ||
| 439 | |||
| 440 | ✗ | void UtilityBill_Impl::resetMeterSpecificInstallLocation() { | |
| 441 | ✗ | bool result = setString(OS_UtilityBillFields::MeterSpecificInstallLocation, ""); | |
| 442 | ✗ | OS_ASSERT(result); | |
| 443 | ✗ | } | |
| 444 | |||
| 445 | ✗ | bool UtilityBill_Impl::setMeterEndUseCategory(const EndUseCategoryType& meterEndUseCategory) { | |
| 446 | ✗ | bool result = setString(OS_UtilityBillFields::MeterEndUseCategory, meterEndUseCategory.valueName()); | |
| 447 | ✗ | return result; | |
| 448 | } | ||
| 449 | |||
| 450 | ✗ | void UtilityBill_Impl::resetMeterEndUseCategory() { | |
| 451 | ✗ | bool result = setString(OS_UtilityBillFields::MeterEndUseCategory, ""); | |
| 452 | ✗ | OS_ASSERT(result); | |
| 453 | ✗ | } | |
| 454 | |||
| 455 | ✗ | bool UtilityBill_Impl::setMeterSpecificEndUse(const std::string& meterSpecificEndUse) { | |
| 456 | ✗ | bool result = setString(OS_UtilityBillFields::MeterSpecificEndUse, meterSpecificEndUse); | |
| 457 | ✗ | return result; | |
| 458 | } | ||
| 459 | |||
| 460 | ✗ | void UtilityBill_Impl::resetMeterSpecificEndUse() { | |
| 461 | ✗ | bool result = setString(OS_UtilityBillFields::MeterSpecificEndUse, ""); | |
| 462 | ✗ | OS_ASSERT(result); | |
| 463 | ✗ | } | |
| 464 | |||
| 465 | 77 | bool UtilityBill_Impl::setConsumptionUnit(const std::string& consumptionUnit) { | |
| 466 | 77 | bool result = false; | |
| 467 |
1/1✓ Branch 1 taken 77 times.
|
77 | std::vector<std::string> consumptionUnitValues = this->consumptionUnitValues(); |
| 468 |
1/1✓ Branch 3 taken 77 times.
|
77 | auto it = std::find(consumptionUnitValues.begin(), consumptionUnitValues.end(), consumptionUnit); |
| 469 |
1/2✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
|
77 | if (it != consumptionUnitValues.end()) { |
| 470 |
1/1✓ Branch 1 taken 77 times.
|
77 | std::string oldConsumptionUnit = this->consumptionUnit(); |
| 471 |
1/1✓ Branch 1 taken 77 times.
|
77 | result = setString(OS_UtilityBillFields::ConsumptionUnit, consumptionUnit); |
| 472 |
5/6✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 62 times.
✓ Branch 6 taken 15 times.
|
77 | if (result && (oldConsumptionUnit != consumptionUnit)) { |
| 473 |
1/1✓ Branch 1 taken 62 times.
|
62 | resetConsumptionUnitConversionFactor(); |
| 474 | } | ||
| 475 | 77 | } | |
| 476 | 77 | return result; | |
| 477 | 77 | } | |
| 478 | |||
| 479 | ✗ | bool UtilityBill_Impl::setConsumptionUnitConversionFactor(double consumptionUnitConversionFactor) { | |
| 480 | ✗ | bool result = setDouble(OS_UtilityBillFields::ConsumptionUnitConversionFactor, consumptionUnitConversionFactor); | |
| 481 | ✗ | return result; | |
| 482 | } | ||
| 483 | |||
| 484 | 62 | void UtilityBill_Impl::resetConsumptionUnitConversionFactor() { | |
| 485 |
2/2✓ Branch 1 taken 62 times.
✓ Branch 4 taken 62 times.
|
124 | bool result = setString(OS_UtilityBillFields::ConsumptionUnitConversionFactor, ""); |
| 486 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
|
62 | OS_ASSERT(result); |
| 487 | 62 | } | |
| 488 | |||
| 489 | 15 | bool UtilityBill_Impl::setPeakDemandUnit(const std::string& peakDemandUnit) { | |
| 490 | 15 | bool result = false; | |
| 491 |
1/1✓ Branch 1 taken 15 times.
|
15 | std::vector<std::string> peakDemandUnitValues = this->peakDemandUnitValues(); |
| 492 |
2/6✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
|
15 | if (peakDemandUnitValues.empty() && peakDemandUnit.empty()) { |
| 493 | ✗ | result = setString(OS_UtilityBillFields::PeakDemandUnit, peakDemandUnit); | |
| 494 | } else { | ||
| 495 |
1/1✓ Branch 3 taken 15 times.
|
15 | auto it = std::find(peakDemandUnitValues.begin(), peakDemandUnitValues.end(), peakDemandUnit); |
| 496 |
1/2✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
|
15 | if (it != peakDemandUnitValues.end()) { |
| 497 |
1/1✓ Branch 1 taken 15 times.
|
15 | result = setString(OS_UtilityBillFields::PeakDemandUnit, peakDemandUnit); |
| 498 | } | ||
| 499 | } | ||
| 500 | 15 | return result; | |
| 501 | 15 | } | |
| 502 | |||
| 503 | ✗ | bool UtilityBill_Impl::setTimestepsInPeakDemandWindow(unsigned timestepsInPeakDemandWindow) { | |
| 504 | ✗ | if (this->fuelType() == FuelType::Electricity) { | |
| 505 | ✗ | return setUnsigned(OS_UtilityBillFields::TimestepsinPeakDemandWindow, timestepsInPeakDemandWindow); | |
| 506 | } | ||
| 507 | ✗ | return false; | |
| 508 | } | ||
| 509 | |||
| 510 | ✗ | void UtilityBill_Impl::resetTimestepsInPeakDemandWindow() { | |
| 511 | ✗ | bool test = setString(OS_UtilityBillFields::TimestepsinPeakDemandWindow, ""); | |
| 512 | ✗ | OS_ASSERT(test); | |
| 513 | ✗ | } | |
| 514 | |||
| 515 | 125 | std::vector<std::string> UtilityBill_Impl::consumptionUnitValues() const { | |
| 516 | 125 | std::vector<std::string> result; | |
| 517 |
1/1✓ Branch 1 taken 125 times.
|
125 | FuelType fuelType = this->fuelType(); |
| 518 |
16/17✓ Branch 1 taken 125 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 13 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 10 times.
✓ Branch 13 taken 7 times.
✓ Branch 14 taken 7 times.
✓ Branch 15 taken 6 times.
✓ Branch 16 taken 6 times.
✓ Branch 17 taken 6 times.
✗ Branch 18 not taken.
|
125 | switch (fuelType.value()) { |
| 519 | 12 | case FuelType::Electricity: | |
| 520 |
1/1✓ Branch 1 taken 12 times.
|
12 | result.emplace_back("kWh"); |
| 521 |
1/1✓ Branch 1 taken 12 times.
|
12 | result.emplace_back("MWh"); |
| 522 |
1/1✓ Branch 1 taken 12 times.
|
12 | result.emplace_back("kBtu"); |
| 523 |
1/1✓ Branch 1 taken 12 times.
|
12 | result.emplace_back("MBtu"); |
| 524 | 12 | break; | |
| 525 | 14 | case FuelType::Gas: | |
| 526 |
1/1✓ Branch 1 taken 14 times.
|
14 | result.emplace_back("therms"); |
| 527 |
1/1✓ Branch 1 taken 14 times.
|
14 | result.emplace_back("cf"); |
| 528 |
1/1✓ Branch 1 taken 14 times.
|
14 | result.emplace_back("Ccf"); |
| 529 |
1/1✓ Branch 1 taken 14 times.
|
14 | result.emplace_back("Mcf"); |
| 530 |
1/1✓ Branch 1 taken 14 times.
|
14 | result.emplace_back("MMcf"); |
| 531 |
1/1✓ Branch 1 taken 14 times.
|
14 | result.emplace_back("m3"); |
| 532 |
1/1✓ Branch 1 taken 14 times.
|
14 | result.emplace_back("kBtu"); |
| 533 |
1/1✓ Branch 1 taken 14 times.
|
14 | result.emplace_back("MBtu"); |
| 534 | 14 | break; | |
| 535 | 8 | case FuelType::Gasoline: | |
| 536 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("gal"); |
| 537 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("L"); |
| 538 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("kBtu"); |
| 539 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("MBtu"); |
| 540 | 8 | break; | |
| 541 | 8 | case FuelType::Diesel: | |
| 542 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("gal"); |
| 543 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("L"); |
| 544 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("kBtu"); |
| 545 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("MBtu"); |
| 546 | 8 | break; | |
| 547 | 6 | case FuelType::Coal: | |
| 548 | // result.emplace_back("tons"); | ||
| 549 | // result.emplace_back("lbs"); | ||
| 550 | // result.emplace_back("kLbs"); | ||
| 551 | // result.emplace_back("MLbs"); | ||
| 552 |
1/1✓ Branch 1 taken 6 times.
|
6 | result.emplace_back("kBtu"); |
| 553 |
1/1✓ Branch 1 taken 6 times.
|
6 | result.emplace_back("MBtu"); |
| 554 | 6 | break; | |
| 555 | 8 | case FuelType::FuelOil_1: | |
| 556 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("gal"); |
| 557 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("L"); |
| 558 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("kBtu"); |
| 559 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("MBtu"); |
| 560 | 8 | break; | |
| 561 | 8 | case FuelType::FuelOil_2: | |
| 562 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("gal"); |
| 563 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("L"); |
| 564 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("kBtu"); |
| 565 |
1/1✓ Branch 1 taken 8 times.
|
8 | result.emplace_back("MBtu"); |
| 566 | 8 | break; | |
| 567 | 13 | case FuelType::Propane: | |
| 568 |
1/1✓ Branch 1 taken 13 times.
|
13 | result.emplace_back("cf"); |
| 569 |
1/1✓ Branch 1 taken 13 times.
|
13 | result.emplace_back("Ccf"); |
| 570 |
1/1✓ Branch 1 taken 13 times.
|
13 | result.emplace_back("Mcf"); |
| 571 |
1/1✓ Branch 1 taken 13 times.
|
13 | result.emplace_back("MMcf"); |
| 572 |
1/1✓ Branch 1 taken 13 times.
|
13 | result.emplace_back("m3"); |
| 573 |
1/1✓ Branch 1 taken 13 times.
|
13 | result.emplace_back("gal"); |
| 574 |
1/1✓ Branch 1 taken 13 times.
|
13 | result.emplace_back("L"); |
| 575 |
1/1✓ Branch 1 taken 13 times.
|
13 | result.emplace_back("kBtu"); |
| 576 |
1/1✓ Branch 1 taken 13 times.
|
13 | result.emplace_back("MBtu"); |
| 577 | 13 | break; | |
| 578 | 6 | case FuelType::Water: | |
| 579 |
1/1✓ Branch 1 taken 6 times.
|
6 | result.emplace_back("gal"); |
| 580 |
1/1✓ Branch 1 taken 6 times.
|
6 | result.emplace_back("L"); |
| 581 | 6 | break; | |
| 582 | 10 | case FuelType::Steam: | |
| 583 |
1/1✓ Branch 1 taken 10 times.
|
10 | result.emplace_back("lbs"); |
| 584 |
1/1✓ Branch 1 taken 10 times.
|
10 | result.emplace_back("kLbs"); |
| 585 |
1/1✓ Branch 1 taken 10 times.
|
10 | result.emplace_back("MLbs"); |
| 586 |
1/1✓ Branch 1 taken 10 times.
|
10 | result.emplace_back("therms"); |
| 587 |
1/1✓ Branch 1 taken 10 times.
|
10 | result.emplace_back("kBtu"); |
| 588 |
1/1✓ Branch 1 taken 10 times.
|
10 | result.emplace_back("MBtu"); |
| 589 | 10 | break; | |
| 590 | 7 | case FuelType::DistrictCooling: | |
| 591 |
1/1✓ Branch 1 taken 7 times.
|
7 | result.emplace_back("RTh"); |
| 592 |
1/1✓ Branch 1 taken 7 times.
|
7 | result.emplace_back("kBtu"); |
| 593 |
1/1✓ Branch 1 taken 7 times.
|
7 | result.emplace_back("MBtu"); |
| 594 | 7 | break; | |
| 595 | 7 | case FuelType::DistrictHeating: | |
| 596 |
1/1✓ Branch 1 taken 7 times.
|
7 | result.emplace_back("therms"); |
| 597 |
1/1✓ Branch 1 taken 7 times.
|
7 | result.emplace_back("kBtu"); |
| 598 |
1/1✓ Branch 1 taken 7 times.
|
7 | result.emplace_back("MBtu"); |
| 599 | 7 | break; | |
| 600 | 6 | case FuelType::OtherFuel_1: | |
| 601 |
1/1✓ Branch 1 taken 6 times.
|
6 | result.emplace_back("kBtu"); |
| 602 |
1/1✓ Branch 1 taken 6 times.
|
6 | result.emplace_back("MBtu"); |
| 603 | 6 | break; | |
| 604 | 6 | case FuelType::OtherFuel_2: | |
| 605 |
1/1✓ Branch 1 taken 6 times.
|
6 | result.emplace_back("kBtu"); |
| 606 |
1/1✓ Branch 1 taken 6 times.
|
6 | result.emplace_back("MBtu"); |
| 607 | 6 | break; | |
| 608 | 6 | case FuelType::EnergyTransfer: | |
| 609 |
1/1✓ Branch 1 taken 6 times.
|
6 | result.emplace_back("kBtu"); |
| 610 |
1/1✓ Branch 1 taken 6 times.
|
6 | result.emplace_back("MBtu"); |
| 611 | 6 | break; | |
| 612 | ✗ | default: | |
| 613 | ✗ | LOG_AND_THROW("Unknown fuel type '" + fuelType.valueDescription() + "'"); | |
| 614 | } | ||
| 615 | |||
| 616 | 250 | return result; | |
| 617 | ✗ | } | |
| 618 | |||
| 619 | 92 | std::vector<std::string> UtilityBill_Impl::peakDemandUnitValues() const { | |
| 620 | 92 | std::vector<std::string> result; | |
| 621 |
1/1✓ Branch 1 taken 92 times.
|
92 | FuelType fuelType = this->fuelType(); |
| 622 |
16/17✓ Branch 1 taken 92 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 10 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 7 times.
✓ Branch 13 taken 4 times.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 17 taken 3 times.
✗ Branch 18 not taken.
|
92 | switch (fuelType.value()) { |
| 623 | 22 | case FuelType::Electricity: | |
| 624 |
1/1✓ Branch 1 taken 22 times.
|
22 | result.emplace_back("kW"); |
| 625 |
1/1✓ Branch 1 taken 22 times.
|
22 | result.emplace_back("MW"); |
| 626 |
1/1✓ Branch 1 taken 22 times.
|
22 | result.emplace_back("W"); |
| 627 | 22 | break; | |
| 628 | 10 | case FuelType::Gas: | |
| 629 | 10 | break; | |
| 630 | 5 | case FuelType::Gasoline: | |
| 631 | 5 | break; | |
| 632 | 5 | case FuelType::Diesel: | |
| 633 | 5 | break; | |
| 634 | 3 | case FuelType::Coal: | |
| 635 | 3 | break; | |
| 636 | 5 | case FuelType::FuelOil_1: | |
| 637 | 5 | break; | |
| 638 | 5 | case FuelType::FuelOil_2: | |
| 639 | 5 | break; | |
| 640 | 10 | case FuelType::Propane: | |
| 641 | 10 | break; | |
| 642 | 3 | case FuelType::Water: | |
| 643 | 3 | break; | |
| 644 | 7 | case FuelType::Steam: | |
| 645 | 7 | break; | |
| 646 | 4 | case FuelType::DistrictCooling: | |
| 647 | 4 | break; | |
| 648 | 4 | case FuelType::DistrictHeating: | |
| 649 | 4 | break; | |
| 650 | 3 | case FuelType::OtherFuel_1: | |
| 651 | 3 | break; | |
| 652 | 3 | case FuelType::OtherFuel_2: | |
| 653 | 3 | break; | |
| 654 | 3 | case FuelType::EnergyTransfer: | |
| 655 | 3 | break; | |
| 656 | ✗ | default: | |
| 657 | ✗ | LOG_AND_THROW("Unknown fuel type '" + fuelType.valueDescription() + "'"); | |
| 658 | } | ||
| 659 | |||
| 660 | 184 | return result; | |
| 661 | ✗ | } | |
| 662 | |||
| 663 | 84 | OutputMeter UtilityBill_Impl::consumptionMeter() const { | |
| 664 |
1/1✓ Branch 1 taken 84 times.
|
84 | FuelType fuelType = this->fuelType(); |
| 665 |
1/1✓ Branch 1 taken 84 times.
|
84 | InstallLocationType meterInstallLocation = this->meterInstallLocation(); |
| 666 |
1/1✓ Branch 1 taken 84 times.
|
84 | boost::optional<std::string> meterSpecificInstallLocation = this->meterSpecificInstallLocation(); |
| 667 |
1/1✓ Branch 1 taken 84 times.
|
84 | boost::optional<EndUseCategoryType> meterEndUseCategory = this->meterEndUseCategory(); |
| 668 | 84 | boost::optional<EndUseType> meterEndUse; | |
| 669 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
|
84 | if (meterEndUseCategory) { |
| 670 | ✗ | meterEndUse = EndUseType(meterEndUseCategory->valueName()); | |
| 671 | } | ||
| 672 |
1/1✓ Branch 1 taken 84 times.
|
84 | boost::optional<std::string> meterSpecificEndUse = this->meterSpecificEndUse(); |
| 673 | |||
| 674 |
3/3✓ Branch 1 taken 84 times.
✓ Branch 4 taken 84 times.
✓ Branch 7 taken 84 times.
|
84 | std::string meterName = OutputMeter::getName(meterSpecificEndUse, meterEndUse, fuelType, meterInstallLocation, meterSpecificInstallLocation); |
| 675 | |||
| 676 | 84 | boost::optional<OutputMeter> result; | |
| 677 |
4/4✓ Branch 1 taken 84 times.
✓ Branch 4 taken 84 times.
✓ Branch 12 taken 276 times.
✓ Branch 13 taken 36 times.
|
312 | for (const OutputMeter& meter : this->model().getConcreteModelObjects<OutputMeter>()) { |
| 678 |
18/27✓ Branch 1 taken 276 times.
✓ Branch 4 taken 276 times.
✓ Branch 6 taken 54 times.
✓ Branch 7 taken 222 times.
✓ Branch 9 taken 54 times.
✓ Branch 12 taken 54 times.
✓ Branch 15 taken 54 times.
✓ Branch 17 taken 48 times.
✓ Branch 18 taken 6 times.
✓ Branch 19 taken 54 times.
✓ Branch 20 taken 222 times.
✓ Branch 22 taken 54 times.
✓ Branch 23 taken 222 times.
✓ Branch 24 taken 54 times.
✓ Branch 25 taken 222 times.
✓ Branch 27 taken 276 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 48 times.
✓ Branch 31 taken 228 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
|
384 | if ((istringEqual(meter.name(), meterName)) && (istringEqual("Daily", meter.reportingFrequency()))) { |
| 679 |
1/1✓ Branch 1 taken 48 times.
|
48 | return meter; |
| 680 | } | ||
| 681 | 84 | } | |
| 682 | |||
| 683 |
3/3✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
|
36 | result = OutputMeter(this->model()); |
| 684 |
3/3✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 7 taken 36 times.
|
72 | result->setReportingFrequency("Daily"); |
| 685 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | result->setFuelType(fuelType); |
| 686 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | result->setInstallLocationType(meterInstallLocation); |
| 687 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
|
36 | if (meterSpecificInstallLocation) { |
| 688 | ✗ | result->setSpecificInstallLocation(*meterSpecificInstallLocation); | |
| 689 | } | ||
| 690 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
|
36 | if (meterEndUse) { |
| 691 | ✗ | result->setEndUseType(*meterEndUse); | |
| 692 | } | ||
| 693 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
|
36 | if (meterSpecificEndUse) { |
| 694 | ✗ | result->setSpecificEndUse(*meterSpecificEndUse); | |
| 695 | } | ||
| 696 | |||
| 697 |
2/2✓ Branch 1 taken 36 times.
✓ Branch 4 taken 36 times.
|
36 | return result.get(); |
| 698 | 84 | } | |
| 699 | |||
| 700 | 36 | boost::optional<OutputMeter> UtilityBill_Impl::peakDemandMeter() const { | |
| 701 |
1/1✓ Branch 1 taken 36 times.
|
36 | FuelType fuelType = this->fuelType(); |
| 702 |
1/1✓ Branch 1 taken 36 times.
|
36 | InstallLocationType meterInstallLocation = this->meterInstallLocation(); |
| 703 |
1/1✓ Branch 1 taken 36 times.
|
36 | boost::optional<std::string> meterSpecificInstallLocation = this->meterSpecificInstallLocation(); |
| 704 |
1/1✓ Branch 1 taken 36 times.
|
36 | boost::optional<EndUseCategoryType> meterEndUseCategory = this->meterEndUseCategory(); |
| 705 | 36 | boost::optional<EndUseType> meterEndUse; | |
| 706 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
|
36 | if (meterEndUseCategory) { |
| 707 | ✗ | meterEndUse = EndUseType(meterEndUseCategory->valueName()); | |
| 708 | } | ||
| 709 |
1/1✓ Branch 1 taken 36 times.
|
36 | boost::optional<std::string> meterSpecificEndUse = this->meterSpecificEndUse(); |
| 710 | |||
| 711 |
3/3✓ Branch 1 taken 36 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 26 times.
|
36 | if (fuelType != FuelType::Electricity) { |
| 712 | 10 | return boost::none; | |
| 713 | } | ||
| 714 | |||
| 715 |
3/3✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
✓ Branch 7 taken 26 times.
|
26 | std::string meterName = OutputMeter::getName(meterSpecificEndUse, meterEndUse, fuelType, meterInstallLocation, meterSpecificInstallLocation); |
| 716 | |||
| 717 | 26 | boost::optional<OutputMeter> result; | |
| 718 |
4/4✓ Branch 1 taken 26 times.
✓ Branch 4 taken 26 times.
✓ Branch 12 taken 28 times.
✓ Branch 13 taken 12 times.
|
40 | for (const OutputMeter& meter : this->model().getConcreteModelObjects<OutputMeter>()) { |
| 719 |
14/27✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 28 times.
✓ Branch 12 taken 28 times.
✓ Branch 15 taken 28 times.
✓ Branch 17 taken 14 times.
✓ Branch 18 taken 14 times.
✓ Branch 19 taken 28 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 28 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 28 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 14 times.
✓ Branch 31 taken 14 times.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
|
84 | if ((istringEqual(meter.name(), meterName)) && (istringEqual("Timestep", meter.reportingFrequency()))) { |
| 720 |
1/1✓ Branch 1 taken 14 times.
|
14 | return meter; |
| 721 | } | ||
| 722 | 26 | } | |
| 723 | |||
| 724 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
12 | result = OutputMeter(this->model()); |
| 725 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
24 | result->setReportingFrequency("Timestep"); |
| 726 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | result->setFuelType(fuelType); |
| 727 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | result->setInstallLocationType(meterInstallLocation); |
| 728 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if (meterSpecificInstallLocation) { |
| 729 | ✗ | result->setSpecificInstallLocation(*meterSpecificInstallLocation); | |
| 730 | } | ||
| 731 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if (meterEndUse) { |
| 732 | ✗ | result->setEndUseType(*meterEndUse); | |
| 733 | } | ||
| 734 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if (meterSpecificEndUse) { |
| 735 | ✗ | result->setSpecificEndUse(*meterSpecificEndUse); | |
| 736 | } | ||
| 737 | |||
| 738 | 12 | return result; | |
| 739 | 36 | } | |
| 740 | |||
| 741 | 25 | std::vector<BillingPeriod> UtilityBill_Impl::billingPeriods() const { | |
| 742 |
1/1✓ Branch 1 taken 25 times.
|
25 | IdfExtensibleGroupVector egs = extensibleGroups(); |
| 743 | 25 | std::vector<BillingPeriod> result; | |
| 744 |
2/2✓ Branch 4 taken 5 times.
✓ Branch 5 taken 25 times.
|
30 | for (const IdfExtensibleGroup& eg : egs) { |
| 745 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | result.push_back(eg.cast<BillingPeriod>()); |
| 746 | } | ||
| 747 | 50 | return result; | |
| 748 | 25 | } | |
| 749 | |||
| 750 | ✗ | void UtilityBill_Impl::clearBillingPeriods() { | |
| 751 | ✗ | clearExtensibleGroups(); | |
| 752 | ✗ | OS_ASSERT(numExtensibleGroups() == 0u); | |
| 753 | ✗ | } | |
| 754 | |||
| 755 | 7 | BillingPeriod UtilityBill_Impl::addBillingPeriod() { | |
| 756 |
1/1✓ Branch 1 taken 7 times.
|
7 | std::vector<BillingPeriod> billingPeriods = this->billingPeriods(); |
| 757 | |||
| 758 | 7 | std::vector<std::string> values; | |
| 759 | |||
| 760 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 4 times.
|
7 | if (billingPeriods.empty()) { |
| 761 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | boost::optional<model::YearDescription> yd = this->model().yearDescription(); |
| 762 | //DLM: we could assert yd and also yd->calendarYear here | ||
| 763 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (!yd) { |
| 764 | ✗ | yd = this->model().getUniqueModelObject<model::YearDescription>(); | |
| 765 | } | ||
| 766 | |||
| 767 |
2/4✓ Branch 0 taken 21 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
24 | values = { |
| 768 | toString(1), // month | ||
| 769 | toString(1), // day | ||
| 770 |
1/1✓ Branch 1 taken 3 times.
|
3 | toString(yd->assumedYear()), // year |
| 771 | toString(30), // number of days | ||
| 772 | "", // consumption | ||
| 773 | "", // peak demand | ||
| 774 | "", // cost | ||
| 775 | 24 | }; | |
| 776 | |||
| 777 | ✗ | } else { | |
| 778 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 8 taken 4 times.
|
4 | Date startDate = billingPeriods.back().endDate() + Time(1); |
| 779 | |||
| 780 |
2/4✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
32 | values = { |
| 781 |
1/1✓ Branch 1 taken 4 times.
|
4 | toString(startDate.monthOfYear().value()), // month |
| 782 | 8 | toString(startDate.dayOfMonth()), // day | |
| 783 | 8 | toString(startDate.year()), // year | |
| 784 |
1/1✓ Branch 1 taken 4 times.
|
4 | toString(billingPeriods.back().numberOfDays()), // number of days |
| 785 | "", // consumption | ||
| 786 | "", // peak demand | ||
| 787 | "", // cost | ||
| 788 | 32 | }; | |
| 789 | } | ||
| 790 | |||
| 791 |
1/1✓ Branch 1 taken 7 times.
|
7 | IdfExtensibleGroup eg = pushExtensibleGroup(values, false); |
| 792 |
2/4✓ Branch 1 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 6 not taken.
|
7 | OS_ASSERT(!eg.empty()); |
| 793 | |||
| 794 |
1/1✓ Branch 1 taken 7 times.
|
7 | this->emitChangeSignals(); |
| 795 | |||
| 796 |
1/1✓ Branch 1 taken 7 times.
|
7 | auto result = eg.cast<BillingPeriod>(); |
| 797 | |||
| 798 | 14 | return result; | |
| 799 | 39 | } | |
| 800 | |||
| 801 | ✗ | unsigned UtilityBill_Impl::numberBillingPeriodsInCalculations() const { | |
| 802 | ✗ | unsigned n = 0; | |
| 803 | ✗ | for (const BillingPeriod& p : this->billingPeriods()) { | |
| 804 | ✗ | boost::optional<double> consumption = p.consumption(); | |
| 805 | ✗ | if (consumption) { | |
| 806 | ✗ | boost::optional<double> modelConsumption = p.modelConsumption(); | |
| 807 | ✗ | if (modelConsumption) { | |
| 808 | ✗ | n += 1; | |
| 809 | } | ||
| 810 | } | ||
| 811 | ✗ | } | |
| 812 | |||
| 813 | ✗ | return n; | |
| 814 | } | ||
| 815 | |||
| 816 | ✗ | boost::optional<double> UtilityBill_Impl::CVRMSE() const { | |
| 817 | ✗ | boost::optional<double> result; | |
| 818 | ✗ | double ysum = 0; | |
| 819 | ✗ | double squaredError = 0; | |
| 820 | ✗ | unsigned n = 0; | |
| 821 | ✗ | double conv = this->consumptionUnitConversionFactor(); | |
| 822 | ✗ | for (const BillingPeriod& p : this->billingPeriods()) { | |
| 823 | ✗ | boost::optional<double> consumption = p.consumption(); | |
| 824 | ✗ | if (consumption) { | |
| 825 | ✗ | double convertedConsumption = conv * consumption.get(); | |
| 826 | ✗ | boost::optional<double> modelConsumption = p.modelConsumption(); | |
| 827 | ✗ | if (modelConsumption) { | |
| 828 | ✗ | ysum += convertedConsumption; | |
| 829 | ✗ | squaredError += std::pow(convertedConsumption - *modelConsumption, 2); | |
| 830 | ✗ | n += 1; | |
| 831 | } | ||
| 832 | } | ||
| 833 | ✗ | } | |
| 834 | |||
| 835 | ✗ | if (n > 1) { | |
| 836 | ✗ | double ybar = ysum / n; | |
| 837 | ✗ | result = 100.0 * std::pow(squaredError / (n - 1), 0.5) / ybar; | |
| 838 | } | ||
| 839 | |||
| 840 | ✗ | return result; | |
| 841 | } | ||
| 842 | |||
| 843 | ✗ | boost::optional<double> UtilityBill_Impl::NMBE() const { | |
| 844 | ✗ | boost::optional<double> result; | |
| 845 | ✗ | double ysum = 0; | |
| 846 | ✗ | double sumError = 0; | |
| 847 | ✗ | unsigned n = 0; | |
| 848 | ✗ | double conv = this->consumptionUnitConversionFactor(); | |
| 849 | ✗ | for (const BillingPeriod& p : this->billingPeriods()) { | |
| 850 | ✗ | boost::optional<double> consumption = p.consumption(); | |
| 851 | ✗ | if (consumption) { | |
| 852 | ✗ | double convertedConsumption = conv * consumption.get(); | |
| 853 | ✗ | boost::optional<double> modelConsumption = p.modelConsumption(); | |
| 854 | ✗ | if (modelConsumption) { | |
| 855 | ✗ | ysum += convertedConsumption; | |
| 856 | ✗ | sumError += (convertedConsumption - *modelConsumption); | |
| 857 | ✗ | n += 1; | |
| 858 | } | ||
| 859 | } | ||
| 860 | ✗ | } | |
| 861 | |||
| 862 | ✗ | if (n > 1) { | |
| 863 | ✗ | double ybar = ysum / n; | |
| 864 | ✗ | result = 100.0 * (sumError / (n - 1)) / ybar; | |
| 865 | } | ||
| 866 | |||
| 867 | ✗ | return result; | |
| 868 | } | ||
| 869 | |||
| 870 | } // namespace detail | ||
| 871 | |||
| 872 | 41 | Date BillingPeriod::startDate() const { | |
| 873 |
1/1✓ Branch 1 taken 41 times.
|
41 | boost::optional<int> beginMonth = getInt(OS_UtilityBillExtensibleFields::BillingPeriodBeginMonth); |
| 874 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 4 not taken.
|
41 | OS_ASSERT(beginMonth); |
| 875 |
1/1✓ Branch 1 taken 41 times.
|
41 | boost::optional<unsigned> beginDay = getUnsigned(OS_UtilityBillExtensibleFields::BillingPeriodBeginDayofMonth); |
| 876 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 4 not taken.
|
41 | OS_ASSERT(beginDay); |
| 877 |
1/1✓ Branch 1 taken 41 times.
|
41 | boost::optional<int> beginYear = getInt(OS_UtilityBillExtensibleFields::BillingPeriodBeginYear); |
| 878 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 4 not taken.
|
41 | OS_ASSERT(beginYear); |
| 879 | |||
| 880 |
5/5✓ Branch 1 taken 41 times.
✓ Branch 4 taken 41 times.
✓ Branch 7 taken 41 times.
✓ Branch 10 taken 41 times.
✓ Branch 13 taken 41 times.
|
41 | return {MonthOfYear{beginMonth.get()}, beginDay.get(), beginYear.get()}; |
| 881 | } | ||
| 882 | |||
| 883 | 24 | Date BillingPeriod::endDate() const { | |
| 884 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
|
24 | Date result = this->startDate() + Time(this->numberOfDays() - 1); |
| 885 | 24 | return result; | |
| 886 | } | ||
| 887 | |||
| 888 | 45 | unsigned BillingPeriod::numberOfDays() const { | |
| 889 |
1/1✓ Branch 1 taken 45 times.
|
45 | boost::optional<unsigned> numberOfDays = getUnsigned(OS_UtilityBillExtensibleFields::NumberofDaysinBillingPeriod); |
| 890 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
✗ Branch 4 not taken.
|
45 | OS_ASSERT(numberOfDays); |
| 891 |
1/1✓ Branch 1 taken 45 times.
|
90 | return numberOfDays.get(); |
| 892 | } | ||
| 893 | |||
| 894 | ✗ | boost::optional<double> BillingPeriod::consumption() const { | |
| 895 | ✗ | return getDouble(OS_UtilityBillExtensibleFields::BillingPeriodConsumption); | |
| 896 | } | ||
| 897 | |||
| 898 | ✗ | boost::optional<double> BillingPeriod::peakDemand() const { | |
| 899 | ✗ | return getDouble(OS_UtilityBillExtensibleFields::BillingPeriodPeakDemand); | |
| 900 | } | ||
| 901 | |||
| 902 | ✗ | boost::optional<double> BillingPeriod::totalCost() const { | |
| 903 | ✗ | return getDouble(OS_UtilityBillExtensibleFields::BillingPeriodTotalCost); | |
| 904 | } | ||
| 905 | |||
| 906 | 5 | bool BillingPeriod::setStartDate(const Date& startDate) { | |
| 907 |
1/1✓ Branch 1 taken 5 times.
|
5 | Date currentEndDate = this->endDate(); |
| 908 | |||
| 909 | /* If startDate is before endDate then endDate is retained. | ||
| 910 | If startDate is after endDate then numberOfDays is retained. */ | ||
| 911 | |||
| 912 |
1/1✓ Branch 1 taken 5 times.
|
5 | std::vector<std::string> fields = this->fields(); |
| 913 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 4 not taken.
|
5 | OS_ASSERT(fields.size() == 7); |
| 914 | |||
| 915 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
|
5 | fields[0] = toString(startDate.monthOfYear().value()); |
| 916 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | fields[1] = toString(startDate.dayOfMonth()); |
| 917 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | fields[2] = toString(startDate.assumedBaseYear()); |
| 918 | |||
| 919 |
3/3✓ Branch 1 taken 5 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1 time.
|
5 | if (startDate < currentEndDate) { |
| 920 |
1/1✓ Branch 1 taken 4 times.
|
4 | Time newNumberOfDays = currentEndDate - startDate; |
| 921 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | fields[3] = toString(newNumberOfDays.days() + 1); |
| 922 | } | ||
| 923 | |||
| 924 |
1/1✓ Branch 1 taken 5 times.
|
5 | bool test = this->setFields(fields, false); |
| 925 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
|
5 | OS_ASSERT(test); |
| 926 |
1/1✓ Branch 2 taken 5 times.
|
5 | m_impl->emitChangeSignals(); |
| 927 | |||
| 928 | 5 | return test; | |
| 929 | 5 | } | |
| 930 | |||
| 931 | 2 | bool BillingPeriod::setEndDate(const Date& endDate) { | |
| 932 |
1/1✓ Branch 1 taken 2 times.
|
2 | Date currentStartDate = this->startDate(); |
| 933 | |||
| 934 |
1/1✓ Branch 1 taken 2 times.
|
2 | unsigned currentNumberOfDays = this->numberOfDays(); |
| 935 | |||
| 936 | /* If endDate is after startDate then startDate is retained. | ||
| 937 | If endDate is before startDate then numberOfDays is retained. */ | ||
| 938 | |||
| 939 | 2 | bool test = false; | |
| 940 | |||
| 941 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | if (endDate > currentStartDate) { |
| 942 |
1/1✓ Branch 1 taken 1 time.
|
1 | Time newNumberOfDays = endDate - currentStartDate; |
| 943 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | test = this->setNumberOfDays(newNumberOfDays.days() + 1); |
| 944 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
|
1 | OS_ASSERT(test); |
| 945 | } else { | ||
| 946 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | Date newStartDate = endDate - Time(currentNumberOfDays - 1); |
| 947 | |||
| 948 |
1/1✓ Branch 1 taken 1 time.
|
1 | test = this->setStartDate(newStartDate); |
| 949 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
|
1 | OS_ASSERT(test); |
| 950 |
1/1✓ Branch 1 taken 1 time.
|
1 | test = this->setNumberOfDays(currentNumberOfDays); |
| 951 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
|
1 | OS_ASSERT(test); |
| 952 | } | ||
| 953 | |||
| 954 | 2 | return test; | |
| 955 | } | ||
| 956 | |||
| 957 | 4 | bool BillingPeriod::setNumberOfDays(unsigned numberOfDays) { | |
| 958 | 4 | bool test = setUnsigned(OS_UtilityBillExtensibleFields::NumberofDaysinBillingPeriod, numberOfDays); | |
| 959 | 4 | return test; | |
| 960 | } | ||
| 961 | |||
| 962 | ✗ | bool BillingPeriod::setConsumption(double consumption) { | |
| 963 | ✗ | return setDouble(OS_UtilityBillExtensibleFields::BillingPeriodConsumption, consumption); | |
| 964 | } | ||
| 965 | |||
| 966 | ✗ | void BillingPeriod::resetConsumption() { | |
| 967 | ✗ | bool test = setString(OS_UtilityBillExtensibleFields::BillingPeriodConsumption, ""); | |
| 968 | ✗ | OS_ASSERT(test); | |
| 969 | ✗ | } | |
| 970 | |||
| 971 | ✗ | bool BillingPeriod::setPeakDemand(double peakDemand) { | |
| 972 | ✗ | return setDouble(OS_UtilityBillExtensibleFields::BillingPeriodPeakDemand, peakDemand); | |
| 973 | } | ||
| 974 | |||
| 975 | ✗ | void BillingPeriod::resetPeakDemand() { | |
| 976 | ✗ | bool test = setString(OS_UtilityBillExtensibleFields::BillingPeriodPeakDemand, ""); | |
| 977 | ✗ | OS_ASSERT(test); | |
| 978 | ✗ | } | |
| 979 | |||
| 980 | ✗ | bool BillingPeriod::setTotalCost(double totalCost) { | |
| 981 | ✗ | return setDouble(OS_UtilityBillExtensibleFields::BillingPeriodTotalCost, totalCost); | |
| 982 | } | ||
| 983 | |||
| 984 | ✗ | void BillingPeriod::resetTotalCost() { | |
| 985 | ✗ | bool test = setString(OS_UtilityBillExtensibleFields::BillingPeriodTotalCost, ""); | |
| 986 | ✗ | OS_ASSERT(test); | |
| 987 | ✗ | } | |
| 988 | |||
| 989 | ✗ | bool BillingPeriod::withinRunPeriod() const { | |
| 990 | ✗ | model::Model model = getImpl<detail::UtilityBill_Impl>()->model(); | |
| 991 | |||
| 992 | ✗ | boost::optional<RunPeriod> runPeriod = model.runPeriod(); | |
| 993 | ✗ | if (!runPeriod) { | |
| 994 | ✗ | return false; | |
| 995 | } | ||
| 996 | |||
| 997 | ✗ | boost::optional<model::YearDescription> yd = model.yearDescription(); | |
| 998 | ✗ | if (!yd) { | |
| 999 | ✗ | return false; | |
| 1000 | } | ||
| 1001 | |||
| 1002 | ✗ | boost::optional<int> calendarYear = yd->calendarYear(); | |
| 1003 | ✗ | if (!calendarYear) { | |
| 1004 | ✗ | return false; | |
| 1005 | } | ||
| 1006 | |||
| 1007 | ✗ | Date runPeriodStartDate = Date(runPeriod->getBeginMonth(), runPeriod->getBeginDayOfMonth(), *calendarYear); | |
| 1008 | ✗ | Date runPeriodEndDate = Date(runPeriod->getEndMonth(), runPeriod->getEndDayOfMonth(), *calendarYear); | |
| 1009 | |||
| 1010 | ✗ | Date startDate = this->startDate(); | |
| 1011 | ✗ | Date endDate = this->endDate(); | |
| 1012 | |||
| 1013 | ✗ | bool startDateInRunPeriod = (startDate >= runPeriodStartDate) && (startDate <= runPeriodEndDate); | |
| 1014 | ✗ | bool endDateInRunPeriod = (endDate >= runPeriodStartDate) && (endDate <= runPeriodEndDate); | |
| 1015 | |||
| 1016 | ✗ | bool result = (startDateInRunPeriod && endDateInRunPeriod); | |
| 1017 | |||
| 1018 | ✗ | return result; | |
| 1019 | ✗ | } | |
| 1020 | |||
| 1021 | ✗ | bool BillingPeriod::withinPeriodicRunPeriod() const { | |
| 1022 | ✗ | model::Model model = getImpl<detail::UtilityBill_Impl>()->model(); | |
| 1023 | |||
| 1024 | ✗ | bool withinRunPeriod = this->withinRunPeriod(); | |
| 1025 | ✗ | if (withinRunPeriod) { | |
| 1026 | ✗ | return true; | |
| 1027 | } | ||
| 1028 | |||
| 1029 | ✗ | bool overlapsRunPeriod = this->overlapsRunPeriod(); | |
| 1030 | ✗ | if (!overlapsRunPeriod) { | |
| 1031 | ✗ | return false; | |
| 1032 | } | ||
| 1033 | |||
| 1034 | ✗ | boost::optional<RunPeriod> runPeriod = model.runPeriod(); | |
| 1035 | ✗ | if (!runPeriod) { | |
| 1036 | ✗ | return false; | |
| 1037 | } | ||
| 1038 | |||
| 1039 | ✗ | boost::optional<model::YearDescription> yd = model.yearDescription(); | |
| 1040 | ✗ | if (!yd) { | |
| 1041 | ✗ | return false; | |
| 1042 | } | ||
| 1043 | |||
| 1044 | ✗ | boost::optional<int> calendarYear = yd->calendarYear(); | |
| 1045 | ✗ | if (!calendarYear) { | |
| 1046 | ✗ | return false; | |
| 1047 | } | ||
| 1048 | |||
| 1049 | ✗ | Date runPeriodStartDatePeriodic = Date(runPeriod->getBeginMonth(), runPeriod->getBeginDayOfMonth(), *calendarYear + 1); | |
| 1050 | ✗ | Date runPeriodEndDate = Date(runPeriod->getEndMonth(), runPeriod->getEndDayOfMonth(), *calendarYear); | |
| 1051 | ✗ | Time time = runPeriodStartDatePeriodic - runPeriodEndDate; | |
| 1052 | |||
| 1053 | ✗ | bool result = (time.days() == 1); | |
| 1054 | |||
| 1055 | ✗ | return result; | |
| 1056 | ✗ | } | |
| 1057 | |||
| 1058 | ✗ | bool BillingPeriod::overlapsRunPeriod() const { | |
| 1059 | ✗ | model::Model model = getImpl<detail::UtilityBill_Impl>()->model(); | |
| 1060 | |||
| 1061 | ✗ | boost::optional<RunPeriod> runPeriod = model.runPeriod(); | |
| 1062 | ✗ | if (!runPeriod) { | |
| 1063 | ✗ | return false; | |
| 1064 | } | ||
| 1065 | |||
| 1066 | ✗ | boost::optional<model::YearDescription> yd = model.yearDescription(); | |
| 1067 | ✗ | if (!yd) { | |
| 1068 | ✗ | return false; | |
| 1069 | } | ||
| 1070 | |||
| 1071 | ✗ | boost::optional<int> calendarYear = yd->calendarYear(); | |
| 1072 | ✗ | if (!calendarYear) { | |
| 1073 | ✗ | return false; | |
| 1074 | } | ||
| 1075 | |||
| 1076 | ✗ | Date runPeriodStartDate = Date(runPeriod->getBeginMonth(), runPeriod->getBeginDayOfMonth(), *calendarYear); | |
| 1077 | ✗ | Date runPeriodEndDate = Date(runPeriod->getEndMonth(), runPeriod->getEndDayOfMonth(), *calendarYear); | |
| 1078 | |||
| 1079 | ✗ | Date startDate = this->startDate(); | |
| 1080 | ✗ | Date endDate = this->endDate(); | |
| 1081 | |||
| 1082 | ✗ | bool startDateInRunPeriod = (startDate >= runPeriodStartDate) && (startDate <= runPeriodEndDate); | |
| 1083 | ✗ | bool endDateInRunPeriod = (endDate >= runPeriodStartDate) && (endDate <= runPeriodEndDate); | |
| 1084 | |||
| 1085 | ✗ | bool result = (startDateInRunPeriod || endDateInRunPeriod); | |
| 1086 | |||
| 1087 | ✗ | return result; | |
| 1088 | ✗ | } | |
| 1089 | |||
| 1090 | ✗ | Vector BillingPeriod::modelConsumptionValues() const { | |
| 1091 | ✗ | model::Model model = getImpl<detail::UtilityBill_Impl>()->model(); | |
| 1092 | |||
| 1093 | ✗ | boost::optional<RunPeriod> runPeriod = model.runPeriod(); | |
| 1094 | ✗ | if (!runPeriod) { | |
| 1095 | ✗ | return {}; | |
| 1096 | } | ||
| 1097 | |||
| 1098 | ✗ | boost::optional<model::YearDescription> yd = model.yearDescription(); | |
| 1099 | ✗ | if (!yd) { | |
| 1100 | ✗ | return {}; | |
| 1101 | } | ||
| 1102 | |||
| 1103 | ✗ | boost::optional<int> calendarYear = yd->calendarYear(); | |
| 1104 | ✗ | if (!calendarYear) { | |
| 1105 | ✗ | return {}; | |
| 1106 | } | ||
| 1107 | |||
| 1108 | ✗ | Vector result; | |
| 1109 | |||
| 1110 | ✗ | OutputMeter meter = getImpl<detail::UtilityBill_Impl>()->consumptionMeter(); | |
| 1111 | |||
| 1112 | ✗ | Date runPeriodStartDate = Date(runPeriod->getBeginMonth(), runPeriod->getBeginDayOfMonth(), *calendarYear); | |
| 1113 | ✗ | Date runPeriodEndDate = Date(runPeriod->getEndMonth(), runPeriod->getEndDayOfMonth(), *calendarYear); | |
| 1114 | |||
| 1115 | ✗ | boost::optional<openstudio::TimeSeries> timeseries = meter.getData(runPeriod->name().get()); | |
| 1116 | ✗ | if (timeseries) { | |
| 1117 | ✗ | result = Vector(this->numberOfDays()); | |
| 1118 | |||
| 1119 | ✗ | double outOfRangeValue = std::numeric_limits<double>::min(); | |
| 1120 | ✗ | timeseries->setOutOfRangeValue(outOfRangeValue); | |
| 1121 | |||
| 1122 | ✗ | unsigned i = 0; | |
| 1123 | ✗ | Date date = this->startDate(); | |
| 1124 | ✗ | Date endDate = this->endDate(); | |
| 1125 | ✗ | while (date <= endDate) { | |
| 1126 | |||
| 1127 | // Since E+ v8.9.0, sql has year field | ||
| 1128 | ✗ | DateTime dateTime(date, Time(1)); | |
| 1129 | |||
| 1130 | ✗ | double value = timeseries->value(dateTime); | |
| 1131 | ✗ | if (value == outOfRangeValue) { | |
| 1132 | ✗ | LOG(Debug, "Could not find value of timeseries at dateTime " << dateTime); | |
| 1133 | ✗ | return {}; | |
| 1134 | } else { | ||
| 1135 | ✗ | result[i] = value; | |
| 1136 | } | ||
| 1137 | |||
| 1138 | ✗ | ++i; | |
| 1139 | ✗ | date += Time(1); | |
| 1140 | } | ||
| 1141 | } | ||
| 1142 | |||
| 1143 | ✗ | return result; | |
| 1144 | ✗ | } | |
| 1145 | |||
| 1146 | ✗ | boost::optional<double> BillingPeriod::modelConsumption() const { | |
| 1147 | ✗ | boost::optional<double> result; | |
| 1148 | ✗ | Vector modelConsumptionValues = this->modelConsumptionValues(); | |
| 1149 | ✗ | if (!modelConsumptionValues.empty()) { | |
| 1150 | ✗ | result = sum(modelConsumptionValues); | |
| 1151 | } | ||
| 1152 | ✗ | return result; | |
| 1153 | ✗ | } | |
| 1154 | |||
| 1155 | ✗ | boost::optional<double> BillingPeriod::modelPeakDemand() const { | |
| 1156 | ✗ | model::Model model = getImpl<detail::UtilityBill_Impl>()->model(); | |
| 1157 | |||
| 1158 | ✗ | boost::optional<RunPeriod> runPeriod = model.runPeriod(); | |
| 1159 | ✗ | if (!runPeriod) { | |
| 1160 | ✗ | return boost::none; | |
| 1161 | } | ||
| 1162 | |||
| 1163 | ✗ | boost::optional<model::YearDescription> yd = model.yearDescription(); | |
| 1164 | ✗ | if (!yd) { | |
| 1165 | ✗ | return boost::none; | |
| 1166 | } | ||
| 1167 | |||
| 1168 | ✗ | boost::optional<int> calendarYear = yd->calendarYear(); | |
| 1169 | ✗ | if (!calendarYear) { | |
| 1170 | ✗ | return boost::none; | |
| 1171 | } | ||
| 1172 | |||
| 1173 | ✗ | boost::optional<OutputMeter> meter = getImpl<detail::UtilityBill_Impl>()->peakDemandMeter(); | |
| 1174 | ✗ | if (!meter) { | |
| 1175 | ✗ | return boost::none; | |
| 1176 | } | ||
| 1177 | |||
| 1178 | ✗ | boost::optional<unsigned> timestepsInPeakDemandWindow = getImpl<detail::UtilityBill_Impl>()->timestepsInPeakDemandWindow(); | |
| 1179 | ✗ | if (!timestepsInPeakDemandWindow) { | |
| 1180 | ✗ | return boost::none; | |
| 1181 | } | ||
| 1182 | |||
| 1183 | ✗ | boost::optional<double> minutesInPeakDemandWindow = getImpl<detail::UtilityBill_Impl>()->minutesInPeakDemandWindow(); | |
| 1184 | ✗ | if (!minutesInPeakDemandWindow) { | |
| 1185 | ✗ | return boost::none; | |
| 1186 | } | ||
| 1187 | |||
| 1188 | ✗ | boost::optional<double> result; | |
| 1189 | ✗ | Vector window(*timestepsInPeakDemandWindow, 0); | |
| 1190 | |||
| 1191 | ✗ | boost::optional<openstudio::TimeSeries> timeseries = meter->getData(runPeriod->name().get()); | |
| 1192 | ✗ | if (timeseries) { | |
| 1193 | ✗ | result = std::numeric_limits<double>::min(); | |
| 1194 | |||
| 1195 | ✗ | double outOfRangeValue = std::numeric_limits<double>::min(); | |
| 1196 | ✗ | timeseries->setOutOfRangeValue(outOfRangeValue); | |
| 1197 | |||
| 1198 | // includes year in billing period start date | ||
| 1199 | ✗ | Date startDate = this->startDate(); | |
| 1200 | ✗ | Date endDate = this->endDate(); | |
| 1201 | |||
| 1202 | // Note JM 2019-03-18: Since E+ v8.9.0, Sql has a Year field, so no need to intentionally leave out calendar year | ||
| 1203 | //Date runPeriodStartDate = Date(startDate.monthOfYear(), startDate.dayOfMonth()); | ||
| 1204 | //Date runPeriodEndDate = Date(endDate.monthOfYear(), endDate.dayOfMonth()); | ||
| 1205 | |||
| 1206 | ✗ | DateTime runPeriodStartDateTime = DateTime(startDate, Time(0, 1, 0, 0)); | |
| 1207 | ✗ | DateTime runPeriodEndDateTime = DateTime(endDate, Time(0, 24, 0, 0)); | |
| 1208 | |||
| 1209 | ✗ | Vector values = timeseries->values(runPeriodStartDateTime, runPeriodEndDateTime); | |
| 1210 | ✗ | unsigned numValues = values.size(); | |
| 1211 | |||
| 1212 | ✗ | if (numValues < *timestepsInPeakDemandWindow) { | |
| 1213 | ✗ | return boost::none; | |
| 1214 | } | ||
| 1215 | |||
| 1216 | ✗ | for (unsigned i = 0; i < numValues; ++i) { | |
| 1217 | // shift window | ||
| 1218 | ✗ | for (unsigned j = *timestepsInPeakDemandWindow - 1; j > 0; --j) { | |
| 1219 | ✗ | window[j] = window[j - 1]; | |
| 1220 | } | ||
| 1221 | ✗ | window[0] = values[i]; | |
| 1222 | |||
| 1223 | // compute energy over window in J | ||
| 1224 | ✗ | double energy = sum(window); | |
| 1225 | |||
| 1226 | // compute average power in W | ||
| 1227 | ✗ | double power = energy / (60.0 * minutesInPeakDemandWindow.get()); | |
| 1228 | |||
| 1229 | ✗ | result = std::max(power, *result); | |
| 1230 | } | ||
| 1231 | ✗ | } | |
| 1232 | |||
| 1233 | ✗ | return result; | |
| 1234 | ✗ | } | |
| 1235 | |||
| 1236 | ✗ | boost::optional<double> BillingPeriod::modelTotalCost() const { | |
| 1237 | ✗ | return boost::none; | |
| 1238 | } | ||
| 1239 | |||
| 1240 |
1/1✓ Branch 2 taken 12 times.
|
12 | BillingPeriod::BillingPeriod(std::shared_ptr<detail::UtilityBill_Impl> impl, unsigned index) : ModelExtensibleGroup(impl, index) {} |
| 1241 | |||
| 1242 | 20 | UtilityBill::UtilityBill(const FuelType& fuelType, const Model& model) : ModelObject(UtilityBill::iddObjectType(), model) { | |
| 1243 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
✗ Branch 5 not taken.
|
20 | OS_ASSERT(getImpl<detail::UtilityBill_Impl>()); |
| 1244 | |||
| 1245 |
2/2✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
|
20 | bool test = setString(OS_UtilityBillFields::FuelType, fuelType.valueDescription()); |
| 1246 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 18 times.
|
20 | if (!test) { |
| 1247 |
1/1✓ Branch 1 taken 2 times.
|
2 | remove(); |
| 1248 |
19/19✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 17 taken 2 times.
✓ Branch 20 taken 2 times.
✓ Branch 23 taken 2 times.
✓ Branch 29 taken 2 times.
✓ Branch 32 taken 2 times.
✓ Branch 35 taken 2 times.
✓ Branch 38 taken 2 times.
✓ Branch 41 taken 2 times.
✓ Branch 44 taken 2 times.
✓ Branch 47 taken 2 times.
✓ Branch 50 taken 2 times.
✓ Branch 53 taken 2 times.
✓ Branch 58 taken 2 times.
✓ Branch 61 taken 2 times.
|
2 | LOG_AND_THROW("Unable to create UtilityBill for FuelType " << fuelType.valueDescription() << "."); |
| 1249 | } | ||
| 1250 | |||
| 1251 |
1/1✓ Branch 1 taken 18 times.
|
18 | std::vector<std::string> consumptionUnitValues = this->consumptionUnitValues(); |
| 1252 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
|
18 | OS_ASSERT(!consumptionUnitValues.empty()); |
| 1253 |
1/1✓ Branch 2 taken 18 times.
|
18 | test = setConsumptionUnit(consumptionUnitValues[0]); |
| 1254 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 3 not taken.
|
18 | OS_ASSERT(test); |
| 1255 | |||
| 1256 |
1/1✓ Branch 1 taken 18 times.
|
18 | std::vector<std::string> peakDemandUnitValues = this->peakDemandUnitValues(); |
| 1257 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 15 times.
|
18 | if (!peakDemandUnitValues.empty()) { |
| 1258 |
1/1✓ Branch 2 taken 3 times.
|
3 | test = setPeakDemandUnit(peakDemandUnitValues[0]); |
| 1259 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
|
3 | OS_ASSERT(test); |
| 1260 | } | ||
| 1261 | 20 | } | |
| 1262 | |||
| 1263 | 8539 | IddObjectType UtilityBill::iddObjectType() { | |
| 1264 |
1/1✓ Branch 1 taken 8539 times.
|
8539 | return {IddObjectType::OS_UtilityBill}; |
| 1265 | } | ||
| 1266 | |||
| 1267 | 48 | std::vector<std::string> UtilityBill::consumptionUnitValues() { | |
| 1268 |
1/1✓ Branch 3 taken 48 times.
|
48 | return getImpl<detail::UtilityBill_Impl>()->consumptionUnitValues(); |
| 1269 | } | ||
| 1270 | |||
| 1271 | 77 | std::vector<std::string> UtilityBill::peakDemandUnitValues() { | |
| 1272 |
1/1✓ Branch 3 taken 77 times.
|
77 | return getImpl<detail::UtilityBill_Impl>()->peakDemandUnitValues(); |
| 1273 | } | ||
| 1274 | |||
| 1275 | 1 | std::vector<std::string> UtilityBill::calibrationGuidelines() { | |
| 1276 | 1 | std::vector<std::string> result; | |
| 1277 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
2 | result.push_back("ASHRAE 14-2002"); |
| 1278 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | result.push_back("FEMP"); // TODO, name, year? |
| 1279 | 1 | return result; | |
| 1280 | ✗ | } | |
| 1281 | |||
| 1282 | 2 | boost::optional<double> UtilityBill::maxNMBE(const std::string& calibrationGuideline) { | |
| 1283 | 2 | boost::optional<double> result; | |
| 1284 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 1 time.
|
4 | if (istringEqual("ASHRAE 14-2002", calibrationGuideline)) { |
| 1285 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = 5; |
| 1286 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
|
2 | } else if (istringEqual("FEMP", calibrationGuideline)) { |
| 1287 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = 15; |
| 1288 | } | ||
| 1289 | 2 | return result; | |
| 1290 | } | ||
| 1291 | |||
| 1292 | 2 | boost::optional<double> UtilityBill::maxCVRMSE(const std::string& calibrationGuideline) { | |
| 1293 | 2 | boost::optional<double> result; | |
| 1294 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 1 time.
|
4 | if (istringEqual("ASHRAE 14-2002", calibrationGuideline)) { |
| 1295 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = 15; |
| 1296 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
|
2 | } else if (istringEqual("FEMP", calibrationGuideline)) { |
| 1297 |
1/1✓ Branch 1 taken 1 time.
|
1 | result = 10; |
| 1298 | } | ||
| 1299 | 2 | return result; | |
| 1300 | } | ||
| 1301 | |||
| 1302 | 18 | FuelType UtilityBill::fuelType() const { | |
| 1303 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::UtilityBill_Impl>()->fuelType(); |
| 1304 | } | ||
| 1305 | |||
| 1306 | 18 | InstallLocationType UtilityBill::meterInstallLocation() const { | |
| 1307 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::UtilityBill_Impl>()->meterInstallLocation(); |
| 1308 | } | ||
| 1309 | |||
| 1310 | 18 | bool UtilityBill::isMeterInstallLocationDefaulted() const { | |
| 1311 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::UtilityBill_Impl>()->isMeterInstallLocationDefaulted(); |
| 1312 | } | ||
| 1313 | |||
| 1314 | 18 | boost::optional<std::string> UtilityBill::meterSpecificInstallLocation() const { | |
| 1315 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::UtilityBill_Impl>()->meterSpecificInstallLocation(); |
| 1316 | } | ||
| 1317 | |||
| 1318 | 18 | boost::optional<EndUseCategoryType> UtilityBill::meterEndUseCategory() const { | |
| 1319 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::UtilityBill_Impl>()->meterEndUseCategory(); |
| 1320 | } | ||
| 1321 | |||
| 1322 | 18 | boost::optional<std::string> UtilityBill::meterSpecificEndUse() const { | |
| 1323 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::UtilityBill_Impl>()->meterSpecificEndUse(); |
| 1324 | } | ||
| 1325 | |||
| 1326 | 77 | std::string UtilityBill::consumptionUnit() const { | |
| 1327 |
1/1✓ Branch 3 taken 77 times.
|
77 | return getImpl<detail::UtilityBill_Impl>()->consumptionUnit(); |
| 1328 | } | ||
| 1329 | |||
| 1330 | 59 | boost::optional<std::string> UtilityBill::consumptionUnitDescription() const { | |
| 1331 |
1/1✓ Branch 3 taken 59 times.
|
59 | return getImpl<detail::UtilityBill_Impl>()->consumptionUnitDescription(); |
| 1332 | } | ||
| 1333 | |||
| 1334 | 77 | double UtilityBill::consumptionUnitConversionFactor() const { | |
| 1335 |
1/1✓ Branch 3 taken 77 times.
|
77 | return getImpl<detail::UtilityBill_Impl>()->consumptionUnitConversionFactor(); |
| 1336 | } | ||
| 1337 | |||
| 1338 | ✗ | bool UtilityBill::isConsumptionUnitConversionFactorDefaulted() const { | |
| 1339 | ✗ | return getImpl<detail::UtilityBill_Impl>()->isConsumptionUnitConversionFactorDefaulted(); | |
| 1340 | } | ||
| 1341 | |||
| 1342 | 29 | boost::optional<std::string> UtilityBill::peakDemandUnit() const { | |
| 1343 |
1/1✓ Branch 3 taken 29 times.
|
29 | return getImpl<detail::UtilityBill_Impl>()->peakDemandUnit(); |
| 1344 | } | ||
| 1345 | |||
| 1346 | 12 | boost::optional<std::string> UtilityBill::peakDemandUnitDescription() const { | |
| 1347 |
1/1✓ Branch 3 taken 12 times.
|
12 | return getImpl<detail::UtilityBill_Impl>()->peakDemandUnitDescription(); |
| 1348 | } | ||
| 1349 | |||
| 1350 | 24 | boost::optional<double> UtilityBill::peakDemandUnitConversionFactor() const { | |
| 1351 |
1/1✓ Branch 3 taken 24 times.
|
24 | return getImpl<detail::UtilityBill_Impl>()->peakDemandUnitConversionFactor(); |
| 1352 | } | ||
| 1353 | |||
| 1354 | ✗ | boost::optional<unsigned> UtilityBill::timestepsInPeakDemandWindow() const { | |
| 1355 | ✗ | return getImpl<detail::UtilityBill_Impl>()->timestepsInPeakDemandWindow(); | |
| 1356 | } | ||
| 1357 | |||
| 1358 | ✗ | bool UtilityBill::isTimestepsInPeakDemandWindowDefaulted() const { | |
| 1359 | ✗ | return getImpl<detail::UtilityBill_Impl>()->isTimestepsInPeakDemandWindowDefaulted(); | |
| 1360 | } | ||
| 1361 | |||
| 1362 | ✗ | boost::optional<double> UtilityBill::minutesInPeakDemandWindow() const { | |
| 1363 | ✗ | return getImpl<detail::UtilityBill_Impl>()->minutesInPeakDemandWindow(); | |
| 1364 | } | ||
| 1365 | |||
| 1366 | ✗ | bool UtilityBill::setMeterInstallLocation(const InstallLocationType& meterInstallLocation) { | |
| 1367 | ✗ | return getImpl<detail::UtilityBill_Impl>()->setMeterInstallLocation(meterInstallLocation); | |
| 1368 | } | ||
| 1369 | |||
| 1370 | ✗ | void UtilityBill::resetMeterInstallLocation() { | |
| 1371 | ✗ | getImpl<detail::UtilityBill_Impl>()->resetMeterInstallLocation(); | |
| 1372 | ✗ | } | |
| 1373 | |||
| 1374 | ✗ | bool UtilityBill::setMeterSpecificInstallLocation(const std::string& meterSpecificInstallLocation) { | |
| 1375 | ✗ | return getImpl<detail::UtilityBill_Impl>()->setMeterSpecificInstallLocation(meterSpecificInstallLocation); | |
| 1376 | } | ||
| 1377 | |||
| 1378 | ✗ | void UtilityBill::resetMeterSpecificInstallLocation() { | |
| 1379 | ✗ | getImpl<detail::UtilityBill_Impl>()->resetMeterSpecificInstallLocation(); | |
| 1380 | ✗ | } | |
| 1381 | |||
| 1382 | ✗ | bool UtilityBill::setMeterEndUseCategory(const EndUseCategoryType& meterEndUseCategory) { | |
| 1383 | ✗ | return getImpl<detail::UtilityBill_Impl>()->setMeterEndUseCategory(meterEndUseCategory); | |
| 1384 | } | ||
| 1385 | |||
| 1386 | ✗ | void UtilityBill::resetMeterEndUseCategory() { | |
| 1387 | ✗ | getImpl<detail::UtilityBill_Impl>()->resetMeterEndUseCategory(); | |
| 1388 | ✗ | } | |
| 1389 | |||
| 1390 | ✗ | bool UtilityBill::setMeterSpecificEndUse(const std::string& meterSpecificEndUse) { | |
| 1391 | ✗ | return getImpl<detail::UtilityBill_Impl>()->setMeterSpecificEndUse(meterSpecificEndUse); | |
| 1392 | } | ||
| 1393 | |||
| 1394 | ✗ | void UtilityBill::resetMeterSpecificEndUse() { | |
| 1395 | ✗ | getImpl<detail::UtilityBill_Impl>()->resetMeterSpecificEndUse(); | |
| 1396 | ✗ | } | |
| 1397 | |||
| 1398 | 77 | bool UtilityBill::setConsumptionUnit(const std::string& consumptionUnit) { | |
| 1399 |
1/1✓ Branch 3 taken 77 times.
|
77 | return getImpl<detail::UtilityBill_Impl>()->setConsumptionUnit(consumptionUnit); |
| 1400 | } | ||
| 1401 | |||
| 1402 | ✗ | bool UtilityBill::setConsumptionUnitConversionFactor(double consumptionUnitConversionFactor) { | |
| 1403 | ✗ | return getImpl<detail::UtilityBill_Impl>()->setConsumptionUnitConversionFactor(consumptionUnitConversionFactor); | |
| 1404 | } | ||
| 1405 | |||
| 1406 | ✗ | void UtilityBill::resetConsumptionUnitConversionFactor() { | |
| 1407 | ✗ | getImpl<detail::UtilityBill_Impl>()->resetConsumptionUnitConversionFactor(); | |
| 1408 | ✗ | } | |
| 1409 | |||
| 1410 | 15 | bool UtilityBill::setPeakDemandUnit(const std::string& peakDemandUnit) { | |
| 1411 |
1/1✓ Branch 3 taken 15 times.
|
15 | return getImpl<detail::UtilityBill_Impl>()->setPeakDemandUnit(peakDemandUnit); |
| 1412 | } | ||
| 1413 | |||
| 1414 | ✗ | bool UtilityBill::setTimestepsInPeakDemandWindow(unsigned timestepsInPeakDemandWindow) { | |
| 1415 | ✗ | return getImpl<detail::UtilityBill_Impl>()->setTimestepsInPeakDemandWindow(timestepsInPeakDemandWindow); | |
| 1416 | } | ||
| 1417 | |||
| 1418 | ✗ | void UtilityBill::resetTimestepsInPeakDemandWindow() { | |
| 1419 | ✗ | getImpl<detail::UtilityBill_Impl>()->resetTimestepsInPeakDemandWindow(); | |
| 1420 | ✗ | } | |
| 1421 | |||
| 1422 | 84 | OutputMeter UtilityBill::consumptionMeter() const { | |
| 1423 |
1/1✓ Branch 3 taken 84 times.
|
84 | return getImpl<detail::UtilityBill_Impl>()->consumptionMeter(); |
| 1424 | } | ||
| 1425 | |||
| 1426 | 36 | boost::optional<OutputMeter> UtilityBill::peakDemandMeter() const { | |
| 1427 |
1/1✓ Branch 3 taken 36 times.
|
36 | return getImpl<detail::UtilityBill_Impl>()->peakDemandMeter(); |
| 1428 | } | ||
| 1429 | |||
| 1430 | 18 | std::vector<BillingPeriod> UtilityBill::billingPeriods() const { | |
| 1431 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::UtilityBill_Impl>()->billingPeriods(); |
| 1432 | } | ||
| 1433 | |||
| 1434 | ✗ | void UtilityBill::clearBillingPeriods() { | |
| 1435 | ✗ | getImpl<detail::UtilityBill_Impl>()->clearBillingPeriods(); | |
| 1436 | ✗ | } | |
| 1437 | |||
| 1438 | 7 | BillingPeriod UtilityBill::addBillingPeriod() { | |
| 1439 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::UtilityBill_Impl>()->addBillingPeriod(); |
| 1440 | } | ||
| 1441 | |||
| 1442 | ✗ | unsigned UtilityBill::numberBillingPeriodsInCalculations() const { | |
| 1443 | ✗ | return getImpl<detail::UtilityBill_Impl>()->numberBillingPeriodsInCalculations(); | |
| 1444 | } | ||
| 1445 | |||
| 1446 | ✗ | boost::optional<double> UtilityBill::CVRMSE() const { | |
| 1447 | ✗ | return getImpl<detail::UtilityBill_Impl>()->CVRMSE(); | |
| 1448 | } | ||
| 1449 | |||
| 1450 | ✗ | boost::optional<double> UtilityBill::NMBE() const { | |
| 1451 | ✗ | return getImpl<detail::UtilityBill_Impl>()->NMBE(); | |
| 1452 | } | ||
| 1453 | |||
| 1454 | /// @cond | ||
| 1455 |
1/1✓ Branch 3 taken 20 times.
|
20 | UtilityBill::UtilityBill(std::shared_ptr<detail::UtilityBill_Impl> impl) : ModelObject(std::move(impl)) {} |
| 1456 | /// @endcond | ||
| 1457 | |||
| 1458 | } // namespace model | ||
| 1459 | } // namespace openstudio | ||
| 1460 |