Skip to content

Commit 76ea7da

Browse files
authored
Merge pull request #11508 from NatLabRockies/no-array-input
Refactor array-based input code to use key-based input (part 1)
2 parents 2adc13d + d2c4da1 commit 76ea7da

12 files changed

Lines changed: 339 additions & 297 deletions

src/EnergyPlus/Coils/CoilCoolingDX.cc

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
#include <EnergyPlus/DataGlobals.hh>
6161
#include <EnergyPlus/DataHVACGlobals.hh>
6262
#include <EnergyPlus/DataHeatBalance.hh>
63-
#include <EnergyPlus/DataIPShortCuts.hh>
6463
#include <EnergyPlus/DataLoopNode.hh>
6564
#include <EnergyPlus/DataWater.hh>
6665
#include <EnergyPlus/Fans.hh>
@@ -116,35 +115,31 @@ int CoilCoolingDX::factory(EnergyPlus::EnergyPlusData &state, std::string const
116115

117116
void CoilCoolingDX::getInput(EnergyPlusData &state)
118117
{
119-
int numCoolingCoilDXs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, state.dataCoilCoolingDX->coilCoolingDXObjectName);
120-
if (numCoolingCoilDXs <= 0) {
118+
auto *inputProcessor = state.dataInputProcessing->inputProcessor.get();
119+
auto const coilInstances = inputProcessor->epJSON.find(state.dataCoilCoolingDX->coilCoolingDXObjectName);
120+
if (coilInstances == inputProcessor->epJSON.end() || coilInstances->empty()) {
121121
ShowFatalError(state, R"(No "Coil:Cooling:DX" objects in input file)");
122122
}
123-
for (int coilNum = 1; coilNum <= numCoolingCoilDXs; ++coilNum) {
124-
int NumAlphas; // Number of Alphas for each GetObjectItem call
125-
int NumNumbers; // Number of Numbers for each GetObjectItem call
126-
int IOStatus;
127-
state.dataInputProcessing->inputProcessor->getObjectItem(state,
128-
state.dataCoilCoolingDX->coilCoolingDXObjectName,
129-
coilNum,
130-
state.dataIPShortCut->cAlphaArgs,
131-
NumAlphas,
132-
state.dataIPShortCut->rNumericArgs,
133-
NumNumbers,
134-
IOStatus);
123+
auto const &coilSchemaProps = inputProcessor->getObjectSchemaProps(state, state.dataCoilCoolingDX->coilCoolingDXObjectName);
124+
125+
for (auto const &coilInstance : coilInstances.value().items()) {
126+
auto const &coilFields = coilInstance.value();
135127
CoilCoolingDXInputSpecification input_specs;
136-
input_specs.name = state.dataIPShortCut->cAlphaArgs(1);
137-
input_specs.evaporator_inlet_node_name = state.dataIPShortCut->cAlphaArgs(2);
138-
input_specs.evaporator_outlet_node_name = state.dataIPShortCut->cAlphaArgs(3);
139-
input_specs.availability_schedule_name = state.dataIPShortCut->cAlphaArgs(4);
140-
input_specs.condenser_zone_name = state.dataIPShortCut->cAlphaArgs(5);
141-
input_specs.condenser_inlet_node_name = state.dataIPShortCut->cAlphaArgs(6);
142-
input_specs.condenser_outlet_node_name = state.dataIPShortCut->cAlphaArgs(7);
143-
input_specs.performance_object_name = state.dataIPShortCut->cAlphaArgs(8);
144-
input_specs.condensate_collection_water_storage_tank_name = state.dataIPShortCut->cAlphaArgs(9);
145-
input_specs.evaporative_condenser_supply_water_storage_tank_name = state.dataIPShortCut->cAlphaArgs(10);
128+
input_specs.name = Util::makeUPPER(coilInstance.key());
129+
input_specs.evaporator_inlet_node_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "evaporator_inlet_node_name");
130+
input_specs.evaporator_outlet_node_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "evaporator_outlet_node_name");
131+
input_specs.availability_schedule_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "availability_schedule_name");
132+
input_specs.condenser_zone_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "condenser_zone_name");
133+
input_specs.condenser_inlet_node_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "condenser_inlet_node_name");
134+
input_specs.condenser_outlet_node_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "condenser_outlet_node_name");
135+
input_specs.performance_object_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "performance_object_name");
136+
input_specs.condensate_collection_water_storage_tank_name =
137+
inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "condensate_collection_water_storage_tank_name");
138+
input_specs.evaporative_condenser_supply_water_storage_tank_name =
139+
inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "evaporative_condenser_supply_water_storage_tank_name");
146140
CoilCoolingDX thisCoil;
147141
thisCoil.instantiateFromInputSpec(state, input_specs);
142+
inputProcessor->markObjectAsUsed(state.dataCoilCoolingDX->coilCoolingDXObjectName, coilInstance.key());
148143
state.dataCoilCoolingDX->coilCoolingDXs.push_back(thisCoil);
149144
}
150145
}

