src/energyplus/ReverseTranslator/ReverseTranslateElectricLoadCenterStorageLiIonNMCBattery.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 "../ReverseTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/ElectricLoadCenterStorageLiIonNMCBattery.hpp" | ||
| 9 | #include "../../model/ElectricLoadCenterStorageLiIonNMCBattery_Impl.hpp" | ||
| 10 | |||
| 11 | #include "../../model/Schedule.hpp" | ||
| 12 | #include "../../model/Schedule_Impl.hpp" | ||
| 13 | #include "../../model/ThermalZone.hpp" | ||
| 14 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 15 | #include "../../model/Space.hpp" | ||
| 16 | #include "../../model/Space_Impl.hpp" | ||
| 17 | |||
| 18 | #include <utilities/idd/ElectricLoadCenter_Storage_LiIonNMCBattery_FieldEnums.hxx> | ||
| 19 | |||
| 20 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 21 | #include <utilities/idd/IddEnums.hxx> | ||
| 22 | |||
| 23 | using namespace openstudio::model; | ||
| 24 | |||
| 25 | namespace openstudio { | ||
| 26 | |||
| 27 | namespace energyplus { | ||
| 28 | |||
| 29 | 2 | OptionalModelObject ReverseTranslator::translateElectricLoadCenterStorageLiIonNMCBattery(const WorkspaceObject& workspaceObject) { | |
| 30 | |||
| 31 | 2 | OptionalDouble d; | |
| 32 | 2 | boost::optional<WorkspaceObject> owo; | |
| 33 | 2 | OptionalString optS; | |
| 34 | 2 | OptionalInt i; | |
| 35 | |||
| 36 | // Number of Cells in Series | ||
| 37 | 2 | OptionalInt nSeries; | |
| 38 |
1/1✓ Branch 1 taken 2 times.
|
2 | nSeries = workspaceObject.getInt(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::NumberofCellsinSeries); |
| 39 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!nSeries) { |
| 40 | ✗ | LOG(Error, workspaceObject.briefDescription() << " is missing required field 'Number of Cells in Series'. It will not be translated."); | |
| 41 | ✗ | return boost::none; | |
| 42 | } | ||
| 43 | |||
| 44 | // Number of Strings in Parallel | ||
| 45 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalInt nParallel = workspaceObject.getInt(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::NumberofStringsinParallel); |
| 46 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!nParallel) { |
| 47 | ✗ | LOG(Error, workspaceObject.briefDescription() << " is missing required field 'Number of Strings in Parallel'. It will not be translated."); | |
| 48 | ✗ | return boost::none; | |
| 49 | } | ||
| 50 | |||
| 51 | // Battery Mass | ||
| 52 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble mass = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::BatteryMass); |
| 53 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!mass) { |
| 54 | ✗ | LOG(Error, workspaceObject.briefDescription() << " is missing required field 'Battery Mass'. It will not be translated."); | |
| 55 | ✗ | return boost::none; | |
| 56 | } | ||
| 57 | |||
| 58 | // Battery Surface Area | ||
| 59 |
1/1✓ Branch 1 taken 2 times.
|
2 | OptionalDouble surfaceArea = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::BatterySurfaceArea); |
| 60 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!surfaceArea) { |
| 61 | ✗ | LOG(Error, workspaceObject.briefDescription() << " is missing required field 'Battery Surface Area'. It will not be translated."); | |
| 62 | ✗ | return boost::none; | |
| 63 | } | ||
| 64 | |||
| 65 |
5/5✓ 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.
|
2 | openstudio::model::ElectricLoadCenterStorageLiIonNMCBattery elcStorLiIonNMCBattery(m_model, *nSeries, *nParallel, *mass, *surfaceArea); |
| 66 | |||
| 67 | // Name | ||
| 68 |
1/1✓ Branch 1 taken 2 times.
|
2 | optS = workspaceObject.name(); |
| 69 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (optS) { |
| 70 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | elcStorLiIonNMCBattery.setName(*optS); |
| 71 | } | ||
| 72 | |||
| 73 | // AvailabilityScheduleName | ||
| 74 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
4 | if ((owo = workspaceObject.getTarget(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::AvailabilityScheduleName))) { |
| 75 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(owo.get())) { | |
| 76 | ✗ | if (boost::optional<Schedule> schedule = mo->optionalCast<Schedule>()) { | |
| 77 | ✗ | elcStorLiIonNMCBattery.setAvailabilitySchedule(schedule.get()); | |
| 78 | ✗ | } | |
| 79 | ✗ | } | |
| 80 | } | ||
| 81 | |||
| 82 | // ZoneName | ||
| 83 |
2/3✓ Branch 1 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
4 | if ((owo = workspaceObject.getTarget(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::ZoneName))) { |
| 84 | ✗ | if (boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(owo.get())) { | |
| 85 | // Zone is translated, and a Space is returned instead | ||
| 86 | ✗ | if (boost::optional<Space> space_ = mo->optionalCast<Space>()) { | |
| 87 | ✗ | if (auto z_ = space_->thermalZone()) { | |
| 88 | ✗ | elcStorLiIonNMCBattery.setThermalZone(z_.get()); | |
| 89 | ✗ | } | |
| 90 | ✗ | } | |
| 91 | ✗ | } | |
| 92 | } | ||
| 93 | |||
| 94 | // Radiative Fraction | ||
| 95 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::RadiativeFraction); |
| 96 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 97 | ✗ | elcStorLiIonNMCBattery.setRadiativeFraction(*d); | |
| 98 | } | ||
| 99 | |||
| 100 | // Lifetime Model | ||
| 101 |
1/1✓ Branch 1 taken 2 times.
|
2 | optS = workspaceObject.getString(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::LifetimeModel); |
| 102 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (optS) { |
| 103 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | elcStorLiIonNMCBattery.setLifetimeModel(*optS); |
| 104 | } | ||
| 105 | |||
| 106 | // Initial Fractional State of Charge | ||
| 107 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::InitialFractionalStateofCharge); |
| 108 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 109 | ✗ | elcStorLiIonNMCBattery.setInitialFractionalStateofCharge(*d); | |
| 110 | } | ||
| 111 | |||
| 112 | // DC to DC Charging Efficiency | ||
| 113 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::DCtoDCChargingEfficiency); |
| 114 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 115 | ✗ | elcStorLiIonNMCBattery.setDCtoDCChargingEfficiency(*d); | |
| 116 | } | ||
| 117 | |||
| 118 | // Battery Specific Heat Capacity | ||
| 119 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::BatterySpecificHeatCapacity); |
| 120 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 121 | ✗ | elcStorLiIonNMCBattery.setBatterySpecificHeatCapacity(*d); | |
| 122 | } | ||
| 123 | |||
| 124 | // Heat Transfer Coefficient Between Battery and Ambient | ||
| 125 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::HeatTransferCoefficientBetweenBatteryandAmbient); |
| 126 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 127 | ✗ | elcStorLiIonNMCBattery.setHeatTransferCoefficientBetweenBatteryandAmbient(*d); | |
| 128 | } | ||
| 129 | |||
| 130 | // Fully Charged Cell Voltage | ||
| 131 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::FullyChargedCellVoltage); |
| 132 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 133 | ✗ | elcStorLiIonNMCBattery.setFullyChargedCellVoltage(*d); | |
| 134 | } | ||
| 135 | |||
| 136 | // Cell Voltage at End of Exponential Zone | ||
| 137 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::CellVoltageatEndofExponentialZone); |
| 138 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 139 | ✗ | elcStorLiIonNMCBattery.setCellVoltageatEndofExponentialZone(*d); | |
| 140 | } | ||
| 141 | |||
| 142 | // Cell Voltage at End of Nominal Zone | ||
| 143 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::CellVoltageatEndofNominalZone); |
| 144 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 145 | ✗ | elcStorLiIonNMCBattery.setCellVoltageatEndofNominalZone(*d); | |
| 146 | } | ||
| 147 | |||
| 148 | // Default Nominal Cell Voltage | ||
| 149 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::DefaultNominalCellVoltage); |
| 150 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 151 | ✗ | elcStorLiIonNMCBattery.setDefaultNominalCellVoltage(*d); | |
| 152 | } | ||
| 153 | |||
| 154 | // Fully Charged Cell Capacity | ||
| 155 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::FullyChargedCellCapacity); |
| 156 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 157 | ✗ | elcStorLiIonNMCBattery.setFullyChargedCellCapacity(*d); | |
| 158 | } | ||
| 159 | |||
| 160 | // Fraction of Cell Capacity Removed at the End of Exponential Zone | ||
| 161 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::FractionofCellCapacityRemovedattheEndofExponentialZone); |
| 162 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 163 | ✗ | elcStorLiIonNMCBattery.setFractionofCellCapacityRemovedattheEndofExponentialZone(*d); | |
| 164 | } | ||
| 165 | |||
| 166 | // Fraction of Cell Capacity Removed at the End of Nominal Zone | ||
| 167 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::FractionofCellCapacityRemovedattheEndofNominalZone); |
| 168 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 169 | ✗ | elcStorLiIonNMCBattery.setFractionofCellCapacityRemovedattheEndofNominalZone(*d); | |
| 170 | } | ||
| 171 | |||
| 172 | // Charge Rate at Which Voltage vs Capacity Curve Was Generated | ||
| 173 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::ChargeRateatWhichVoltagevsCapacityCurveWasGenerated); |
| 174 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 175 | ✗ | elcStorLiIonNMCBattery.setChargeRateatWhichVoltagevsCapacityCurveWasGenerated(*d); | |
| 176 | } | ||
| 177 | |||
| 178 | // Battery Cell Internal Electrical Resistance | ||
| 179 |
1/1✓ Branch 1 taken 2 times.
|
2 | d = workspaceObject.getDouble(ElectricLoadCenter_Storage_LiIonNMCBatteryFields::BatteryCellInternalElectricalResistance); |
| 180 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (d) { |
| 181 | ✗ | elcStorLiIonNMCBattery.setBatteryCellInternalElectricalResistance(*d); | |
| 182 | } | ||
| 183 | |||
| 184 |
1/1✓ Branch 1 taken 2 times.
|
2 | return elcStorLiIonNMCBattery; |
| 185 | 2 | } | |
| 186 | |||
| 187 | } // namespace energyplus | ||
| 188 | |||
| 189 | } // namespace openstudio | ||
| 190 |