src/EnergyPlus/Coils/CoilCoolingDXCurveFitOperatingMode.cc

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#include <EnergyPlus/Data/EnergyPlusData.hh>
5454
#include <EnergyPlus/DataEnvironment.hh>
5555
#include <EnergyPlus/DataHVACGlobals.hh>
56-
#include <EnergyPlus/DataIPShortCuts.hh>
5756
#include <EnergyPlus/DataSizing.hh>
5857
#include <EnergyPlus/EMSManager.hh>
5958
#include <EnergyPlus/InputProcessing/InputProcessor.hh>
@@ -125,50 +124,54 @@ void CoilCoolingDXCurveFitOperatingMode::instantiateFromInputSpec(EnergyPlus::En
125124

126125
CoilCoolingDXCurveFitOperatingMode::CoilCoolingDXCurveFitOperatingMode(EnergyPlus::EnergyPlusData &state, const std::string &name_to_find)
127126
{
128-
int numModes = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CoilCoolingDXCurveFitOperatingMode::object_name);
129-
if (numModes <= 0) {
127+
auto *inputProcessor = state.dataInputProcessing->inputProcessor.get();
128+
auto const modeInstances = inputProcessor->epJSON.find(CoilCoolingDXCurveFitOperatingMode::object_name);
129+
if (modeInstances == inputProcessor->epJSON.end()) {
130130
// error
131131
}
132+
auto const &modeSchemaProps = inputProcessor->getObjectSchemaProps(state, CoilCoolingDXCurveFitOperatingMode::object_name);
132133
bool found_it = false;
133-
for (int modeNum = 1; modeNum <= numModes; ++modeNum) {
134-
int NumAlphas; // Number of Alphas for each GetObjectItem call
135-
int NumNumbers; // Number of Numbers for each GetObjectItem call
136-
int IOStatus;
137-
state.dataInputProcessing->inputProcessor->getObjectItem(state,
138-
CoilCoolingDXCurveFitOperatingMode::object_name,
139-
modeNum,
140-
state.dataIPShortCut->cAlphaArgs,
141-
NumAlphas,
142-
state.dataIPShortCut->rNumericArgs,
143-
NumNumbers,
144-
IOStatus);
145-
if (!Util::SameString(name_to_find, state.dataIPShortCut->cAlphaArgs(1))) {
134+
for (auto const &modeInstance : modeInstances.value().items()) {
135+
auto const modeName = Util::makeUPPER(modeInstance.key());
136+
auto const &modeFields = modeInstance.value();
137+
if (!Util::SameString(name_to_find, modeName)) {
146138
continue;
147139
}
148140
found_it = true;
149141

150142
CoilCoolingDXCurveFitOperatingModeInputSpecification input_specs;
151143

152-
input_specs.name = state.dataIPShortCut->cAlphaArgs(1);
153-
input_specs.gross_rated_total_cooling_capacity = state.dataIPShortCut->rNumericArgs(1);
154-
input_specs.rated_evaporator_air_flow_rate = state.dataIPShortCut->rNumericArgs(2);
155-
input_specs.rated_condenser_air_flow_rate = state.dataIPShortCut->rNumericArgs(3);
156-
input_specs.maximum_cycling_rate = state.dataIPShortCut->rNumericArgs(4);
157-
input_specs.ratio_of_initial_moisture_evaporation_rate_and_steady_state_latent_capacity = state.dataIPShortCut->rNumericArgs(5);
158-
input_specs.latent_capacity_time_constant = state.dataIPShortCut->rNumericArgs(6);
159-
input_specs.nominal_time_for_condensate_removal_to_begin = state.dataIPShortCut->rNumericArgs(7);
160-
input_specs.apply_latent_degradation_to_speeds_greater_than_1 = state.dataIPShortCut->cAlphaArgs(2);
161-
input_specs.condenser_type = state.dataIPShortCut->cAlphaArgs(3);
162-
input_specs.nominal_evap_condenser_pump_power = state.dataIPShortCut->rNumericArgs(8);
163-
input_specs.nominal_speed_number = state.dataIPShortCut->rNumericArgs(9);
164-
for (int fieldNum = 4; fieldNum <= NumAlphas; fieldNum++) {
165-
if (state.dataIPShortCut->cAlphaArgs(fieldNum).empty()) {
144+
input_specs.name = modeName;
145+
input_specs.gross_rated_total_cooling_capacity =
146+
inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "rated_gross_total_cooling_capacity");
147+
input_specs.rated_evaporator_air_flow_rate = inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "rated_evaporator_air_flow_rate");
148+
input_specs.rated_condenser_air_flow_rate = inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "rated_condenser_air_flow_rate");
149+
input_specs.maximum_cycling_rate = inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "maximum_cycling_rate");
150+
input_specs.ratio_of_initial_moisture_evaporation_rate_and_steady_state_latent_capacity = inputProcessor->getRealFieldValue(
151+
modeFields, modeSchemaProps, "ratio_of_initial_moisture_evaporation_rate_and_steady_state_latent_capacity");
152+
input_specs.latent_capacity_time_constant = inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "latent_capacity_time_constant");
153+
input_specs.nominal_time_for_condensate_removal_to_begin =
154+
inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "nominal_time_for_condensate_removal_to_begin");
155+
input_specs.apply_latent_degradation_to_speeds_greater_than_1 =
156+
inputProcessor->getAlphaFieldValue(modeFields, modeSchemaProps, "apply_latent_degradation_to_speeds_greater_than_1");
157+
input_specs.condenser_type = inputProcessor->getAlphaFieldValue(modeFields, modeSchemaProps, "condenser_type");
158+
input_specs.nominal_evap_condenser_pump_power =
159+
inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "nominal_evaporative_condenser_pump_power");
160+
input_specs.nominal_speed_number = inputProcessor->getIntFieldValue(modeFields, modeSchemaProps, "nominal_speed_number");
161+
for (int fieldNum = 1; fieldNum <= 10; ++fieldNum) {
162+
auto const speedFieldName = format("speed_{}_name", fieldNum);
163+
auto const speedName = inputProcessor->getAlphaFieldValue(modeFields, modeSchemaProps, speedFieldName);
164+
if (speedName.empty()) {
166165
break;
167166
}
168-
input_specs.speed_data_names.push_back(state.dataIPShortCut->cAlphaArgs(fieldNum));
167+
input_specs.speed_data_names.push_back(speedName);
168+
}
169+
if (input_specs.nominal_speed_number == 0) {
170+
input_specs.nominal_speed_number = static_cast<int>(input_specs.speed_data_names.size());
169171
}
170172

171173
this->instantiateFromInputSpec(state, input_specs);
174+
inputProcessor->markObjectAsUsed(CoilCoolingDXCurveFitOperatingMode::object_name, modeInstance.key());
172175
break;
173176
}
174177

src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.cc

Lines changed: 34 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#include <EnergyPlus/DataEnvironment.hh>
5252
#include <EnergyPlus/DataGlobalConstants.hh>
5353
#include <EnergyPlus/DataHVACGlobals.hh>
54-
#include <EnergyPlus/DataIPShortCuts.hh>
5554
#include <EnergyPlus/Fans.hh>
5655
#include <EnergyPlus/General.hh>
5756
#include <EnergyPlus/GeneralRoutines.hh>
@@ -155,58 +154,51 @@ void CoilCoolingDXCurveFitPerformance::instantiateFromInputSpec(EnergyPlus::Ener
155154
CoilCoolingDXCurveFitPerformance::CoilCoolingDXCurveFitPerformance(EnergyPlus::EnergyPlusData &state, const std::string &name_to_find)
156155
: CoilCoolingDXPerformanceBase()
157156
{
158-
int numPerformances = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CoilCoolingDXCurveFitPerformance::object_name);
159-
if (numPerformances <= 0) {
157+
std::string const objectName{CoilCoolingDXCurveFitPerformance::object_name};
158+
auto *inputProcessor = state.dataInputProcessing->inputProcessor.get();
159+
auto const performanceInstances = inputProcessor->epJSON.find(objectName);
160+
if (performanceInstances == inputProcessor->epJSON.end()) {
160161
// error
161162
}
163+
auto const &performanceSchemaProps = inputProcessor->getObjectSchemaProps(state, objectName);
162164
bool found_it = false;
163-
for (int perfNum = 1; perfNum <= numPerformances; ++perfNum) {
164-
int NumAlphas; // Number of Alphas for each GetObjectItem call
165-
int NumNumbers; // Number of Numbers for each GetObjectItem call
166-
int IOStatus;
167-
state.dataInputProcessing->inputProcessor->getObjectItem(state,
168-
CoilCoolingDXCurveFitPerformance::object_name,
169-
perfNum,
170-
state.dataIPShortCut->cAlphaArgs,
171-
NumAlphas,
172-
state.dataIPShortCut->rNumericArgs,
173-
NumNumbers,
174-
IOStatus,
175-
_,
176-
state.dataIPShortCut->lAlphaFieldBlanks);
177-
if (!Util::SameString(name_to_find, state.dataIPShortCut->cAlphaArgs(1))) {
165+
for (auto const &performanceInstance : performanceInstances.value().items()) {
166+
auto const performanceName = Util::makeUPPER(performanceInstance.key());
167+
auto const &performanceFields = performanceInstance.value();
168+
if (!Util::SameString(name_to_find, performanceName)) {
178169
continue;
179170
}
180171
found_it = true;
181172

182173
CoilCoolingDXCurveFitPerformanceInputSpecification input_specs;
183174

184-
input_specs.name = state.dataIPShortCut->cAlphaArgs(1);
185-
input_specs.crankcase_heater_capacity = state.dataIPShortCut->rNumericArgs(1);
186-
input_specs.minimum_outdoor_dry_bulb_temperature_for_compressor_operation = state.dataIPShortCut->rNumericArgs(2);
187-
input_specs.maximum_outdoor_dry_bulb_temperature_for_crankcase_heater_operation = state.dataIPShortCut->rNumericArgs(3);
188-
if (state.dataIPShortCut->lNumericFieldBlanks(4)) {
189-
input_specs.unit_internal_static_air_pressure = 0.0;
190-
} else {
191-
input_specs.unit_internal_static_air_pressure = state.dataIPShortCut->rNumericArgs(4);
192-
}
193-
if (!state.dataIPShortCut->lAlphaFieldBlanks(2)) {
194-
input_specs.outdoor_temperature_dependent_crankcase_heater_capacity_curve_name = state.dataIPShortCut->cAlphaArgs(2);
195-
}
196-
input_specs.capacity_control = state.dataIPShortCut->cAlphaArgs(3);
197-
input_specs.basin_heater_capacity = state.dataIPShortCut->rNumericArgs(5);
198-
input_specs.basin_heater_setpoint_temperature = state.dataIPShortCut->rNumericArgs(6);
199-
input_specs.basin_heater_operating_schedule_name = state.dataIPShortCut->cAlphaArgs(4);
200-
input_specs.compressor_fuel_type = state.dataIPShortCut->cAlphaArgs(5);
201-
input_specs.base_operating_mode_name = state.dataIPShortCut->cAlphaArgs(6);
202-
if (!state.dataIPShortCut->lAlphaFieldBlanks(6)) {
203-
input_specs.alternate_operating_mode_name = state.dataIPShortCut->cAlphaArgs(7);
204-
}
205-
if (!state.dataIPShortCut->lAlphaFieldBlanks(8)) {
206-
input_specs.alternate_operating_mode2_name = state.dataIPShortCut->cAlphaArgs(8);
207-
}
175+
input_specs.name = performanceName;
176+
input_specs.crankcase_heater_capacity =
177+
inputProcessor->getRealFieldValue(performanceFields, performanceSchemaProps, "crankcase_heater_capacity");
178+
input_specs.minimum_outdoor_dry_bulb_temperature_for_compressor_operation = inputProcessor->getRealFieldValue(
179+
performanceFields, performanceSchemaProps, "minimum_outdoor_dry_bulb_temperature_for_compressor_operation");
180+
input_specs.maximum_outdoor_dry_bulb_temperature_for_crankcase_heater_operation = inputProcessor->getRealFieldValue(
181+
performanceFields, performanceSchemaProps, "maximum_outdoor_dry_bulb_temperature_for_crankcase_heater_operation");
182+
input_specs.unit_internal_static_air_pressure =
183+
inputProcessor->getRealFieldValue(performanceFields, performanceSchemaProps, "unit_internal_static_air_pressure");
184+
input_specs.outdoor_temperature_dependent_crankcase_heater_capacity_curve_name = inputProcessor->getAlphaFieldValue(
185+
performanceFields, performanceSchemaProps, "crankcase_heater_capacity_function_of_temperature_curve_name");
186+
input_specs.capacity_control = inputProcessor->getAlphaFieldValue(performanceFields, performanceSchemaProps, "capacity_control_method");
187+
input_specs.basin_heater_capacity =
188+
inputProcessor->getRealFieldValue(performanceFields, performanceSchemaProps, "evaporative_condenser_basin_heater_capacity");
189+
input_specs.basin_heater_setpoint_temperature =
190+
inputProcessor->getRealFieldValue(performanceFields, performanceSchemaProps, "evaporative_condenser_basin_heater_setpoint_temperature");
191+
input_specs.basin_heater_operating_schedule_name = inputProcessor->getAlphaFieldValue(
192+
performanceFields, performanceSchemaProps, "evaporative_condenser_basin_heater_operating_schedule_name");
193+
input_specs.compressor_fuel_type = inputProcessor->getAlphaFieldValue(performanceFields, performanceSchemaProps, "compressor_fuel_type");
194+
input_specs.base_operating_mode_name = inputProcessor->getAlphaFieldValue(performanceFields, performanceSchemaProps, "base_operating_mode");
195+
input_specs.alternate_operating_mode_name =
196+
inputProcessor->getAlphaFieldValue(performanceFields, performanceSchemaProps, "alternative_operating_mode_1");
197+
input_specs.alternate_operating_mode2_name =
198+
inputProcessor->getAlphaFieldValue(performanceFields, performanceSchemaProps, "alternative_operating_mode_2");
208199

209200
this->instantiateFromInputSpec(state, input_specs);
201+
inputProcessor->markObjectAsUsed(objectName, performanceInstance.key());
210202
break;
211203
}
212204

0 commit comments

Comments
 (0)