diff --git a/src/EnergyPlus/BoilerSteam.cc b/src/EnergyPlus/BoilerSteam.cc index d6d0155c57e..636e24a9016 100644 --- a/src/EnergyPlus/BoilerSteam.cc +++ b/src/EnergyPlus/BoilerSteam.cc @@ -151,14 +151,11 @@ namespace BoilerSteam { static constexpr std::string_view RoutineName("GetBoilerInput: "); // LOCAL VARIABLES - int BoilerNum; // boiler identifier - int NumAlphas; // Number of elements in the alpha array - int NumNums; // Number of elements in the numeric array - int IOStat; // IO Status when calling get input subroutine bool ErrorsFound(false); state.dataIPShortCut->cCurrentModuleObject = "Boiler:Steam"; - int numBoilers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + int numBoilers = inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject); if (numBoilers <= 0) { ShowSevereError(state, EnergyPlus::format("No {} equipment specified in input file", state.dataIPShortCut->cCurrentModuleObject)); @@ -172,120 +169,107 @@ namespace BoilerSteam { // Boiler will have fuel input to it , that is it ! state.dataBoilerSteam->Boiler.allocate(numBoilers); + auto const &boilerSchemaProps = inputProcessor->getObjectSchemaProps(state, state.dataIPShortCut->cCurrentModuleObject); + auto const boilerObjects = inputProcessor->epJSON.find(state.dataIPShortCut->cCurrentModuleObject); + + int BoilerNum = 1; + if (boilerObjects != inputProcessor->epJSON.end()) { + for (auto const &boilerInstance : boilerObjects.value().items()) { + auto const &boilerFields = boilerInstance.value(); + auto const boilerName = Util::makeUPPER(boilerInstance.key()); + auto const fuelType = inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "fuel_type"); + auto const waterInletNodeName = inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "water_inlet_node_name"); + auto const steamOutletNodeName = inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "steam_outlet_node_name"); + + inputProcessor->markObjectAsUsed(state.dataIPShortCut->cCurrentModuleObject, boilerInstance.key()); + + // ErrorsFound will be set to True if problem was found, left untouched otherwise + GlobalNames::VerifyUniqueBoilerName( + state, state.dataIPShortCut->cCurrentModuleObject, boilerName, ErrorsFound, state.dataIPShortCut->cCurrentModuleObject + " Name"); + auto &thisBoiler = state.dataBoilerSteam->Boiler(BoilerNum); + thisBoiler.Name = boilerName; + + // Validate fuel type input + thisBoiler.FuelType = static_cast(getEnumValue(Constant::eFuelNamesUC, fuelType)); + + // INPUTS from the IDF file + thisBoiler.BoilerMaxOperPress = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "maximum_operating_pressure"); + if (thisBoiler.BoilerMaxOperPress < 1e5) { + ShowWarningMessage(state, EnergyPlus::format("{}=\"{}\"", state.dataIPShortCut->cCurrentModuleObject, boilerName)); + ShowContinueError(state, "Field: Maximum Operation Pressure units are Pa. Verify units."); + } + thisBoiler.NomEffic = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "theoretical_efficiency"); + thisBoiler.TempUpLimitBoilerOut = + inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "design_outlet_steam_temperature"); + thisBoiler.NomCap = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "nominal_capacity"); + if (thisBoiler.NomCap == DataSizing::AutoSize) { + thisBoiler.NomCapWasAutoSized = true; + } + thisBoiler.MinPartLoadRat = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "minimum_part_load_ratio"); + thisBoiler.MaxPartLoadRat = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "maximum_part_load_ratio"); + thisBoiler.OptPartLoadRat = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "optimum_part_load_ratio"); + thisBoiler.FullLoadCoef[0] = + inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "coefficient_1_of_fuel_use_function_of_part_load_ratio_curve"); + thisBoiler.FullLoadCoef[1] = + inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "coefficient_2_of_fuel_use_function_of_part_load_ratio_curve"); + thisBoiler.FullLoadCoef[2] = + inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "coefficient_3_of_fuel_use_function_of_part_load_ratio_curve"); + thisBoiler.SizFac = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "sizing_factor"); + if (thisBoiler.SizFac <= 0.0) { + thisBoiler.SizFac = 1.0; + } - // LOAD ARRAYS WITH CURVE FIT Boiler DATA - for (BoilerNum = 1; BoilerNum <= numBoilers; ++BoilerNum) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, - BoilerNum, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNums, - IOStat, - _, - _, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); - - // ErrorsFound will be set to True if problem was found, left untouched otherwise - GlobalNames::VerifyUniqueBoilerName(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - ErrorsFound, - state.dataIPShortCut->cCurrentModuleObject + " Name"); - auto &thisBoiler = state.dataBoilerSteam->Boiler(BoilerNum); - thisBoiler.Name = state.dataIPShortCut->cAlphaArgs(1); - - // Validate fuel type input - thisBoiler.FuelType = static_cast(getEnumValue(Constant::eFuelNamesUC, state.dataIPShortCut->cAlphaArgs(2))); - - // INPUTS from the IDF file - thisBoiler.BoilerMaxOperPress = state.dataIPShortCut->rNumericArgs(1); - if (thisBoiler.BoilerMaxOperPress < 1e5) { - ShowWarningMessage(state, - EnergyPlus::format("{}=\"{}\"", state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, "Field: Maximum Operation Pressure units are Pa. Verify units."); - } - thisBoiler.NomEffic = state.dataIPShortCut->rNumericArgs(2); - thisBoiler.TempUpLimitBoilerOut = state.dataIPShortCut->rNumericArgs(3); - thisBoiler.NomCap = state.dataIPShortCut->rNumericArgs(4); - if (thisBoiler.NomCap == DataSizing::AutoSize) { - thisBoiler.NomCapWasAutoSized = true; - } - thisBoiler.MinPartLoadRat = state.dataIPShortCut->rNumericArgs(5); - thisBoiler.MaxPartLoadRat = state.dataIPShortCut->rNumericArgs(6); - thisBoiler.OptPartLoadRat = state.dataIPShortCut->rNumericArgs(7); - thisBoiler.FullLoadCoef[0] = state.dataIPShortCut->rNumericArgs(8); - thisBoiler.FullLoadCoef[1] = state.dataIPShortCut->rNumericArgs(9); - thisBoiler.FullLoadCoef[2] = state.dataIPShortCut->rNumericArgs(10); - thisBoiler.SizFac = state.dataIPShortCut->rNumericArgs(11); - if (thisBoiler.SizFac <= 0.0) { - thisBoiler.SizFac = 1.0; - } - - if ((state.dataIPShortCut->rNumericArgs(8) + state.dataIPShortCut->rNumericArgs(9) + state.dataIPShortCut->rNumericArgs(10)) == 0.0) { - ShowSevereError( - state, - EnergyPlus::format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError(state, " Sum of fuel use curve coefficients = 0.0"); - ErrorsFound = true; - } + if ((thisBoiler.FullLoadCoef[0] + thisBoiler.FullLoadCoef[1] + thisBoiler.FullLoadCoef[2]) == 0.0) { + ShowSevereError(state, EnergyPlus::format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, boilerName)); + ShowContinueError(state, " Sum of fuel use curve coefficients = 0.0"); + ErrorsFound = true; + } - if (state.dataIPShortCut->rNumericArgs(5) < 0.0) { - ShowSevereError( - state, - EnergyPlus::format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError( - state, - EnergyPlus::format("Invalid {}={:.3R}", state.dataIPShortCut->cNumericFieldNames(5), state.dataIPShortCut->rNumericArgs(5))); - ErrorsFound = true; - } + if (thisBoiler.MinPartLoadRat < 0.0) { + ShowSevereError(state, EnergyPlus::format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, boilerName)); + ShowContinueError(state, EnergyPlus::format("Invalid {}={:.3R}", "Minimum Part Load Ratio", thisBoiler.MinPartLoadRat)); + ErrorsFound = true; + } - if (state.dataIPShortCut->rNumericArgs(3) == 0.0) { - ShowSevereError( - state, - EnergyPlus::format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1))); - ShowContinueError( - state, - EnergyPlus::format("Invalid {}={:.3R}", state.dataIPShortCut->cNumericFieldNames(3), state.dataIPShortCut->rNumericArgs(3))); - ErrorsFound = true; - } - thisBoiler.BoilerInletNodeNum = Node::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(3), - ErrorsFound, - Node::ConnectionObjectType::BoilerSteam, - state.dataIPShortCut->cAlphaArgs(1), - Node::FluidType::Steam, - Node::ConnectionType::Inlet, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - thisBoiler.BoilerOutletNodeNum = Node::GetOnlySingleNode(state, - state.dataIPShortCut->cAlphaArgs(4), - ErrorsFound, - Node::ConnectionObjectType::BoilerSteam, - state.dataIPShortCut->cAlphaArgs(1), - Node::FluidType::Steam, - Node::ConnectionType::Outlet, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - Node::TestCompSet(state, - state.dataIPShortCut->cCurrentModuleObject, - state.dataIPShortCut->cAlphaArgs(1), - state.dataIPShortCut->cAlphaArgs(3), - state.dataIPShortCut->cAlphaArgs(4), - "Hot Steam Nodes"); - - thisBoiler.fluid = Fluid::GetSteam(state); - if (thisBoiler.fluid == nullptr && BoilerNum == 1) { - ShowSevereError(state, "Fluid Properties for STEAM not found."); - ErrorsFound = true; - } + if (thisBoiler.TempUpLimitBoilerOut == 0.0) { + ShowSevereError(state, EnergyPlus::format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, boilerName)); + ShowContinueError(state, + EnergyPlus::format("Invalid {}={:.3R}", "Design Outlet Steam Temperature", thisBoiler.TempUpLimitBoilerOut)); + ErrorsFound = true; + } + thisBoiler.BoilerInletNodeNum = Node::GetOnlySingleNode(state, + waterInletNodeName, + ErrorsFound, + Node::ConnectionObjectType::BoilerSteam, + boilerName, + Node::FluidType::Steam, + Node::ConnectionType::Inlet, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); + thisBoiler.BoilerOutletNodeNum = Node::GetOnlySingleNode(state, + steamOutletNodeName, + ErrorsFound, + Node::ConnectionObjectType::BoilerSteam, + boilerName, + Node::FluidType::Steam, + Node::ConnectionType::Outlet, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); + Node::TestCompSet( + state, state.dataIPShortCut->cCurrentModuleObject, boilerName, waterInletNodeName, steamOutletNodeName, "Hot Steam Nodes"); + + thisBoiler.fluid = Fluid::GetSteam(state); + if (thisBoiler.fluid == nullptr && BoilerNum == 1) { + ShowSevereError(state, "Fluid Properties for STEAM not found."); + ErrorsFound = true; + } - if (NumAlphas > 4) { - thisBoiler.EndUseSubcategory = state.dataIPShortCut->cAlphaArgs(5); - } else { - thisBoiler.EndUseSubcategory = "General"; + if (boilerFields.find("end_use_subcategory") != boilerFields.end()) { + thisBoiler.EndUseSubcategory = inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "end_use_subcategory"); + } else { + thisBoiler.EndUseSubcategory = "General"; + } + ++BoilerNum; } } diff --git a/src/EnergyPlus/Boilers.cc b/src/EnergyPlus/Boilers.cc index 7f0c88cb00e..c3995bbede2 100644 --- a/src/EnergyPlus/Boilers.cc +++ b/src/EnergyPlus/Boilers.cc @@ -182,170 +182,191 @@ void GetBoilerInput(EnergyPlusData &state) return; } - // LOAD ARRAYS WITH CURVE FIT Boiler DATA - - for (int BoilerNum = 1; BoilerNum <= numBoilers; ++BoilerNum) { - int NumAlphas; // Number of elements in the alpha array - int NumNums; // Number of elements in the numeric array - int IOStat; // IO Status when calling get input subroutine - state.dataInputProcessing->inputProcessor->getObjectItem(state, - s_ipsc->cCurrentModuleObject, - BoilerNum, - s_ipsc->cAlphaArgs, - NumAlphas, - s_ipsc->rNumericArgs, - NumNums, - IOStat, - s_ipsc->lNumericFieldBlanks, - s_ipsc->lAlphaFieldBlanks, - s_ipsc->cAlphaFieldNames, - s_ipsc->cNumericFieldNames); - - ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const &boilerSchemaProps = inputProcessor->getObjectSchemaProps(state, s_ipsc->cCurrentModuleObject); + auto const boilerObjects = inputProcessor->epJSON.find(s_ipsc->cCurrentModuleObject); + + // LOAD Boiler DATA + for (auto const &boilerInstance : boilerObjects.value().items()) { + auto const &boilerFields = boilerInstance.value(); + auto const boilerName = Util::makeUPPER(boilerInstance.key()); + auto const fuelType = inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "fuel_type"); + auto const efficiencyCurveTempEvalVar = + inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "efficiency_curve_temperature_evaluation_variable"); + auto const normalizedBoilerEfficiencyCurveName = + inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "normalized_boiler_efficiency_curve_name"); + auto const boilerWaterInletNodeName = inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "boiler_water_inlet_node_name"); + auto const boilerWaterOutletNodeName = inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "boiler_water_outlet_node_name"); + auto const boilerFlowMode = inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "boiler_flow_mode"); + + inputProcessor->markObjectAsUsed(s_ipsc->cCurrentModuleObject, boilerInstance.key()); + + ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, boilerName}; // ErrorsFound will be set to True if problem was found, left untouched otherwise - GlobalNames::VerifyUniqueBoilerName( - state, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject + " Name"); + GlobalNames::VerifyUniqueBoilerName(state, s_ipsc->cCurrentModuleObject, boilerName, ErrorsFound, s_ipsc->cCurrentModuleObject + " Name"); state.dataBoilers->Boiler.emplace_back(); - auto &thisBoiler = state.dataBoilers->Boiler[BoilerNum - 1]; - thisBoiler.Name = s_ipsc->cAlphaArgs(1); + auto &thisBoiler = state.dataBoilers->Boiler.back(); + thisBoiler.Name = boilerName; thisBoiler.Type = DataPlant::PlantEquipmentType::Boiler_Simple; // Validate fuel type input - thisBoiler.FuelType = static_cast(getEnumValue(Constant::eFuelNamesUC, s_ipsc->cAlphaArgs(2))); + thisBoiler.FuelType = static_cast(getEnumValue(Constant::eFuelNamesUC, fuelType)); - thisBoiler.NomCap = s_ipsc->rNumericArgs(1); - if (s_ipsc->rNumericArgs(1) == 0.0) { - ShowSevereError(state, fmt::format("{}{}=\"{}\",", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); - ShowContinueError(state, EnergyPlus::format("Invalid {}={:.2R}", s_ipsc->cNumericFieldNames(1), s_ipsc->rNumericArgs(1))); - ShowContinueError(state, EnergyPlus::format("...{} must be greater than 0.0", s_ipsc->cNumericFieldNames(1))); + thisBoiler.NomCap = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "nominal_capacity"); + if (thisBoiler.NomCap == 0.0) { + ShowSevereError(state, fmt::format("{}{}=\"{}\",", RoutineName, s_ipsc->cCurrentModuleObject, boilerName)); + ShowContinueError(state, EnergyPlus::format("Invalid {}={:.2R}", "Nominal Capacity", thisBoiler.NomCap)); + ShowContinueError(state, "...Nominal Capacity must be greater than 0.0"); ErrorsFound = true; } if (thisBoiler.NomCap == DataSizing::AutoSize) { thisBoiler.NomCapWasAutoSized = true; } - thisBoiler.NomEffic = s_ipsc->rNumericArgs(2); - if (s_ipsc->rNumericArgs(2) == 0.0) { - ShowSevereError(state, fmt::format("{}{}=\"{}\",", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); - ShowContinueError(state, EnergyPlus::format("Invalid {}={:.3R}", s_ipsc->cNumericFieldNames(2), s_ipsc->rNumericArgs(2))); - ShowContinueError(state, EnergyPlus::format("...{} must be greater than 0.0", s_ipsc->cNumericFieldNames(2))); + thisBoiler.NomEffic = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "nominal_thermal_efficiency"); + if (thisBoiler.NomEffic == 0.0) { + ShowSevereError(state, fmt::format("{}{}=\"{}\",", RoutineName, s_ipsc->cCurrentModuleObject, boilerName)); + ShowContinueError(state, EnergyPlus::format("Invalid {}={:.3R}", "Nominal Thermal Efficiency", thisBoiler.NomEffic)); + ShowContinueError(state, "...Nominal Thermal Efficiency must be greater than 0.0"); ErrorsFound = true; - } else if (s_ipsc->rNumericArgs(2) > 1.0) { + } else if (thisBoiler.NomEffic > 1.0) { ShowWarningError(state, fmt::format("{} = {}: {}={} should not typically be greater than 1.", s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaArgs(1), - s_ipsc->cNumericFieldNames(2), - s_ipsc->rNumericArgs(2))); + boilerName, + "Nominal Thermal Efficiency", + thisBoiler.NomEffic)); } - if (s_ipsc->cAlphaArgs(3) == "ENTERINGBOILER") { + if (efficiencyCurveTempEvalVar == "ENTERINGBOILER") { thisBoiler.CurveTempMode = TempMode::ENTERINGBOILERTEMP; - } else if (s_ipsc->cAlphaArgs(3) == "LEAVINGBOILER") { + } else if (efficiencyCurveTempEvalVar == "LEAVINGBOILER") { thisBoiler.CurveTempMode = TempMode::LEAVINGBOILERTEMP; } else { thisBoiler.CurveTempMode = TempMode::NOTSET; } - if (s_ipsc->lAlphaFieldBlanks(4)) { + if (normalizedBoilerEfficiencyCurveName.empty()) { // Ok if this is empty? - } else if ((thisBoiler.EfficiencyCurve = Curve::GetCurve(state, s_ipsc->cAlphaArgs(4))) == nullptr) { - ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); + } else if ((thisBoiler.EfficiencyCurve = Curve::GetCurve(state, normalizedBoilerEfficiencyCurveName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Normalized Boiler Efficiency Curve Name", normalizedBoilerEfficiencyCurveName); ErrorsFound = true; } else if (thisBoiler.EfficiencyCurve->numDims != 1 && thisBoiler.EfficiencyCurve->numDims != 2) { - Curve::ShowSevereCurveDims(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4), "1 or 2", thisBoiler.EfficiencyCurve->numDims); + Curve::ShowSevereCurveDims(state, + eoh, + "Normalized Boiler Efficiency Curve Name", + normalizedBoilerEfficiencyCurveName, + "1 or 2", + thisBoiler.EfficiencyCurve->numDims); ErrorsFound = true; - } else - // if curve uses temperature, make sure water temp mode has been set - if (thisBoiler.EfficiencyCurve->numDims == 2) { // curve uses water temperature - if (thisBoiler.CurveTempMode == TempMode::NOTSET) { // throw error - if (!s_ipsc->lAlphaFieldBlanks(3)) { - ShowSevereError(state, fmt::format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); - ShowContinueError(state, EnergyPlus::format("Invalid {}={}", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3))); - ShowContinueError(state, - EnergyPlus::format("boilers.Boiler using curve type of {} must specify {}", - Curve::objectNames[(int)thisBoiler.EfficiencyCurve->curveType], - s_ipsc->cAlphaFieldNames(3))); - ShowContinueError(state, "Available choices are EnteringBoiler or LeavingBoiler"); - } else { - ShowSevereError(state, fmt::format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); - ShowContinueError(state, EnergyPlus::format("Field {} is blank", s_ipsc->cAlphaFieldNames(3))); - ShowContinueError( - state, - EnergyPlus::format("boilers.Boiler using curve type of {} must specify either EnteringBoiler or LeavingBoiler", - Curve::objectNames[(int)thisBoiler.EfficiencyCurve->curveType])); - } - ErrorsFound = true; + } else if (thisBoiler.EfficiencyCurve->numDims == 2) { + if (thisBoiler.CurveTempMode == TempMode::NOTSET) { + if (!efficiencyCurveTempEvalVar.empty()) { + ShowSevereError(state, fmt::format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, boilerName)); + ShowContinueError( + state, EnergyPlus::format("Invalid {}={}", "Efficiency Curve Temperature Evaluation Variable", efficiencyCurveTempEvalVar)); + ShowContinueError(state, + EnergyPlus::format("boilers.Boiler using curve type of {} must specify {}", + Curve::objectNames[(int)thisBoiler.EfficiencyCurve->curveType], + "Efficiency Curve Temperature Evaluation Variable")); + ShowContinueError(state, "Available choices are EnteringBoiler or LeavingBoiler"); + } else { + ShowSevereError(state, fmt::format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, boilerName)); + ShowContinueError(state, EnergyPlus::format("Field {} is blank", "Efficiency Curve Temperature Evaluation Variable")); + ShowContinueError(state, + EnergyPlus::format("boilers.Boiler using curve type of {} must specify either EnteringBoiler or LeavingBoiler", + Curve::objectNames[(int)thisBoiler.EfficiencyCurve->curveType])); } + ErrorsFound = true; } + } - thisBoiler.VolFlowRate = s_ipsc->rNumericArgs(3); + thisBoiler.VolFlowRate = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "design_water_flow_rate"); if (thisBoiler.VolFlowRate == DataSizing::AutoSize) { thisBoiler.VolFlowRateWasAutoSized = true; } - thisBoiler.MinPartLoadRat = s_ipsc->rNumericArgs(4); - thisBoiler.MaxPartLoadRat = s_ipsc->rNumericArgs(5); - thisBoiler.OptPartLoadRat = s_ipsc->rNumericArgs(6); + thisBoiler.MinPartLoadRat = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "minimum_part_load_ratio"); + thisBoiler.MaxPartLoadRat = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "maximum_part_load_ratio"); + thisBoiler.OptPartLoadRat = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "optimum_part_load_ratio"); - thisBoiler.TempUpLimitBoilerOut = s_ipsc->rNumericArgs(7); - // default to 99.9C if upper temperature limit is left blank. + thisBoiler.TempUpLimitBoilerOut = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "water_outlet_upper_temperature_limit"); if (thisBoiler.TempUpLimitBoilerOut <= 0.0) { thisBoiler.TempUpLimitBoilerOut = 99.9; } - thisBoiler.ParasiticElecLoad = s_ipsc->rNumericArgs(8); - thisBoiler.ParasiticFuelCapacity = s_ipsc->rNumericArgs(10); + auto getOptionalNumericField = [&boilerFields](std::string_view fieldName, Real64 defaultValue = 0.0) { + auto const it = boilerFields.find(std::string(fieldName)); + if (it == boilerFields.end()) { + return defaultValue; + } + auto const &fieldValue = it.value(); + if (fieldValue.is_number_integer()) { + return static_cast(fieldValue.get()); + } + if (fieldValue.is_number()) { + return fieldValue.get(); + } + if (fieldValue.is_string() && fieldValue.get().empty()) { + return defaultValue; + } + return defaultValue; + }; + + thisBoiler.ParasiticElecLoad = getOptionalNumericField("on_cycle_parasitic_electric_load"); + if (thisBoiler.ParasiticElecLoad == 0.0) { + thisBoiler.ParasiticElecLoad = getOptionalNumericField("parasitic_electric_load"); + } + + thisBoiler.ParasiticFuelCapacity = getOptionalNumericField("off_cycle_parasitic_fuel_load"); if (thisBoiler.FuelType == Constant::eFuel::Electricity && thisBoiler.ParasiticFuelCapacity > 0) { - ShowWarningError(state, fmt::format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); - ShowContinueError(state, EnergyPlus::format("{} should be zero when the fuel type is electricity.", s_ipsc->cNumericFieldNames(10))); + ShowWarningError(state, fmt::format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, boilerName)); + ShowContinueError(state, EnergyPlus::format("{} should be zero when the fuel type is electricity.", "Parasitic Fuel Capacity")); ShowContinueError(state, "It will be ignored and the simulation continues."); thisBoiler.ParasiticFuelCapacity = 0.0; } - thisBoiler.SizFac = s_ipsc->rNumericArgs(9); + thisBoiler.SizFac = inputProcessor->getRealFieldValue(boilerFields, boilerSchemaProps, "sizing_factor"); if (thisBoiler.SizFac == 0.0) { thisBoiler.SizFac = 1.0; } thisBoiler.BoilerInletNodeNum = Node::GetOnlySingleNode(state, - s_ipsc->cAlphaArgs(5), + boilerWaterInletNodeName, ErrorsFound, Node::ConnectionObjectType::BoilerHotWater, - s_ipsc->cAlphaArgs(1), + boilerName, Node::FluidType::Water, Node::ConnectionType::Inlet, Node::CompFluidStream::Primary, Node::ObjectIsNotParent); thisBoiler.BoilerOutletNodeNum = Node::GetOnlySingleNode(state, - s_ipsc->cAlphaArgs(6), + boilerWaterOutletNodeName, ErrorsFound, Node::ConnectionObjectType::BoilerHotWater, - s_ipsc->cAlphaArgs(1), + boilerName, Node::FluidType::Water, Node::ConnectionType::Outlet, Node::CompFluidStream::Primary, Node::ObjectIsNotParent); - Node::TestCompSet( - state, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), s_ipsc->cAlphaArgs(5), s_ipsc->cAlphaArgs(6), "Hot Water Nodes"); + Node::TestCompSet(state, s_ipsc->cCurrentModuleObject, boilerName, boilerWaterInletNodeName, boilerWaterOutletNodeName, "Hot Water Nodes"); - if (s_ipsc->cAlphaArgs(7) == "CONSTANTFLOW") { + if (boilerFlowMode == "CONSTANTFLOW") { thisBoiler.FlowMode = DataPlant::FlowMode::Constant; - } else if (s_ipsc->cAlphaArgs(7) == "LEAVINGSETPOINTMODULATED") { + } else if (boilerFlowMode == "LEAVINGSETPOINTMODULATED") { thisBoiler.FlowMode = DataPlant::FlowMode::LeavingSetpointModulated; - } else if (s_ipsc->cAlphaArgs(7) == "NOTMODULATED") { + } else if (boilerFlowMode == "NOTMODULATED" || boilerFlowMode.empty()) { thisBoiler.FlowMode = DataPlant::FlowMode::NotModulated; } else { - ShowSevereError(state, fmt::format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))); - ShowContinueError(state, EnergyPlus::format("Invalid {}={}", s_ipsc->cAlphaFieldNames(7), s_ipsc->cAlphaArgs(7))); + ShowSevereError(state, fmt::format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, boilerName)); + ShowContinueError(state, EnergyPlus::format("Invalid {}={}", "Boiler Flow Mode", boilerFlowMode)); ShowContinueError(state, "Available choices are ConstantFlow, NotModulated, or LeavingSetpointModulated"); ShowContinueError(state, "Flow mode NotModulated is assumed and the simulation continues."); - // We will assume variable flow if not specified thisBoiler.FlowMode = DataPlant::FlowMode::NotModulated; } - if (NumAlphas > 7) { - thisBoiler.EndUseSubcategory = s_ipsc->cAlphaArgs(8); + if (boilerFields.find("end_use_subcategory") != boilerFields.end()) { + thisBoiler.EndUseSubcategory = inputProcessor->getAlphaFieldValue(boilerFields, boilerSchemaProps, "end_use_subcategory"); } else { thisBoiler.EndUseSubcategory = "Boiler"; // leave this as "boiler" instead of "general" like other end use subcategories since // it appears this way in existing output files. diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index 17c66d14413..11ce62bf83b 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -149,15 +149,11 @@ namespace CTElectricGenerator { // required by the CT Generator models. static constexpr std::string_view routineName = "GetCTGeneratorInput"; - int NumAlphas; // Number of elements in the alpha array - int NumNums; // Number of elements in the numeric array - int IOStat; // IO Status when calling get input subroutine - Array1D_string AlphArray(12); // character string data - Array1D NumArray(12); // numeric data - bool ErrorsFound(false); // error flag + bool ErrorsFound(false); // error flag state.dataIPShortCut->cCurrentModuleObject = "Generator:CombustionTurbine"; - int NumCTGenerators = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + int NumCTGenerators = inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject); if (NumCTGenerators <= 0) { ShowSevereError(state, EnergyPlus::format("No {} equipment specified in input file", state.dataIPShortCut->cCurrentModuleObject)); @@ -168,183 +164,229 @@ namespace CTElectricGenerator { state.dataCTElectricGenerator->CTGenerator.allocate(NumCTGenerators); // LOAD ARRAYS WITH CT CURVE FIT Generator DATA - for (int genNum = 1; genNum <= NumCTGenerators; ++genNum) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataIPShortCut->cCurrentModuleObject, - genNum, - AlphArray, - NumAlphas, - NumArray, - NumNums, - IOStat, - _, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); - - ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, AlphArray(1)}; - - state.dataCTElectricGenerator->CTGenerator(genNum).Name = AlphArray(1); - - state.dataCTElectricGenerator->CTGenerator(genNum).RatedPowerOutput = NumArray(1); - if (NumArray(1) == 0.0) { - ShowSevereError(state, EnergyPlus::format("Invalid {}={:.2R}", state.dataIPShortCut->cNumericFieldNames(1), NumArray(1))); - ShowContinueError(state, EnergyPlus::format("Entered in {}={}", state.dataIPShortCut->cCurrentModuleObject, AlphArray(1))); - ErrorsFound = true; - } - - // Not sure what to do with electric nodes, so do not use optional arguments - state.dataCTElectricGenerator->CTGenerator(genNum).ElectricCircuitNode = - Node::GetOnlySingleNode(state, - AlphArray(2), - ErrorsFound, - Node::ConnectionObjectType::GeneratorCombustionTurbine, - AlphArray(1), - Node::FluidType::Electric, - Node::ConnectionType::Electric, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - - state.dataCTElectricGenerator->CTGenerator(genNum).MinPartLoadRat = NumArray(2); - state.dataCTElectricGenerator->CTGenerator(genNum).MaxPartLoadRat = NumArray(3); - state.dataCTElectricGenerator->CTGenerator(genNum).OptPartLoadRat = NumArray(4); - - // Load Special CT Generator Input - - state.dataCTElectricGenerator->CTGenerator(genNum).PLBasedFuelInputCurve = Curve::GetCurve(state, AlphArray(3)); - if (state.dataCTElectricGenerator->CTGenerator(genNum).PLBasedFuelInputCurve == 0) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphArray(3)); - ErrorsFound = true; - } + auto const &objectSchemaProps = inputProcessor->getObjectSchemaProps(state, state.dataIPShortCut->cCurrentModuleObject); + auto const generatorObjects = inputProcessor->epJSON.find(state.dataIPShortCut->cCurrentModuleObject); + if (generatorObjects != inputProcessor->epJSON.end()) { + int genNum = 1; + for (auto const &generatorInstance : generatorObjects.value().items()) { + auto const &generatorFields = generatorInstance.value(); + auto const generatorName = Util::makeUPPER(generatorInstance.key()); + auto const electricCircuitNodeName = + inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "electric_circuit_node_name"); + auto const partLoadBasedFuelInputCurveName = + inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "part_load_based_fuel_input_curve_name"); + auto const temperatureBasedFuelInputCurveName = + inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "temperature_based_fuel_input_curve_name"); + auto const exhaustFlowCurveName = inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "exhaust_flow_curve_name"); + auto const partLoadBasedExhaustTemperatureCurveName = + inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "part_load_based_exhaust_temperature_curve_name"); + auto const temperatureBasedExhaustTemperatureCurveName = + inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "temperature_based_exhaust_temperature_curve_name"); + auto const heatRecoveryLubeEnergyCurveName = + inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "heat_recovery_lube_energy_curve_name"); + auto const heatRecoveryInletNodeName = + generatorFields.contains("heat_recovery_inlet_node_name") + ? inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "heat_recovery_inlet_node_name") + : std::string(); + auto const heatRecoveryOutletNodeName = + generatorFields.contains("heat_recovery_outlet_node_name") + ? inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "heat_recovery_outlet_node_name") + : std::string(); + auto const fuelType = generatorFields.contains("fuel_type") + ? inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "fuel_type") + : std::string("NaturalGas"); + auto const outdoorAirInletNodeName = + generatorFields.contains("outdoor_air_inlet_node_name") + ? inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "outdoor_air_inlet_node_name") + : std::string(); + + inputProcessor->markObjectAsUsed(state.dataIPShortCut->cCurrentModuleObject, generatorInstance.key()); + + ErrorObjectHeader eoh{routineName, state.dataIPShortCut->cCurrentModuleObject, generatorName}; + + state.dataCTElectricGenerator->CTGenerator(genNum).Name = generatorName; + + state.dataCTElectricGenerator->CTGenerator(genNum).RatedPowerOutput = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "rated_power_output"); + if (state.dataCTElectricGenerator->CTGenerator(genNum).RatedPowerOutput == 0.0) { + ShowSevereError(state, EnergyPlus::format("Invalid {}={:.2R}", "rated_power_output", 0.0)); + ShowContinueError(state, EnergyPlus::format("Entered in {}={}", state.dataIPShortCut->cCurrentModuleObject, generatorName)); + ErrorsFound = true; + } - state.dataCTElectricGenerator->CTGenerator(genNum).TempBasedFuelInputCurve = Curve::GetCurve(state, AlphArray(4)); - if (state.dataCTElectricGenerator->CTGenerator(genNum).TempBasedFuelInputCurve == nullptr) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), AlphArray(4)); - ErrorsFound = true; - } + // Not sure what to do with electric nodes, so do not use optional arguments + state.dataCTElectricGenerator->CTGenerator(genNum).ElectricCircuitNode = + Node::GetOnlySingleNode(state, + electricCircuitNodeName, + ErrorsFound, + Node::ConnectionObjectType::GeneratorCombustionTurbine, + generatorName, + Node::FluidType::Electric, + Node::ConnectionType::Electric, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); - state.dataCTElectricGenerator->CTGenerator(genNum).ExhaustFlowCurve = Curve::GetCurve(state, AlphArray(5)); - if (state.dataCTElectricGenerator->CTGenerator(genNum).ExhaustFlowCurve == nullptr) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(5), AlphArray(5)); - ErrorsFound = true; - } + state.dataCTElectricGenerator->CTGenerator(genNum).MinPartLoadRat = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "minimum_part_load_ratio"); + state.dataCTElectricGenerator->CTGenerator(genNum).MaxPartLoadRat = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "maximum_part_load_ratio"); + state.dataCTElectricGenerator->CTGenerator(genNum).OptPartLoadRat = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "optimum_part_load_ratio"); - state.dataCTElectricGenerator->CTGenerator(genNum).PLBasedExhaustTempCurve = Curve::GetCurve(state, AlphArray(6)); - if (state.dataCTElectricGenerator->CTGenerator(genNum).PLBasedExhaustTempCurve == nullptr) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(6), AlphArray(6)); - ErrorsFound = true; - } + // Load Special CT Generator Input - state.dataCTElectricGenerator->CTGenerator(genNum).TempBasedExhaustTempCurve = Curve::GetCurve(state, AlphArray(7)); - if (state.dataCTElectricGenerator->CTGenerator(genNum).TempBasedExhaustTempCurve == nullptr) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(7), AlphArray(7)); - ErrorsFound = true; - } + state.dataCTElectricGenerator->CTGenerator(genNum).PLBasedFuelInputCurve = Curve::GetCurve(state, partLoadBasedFuelInputCurveName); + if (state.dataCTElectricGenerator->CTGenerator(genNum).PLBasedFuelInputCurve == 0) { + ShowSevereItemNotFound(state, eoh, "part_load_based_fuel_input_curve_name", partLoadBasedFuelInputCurveName); + ErrorsFound = true; + } - state.dataCTElectricGenerator->CTGenerator(genNum).QLubeOilRecoveredCurve = Curve::GetCurve(state, AlphArray(8)); - if (state.dataCTElectricGenerator->CTGenerator(genNum).QLubeOilRecoveredCurve == nullptr) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(8), AlphArray(8)); - ErrorsFound = true; - } + state.dataCTElectricGenerator->CTGenerator(genNum).TempBasedFuelInputCurve = + Curve::GetCurve(state, temperatureBasedFuelInputCurveName); + if (state.dataCTElectricGenerator->CTGenerator(genNum).TempBasedFuelInputCurve == nullptr) { + ShowSevereItemNotFound(state, eoh, "temperature_based_fuel_input_curve_name", temperatureBasedFuelInputCurveName); + ErrorsFound = true; + } - state.dataCTElectricGenerator->CTGenerator(genNum).UACoef[0] = NumArray(5); - state.dataCTElectricGenerator->CTGenerator(genNum).UACoef[1] = NumArray(6); + state.dataCTElectricGenerator->CTGenerator(genNum).ExhaustFlowCurve = Curve::GetCurve(state, exhaustFlowCurveName); + if (state.dataCTElectricGenerator->CTGenerator(genNum).ExhaustFlowCurve == nullptr) { + ShowSevereItemNotFound(state, eoh, "exhaust_flow_curve_name", exhaustFlowCurveName); + ErrorsFound = true; + } - state.dataCTElectricGenerator->CTGenerator(genNum).MaxExhaustperCTPower = NumArray(7); - state.dataCTElectricGenerator->CTGenerator(genNum).DesignMinExitGasTemp = NumArray(8); - state.dataCTElectricGenerator->CTGenerator(genNum).DesignAirInletTemp = NumArray(9); - state.dataCTElectricGenerator->CTGenerator(genNum).FuelHeatingValue = NumArray(10); - state.dataCTElectricGenerator->CTGenerator(genNum).DesignHeatRecVolFlowRate = NumArray(11); + state.dataCTElectricGenerator->CTGenerator(genNum).PLBasedExhaustTempCurve = + Curve::GetCurve(state, partLoadBasedExhaustTemperatureCurveName); + if (state.dataCTElectricGenerator->CTGenerator(genNum).PLBasedExhaustTempCurve == nullptr) { + ShowSevereItemNotFound(state, eoh, "part_load_based_exhaust_temperature_curve_name", partLoadBasedExhaustTemperatureCurveName); + ErrorsFound = true; + } - if (state.dataCTElectricGenerator->CTGenerator(genNum).DesignHeatRecVolFlowRate > 0.0) { - state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecActive = true; - state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecInletNodeNum = - Node::GetOnlySingleNode(state, - AlphArray(9), - ErrorsFound, - Node::ConnectionObjectType::GeneratorCombustionTurbine, - AlphArray(1), - Node::FluidType::Water, - Node::ConnectionType::Inlet, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - if (state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecInletNodeNum == 0) { - ShowSevereError(state, - EnergyPlus::format("Missing Node Name, Heat Recovery Inlet, for {}={}", - state.dataIPShortCut->cCurrentModuleObject, - AlphArray(1))); + state.dataCTElectricGenerator->CTGenerator(genNum).TempBasedExhaustTempCurve = + Curve::GetCurve(state, temperatureBasedExhaustTemperatureCurveName); + if (state.dataCTElectricGenerator->CTGenerator(genNum).TempBasedExhaustTempCurve == nullptr) { + ShowSevereItemNotFound( + state, eoh, "temperature_based_exhaust_temperature_curve_name", temperatureBasedExhaustTemperatureCurveName); ErrorsFound = true; } - state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecOutletNodeNum = - Node::GetOnlySingleNode(state, - AlphArray(10), - ErrorsFound, - Node::ConnectionObjectType::GeneratorCombustionTurbine, - AlphArray(1), - Node::FluidType::Water, - Node::ConnectionType::Outlet, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - if (state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecOutletNodeNum == 0) { - ShowSevereError(state, - EnergyPlus::format("Missing Node Name, Heat Recovery Outlet, for {}={}", - state.dataIPShortCut->cCurrentModuleObject, - AlphArray(1))); + + state.dataCTElectricGenerator->CTGenerator(genNum).QLubeOilRecoveredCurve = Curve::GetCurve(state, heatRecoveryLubeEnergyCurveName); + if (state.dataCTElectricGenerator->CTGenerator(genNum).QLubeOilRecoveredCurve == nullptr) { + ShowSevereItemNotFound(state, eoh, "heat_recovery_lube_energy_curve_name", heatRecoveryLubeEnergyCurveName); ErrorsFound = true; } - Node::TestCompSet( - state, state.dataIPShortCut->cCurrentModuleObject, AlphArray(1), AlphArray(9), AlphArray(10), "Heat Recovery Nodes"); - PlantUtilities::RegisterPlantCompDesignFlow(state, - state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecInletNodeNum, - state.dataCTElectricGenerator->CTGenerator(genNum).DesignHeatRecVolFlowRate); - } else { - state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecActive = false; - state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecInletNodeNum = 0; - state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecOutletNodeNum = 0; - if (!state.dataIPShortCut->lAlphaFieldBlanks(9) || !state.dataIPShortCut->lAlphaFieldBlanks(10)) { - ShowWarningError(state, - EnergyPlus::format("Since Design Heat Flow Rate = 0.0, Heat Recovery inactive for {}={}", - state.dataIPShortCut->cCurrentModuleObject, - AlphArray(1))); - ShowContinueError(state, "However, Node names were specified for Heat Recovery inlet or outlet nodes"); + state.dataCTElectricGenerator->CTGenerator(genNum).UACoef[0] = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "coefficient_1_of_u_factor_times_area_curve"); + state.dataCTElectricGenerator->CTGenerator(genNum).UACoef[1] = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "coefficient_2_of_u_factor_times_area_curve"); + + state.dataCTElectricGenerator->CTGenerator(genNum).MaxExhaustperCTPower = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "maximum_exhaust_flow_per_unit_of_power_output"); + state.dataCTElectricGenerator->CTGenerator(genNum).DesignMinExitGasTemp = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "design_minimum_exhaust_temperature"); + state.dataCTElectricGenerator->CTGenerator(genNum).DesignAirInletTemp = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "design_air_inlet_temperature"); + state.dataCTElectricGenerator->CTGenerator(genNum).FuelHeatingValue = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "fuel_higher_heating_value"); + state.dataCTElectricGenerator->CTGenerator(genNum).DesignHeatRecVolFlowRate = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "design_heat_recovery_water_flow_rate"); + + if (state.dataCTElectricGenerator->CTGenerator(genNum).DesignHeatRecVolFlowRate > 0.0) { + state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecActive = true; + state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecInletNodeNum = + Node::GetOnlySingleNode(state, + heatRecoveryInletNodeName, + ErrorsFound, + Node::ConnectionObjectType::GeneratorCombustionTurbine, + generatorName, + Node::FluidType::Water, + Node::ConnectionType::Inlet, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); + if (state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecInletNodeNum == 0) { + ShowSevereError(state, + EnergyPlus::format("Missing Node Name, Heat Recovery Inlet, for {}={}", + state.dataIPShortCut->cCurrentModuleObject, + generatorName)); + ErrorsFound = true; + } + state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecOutletNodeNum = + Node::GetOnlySingleNode(state, + heatRecoveryOutletNodeName, + ErrorsFound, + Node::ConnectionObjectType::GeneratorCombustionTurbine, + generatorName, + Node::FluidType::Water, + Node::ConnectionType::Outlet, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); + if (state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecOutletNodeNum == 0) { + ShowSevereError(state, + EnergyPlus::format("Missing Node Name, Heat Recovery Outlet, for {}={}", + state.dataIPShortCut->cCurrentModuleObject, + generatorName)); + ErrorsFound = true; + } + + Node::TestCompSet(state, + state.dataIPShortCut->cCurrentModuleObject, + generatorName, + heatRecoveryInletNodeName, + heatRecoveryOutletNodeName, + "Heat Recovery Nodes"); + PlantUtilities::RegisterPlantCompDesignFlow(state, + state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecInletNodeNum, + state.dataCTElectricGenerator->CTGenerator(genNum).DesignHeatRecVolFlowRate); + } else { + state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecActive = false; + state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecInletNodeNum = 0; + state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecOutletNodeNum = 0; + if (!heatRecoveryInletNodeName.empty() || !heatRecoveryOutletNodeName.empty()) { + ShowWarningError(state, + EnergyPlus::format("Since Design Heat Flow Rate = 0.0, Heat Recovery inactive for {}={}", + state.dataIPShortCut->cCurrentModuleObject, + generatorName)); + ShowContinueError(state, "However, Node names were specified for Heat Recovery inlet or outlet nodes"); + } } - } - // Validate fuel type input - state.dataCTElectricGenerator->CTGenerator(genNum).FuelType = - static_cast(getEnumValue(Constant::eFuelNamesUC, AlphArray(11))); - if (state.dataCTElectricGenerator->CTGenerator(genNum).FuelType == Constant::eFuel::Invalid) { - ShowSevereError(state, EnergyPlus::format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(11), AlphArray(11))); - ShowContinueError(state, EnergyPlus::format("Entered in {}={}", state.dataIPShortCut->cCurrentModuleObject, AlphArray(1))); - ErrorsFound = true; - } + // Validate fuel type input + state.dataCTElectricGenerator->CTGenerator(genNum).FuelType = + static_cast(getEnumValue(Constant::eFuelNamesUC, fuelType)); + if (state.dataCTElectricGenerator->CTGenerator(genNum).FuelType == Constant::eFuel::Invalid) { + ShowSevereError(state, EnergyPlus::format("Invalid {}={}", "fuel_type", fuelType)); + ShowContinueError(state, EnergyPlus::format("Entered in {}={}", state.dataIPShortCut->cCurrentModuleObject, generatorName)); + ErrorsFound = true; + } - state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecMaxTemp = NumArray(12); + state.dataCTElectricGenerator->CTGenerator(genNum).HeatRecMaxTemp = + inputProcessor->getRealFieldValue(generatorFields, objectSchemaProps, "heat_recovery_maximum_temperature"); - // begin CR7021 - if (state.dataIPShortCut->lAlphaFieldBlanks(12)) { - state.dataCTElectricGenerator->CTGenerator(genNum).OAInletNode = 0; - } else { - state.dataCTElectricGenerator->CTGenerator(genNum).OAInletNode = - Node::GetOnlySingleNode(state, - AlphArray(12), - ErrorsFound, - Node::ConnectionObjectType::GeneratorCombustionTurbine, - AlphArray(1), - Node::FluidType::Air, - Node::ConnectionType::OutsideAirReference, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - if (!OutAirNodeManager::CheckOutAirNodeNumber(state, state.dataCTElectricGenerator->CTGenerator(genNum).OAInletNode)) { - ShowSevereError(state, - EnergyPlus::format("{}, \"{}\" Outdoor Air Inlet Node Name not valid Outdoor Air Node= {}", - state.dataIPShortCut->cCurrentModuleObject, - state.dataCTElectricGenerator->CTGenerator(genNum).Name, - AlphArray(12))); - ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node."); - ErrorsFound = true; + // begin CR7021 + if (outdoorAirInletNodeName.empty()) { + state.dataCTElectricGenerator->CTGenerator(genNum).OAInletNode = 0; + } else { + state.dataCTElectricGenerator->CTGenerator(genNum).OAInletNode = + Node::GetOnlySingleNode(state, + outdoorAirInletNodeName, + ErrorsFound, + Node::ConnectionObjectType::GeneratorCombustionTurbine, + generatorName, + Node::FluidType::Air, + Node::ConnectionType::OutsideAirReference, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); + if (!OutAirNodeManager::CheckOutAirNodeNumber(state, state.dataCTElectricGenerator->CTGenerator(genNum).OAInletNode)) { + ShowSevereError(state, + EnergyPlus::format("{}, \"{}\" Outdoor Air Inlet Node Name not valid Outdoor Air Node= {}", + state.dataIPShortCut->cCurrentModuleObject, + state.dataCTElectricGenerator->CTGenerator(genNum).Name, + outdoorAirInletNodeName)); + ShowContinueError(state, "...does not appear in an OutdoorAir:NodeList or as an OutdoorAir:Node."); + ErrorsFound = true; + } } + ++genNum; } } diff --git a/src/EnergyPlus/Coils/CoilCoolingDX.cc b/src/EnergyPlus/Coils/CoilCoolingDX.cc index 42cdba8e0ad..fea7665c905 100644 --- a/src/EnergyPlus/Coils/CoilCoolingDX.cc +++ b/src/EnergyPlus/Coils/CoilCoolingDX.cc @@ -60,7 +60,6 @@ #include #include #include -#include #include #include #include @@ -116,35 +115,31 @@ int CoilCoolingDX::factory(EnergyPlus::EnergyPlusData &state, std::string const void CoilCoolingDX::getInput(EnergyPlusData &state) { - int numCoolingCoilDXs = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, state.dataCoilCoolingDX->coilCoolingDXObjectName); - if (numCoolingCoilDXs <= 0) { + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const coilInstances = inputProcessor->epJSON.find(state.dataCoilCoolingDX->coilCoolingDXObjectName); + if (coilInstances == inputProcessor->epJSON.end() || coilInstances->empty()) { ShowFatalError(state, R"(No "Coil:Cooling:DX" objects in input file)"); } - for (int coilNum = 1; coilNum <= numCoolingCoilDXs; ++coilNum) { - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call - int IOStatus; - state.dataInputProcessing->inputProcessor->getObjectItem(state, - state.dataCoilCoolingDX->coilCoolingDXObjectName, - coilNum, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNumbers, - IOStatus); + auto const &coilSchemaProps = inputProcessor->getObjectSchemaProps(state, state.dataCoilCoolingDX->coilCoolingDXObjectName); + + for (auto const &coilInstance : coilInstances.value().items()) { + auto const &coilFields = coilInstance.value(); CoilCoolingDXInputSpecification input_specs; - input_specs.name = state.dataIPShortCut->cAlphaArgs(1); - input_specs.evaporator_inlet_node_name = state.dataIPShortCut->cAlphaArgs(2); - input_specs.evaporator_outlet_node_name = state.dataIPShortCut->cAlphaArgs(3); - input_specs.availability_schedule_name = state.dataIPShortCut->cAlphaArgs(4); - input_specs.condenser_zone_name = state.dataIPShortCut->cAlphaArgs(5); - input_specs.condenser_inlet_node_name = state.dataIPShortCut->cAlphaArgs(6); - input_specs.condenser_outlet_node_name = state.dataIPShortCut->cAlphaArgs(7); - input_specs.performance_object_name = state.dataIPShortCut->cAlphaArgs(8); - input_specs.condensate_collection_water_storage_tank_name = state.dataIPShortCut->cAlphaArgs(9); - input_specs.evaporative_condenser_supply_water_storage_tank_name = state.dataIPShortCut->cAlphaArgs(10); + input_specs.name = Util::makeUPPER(coilInstance.key()); + input_specs.evaporator_inlet_node_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "evaporator_inlet_node_name"); + input_specs.evaporator_outlet_node_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "evaporator_outlet_node_name"); + input_specs.availability_schedule_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "availability_schedule_name"); + input_specs.condenser_zone_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "condenser_zone_name"); + input_specs.condenser_inlet_node_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "condenser_inlet_node_name"); + input_specs.condenser_outlet_node_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "condenser_outlet_node_name"); + input_specs.performance_object_name = inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "performance_object_name"); + input_specs.condensate_collection_water_storage_tank_name = + inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "condensate_collection_water_storage_tank_name"); + input_specs.evaporative_condenser_supply_water_storage_tank_name = + inputProcessor->getAlphaFieldValue(coilFields, coilSchemaProps, "evaporative_condenser_supply_water_storage_tank_name"); CoilCoolingDX thisCoil; thisCoil.instantiateFromInputSpec(state, input_specs); + inputProcessor->markObjectAsUsed(state.dataCoilCoolingDX->coilCoolingDXObjectName, coilInstance.key()); state.dataCoilCoolingDX->coilCoolingDXs.push_back(thisCoil); } } diff --git a/src/EnergyPlus/Coils/CoilCoolingDXCurveFitOperatingMode.cc b/src/EnergyPlus/Coils/CoilCoolingDXCurveFitOperatingMode.cc index 77abf4e61d1..9ed8eead48d 100644 --- a/src/EnergyPlus/Coils/CoilCoolingDXCurveFitOperatingMode.cc +++ b/src/EnergyPlus/Coils/CoilCoolingDXCurveFitOperatingMode.cc @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -125,50 +124,54 @@ void CoilCoolingDXCurveFitOperatingMode::instantiateFromInputSpec(EnergyPlus::En CoilCoolingDXCurveFitOperatingMode::CoilCoolingDXCurveFitOperatingMode(EnergyPlus::EnergyPlusData &state, const std::string &name_to_find) { - int numModes = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CoilCoolingDXCurveFitOperatingMode::object_name); - if (numModes <= 0) { + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const modeInstances = inputProcessor->epJSON.find(CoilCoolingDXCurveFitOperatingMode::object_name); + if (modeInstances == inputProcessor->epJSON.end()) { // error } + auto const &modeSchemaProps = inputProcessor->getObjectSchemaProps(state, CoilCoolingDXCurveFitOperatingMode::object_name); bool found_it = false; - for (int modeNum = 1; modeNum <= numModes; ++modeNum) { - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call - int IOStatus; - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CoilCoolingDXCurveFitOperatingMode::object_name, - modeNum, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNumbers, - IOStatus); - if (!Util::SameString(name_to_find, state.dataIPShortCut->cAlphaArgs(1))) { + for (auto const &modeInstance : modeInstances.value().items()) { + auto const modeName = Util::makeUPPER(modeInstance.key()); + auto const &modeFields = modeInstance.value(); + if (!Util::SameString(name_to_find, modeName)) { continue; } found_it = true; CoilCoolingDXCurveFitOperatingModeInputSpecification input_specs; - input_specs.name = state.dataIPShortCut->cAlphaArgs(1); - input_specs.gross_rated_total_cooling_capacity = state.dataIPShortCut->rNumericArgs(1); - input_specs.rated_evaporator_air_flow_rate = state.dataIPShortCut->rNumericArgs(2); - input_specs.rated_condenser_air_flow_rate = state.dataIPShortCut->rNumericArgs(3); - input_specs.maximum_cycling_rate = state.dataIPShortCut->rNumericArgs(4); - input_specs.ratio_of_initial_moisture_evaporation_rate_and_steady_state_latent_capacity = state.dataIPShortCut->rNumericArgs(5); - input_specs.latent_capacity_time_constant = state.dataIPShortCut->rNumericArgs(6); - input_specs.nominal_time_for_condensate_removal_to_begin = state.dataIPShortCut->rNumericArgs(7); - input_specs.apply_latent_degradation_to_speeds_greater_than_1 = state.dataIPShortCut->cAlphaArgs(2); - input_specs.condenser_type = state.dataIPShortCut->cAlphaArgs(3); - input_specs.nominal_evap_condenser_pump_power = state.dataIPShortCut->rNumericArgs(8); - input_specs.nominal_speed_number = state.dataIPShortCut->rNumericArgs(9); - for (int fieldNum = 4; fieldNum <= NumAlphas; fieldNum++) { - if (state.dataIPShortCut->cAlphaArgs(fieldNum).empty()) { + input_specs.name = modeName; + input_specs.gross_rated_total_cooling_capacity = + inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "rated_gross_total_cooling_capacity"); + input_specs.rated_evaporator_air_flow_rate = inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "rated_evaporator_air_flow_rate"); + input_specs.rated_condenser_air_flow_rate = inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "rated_condenser_air_flow_rate"); + input_specs.maximum_cycling_rate = inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "maximum_cycling_rate"); + input_specs.ratio_of_initial_moisture_evaporation_rate_and_steady_state_latent_capacity = inputProcessor->getRealFieldValue( + modeFields, modeSchemaProps, "ratio_of_initial_moisture_evaporation_rate_and_steady_state_latent_capacity"); + input_specs.latent_capacity_time_constant = inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "latent_capacity_time_constant"); + input_specs.nominal_time_for_condensate_removal_to_begin = + inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "nominal_time_for_condensate_removal_to_begin"); + input_specs.apply_latent_degradation_to_speeds_greater_than_1 = + inputProcessor->getAlphaFieldValue(modeFields, modeSchemaProps, "apply_latent_degradation_to_speeds_greater_than_1"); + input_specs.condenser_type = inputProcessor->getAlphaFieldValue(modeFields, modeSchemaProps, "condenser_type"); + input_specs.nominal_evap_condenser_pump_power = + inputProcessor->getRealFieldValue(modeFields, modeSchemaProps, "nominal_evaporative_condenser_pump_power"); + input_specs.nominal_speed_number = inputProcessor->getIntFieldValue(modeFields, modeSchemaProps, "nominal_speed_number"); + for (int fieldNum = 1; fieldNum <= 10; ++fieldNum) { + auto const speedFieldName = format("speed_{}_name", fieldNum); + auto const speedName = inputProcessor->getAlphaFieldValue(modeFields, modeSchemaProps, speedFieldName); + if (speedName.empty()) { break; } - input_specs.speed_data_names.push_back(state.dataIPShortCut->cAlphaArgs(fieldNum)); + input_specs.speed_data_names.push_back(speedName); + } + if (input_specs.nominal_speed_number == 0) { + input_specs.nominal_speed_number = static_cast(input_specs.speed_data_names.size()); } this->instantiateFromInputSpec(state, input_specs); + inputProcessor->markObjectAsUsed(CoilCoolingDXCurveFitOperatingMode::object_name, modeInstance.key()); break; } diff --git a/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.cc b/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.cc index 960264ae364..edd8905722a 100644 --- a/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.cc +++ b/src/EnergyPlus/Coils/CoilCoolingDXCurveFitPerformance.cc @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -155,58 +154,51 @@ void CoilCoolingDXCurveFitPerformance::instantiateFromInputSpec(EnergyPlus::Ener CoilCoolingDXCurveFitPerformance::CoilCoolingDXCurveFitPerformance(EnergyPlus::EnergyPlusData &state, const std::string &name_to_find) : CoilCoolingDXPerformanceBase() { - int numPerformances = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CoilCoolingDXCurveFitPerformance::object_name); - if (numPerformances <= 0) { + std::string const objectName{CoilCoolingDXCurveFitPerformance::object_name}; + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const performanceInstances = inputProcessor->epJSON.find(objectName); + if (performanceInstances == inputProcessor->epJSON.end()) { // error } + auto const &performanceSchemaProps = inputProcessor->getObjectSchemaProps(state, objectName); bool found_it = false; - for (int perfNum = 1; perfNum <= numPerformances; ++perfNum) { - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call - int IOStatus; - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CoilCoolingDXCurveFitPerformance::object_name, - perfNum, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNumbers, - IOStatus, - _, - state.dataIPShortCut->lAlphaFieldBlanks); - if (!Util::SameString(name_to_find, state.dataIPShortCut->cAlphaArgs(1))) { + for (auto const &performanceInstance : performanceInstances.value().items()) { + auto const performanceName = Util::makeUPPER(performanceInstance.key()); + auto const &performanceFields = performanceInstance.value(); + if (!Util::SameString(name_to_find, performanceName)) { continue; } found_it = true; CoilCoolingDXCurveFitPerformanceInputSpecification input_specs; - input_specs.name = state.dataIPShortCut->cAlphaArgs(1); - input_specs.crankcase_heater_capacity = state.dataIPShortCut->rNumericArgs(1); - input_specs.minimum_outdoor_dry_bulb_temperature_for_compressor_operation = state.dataIPShortCut->rNumericArgs(2); - input_specs.maximum_outdoor_dry_bulb_temperature_for_crankcase_heater_operation = state.dataIPShortCut->rNumericArgs(3); - if (state.dataIPShortCut->lNumericFieldBlanks(4)) { - input_specs.unit_internal_static_air_pressure = 0.0; - } else { - input_specs.unit_internal_static_air_pressure = state.dataIPShortCut->rNumericArgs(4); - } - if (!state.dataIPShortCut->lAlphaFieldBlanks(2)) { - input_specs.outdoor_temperature_dependent_crankcase_heater_capacity_curve_name = state.dataIPShortCut->cAlphaArgs(2); - } - input_specs.capacity_control = state.dataIPShortCut->cAlphaArgs(3); - input_specs.basin_heater_capacity = state.dataIPShortCut->rNumericArgs(5); - input_specs.basin_heater_setpoint_temperature = state.dataIPShortCut->rNumericArgs(6); - input_specs.basin_heater_operating_schedule_name = state.dataIPShortCut->cAlphaArgs(4); - input_specs.compressor_fuel_type = state.dataIPShortCut->cAlphaArgs(5); - input_specs.base_operating_mode_name = state.dataIPShortCut->cAlphaArgs(6); - if (!state.dataIPShortCut->lAlphaFieldBlanks(6)) { - input_specs.alternate_operating_mode_name = state.dataIPShortCut->cAlphaArgs(7); - } - if (!state.dataIPShortCut->lAlphaFieldBlanks(8)) { - input_specs.alternate_operating_mode2_name = state.dataIPShortCut->cAlphaArgs(8); - } + input_specs.name = performanceName; + input_specs.crankcase_heater_capacity = + inputProcessor->getRealFieldValue(performanceFields, performanceSchemaProps, "crankcase_heater_capacity"); + input_specs.minimum_outdoor_dry_bulb_temperature_for_compressor_operation = inputProcessor->getRealFieldValue( + performanceFields, performanceSchemaProps, "minimum_outdoor_dry_bulb_temperature_for_compressor_operation"); + input_specs.maximum_outdoor_dry_bulb_temperature_for_crankcase_heater_operation = inputProcessor->getRealFieldValue( + performanceFields, performanceSchemaProps, "maximum_outdoor_dry_bulb_temperature_for_crankcase_heater_operation"); + input_specs.unit_internal_static_air_pressure = + inputProcessor->getRealFieldValue(performanceFields, performanceSchemaProps, "unit_internal_static_air_pressure"); + input_specs.outdoor_temperature_dependent_crankcase_heater_capacity_curve_name = inputProcessor->getAlphaFieldValue( + performanceFields, performanceSchemaProps, "crankcase_heater_capacity_function_of_temperature_curve_name"); + input_specs.capacity_control = inputProcessor->getAlphaFieldValue(performanceFields, performanceSchemaProps, "capacity_control_method"); + input_specs.basin_heater_capacity = + inputProcessor->getRealFieldValue(performanceFields, performanceSchemaProps, "evaporative_condenser_basin_heater_capacity"); + input_specs.basin_heater_setpoint_temperature = + inputProcessor->getRealFieldValue(performanceFields, performanceSchemaProps, "evaporative_condenser_basin_heater_setpoint_temperature"); + input_specs.basin_heater_operating_schedule_name = inputProcessor->getAlphaFieldValue( + performanceFields, performanceSchemaProps, "evaporative_condenser_basin_heater_operating_schedule_name"); + input_specs.compressor_fuel_type = inputProcessor->getAlphaFieldValue(performanceFields, performanceSchemaProps, "compressor_fuel_type"); + input_specs.base_operating_mode_name = inputProcessor->getAlphaFieldValue(performanceFields, performanceSchemaProps, "base_operating_mode"); + input_specs.alternate_operating_mode_name = + inputProcessor->getAlphaFieldValue(performanceFields, performanceSchemaProps, "alternative_operating_mode_1"); + input_specs.alternate_operating_mode2_name = + inputProcessor->getAlphaFieldValue(performanceFields, performanceSchemaProps, "alternative_operating_mode_2"); this->instantiateFromInputSpec(state, input_specs); + inputProcessor->markObjectAsUsed(objectName, performanceInstance.key()); break; } diff --git a/src/EnergyPlus/Coils/CoilCoolingDXCurveFitSpeed.cc b/src/EnergyPlus/Coils/CoilCoolingDXCurveFitSpeed.cc index 7c3c990e480..3ace36fde7b 100644 --- a/src/EnergyPlus/Coils/CoilCoolingDXCurveFitSpeed.cc +++ b/src/EnergyPlus/Coils/CoilCoolingDXCurveFitSpeed.cc @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -283,52 +282,63 @@ CoilCoolingDXCurveFitSpeed::CoilCoolingDXCurveFitSpeed(EnergyPlus::EnergyPlusDat DryCoilOutletHumRatioMin(0.00001) // dry coil outlet minimum hum ratio kgH2O/kgdry air { - int numSpeeds = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CoilCoolingDXCurveFitSpeed::object_name); - if (numSpeeds <= 0) { + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const speedInstances = inputProcessor->epJSON.find(CoilCoolingDXCurveFitSpeed::object_name); + if (speedInstances == inputProcessor->epJSON.end()) { // error } + auto const &speedSchemaProps = inputProcessor->getObjectSchemaProps(state, CoilCoolingDXCurveFitSpeed::object_name); bool found_it = false; - for (int speedNum = 1; speedNum <= numSpeeds; ++speedNum) { - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call - int IOStatus; - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CoilCoolingDXCurveFitSpeed::object_name, - speedNum, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNumbers, - IOStatus); - if (!Util::SameString(name_to_find, state.dataIPShortCut->cAlphaArgs(1))) { + for (auto const &speedInstance : speedInstances.value().items()) { + auto const speedName = Util::makeUPPER(speedInstance.key()); + auto const &speedFields = speedInstance.value(); + if (!Util::SameString(name_to_find, speedName)) { continue; } found_it = true; CoilCoolingDXCurveFitSpeedInputSpecification input_specs; - input_specs.name = state.dataIPShortCut->cAlphaArgs(1); - input_specs.gross_rated_total_cooling_capacity_ratio_to_nominal = state.dataIPShortCut->rNumericArgs(1); - input_specs.evaporator_air_flow_fraction = state.dataIPShortCut->rNumericArgs(2); - input_specs.condenser_air_flow_fraction = state.dataIPShortCut->rNumericArgs(3); - input_specs.gross_rated_sensible_heat_ratio = state.dataIPShortCut->rNumericArgs(4); - input_specs.gross_rated_cooling_COP = state.dataIPShortCut->rNumericArgs(5); - input_specs.active_fraction_of_coil_face_area = state.dataIPShortCut->rNumericArgs(6); - input_specs.rated_evaporator_fan_power_per_volume_flow_rate = state.dataIPShortCut->rNumericArgs(7); - input_specs.rated_evaporator_fan_power_per_volume_flow_rate_2023 = state.dataIPShortCut->rNumericArgs(8); - input_specs.rated_evaporative_condenser_pump_power_fraction = state.dataIPShortCut->rNumericArgs(9); - input_specs.evaporative_condenser_effectiveness = state.dataIPShortCut->rNumericArgs(10); - input_specs.total_cooling_capacity_function_of_temperature_curve_name = state.dataIPShortCut->cAlphaArgs(2); - input_specs.total_cooling_capacity_function_of_air_flow_fraction_curve_name = state.dataIPShortCut->cAlphaArgs(3); - input_specs.energy_input_ratio_function_of_temperature_curve_name = state.dataIPShortCut->cAlphaArgs(4); - input_specs.energy_input_ratio_function_of_air_flow_fraction_curve_name = state.dataIPShortCut->cAlphaArgs(5); - input_specs.part_load_fraction_correlation_curve_name = state.dataIPShortCut->cAlphaArgs(6); - input_specs.rated_waste_heat_fraction_of_power_input = state.dataIPShortCut->rNumericArgs(11); - input_specs.waste_heat_function_of_temperature_curve_name = state.dataIPShortCut->cAlphaArgs(7); - input_specs.sensible_heat_ratio_modifier_function_of_temperature_curve_name = state.dataIPShortCut->cAlphaArgs(8); - input_specs.sensible_heat_ratio_modifier_function_of_flow_fraction_curve_name = state.dataIPShortCut->cAlphaArgs(9); + input_specs.name = speedName; + input_specs.gross_rated_total_cooling_capacity_ratio_to_nominal = + inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "gross_total_cooling_capacity_fraction"); + input_specs.evaporator_air_flow_fraction = + inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "evaporator_air_flow_rate_fraction"); + input_specs.condenser_air_flow_fraction = + inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "condenser_air_flow_rate_fraction"); + input_specs.gross_rated_sensible_heat_ratio = inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "gross_sensible_heat_ratio"); + input_specs.gross_rated_cooling_COP = inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "gross_cooling_cop"); + input_specs.active_fraction_of_coil_face_area = + inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "active_fraction_of_coil_face_area"); + input_specs.rated_evaporator_fan_power_per_volume_flow_rate = + inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "2017_rated_evaporator_fan_power_per_volume_flow_rate"); + input_specs.rated_evaporator_fan_power_per_volume_flow_rate_2023 = + inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "2023_rated_evaporator_fan_power_per_volume_flow_rate"); + input_specs.rated_evaporative_condenser_pump_power_fraction = + inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "evaporative_condenser_pump_power_fraction"); + input_specs.evaporative_condenser_effectiveness = + inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "evaporative_condenser_effectiveness"); + input_specs.total_cooling_capacity_function_of_temperature_curve_name = + inputProcessor->getAlphaFieldValue(speedFields, speedSchemaProps, "total_cooling_capacity_modifier_function_of_temperature_curve_name"); + input_specs.total_cooling_capacity_function_of_air_flow_fraction_curve_name = inputProcessor->getAlphaFieldValue( + speedFields, speedSchemaProps, "total_cooling_capacity_modifier_function_of_air_flow_fraction_curve_name"); + input_specs.energy_input_ratio_function_of_temperature_curve_name = + inputProcessor->getAlphaFieldValue(speedFields, speedSchemaProps, "energy_input_ratio_modifier_function_of_temperature_curve_name"); + input_specs.energy_input_ratio_function_of_air_flow_fraction_curve_name = + inputProcessor->getAlphaFieldValue(speedFields, speedSchemaProps, "energy_input_ratio_modifier_function_of_air_flow_fraction_curve_name"); + input_specs.part_load_fraction_correlation_curve_name = + inputProcessor->getAlphaFieldValue(speedFields, speedSchemaProps, "part_load_fraction_correlation_curve_name"); + input_specs.rated_waste_heat_fraction_of_power_input = + inputProcessor->getRealFieldValue(speedFields, speedSchemaProps, "rated_waste_heat_fraction_of_power_input"); + input_specs.waste_heat_function_of_temperature_curve_name = + inputProcessor->getAlphaFieldValue(speedFields, speedSchemaProps, "waste_heat_modifier_function_of_temperature_curve_name"); + input_specs.sensible_heat_ratio_modifier_function_of_temperature_curve_name = + inputProcessor->getAlphaFieldValue(speedFields, speedSchemaProps, "sensible_heat_ratio_modifier_function_of_temperature_curve_name"); + input_specs.sensible_heat_ratio_modifier_function_of_flow_fraction_curve_name = + inputProcessor->getAlphaFieldValue(speedFields, speedSchemaProps, "sensible_heat_ratio_modifier_function_of_flow_fraction_curve_name"); this->instantiateFromInputSpec(state, input_specs); + inputProcessor->markObjectAsUsed(CoilCoolingDXCurveFitSpeed::object_name, speedInstance.key()); break; } diff --git a/src/EnergyPlus/CoolTower.cc b/src/EnergyPlus/CoolTower.cc index 1e2eced1df4..8d516a751c7 100644 --- a/src/EnergyPlus/CoolTower.cc +++ b/src/EnergyPlus/CoolTower.cc @@ -147,176 +147,160 @@ namespace CoolTower { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool ErrorsFound(false); // If errors detected in input - int NumAlphas; // Number of Alphas for each GetobjectItem call - int NumNumbers; // Number of Numbers for each GetobjectItem call - int NumArgs; - int IOStat; - Array1D_string cAlphaArgs; // Alpha input items for object - Array1D_string cAlphaFields; // Alpha field names - Array1D_string cNumericFields; // Numeric field names - Array1D rNumericArgs; // Numeric input items for object - Array1D_bool lAlphaBlanks; // Logical array, alpha field input BLANK = .TRUE. - Array1D_bool lNumericBlanks; // Logical array, numeric field input BLANK = .TRUE. - - // Initializations and allocations - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumArgs, NumAlphas, NumNumbers); - cAlphaArgs.allocate(NumAlphas); - cAlphaFields.allocate(NumAlphas); - cNumericFields.allocate(NumNumbers); - rNumericArgs.dimension(NumNumbers, 0.0); - lAlphaBlanks.dimension(NumAlphas, true); - lNumericBlanks.dimension(NumNumbers, true); - - auto &s_ipsc = state.dataIPShortCut; - - int NumCoolTowers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + int NumCoolTowers = inputProcessor->getNumObjectsFound(state, CurrentModuleObject); state.dataCoolTower->CoolTowerSys.allocate(NumCoolTowers); + auto const &objectSchemaProps = inputProcessor->getObjectSchemaProps(state, CurrentModuleObject); + auto const coolTowerObjects = inputProcessor->epJSON.find(CurrentModuleObject); // Obtain inputs - for (int CoolTowerNum = 1; CoolTowerNum <= NumCoolTowers; ++CoolTowerNum) { - - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - CoolTowerNum, - s_ipsc->cAlphaArgs, - NumAlphas, - s_ipsc->rNumericArgs, - NumNumbers, - IOStat, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - - ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; - - auto &coolTower = state.dataCoolTower->CoolTowerSys(CoolTowerNum); + if (coolTowerObjects != inputProcessor->epJSON.end()) { + int CoolTowerNum = 1; + for (auto const &coolTowerInstance : coolTowerObjects.value().items()) { + auto const &coolTowerFields = coolTowerInstance.value(); + auto const coolTowerName = Util::makeUPPER(coolTowerInstance.key()); + auto const availabilityScheduleName = + inputProcessor->getAlphaFieldValue(coolTowerFields, objectSchemaProps, "availability_schedule_name"); + auto const zoneOrSpaceName = inputProcessor->getAlphaFieldValue(coolTowerFields, objectSchemaProps, "zone_or_space_name"); + auto const waterSupplyStorageTankName = + inputProcessor->getAlphaFieldValue(coolTowerFields, objectSchemaProps, "water_supply_storage_tank_name"); + auto const flowControlType = inputProcessor->getAlphaFieldValue(coolTowerFields, objectSchemaProps, "flow_control_type"); + auto const pumpFlowRateScheduleName = + inputProcessor->getAlphaFieldValue(coolTowerFields, objectSchemaProps, "pump_flow_rate_schedule_name"); + + inputProcessor->markObjectAsUsed(CurrentModuleObject, coolTowerInstance.key()); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, coolTowerName}; + + auto &coolTower = state.dataCoolTower->CoolTowerSys(CoolTowerNum); + + coolTower.Name = coolTowerName; // Name of cooltower + if (availabilityScheduleName.empty()) { + coolTower.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((coolTower.availSched = Sched::GetSchedule(state, availabilityScheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Availability Schedule Name", availabilityScheduleName); + ErrorsFound = true; + } - coolTower.Name = s_ipsc->cAlphaArgs(1); // Name of cooltower - if (lAlphaBlanks(2)) { - coolTower.availSched = Sched::GetScheduleAlwaysOn(state); - } else if ((coolTower.availSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(2), s_ipsc->cAlphaArgs(2)); - ErrorsFound = true; - } + if (zoneOrSpaceName.empty()) { + ShowSevereEmptyField(state, eoh, "Zone or Space Name"); + ErrorsFound = true; + } else if ((coolTower.ZonePtr = Util::FindItemInList(zoneOrSpaceName, state.dataHeatBal->Zone)) == 0 && + (coolTower.spacePtr = Util::FindItemInList(zoneOrSpaceName, state.dataHeatBal->space)) == 0) { + ShowSevereItemNotFound(state, eoh, "Zone or Space Name", zoneOrSpaceName); + ErrorsFound = true; + } else if (coolTower.ZonePtr == 0) { + coolTower.ZonePtr = state.dataHeatBal->space(coolTower.spacePtr).zoneNum; + } - if (lAlphaBlanks(3)) { - ShowSevereEmptyField(state, eoh, cAlphaFields(3)); - ErrorsFound = true; - } else if ((coolTower.ZonePtr = Util::FindItemInList(s_ipsc->cAlphaArgs(3), state.dataHeatBal->Zone)) == 0 && - (coolTower.spacePtr = Util::FindItemInList(s_ipsc->cAlphaArgs(3), state.dataHeatBal->space)) == 0) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(3), s_ipsc->cAlphaArgs(3)); - ErrorsFound = true; - } else if (coolTower.ZonePtr == 0) { - coolTower.ZonePtr = state.dataHeatBal->space(coolTower.spacePtr).zoneNum; - } + coolTower.CoolTWaterSupplyName = waterSupplyStorageTankName; // Name of water storage tank + if (waterSupplyStorageTankName.empty()) { + coolTower.CoolTWaterSupplyMode = WaterSupplyMode::FromMains; + } else if (coolTower.CoolTWaterSupplyMode == WaterSupplyMode::FromTank) { + WaterManager::SetupTankDemandComponent(state, + coolTower.Name, + CurrentModuleObject, + coolTower.CoolTWaterSupplyName, + ErrorsFound, + coolTower.CoolTWaterSupTankID, + coolTower.CoolTWaterTankDemandARRID); + } - coolTower.CoolTWaterSupplyName = s_ipsc->cAlphaArgs(4); // Name of water storage tank - if (lAlphaBlanks(4)) { - coolTower.CoolTWaterSupplyMode = WaterSupplyMode::FromMains; - } else if (coolTower.CoolTWaterSupplyMode == WaterSupplyMode::FromTank) { - WaterManager::SetupTankDemandComponent(state, - coolTower.Name, - CurrentModuleObject, - coolTower.CoolTWaterSupplyName, - ErrorsFound, - coolTower.CoolTWaterSupTankID, - coolTower.CoolTWaterTankDemandARRID); - } + coolTower.FlowCtrlType = static_cast(getEnumValue(FlowCtrlNamesUC, flowControlType)); // Type of flow control + if (coolTower.FlowCtrlType == FlowCtrl::Invalid) { + ShowSevereInvalidKey(state, eoh, "Flow Control Type", flowControlType); + ErrorsFound = true; + } - coolTower.FlowCtrlType = static_cast(getEnumValue(FlowCtrlNamesUC, s_ipsc->cAlphaArgs(5))); // Type of flow control - if (coolTower.FlowCtrlType == FlowCtrl::Invalid) { - ShowSevereInvalidKey(state, eoh, cAlphaFields(5), s_ipsc->cAlphaArgs(5)); - ErrorsFound = true; - } + if ((coolTower.pumpSched = Sched::GetSchedule(state, pumpFlowRateScheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Pump Flow Rate Schedule Name", pumpFlowRateScheduleName); + ErrorsFound = true; + } - if ((coolTower.pumpSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(6))) == nullptr) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(6), s_ipsc->cAlphaArgs(6)); - ErrorsFound = true; - } + coolTower.MaxWaterFlowRate = inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "maximum_water_flow_rate"); + if (coolTower.MaxWaterFlowRate > MaximumWaterFlowRate) { + coolTower.MaxWaterFlowRate = MaximumWaterFlowRate; + ShowWarningBadMax(state, eoh, "Maximum Water Flow Rate", coolTower.MaxWaterFlowRate, Clusive::In, MaximumWaterFlowRate); + } + if (coolTower.MaxWaterFlowRate < MinimumWaterFlowRate) { + coolTower.MaxWaterFlowRate = MinimumWaterFlowRate; + ShowWarningBadMin(state, eoh, "Maximum Water Flow Rate", coolTower.MaxWaterFlowRate, Clusive::In, MinimumWaterFlowRate); + } - coolTower.MaxWaterFlowRate = s_ipsc->rNumericArgs(1); // Maximum limit of water supply - if (coolTower.MaxWaterFlowRate > MaximumWaterFlowRate) { - coolTower.MaxWaterFlowRate = MaximumWaterFlowRate; - ShowWarningBadMax(state, eoh, cNumericFields(1), s_ipsc->rNumericArgs(1), Clusive::In, MaximumWaterFlowRate); - } - if (coolTower.MaxWaterFlowRate < MinimumWaterFlowRate) { - coolTower.MaxWaterFlowRate = MinimumWaterFlowRate; - ShowWarningBadMin(state, eoh, cNumericFields(1), s_ipsc->rNumericArgs(1), Clusive::In, MinimumWaterFlowRate); - } + coolTower.TowerHeight = + inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "effective_tower_height"); // Get effective tower height + if (coolTower.TowerHeight > MaxHeight) { + coolTower.TowerHeight = MaxHeight; + ShowWarningBadMax(state, eoh, "Effective Tower Height", coolTower.TowerHeight, Clusive::In, MaxHeight); + } - coolTower.TowerHeight = s_ipsc->rNumericArgs(2); // Get effective tower height - if (coolTower.TowerHeight > MaxHeight) { - coolTower.TowerHeight = MaxHeight; - ShowWarningBadMax(state, eoh, cNumericFields(2), s_ipsc->rNumericArgs(2), Clusive::In, MaxHeight); - } + if (coolTower.TowerHeight < MinHeight) { + coolTower.TowerHeight = MinHeight; + ShowWarningBadMin(state, eoh, "Effective Tower Height", coolTower.TowerHeight, Clusive::In, MinHeight); + } - if (coolTower.TowerHeight < MinHeight) { - coolTower.TowerHeight = MinHeight; - ShowWarningBadMin(state, eoh, cNumericFields(2), s_ipsc->rNumericArgs(2), Clusive::In, MinHeight); - } + coolTower.OutletArea = + inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "airflow_outlet_area"); // Get outlet area + if (coolTower.OutletArea > MaxValue) { + coolTower.OutletArea = MaxValue; + ShowWarningBadMax(state, eoh, "Airflow Outlet Area", coolTower.OutletArea, Clusive::In, MaxValue); + } + if (coolTower.OutletArea < MinValue) { + coolTower.OutletArea = MinValue; + ShowWarningBadMin(state, eoh, "Airflow Outlet Area", coolTower.OutletArea, Clusive::In, MinValue); + } - coolTower.OutletArea = s_ipsc->rNumericArgs(3); // Get outlet area - if (coolTower.OutletArea > MaxValue) { - coolTower.OutletArea = MaxValue; - ShowWarningBadMax(state, eoh, cNumericFields(3), s_ipsc->rNumericArgs(3), Clusive::In, MaxValue); - } - if (coolTower.OutletArea < MinValue) { - coolTower.OutletArea = MinValue; - ShowWarningBadMin(state, eoh, cNumericFields(3), s_ipsc->rNumericArgs(3), Clusive::In, MinValue); - } + coolTower.MaxAirVolFlowRate = inputProcessor->getRealFieldValue( + coolTowerFields, objectSchemaProps, "maximum_air_flow_rate"); // Maximum limit of air flow to the space + if (coolTower.MaxAirVolFlowRate > MaxValue) { + coolTower.MaxAirVolFlowRate = MaxValue; + ShowWarningBadMax(state, eoh, "Maximum Air Flow Rate", coolTower.MaxAirVolFlowRate, Clusive::In, MaxValue); + } + if (coolTower.MaxAirVolFlowRate < MinValue) { + coolTower.MaxAirVolFlowRate = MinValue; + ShowWarningBadMin(state, eoh, "Maximum Air Flow Rate", coolTower.MaxAirVolFlowRate, Clusive::In, MinValue); + } - coolTower.MaxAirVolFlowRate = s_ipsc->rNumericArgs(4); // Maximum limit of air flow to the space - if (coolTower.MaxAirVolFlowRate > MaxValue) { - coolTower.MaxAirVolFlowRate = MaxValue; - ShowWarningBadMax(state, eoh, cNumericFields(4), s_ipsc->rNumericArgs(4), Clusive::In, MaxValue); - } - if (coolTower.MaxAirVolFlowRate < MinValue) { - coolTower.MaxAirVolFlowRate = MinValue; - ShowWarningBadMin(state, eoh, cNumericFields(4), s_ipsc->rNumericArgs(4), Clusive::In, MinValue); - } + coolTower.MinZoneTemp = inputProcessor->getRealFieldValue( + coolTowerFields, objectSchemaProps, "minimum_indoor_temperature"); // Get minimum temp limit which gets this cooltower off + if (coolTower.MinZoneTemp > MaxValue) { + coolTower.MinZoneTemp = MaxValue; + ShowWarningBadMax(state, eoh, "Minimum Indoor Temperature", coolTower.MinZoneTemp, Clusive::In, MaxValue); + } + if (coolTower.MinZoneTemp < MinValue) { + coolTower.MinZoneTemp = MinValue; + ShowWarningBadMin(state, eoh, "Minimum Indoor Temperature", coolTower.MinZoneTemp, Clusive::In, MinValue); + } - coolTower.MinZoneTemp = s_ipsc->rNumericArgs(5); // Get minimum temp limit which gets this cooltower off - if (coolTower.MinZoneTemp > MaxValue) { - coolTower.MinZoneTemp = MaxValue; - ShowWarningBadMax(state, eoh, cNumericFields(5), s_ipsc->rNumericArgs(5), Clusive::In, MaxValue); - } - if (coolTower.MinZoneTemp < MinValue) { - coolTower.MinZoneTemp = MinValue; - ShowWarningBadMin(state, eoh, cNumericFields(5), s_ipsc->rNumericArgs(5), Clusive::In, MinValue); - } + coolTower.FracWaterLoss = + inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "fraction_of_water_loss"); // Fraction of water loss + if (coolTower.FracWaterLoss > MaxFrac) { + coolTower.FracWaterLoss = MaxFrac; + ShowWarningBadMax(state, eoh, "Fraction of Water Loss", coolTower.FracWaterLoss, Clusive::In, MaxFrac); + } + if (coolTower.FracWaterLoss < MinFrac) { + coolTower.FracWaterLoss = MinFrac; + ShowWarningBadMin(state, eoh, "Fraction of Water Loss", coolTower.FracWaterLoss, Clusive::In, MinFrac); + } - coolTower.FracWaterLoss = s_ipsc->rNumericArgs(6); // Fraction of water loss - if (coolTower.FracWaterLoss > MaxFrac) { - coolTower.FracWaterLoss = MaxFrac; - ShowWarningBadMax(state, eoh, cNumericFields(6), s_ipsc->rNumericArgs(6), Clusive::In, MaxFrac); - } - if (coolTower.FracWaterLoss < MinFrac) { - coolTower.FracWaterLoss = MinFrac; - ShowWarningBadMin(state, eoh, cNumericFields(6), s_ipsc->rNumericArgs(6), Clusive::In, MinFrac); - } + coolTower.FracFlowSched = inputProcessor->getRealFieldValue( + coolTowerFields, objectSchemaProps, "fraction_of_flow_schedule"); // Fraction of loss of air flow + if (coolTower.FracFlowSched > MaxFrac) { + coolTower.FracFlowSched = MaxFrac; + ShowWarningBadMax(state, eoh, "Fraction of Flow Schedule", coolTower.FracFlowSched, Clusive::In, MaxFrac); + } + if (coolTower.FracFlowSched < MinFrac) { + coolTower.FracFlowSched = MinFrac; + ShowWarningBadMin(state, eoh, "Fraction of Flow Schedule", coolTower.FracFlowSched, Clusive::In, MinFrac); + } - coolTower.FracFlowSched = s_ipsc->rNumericArgs(7); // Fraction of loss of air flow - if (coolTower.FracFlowSched > MaxFrac) { - coolTower.FracFlowSched = MaxFrac; - ShowWarningBadMax(state, eoh, cNumericFields(7), s_ipsc->rNumericArgs(7), Clusive::In, MaxFrac); - } - if (coolTower.FracFlowSched < MinFrac) { - coolTower.FracFlowSched = MinFrac; - ShowWarningBadMin(state, eoh, cNumericFields(7), s_ipsc->rNumericArgs(7), Clusive::In, MinFrac); + coolTower.RatedPumpPower = + inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "rated_power_consumption"); // Get rated pump power + ++CoolTowerNum; } - - coolTower.RatedPumpPower = s_ipsc->rNumericArgs(8); // Get rated pump power } - cAlphaArgs.deallocate(); - cAlphaFields.deallocate(); - cNumericFields.deallocate(); - rNumericArgs.deallocate(); - lAlphaBlanks.deallocate(); - lNumericBlanks.deallocate(); - if (ErrorsFound) { ShowFatalError(state, EnergyPlus::format("{} errors occurred in input. Program terminates.", CurrentModuleObject)); } diff --git a/src/EnergyPlus/DemandManager.cc b/src/EnergyPlus/DemandManager.cc index 23b4d29d2ff..363d7d3f001 100644 --- a/src/EnergyPlus/DemandManager.cc +++ b/src/EnergyPlus/DemandManager.cc @@ -670,7 +670,7 @@ void GetDemandManagerInput(EnergyPlusData &state) demandMgr.Load.allocate(demandMgr.NumOfLoads); for (int LoadNum = 1; LoadNum <= demandMgr.NumOfLoads; ++LoadNum) { - int LoadPtr = Util::FindItemInList(AlphArray(LoadNum + 4), state.dataExteriorEnergyUse->ExteriorLights); + int LoadPtr = Util::FindItemInList(Util::makeUPPER(AlphArray(LoadNum + 4)), state.dataExteriorEnergyUse->ExteriorLights); if (LoadPtr > 0) { demandMgr.Load(LoadNum) = LoadPtr; diff --git a/src/EnergyPlus/ExteriorEnergyUse.cc b/src/EnergyPlus/ExteriorEnergyUse.cc index 02f2cc1ca20..a9a2640b497 100644 --- a/src/EnergyPlus/ExteriorEnergyUse.cc +++ b/src/EnergyPlus/ExteriorEnergyUse.cc @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -112,13 +111,9 @@ namespace ExteriorEnergyUse { std::string_view constexpr routineName = "GetExteriorEnergyUseInput"; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumNumbers; // Number of Numbers for each GetObjectItem call - int IOStatus; // Used in GetObjectItem bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine std::string EndUseSubcategoryName; - - auto &s_ipsc = state.dataIPShortCut; + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); state.dataExteriorEnergyUse->NumExteriorLights = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Exterior:Lights"); state.dataExteriorEnergyUse->ExteriorLights.allocate(state.dataExteriorEnergyUse->NumExteriorLights); @@ -132,105 +127,105 @@ namespace ExteriorEnergyUse { state.dataExteriorEnergyUse->NumExteriorEqs = 0; // ================================= Get Exterior Lights - std::string_view cCurrentModuleObject = "Exterior:Lights"; - for (int Item = 1; Item <= state.dataExteriorEnergyUse->NumExteriorLights; ++Item) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - Item, - s_ipsc->cAlphaArgs, - NumAlphas, - s_ipsc->rNumericArgs, - NumNumbers, - IOStatus, - s_ipsc->lNumericFieldBlanks, - s_ipsc->lAlphaFieldBlanks, - s_ipsc->cAlphaFieldNames, - s_ipsc->cNumericFieldNames); - - ErrorObjectHeader eoh{routineName, cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; - - state.dataExteriorEnergyUse->ExteriorLights(Item).Name = s_ipsc->cAlphaArgs(1); - - if (s_ipsc->lAlphaFieldBlanks(2)) { - ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); - ErrorsFound = true; - } else if ((state.dataExteriorEnergyUse->ExteriorLights(Item).sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { - ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); - ErrorsFound = true; - } else if (int SchMin = state.dataExteriorEnergyUse->ExteriorLights(Item).sched->getMinVal(state); SchMin < 0.0) { - ShowSevereCustom( - state, - eoh, - EnergyPlus::format( - "{} = {} minimum is [{:.1R}]. Values must be >= 0.0.", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), SchMin)); - ErrorsFound = true; - } + std::string cCurrentModuleObject = "Exterior:Lights"; + auto const &exteriorLightsSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); + auto const exteriorLightsObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + if (exteriorLightsObjects != inputProcessor->epJSON.end()) { + int Item = 1; + for (auto const &lightInstance : exteriorLightsObjects.value().items()) { + auto const &lightFields = lightInstance.value(); + auto const lightName = Util::makeUPPER(lightInstance.key()); + auto const scheduleName = inputProcessor->getAlphaFieldValue(lightFields, exteriorLightsSchemaProps, "schedule_name"); + auto const controlOption = lightFields.contains("control_option") + ? inputProcessor->getAlphaFieldValue(lightFields, exteriorLightsSchemaProps, "control_option") + : std::string(); + + inputProcessor->markObjectAsUsed(cCurrentModuleObject, lightInstance.key()); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, lightName}; + + state.dataExteriorEnergyUse->ExteriorLights(Item).Name = lightName; + + if (scheduleName.empty()) { + ShowSevereEmptyField(state, eoh, "schedule_name"); + ErrorsFound = true; + } else if ((state.dataExteriorEnergyUse->ExteriorLights(Item).sched = Sched::GetSchedule(state, scheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "schedule_name", scheduleName); + ErrorsFound = true; + } else if (int SchMin = state.dataExteriorEnergyUse->ExteriorLights(Item).sched->getMinVal(state); SchMin < 0.0) { + ShowSevereCustom( + state, eoh, EnergyPlus::format("{} = {} minimum is [{:.1R}]. Values must be >= 0.0.", "schedule_name", scheduleName, SchMin)); + ErrorsFound = true; + } - if (s_ipsc->lAlphaFieldBlanks(3)) { - state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode = ExteriorEnergyUse::LightControlType::ScheduleOnly; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "ScheduleNameOnly")) { - state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode = ExteriorEnergyUse::LightControlType::ScheduleOnly; - } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(3), "AstronomicalClock")) { - state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode = ExteriorEnergyUse::LightControlType::AstroClockOverride; - } else { - ShowSevereInvalidKey(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)); - } + if (controlOption.empty()) { + state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode = ExteriorEnergyUse::LightControlType::ScheduleOnly; + } else if (Util::SameString(controlOption, "ScheduleNameOnly")) { + state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode = ExteriorEnergyUse::LightControlType::ScheduleOnly; + } else if (Util::SameString(controlOption, "AstronomicalClock")) { + state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode = ExteriorEnergyUse::LightControlType::AstroClockOverride; + } else { + ShowSevereInvalidKey(state, eoh, "control_option", controlOption); + } - if (NumAlphas > 3) { - EndUseSubcategoryName = state.dataIPShortCut->cAlphaArgs(4); - } else { - EndUseSubcategoryName = "General"; - } + if (lightFields.find("end_use_subcategory") != lightFields.end()) { + EndUseSubcategoryName = inputProcessor->getAlphaFieldValue(lightFields, exteriorLightsSchemaProps, "end_use_subcategory"); + } else { + EndUseSubcategoryName = "General"; + } - state.dataExteriorEnergyUse->ExteriorLights(Item).DesignLevel = state.dataIPShortCut->rNumericArgs(1); - if (state.dataGlobal->AnyEnergyManagementSystemInModel) { - SetupEMSActuator(state, - "ExteriorLights", - state.dataExteriorEnergyUse->ExteriorLights(Item).Name, - "Electricity Rate", - "W", - state.dataExteriorEnergyUse->ExteriorLights(Item).PowerActuatorOn, - state.dataExteriorEnergyUse->ExteriorLights(Item).PowerActuatorValue); - } + state.dataExteriorEnergyUse->ExteriorLights(Item).DesignLevel = + inputProcessor->getRealFieldValue(lightFields, exteriorLightsSchemaProps, "design_level"); + if (state.dataGlobal->AnyEnergyManagementSystemInModel) { + SetupEMSActuator(state, + "ExteriorLights", + state.dataExteriorEnergyUse->ExteriorLights(Item).Name, + "Electricity Rate", + "W", + state.dataExteriorEnergyUse->ExteriorLights(Item).PowerActuatorOn, + state.dataExteriorEnergyUse->ExteriorLights(Item).PowerActuatorValue); + } + + SetupOutputVariable(state, + "Exterior Lights Electricity Rate", + Constant::Units::W, + state.dataExteriorEnergyUse->ExteriorLights(Item).Power, + OutputProcessor::TimeStepType::Zone, + OutputProcessor::StoreType::Average, + state.dataExteriorEnergyUse->ExteriorLights(Item).Name); + + SetupOutputVariable(state, + "Exterior Lights Electricity Energy", + Constant::Units::J, + state.dataExteriorEnergyUse->ExteriorLights(Item).CurrentUse, + OutputProcessor::TimeStepType::Zone, + OutputProcessor::StoreType::Sum, + state.dataExteriorEnergyUse->ExteriorLights(Item).Name, + Constant::eResource::Electricity, + OutputProcessor::Group::Invalid, + OutputProcessor::EndUseCat::ExteriorLights, + EndUseSubcategoryName); - SetupOutputVariable(state, - "Exterior Lights Electricity Rate", - Constant::Units::W, - state.dataExteriorEnergyUse->ExteriorLights(Item).Power, - OutputProcessor::TimeStepType::Zone, - OutputProcessor::StoreType::Average, - state.dataExteriorEnergyUse->ExteriorLights(Item).Name); - - SetupOutputVariable(state, - "Exterior Lights Electricity Energy", - Constant::Units::J, - state.dataExteriorEnergyUse->ExteriorLights(Item).CurrentUse, - OutputProcessor::TimeStepType::Zone, - OutputProcessor::StoreType::Sum, - state.dataExteriorEnergyUse->ExteriorLights(Item).Name, - Constant::eResource::Electricity, - OutputProcessor::Group::Invalid, - OutputProcessor::EndUseCat::ExteriorLights, - EndUseSubcategoryName); - - // entries for predefined tables - PreDefTableEntry(state, - state.dataOutRptPredefined->pdchExLtPower, - state.dataExteriorEnergyUse->ExteriorLights(Item).Name, - state.dataExteriorEnergyUse->ExteriorLights(Item).DesignLevel); - state.dataExteriorEnergyUse->sumDesignLevel += state.dataExteriorEnergyUse->ExteriorLights(Item).DesignLevel; - if (state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode == - ExteriorEnergyUse::LightControlType::AstroClockOverride) { // photocell/schedule - PreDefTableEntry( - state, state.dataOutRptPredefined->pdchExLtClock, state.dataExteriorEnergyUse->ExteriorLights(Item).Name, "AstronomicalClock"); - PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtSchd, state.dataExteriorEnergyUse->ExteriorLights(Item).Name, "-"); - } else { - PreDefTableEntry( - state, state.dataOutRptPredefined->pdchExLtClock, state.dataExteriorEnergyUse->ExteriorLights(Item).Name, "Schedule"); PreDefTableEntry(state, - state.dataOutRptPredefined->pdchExLtSchd, + state.dataOutRptPredefined->pdchExLtPower, state.dataExteriorEnergyUse->ExteriorLights(Item).Name, - state.dataExteriorEnergyUse->ExteriorLights(Item).sched->Name); + state.dataExteriorEnergyUse->ExteriorLights(Item).DesignLevel); + state.dataExteriorEnergyUse->sumDesignLevel += state.dataExteriorEnergyUse->ExteriorLights(Item).DesignLevel; + if (state.dataExteriorEnergyUse->ExteriorLights(Item).ControlMode == ExteriorEnergyUse::LightControlType::AstroClockOverride) { + PreDefTableEntry(state, + state.dataOutRptPredefined->pdchExLtClock, + state.dataExteriorEnergyUse->ExteriorLights(Item).Name, + "AstronomicalClock"); + PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtSchd, state.dataExteriorEnergyUse->ExteriorLights(Item).Name, "-"); + } else { + PreDefTableEntry( + state, state.dataOutRptPredefined->pdchExLtClock, state.dataExteriorEnergyUse->ExteriorLights(Item).Name, "Schedule"); + PreDefTableEntry(state, + state.dataOutRptPredefined->pdchExLtSchd, + state.dataExteriorEnergyUse->ExteriorLights(Item).Name, + state.dataExteriorEnergyUse->ExteriorLights(Item).sched->Name); + } + ++Item; } } PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtPower, "Exterior Lighting Total", state.dataExteriorEnergyUse->sumDesignLevel); @@ -238,190 +233,169 @@ namespace ExteriorEnergyUse { // ================================= Get Exterior Fuel Equipment cCurrentModuleObject = "Exterior:FuelEquipment"; - for (int Item = 1; Item <= NumFuelEq; ++Item) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - Item, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNumbers, - IOStatus, - state.dataIPShortCut->lNumericFieldBlanks, - state.dataIPShortCut->lAlphaFieldBlanks, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); - GlobalNames::VerifyUniqueInterObjectName(state, - state.dataExteriorEnergyUse->UniqueExteriorEquipNames, - state.dataIPShortCut->cAlphaArgs(1), - cCurrentModuleObject, - state.dataIPShortCut->cAlphaFieldNames(1), - ErrorsFound); - - ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; - - ++state.dataExteriorEnergyUse->NumExteriorEqs; - - auto &exteriorEquip = state.dataExteriorEnergyUse->ExteriorEquipment(state.dataExteriorEnergyUse->NumExteriorEqs); - exteriorEquip.Name = state.dataIPShortCut->cAlphaArgs(1); - - if (NumAlphas > 3) { - EndUseSubcategoryName = state.dataIPShortCut->cAlphaArgs(4); - } else { - EndUseSubcategoryName = "General"; + auto const &exteriorFuelSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); + auto const exteriorFuelObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + if (exteriorFuelObjects != inputProcessor->epJSON.end()) { + for (auto const &fuelEquipInstance : exteriorFuelObjects.value().items()) { + auto const &fuelEquipFields = fuelEquipInstance.value(); + auto const equipName = Util::makeUPPER(fuelEquipInstance.key()); + auto const fuelUseType = inputProcessor->getAlphaFieldValue(fuelEquipFields, exteriorFuelSchemaProps, "fuel_use_type"); + auto const scheduleName = inputProcessor->getAlphaFieldValue(fuelEquipFields, exteriorFuelSchemaProps, "schedule_name"); + + inputProcessor->markObjectAsUsed(cCurrentModuleObject, fuelEquipInstance.key()); + GlobalNames::VerifyUniqueInterObjectName( + state, state.dataExteriorEnergyUse->UniqueExteriorEquipNames, equipName, cCurrentModuleObject, "Name", ErrorsFound); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, equipName}; + + ++state.dataExteriorEnergyUse->NumExteriorEqs; + + auto &exteriorEquip = state.dataExteriorEnergyUse->ExteriorEquipment(state.dataExteriorEnergyUse->NumExteriorEqs); + exteriorEquip.Name = equipName; + + if (fuelEquipFields.find("end_use_subcategory") != fuelEquipFields.end()) { + EndUseSubcategoryName = inputProcessor->getAlphaFieldValue(fuelEquipFields, exteriorFuelSchemaProps, "end_use_subcategory"); + } else { + EndUseSubcategoryName = "General"; + } + + if (fuelUseType.empty()) { + ShowSevereEmptyField(state, eoh, "fuel_use_type"); + ErrorsFound = true; + } else if ((exteriorEquip.FuelType = static_cast(getEnumValue(Constant::eFuelNamesUC, fuelUseType))) == + Constant::eFuel::Invalid) { + ShowSevereInvalidKey(state, eoh, "fuel_use_type", fuelUseType); + ErrorsFound = true; + } else if (exteriorEquip.FuelType != Constant::eFuel::Water) { + SetupOutputVariable(state, + "Exterior Equipment Fuel Rate", + Constant::Units::W, + exteriorEquip.Power, + OutputProcessor::TimeStepType::Zone, + OutputProcessor::StoreType::Average, + exteriorEquip.Name); + SetupOutputVariable(state, + EnergyPlus::format("Exterior Equipment {} Energy", Constant::eFuelNames[(int)exteriorEquip.FuelType]), + Constant::Units::J, + exteriorEquip.CurrentUse, + OutputProcessor::TimeStepType::Zone, + OutputProcessor::StoreType::Sum, + exteriorEquip.Name, + Constant::eFuel2eResource[(int)exteriorEquip.FuelType], + OutputProcessor::Group::Invalid, + OutputProcessor::EndUseCat::ExteriorEquipment, + EndUseSubcategoryName); + } else { + SetupOutputVariable(state, + "Exterior Equipment Water Volume Flow Rate", + Constant::Units::m3_s, + exteriorEquip.Power, + OutputProcessor::TimeStepType::Zone, + OutputProcessor::StoreType::Average, + exteriorEquip.Name); + SetupOutputVariable(state, + EnergyPlus::format("Exterior Equipment {} Volume", Constant::eFuelNames[(int)exteriorEquip.FuelType]), + Constant::Units::m3, + exteriorEquip.CurrentUse, + OutputProcessor::TimeStepType::Zone, + OutputProcessor::StoreType::Sum, + exteriorEquip.Name, + Constant::eFuel2eResource[(int)exteriorEquip.FuelType], + OutputProcessor::Group::Invalid, + OutputProcessor::EndUseCat::ExteriorEquipment, + EndUseSubcategoryName); + } + + if (scheduleName.empty()) { + ShowSevereEmptyField(state, eoh, "schedule_name"); + ErrorsFound = true; + } else if ((exteriorEquip.sched = Sched::GetSchedule(state, scheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "schedule_name", scheduleName); + ErrorsFound = true; + } else if (int SchMin = exteriorEquip.sched->getMinVal(state); SchMin < 0.0) { + ShowSevereCustom( + state, eoh, EnergyPlus::format("{} = {} minimum is [{:.1R}]. Values must be >= 0.0.", "schedule_name", scheduleName, SchMin)); + ErrorsFound = true; + } + exteriorEquip.DesignLevel = inputProcessor->getRealFieldValue(fuelEquipFields, exteriorFuelSchemaProps, "design_level"); } + } + + // ================================= Get Exterior Water Equipment + + cCurrentModuleObject = "Exterior:WaterEquipment"; + auto const &exteriorWaterSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); + auto const exteriorWaterObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + if (exteriorWaterObjects != inputProcessor->epJSON.end()) { + for (auto const &waterEquipInstance : exteriorWaterObjects.value().items()) { + auto const &waterEquipFields = waterEquipInstance.value(); + auto const equipName = Util::makeUPPER(waterEquipInstance.key()); + auto const scheduleName = inputProcessor->getAlphaFieldValue(waterEquipFields, exteriorWaterSchemaProps, "schedule_name"); + + inputProcessor->markObjectAsUsed(cCurrentModuleObject, waterEquipInstance.key()); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, equipName}; + + GlobalNames::VerifyUniqueInterObjectName( + state, state.dataExteriorEnergyUse->UniqueExteriorEquipNames, equipName, cCurrentModuleObject, "Name", ErrorsFound); + + ++state.dataExteriorEnergyUse->NumExteriorEqs; + + auto &exteriorEquip = state.dataExteriorEnergyUse->ExteriorEquipment(state.dataExteriorEnergyUse->NumExteriorEqs); + exteriorEquip.Name = equipName; + exteriorEquip.FuelType = Constant::eFuel::Water; + + if (scheduleName.empty()) { + ShowSevereEmptyField(state, eoh, "schedule_name"); + ErrorsFound = true; + } else if ((exteriorEquip.sched = Sched::GetSchedule(state, scheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "schedule_name", scheduleName); + ErrorsFound = true; + } else if (int SchMin = exteriorEquip.sched->getMinVal(state); SchMin < 0.0) { + ShowSevereCustom( + state, eoh, EnergyPlus::format("{} = {} minimum is [{:.1R}]. Values must be >= 0.0.", "schedule_name", scheduleName, SchMin)); + ErrorsFound = true; + } - if (state.dataIPShortCut->lAlphaFieldBlanks(2)) { - ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); - ErrorsFound = true; + if (waterEquipFields.find("end_use_subcategory") != waterEquipFields.end()) { + EndUseSubcategoryName = inputProcessor->getAlphaFieldValue(waterEquipFields, exteriorWaterSchemaProps, "end_use_subcategory"); + } else { + EndUseSubcategoryName = "General"; + } - } else if ((exteriorEquip.FuelType = static_cast(getEnumValue(Constant::eFuelNamesUC, s_ipsc->cAlphaArgs(2)))) == - Constant::eFuel::Invalid) { - ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); - ErrorsFound = true; + exteriorEquip.DesignLevel = inputProcessor->getRealFieldValue(waterEquipFields, exteriorWaterSchemaProps, "design_level"); - } else if (exteriorEquip.FuelType != Constant::eFuel::Water) { SetupOutputVariable(state, - "Exterior Equipment Fuel Rate", - Constant::Units::W, + "Exterior Equipment Water Volume Flow Rate", + Constant::Units::m3_s, exteriorEquip.Power, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Average, exteriorEquip.Name); + SetupOutputVariable(state, - EnergyPlus::format("Exterior Equipment {} Energy", Constant::eFuelNames[(int)exteriorEquip.FuelType]), - Constant::Units::J, + "Exterior Equipment Water Volume", + Constant::Units::m3, exteriorEquip.CurrentUse, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Sum, exteriorEquip.Name, - Constant::eFuel2eResource[(int)exteriorEquip.FuelType], + Constant::eResource::Water, OutputProcessor::Group::Invalid, OutputProcessor::EndUseCat::ExteriorEquipment, EndUseSubcategoryName); - } else { SetupOutputVariable(state, - "Exterior Equipment Water Volume Flow Rate", - Constant::Units::m3_s, - exteriorEquip.Power, - OutputProcessor::TimeStepType::Zone, - OutputProcessor::StoreType::Average, - exteriorEquip.Name); - SetupOutputVariable(state, - EnergyPlus::format("Exterior Equipment {} Volume", Constant::eFuelNames[(int)exteriorEquip.FuelType]), + "Exterior Equipment Mains Water Volume", Constant::Units::m3, exteriorEquip.CurrentUse, OutputProcessor::TimeStepType::Zone, OutputProcessor::StoreType::Sum, exteriorEquip.Name, - Constant::eFuel2eResource[(int)exteriorEquip.FuelType], + Constant::eResource::MainsWater, OutputProcessor::Group::Invalid, OutputProcessor::EndUseCat::ExteriorEquipment, EndUseSubcategoryName); } - - if (s_ipsc->lAlphaFieldBlanks(3)) { - ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(3)); - ErrorsFound = true; - } else if ((exteriorEquip.sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { - ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); - ErrorsFound = true; - } else if (int SchMin = exteriorEquip.sched->getMinVal(state); SchMin < 0.0) { - ShowSevereCustom( - state, - eoh, - EnergyPlus::format( - "{} = {} minimum is [{:.1R}]. Values must be >= 0.0.", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), SchMin)); - ErrorsFound = true; - } - exteriorEquip.DesignLevel = s_ipsc->rNumericArgs(1); - } - - // ================================= Get Exterior Water Equipment - - cCurrentModuleObject = "Exterior:WaterEquipment"; - for (int Item = 1; Item <= NumWtrEq; ++Item) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - Item, - s_ipsc->cAlphaArgs, - NumAlphas, - s_ipsc->rNumericArgs, - NumNumbers, - IOStatus, - s_ipsc->lNumericFieldBlanks, - s_ipsc->lAlphaFieldBlanks, - s_ipsc->cAlphaFieldNames, - s_ipsc->cNumericFieldNames); - - ErrorObjectHeader eoh{routineName, cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; - - GlobalNames::VerifyUniqueInterObjectName(state, - state.dataExteriorEnergyUse->UniqueExteriorEquipNames, - s_ipsc->cAlphaArgs(1), - cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - ErrorsFound); - - ++state.dataExteriorEnergyUse->NumExteriorEqs; - - auto &exteriorEquip = state.dataExteriorEnergyUse->ExteriorEquipment(state.dataExteriorEnergyUse->NumExteriorEqs); - exteriorEquip.Name = s_ipsc->cAlphaArgs(1); - exteriorEquip.FuelType = Constant::eFuel::Water; - - if (s_ipsc->lAlphaFieldBlanks(3)) { - ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(3)); - ErrorsFound = true; - } else if ((exteriorEquip.sched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(3))) == nullptr) { - ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); - ErrorsFound = true; - } else if (int SchMin = exteriorEquip.sched->getMinVal(state); SchMin < 0.0) { - ShowSevereCustom( - state, - eoh, - EnergyPlus::format( - "{} = {} minimum is [{:.1R}]. Values must be >= 0.0.", s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3), SchMin)); - ErrorsFound = true; - } - - if (NumAlphas > 3) { - EndUseSubcategoryName = s_ipsc->cAlphaArgs(4); - } else { - EndUseSubcategoryName = "General"; - } - - exteriorEquip.DesignLevel = s_ipsc->rNumericArgs(1); - - SetupOutputVariable(state, - "Exterior Equipment Water Volume Flow Rate", - Constant::Units::m3_s, - exteriorEquip.Power, - OutputProcessor::TimeStepType::Zone, - OutputProcessor::StoreType::Average, - exteriorEquip.Name); - - SetupOutputVariable(state, - "Exterior Equipment Water Volume", - Constant::Units::m3, - exteriorEquip.CurrentUse, - OutputProcessor::TimeStepType::Zone, - OutputProcessor::StoreType::Sum, - exteriorEquip.Name, - Constant::eResource::Water, - OutputProcessor::Group::Invalid, - OutputProcessor::EndUseCat::ExteriorEquipment, - EndUseSubcategoryName); - SetupOutputVariable(state, - "Exterior Equipment Mains Water Volume", - Constant::Units::m3, - exteriorEquip.CurrentUse, - OutputProcessor::TimeStepType::Zone, - OutputProcessor::StoreType::Sum, - exteriorEquip.Name, - Constant::eResource::MainsWater, - OutputProcessor::Group::Invalid, - OutputProcessor::EndUseCat::ExteriorEquipment, - EndUseSubcategoryName); } if (ErrorsFound) { diff --git a/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc index 93e34e617ca..dde40f1024b 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -81,41 +80,40 @@ namespace GroundTemp { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool found = false; - int NumNums; - int NumAlphas; - int IOStat; - // New shared pointer for this model object auto *thisModel = new FiniteDiffGroundTempsModel(); GroundTemp::ModelType modelType = GroundTemp::ModelType::FiniteDiff; // Search through finite diff models here - std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNamesUC[(int)modelType]; - const int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - - for (int modelNum = 1; modelNum <= numCurrModels; ++modelNum) { + std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNames[(int)modelType]; + std::string const currentModuleObject(cCurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const modelInstances = inputProcessor->epJSON.find(currentModuleObject); + if (modelInstances == inputProcessor->epJSON.end()) { + ShowFatalError(state, fmt::format("{}--Errors getting input for ground temperature model", GroundTemp::modelTypeNames[(int)modelType])); + } + auto const &modelSchemaProps = inputProcessor->getObjectSchemaProps(state, currentModuleObject); - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - modelNum, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNums, - IOStat); + for (auto const &modelInstance : modelInstances.value().items()) { + auto const modelName = Util::makeUPPER(modelInstance.key()); + auto const &modelFields = modelInstance.value(); - if (objectName == state.dataIPShortCut->cAlphaArgs(1)) { + if (objectName == modelName) { // Read input into object here + inputProcessor->markObjectAsUsed(currentModuleObject, modelInstance.key()); thisModel->modelType = modelType; - thisModel->Name = state.dataIPShortCut->cAlphaArgs(1); - thisModel->baseConductivity = state.dataIPShortCut->rNumericArgs(1); - thisModel->baseDensity = state.dataIPShortCut->rNumericArgs(2); - thisModel->baseSpecificHeat = state.dataIPShortCut->rNumericArgs(3); - thisModel->waterContent = state.dataIPShortCut->rNumericArgs(4) / 100.0; - thisModel->saturatedWaterContent = state.dataIPShortCut->rNumericArgs(5) / 100.0; - thisModel->evapotransCoeff = state.dataIPShortCut->rNumericArgs(6); + thisModel->Name = modelName; + thisModel->baseConductivity = inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_thermal_conductivity"); + thisModel->baseDensity = inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_density"); + thisModel->baseSpecificHeat = inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_specific_heat"); + thisModel->waterContent = + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_moisture_content_volume_fraction") / 100.0; + thisModel->saturatedWaterContent = + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_moisture_content_volume_fraction_at_saturation") / 100.0; + thisModel->evapotransCoeff = + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "evapotranspiration_ground_cover_parameter"); found = true; break; diff --git a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc index 73c5a996c54..3a3b8d4f954 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/KusudaAchenbachGroundTemperatureModel.cc @@ -45,9 +45,11 @@ // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. +// C++ Headers +#include + // EnergyPlus Headers #include -#include #include #include #include @@ -72,53 +74,53 @@ namespace GroundTemp { // Locals // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool found = false; - int NumNums; - int NumAlphas; - int IOStat; - // New shared pointer for this model object auto *thisModel = new KusudaGroundTempsModel(); - // There was some **spooky** behavior here. One of the calling sites for this factory was passing in a reference - // to a dataIPShortCuts item as the objectName argument. Inside here, we make a second call to getObjectItem - // which then overwrites the value. So objectName gets overwritten. I made a copy of the string here to ensure - // it persists. + // There was some **spooky** behavior here. One of the calling sites for this factory was passing in a reference + // to a shared input buffer item as the objectName argument. Taking a local copy ensures the sought name persists. const std::string lookingForName = objectName; // NOLINT(*-unnecessary-copy-initialization) ModelType modelType = ModelType::Kusuda; - std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNamesUC[(int)modelType]; - const int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); - - for (int modelNum = 1; modelNum <= numCurrModels; ++modelNum) { + std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNames[(int)modelType]; + std::string const currentModuleObject(cCurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const modelInstances = inputProcessor->epJSON.find(currentModuleObject); + if (modelInstances == inputProcessor->epJSON.end()) { + ShowFatalError(state, fmt::format("{}--Errors getting input for ground temperature model", GroundTemp::modelTypeNames[(int)modelType])); + } + auto const &modelSchemaProps = inputProcessor->getObjectSchemaProps(state, currentModuleObject); - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - modelNum, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNums, - IOStat); + for (auto const &modelInstance : modelInstances.value().items()) { + auto const modelName = Util::makeUPPER(modelInstance.key()); + auto const &modelFields = modelInstance.value(); - if (lookingForName == state.dataIPShortCut->cAlphaArgs(1)) { + if (lookingForName == modelName) { + inputProcessor->markObjectAsUsed(currentModuleObject, modelInstance.key()); // Read input into object here - thisModel->Name = state.dataIPShortCut->cAlphaArgs(1); + thisModel->Name = modelName; thisModel->modelType = modelType; - thisModel->groundThermalDiffusivity = - state.dataIPShortCut->rNumericArgs(1) / (state.dataIPShortCut->rNumericArgs(2) * state.dataIPShortCut->rNumericArgs(3)); + thisModel->groundThermalDiffusivity = inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_thermal_conductivity") / + (inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_density") * + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_specific_heat")); std::array flags = { - state.dataIPShortCut->rNumericArgs(4), state.dataIPShortCut->rNumericArgs(5), state.dataIPShortCut->rNumericArgs(6)}; + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "average_soil_surface_temperature"), + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "average_amplitude_of_surface_temperature"), + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "phase_shift_of_minimum_surface_temperature")}; const bool useGroundTempDataForKusuda = std::any_of(flags.begin(), flags.end(), [](Real64 const flag) { return static_cast(flag); }); if (useGroundTempDataForKusuda) { // Use Kusuda Parameters - thisModel->aveGroundTemp = state.dataIPShortCut->rNumericArgs(4); - thisModel->aveGroundTempAmplitude = state.dataIPShortCut->rNumericArgs(5); - thisModel->phaseShiftInSecs = state.dataIPShortCut->rNumericArgs(6) * Constant::rSecsInDay; + thisModel->aveGroundTemp = inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "average_soil_surface_temperature"); + thisModel->aveGroundTempAmplitude = + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "average_amplitude_of_surface_temperature"); + thisModel->phaseShiftInSecs = + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "phase_shift_of_minimum_surface_temperature") * + Constant::rSecsInDay; } else { // Use data from Site:GroundTemperature:Shallow to generate parameters diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc index 469fd5e3847..f9f15278ccb 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteBuildingSurfaceGroundTemperatures.cc @@ -45,11 +45,13 @@ // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. +// C++ Headers +#include + // EnergyPlus Headers #include #include #include -#include #include #include #include @@ -69,6 +71,7 @@ namespace GroundTemp { // Reads input and creates instance of Site:GroundTemperature:BuildingSurface object // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + constexpr int numMonths = 12; bool errorsFound = false; // New shared pointer for this model object @@ -76,32 +79,39 @@ namespace GroundTemp { ModelType modelType = GroundTemp::ModelType::SiteBuildingSurface; - std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNamesUC[(int)modelType]; - const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNames[(int)modelType]; + std::string const currentModuleObject(cCurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + const int numCurrObjects = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->modelType = modelType; thisModel->Name = objectName; if (numCurrObjects == 1) { - - int NumNums; - int NumAlphas; - int IOStat; bool genErrorMessage = false; - - // Get the object names for each construction from the input processor - state.dataInputProcessing->inputProcessor->getObjectItem( - state, cCurrentModuleObject, 1, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat); - - if (NumNums < 12) { - ShowSevereError(state, fmt::format("{}: Less than 12 values entered.", GroundTemp::modelTypeNames[(int)modelType])); - errorsFound = true; - } + auto const &groundTempsInstances = inputProcessor->epJSON.at(currentModuleObject); + auto const groundTempsInstance = groundTempsInstances.begin(); + auto const &groundTempsFields = groundTempsInstance.value(); + auto const &groundTempsSchemaProps = inputProcessor->getObjectSchemaProps(state, currentModuleObject); + inputProcessor->markObjectAsUsed(currentModuleObject, groundTempsInstance.key()); + static constexpr std::array fieldNames = {"january_ground_temperature", + "february_ground_temperature", + "march_ground_temperature", + "april_ground_temperature", + "may_ground_temperature", + "june_ground_temperature", + "july_ground_temperature", + "august_ground_temperature", + "september_ground_temperature", + "october_ground_temperature", + "november_ground_temperature", + "december_ground_temperature"}; // Assign the ground temps to the variable - for (int i = 1; i <= 12; ++i) { - thisModel->buildingSurfaceGroundTemps[i - 1] = state.dataIPShortCut->rNumericArgs(i); - if (thisModel->buildingSurfaceGroundTemps[i - 1] < 15.0 || thisModel->buildingSurfaceGroundTemps[i - 1] > 25.0) { + for (int i = 0; i < numMonths; ++i) { + thisModel->buildingSurfaceGroundTemps[i] = + inputProcessor->getRealFieldValue(groundTempsFields, groundTempsSchemaProps, std::string(fieldNames[i])); + if (thisModel->buildingSurfaceGroundTemps[i] < 15.0 || thisModel->buildingSurfaceGroundTemps[i] > 25.0) { genErrorMessage = true; } } diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc index ad51d6cee46..7b3e382305f 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteDeepGroundTemperatures.cc @@ -46,13 +46,13 @@ // POSSIBILITY OF SUCH DAMAGE. // C++ Headers +#include #include // EnergyPlus Headers #include #include #include -#include #include #include #include @@ -73,6 +73,7 @@ namespace GroundTemp { // Reads input and creates instance of Site:GroundTemperature:Deep object // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + constexpr int numMonths = 12; bool errorsFound = false; // New shared pointer for this model object @@ -80,30 +81,37 @@ namespace GroundTemp { ModelType modelType = ModelType::SiteDeep; - std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNamesUC[(int)modelType]; - const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNames[(int)modelType]; + std::string const currentModuleObject(cCurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + const int numCurrObjects = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->modelType = modelType; thisModel->Name = objectName; if (numCurrObjects == 1) { - - int NumNums; - int NumAlphas; - int IOStat; - - // Get the object names for each construction from the input processor - state.dataInputProcessing->inputProcessor->getObjectItem( - state, cCurrentModuleObject, 1, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat); - - if (NumNums < 12) { - ShowSevereError(state, fmt::format("{}: Less than 12 values entered.", GroundTemp::modelTypeNames[(int)modelType])); - errorsFound = true; - } + auto const &groundTempsInstances = inputProcessor->epJSON.at(currentModuleObject); + auto const groundTempsInstance = groundTempsInstances.begin(); + auto const &groundTempsFields = groundTempsInstance.value(); + auto const &groundTempsSchemaProps = inputProcessor->getObjectSchemaProps(state, currentModuleObject); + inputProcessor->markObjectAsUsed(currentModuleObject, groundTempsInstance.key()); + static constexpr std::array fieldNames = {"january_deep_ground_temperature", + "february_deep_ground_temperature", + "march_deep_ground_temperature", + "april_deep_ground_temperature", + "may_deep_ground_temperature", + "june_deep_ground_temperature", + "july_deep_ground_temperature", + "august_deep_ground_temperature", + "september_deep_ground_temperature", + "october_deep_ground_temperature", + "november_deep_ground_temperature", + "december_deep_ground_temperature"}; // overwrite values read from weather file for the 0.5m set ground temperatures - for (int i = 1; i <= 12; ++i) { - thisModel->deepGroundTemps[i - 1] = state.dataIPShortCut->rNumericArgs(i); + for (int i = 0; i < numMonths; ++i) { + thisModel->deepGroundTemps[i] = + inputProcessor->getRealFieldValue(groundTempsFields, groundTempsSchemaProps, std::string(fieldNames[i])); } state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::Deep)] = true; diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc index 40e2cdf7118..c9143d48439 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteFCFactorMethodGroundTemperatures.cc @@ -46,12 +46,12 @@ // POSSIBILITY OF SUCH DAMAGE. // C++ Headers +#include // EnergyPlus Headers #include #include #include -#include #include #include #include @@ -72,6 +72,7 @@ namespace GroundTemp { // Reads input and creates instance of Site:GroundTemperature:FCfactorMethod object // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + constexpr int numMonths = 12; bool found = false; // New shared pointer for this model object @@ -79,35 +80,42 @@ namespace GroundTemp { ModelType modelType = ModelType::SiteFCFactorMethod; - std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNamesUC[(int)modelType]; - const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNames[(int)modelType]; + std::string const currentModuleObject(cCurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + const int numCurrObjects = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->modelType = modelType; thisModel->Name = objectName; if (numCurrObjects == 1) { - - int NumNums; - int NumAlphas; - int IOStat; - - // Get the object names for each construction from the input processor - state.dataInputProcessing->inputProcessor->getObjectItem( - state, cCurrentModuleObject, 1, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat); - - if (NumNums < 12) { - ShowSevereError(state, fmt::format("{}: Less than 12 values entered.", GroundTemp::modelTypeNames[(int)modelType])); - // found stays false - } else { - // overwrite values read from weather file for the 0.5m set ground temperatures - for (int i = 1; i <= 12; ++i) { - thisModel->fcFactorGroundTemps[i - 1] = state.dataIPShortCut->rNumericArgs(i); - } - - state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::FCFactorMethod)] = true; - found = true; + auto const &groundTempsInstances = inputProcessor->epJSON.at(currentModuleObject); + auto const groundTempsInstance = groundTempsInstances.begin(); + auto const &groundTempsFields = groundTempsInstance.value(); + auto const &groundTempsSchemaProps = inputProcessor->getObjectSchemaProps(state, currentModuleObject); + inputProcessor->markObjectAsUsed(currentModuleObject, groundTempsInstance.key()); + static constexpr std::array fieldNames = {"january_ground_temperature", + "february_ground_temperature", + "march_ground_temperature", + "april_ground_temperature", + "may_ground_temperature", + "june_ground_temperature", + "july_ground_temperature", + "august_ground_temperature", + "september_ground_temperature", + "october_ground_temperature", + "november_ground_temperature", + "december_ground_temperature"}; + + // overwrite values read from weather file for the 0.5m set ground temperatures + for (int i = 0; i < numMonths; ++i) { + thisModel->fcFactorGroundTemps[i] = + inputProcessor->getRealFieldValue(groundTempsFields, groundTempsSchemaProps, std::string(fieldNames[i])); } + state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::FCFactorMethod)] = true; + found = true; + } else if (numCurrObjects > 1) { ShowSevereError(state, fmt::format("{}: Too many objects entered. Only one allowed.", GroundTemp::modelTypeNames[(int)modelType])); // found stays false diff --git a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc index 3b7658e0753..43deb4b9315 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/SiteShallowGroundTemperatures.cc @@ -46,12 +46,12 @@ // POSSIBILITY OF SUCH DAMAGE. // C++ Headers +#include // EnergyPlus Headers #include #include #include -#include #include #include #include @@ -72,6 +72,7 @@ namespace GroundTemp { // Reads input and creates instance of Site:GroundDomain:Shallow object // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + constexpr int numMonths = 12; bool errorsFound = false; // New shared pointer for this model object @@ -79,30 +80,37 @@ namespace GroundTemp { ModelType modelType = ModelType::SiteShallow; - std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNamesUC[(int)modelType]; - const int numCurrObjects = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNames[(int)modelType]; + std::string const currentModuleObject(cCurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + const int numCurrObjects = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); thisModel->modelType = modelType; thisModel->Name = objectName; if (numCurrObjects == 1) { - - int NumNums; - int NumAlphas; - int IOStat; - - // Get the object names for each construction from the input processor - state.dataInputProcessing->inputProcessor->getObjectItem( - state, cCurrentModuleObject, 1, state.dataIPShortCut->cAlphaArgs, NumAlphas, state.dataIPShortCut->rNumericArgs, NumNums, IOStat); - - if (NumNums < 12) { - ShowSevereError(state, fmt::format("{}: Less than 12 values entered.", GroundTemp::modelTypeNames[(int)modelType])); - errorsFound = true; - } + auto const &groundTempsInstances = inputProcessor->epJSON.at(currentModuleObject); + auto const groundTempsInstance = groundTempsInstances.begin(); + auto const &groundTempsFields = groundTempsInstance.value(); + auto const &groundTempsSchemaProps = inputProcessor->getObjectSchemaProps(state, currentModuleObject); + inputProcessor->markObjectAsUsed(currentModuleObject, groundTempsInstance.key()); + static constexpr std::array fieldNames = {"january_surface_ground_temperature", + "february_surface_ground_temperature", + "march_surface_ground_temperature", + "april_surface_ground_temperature", + "may_surface_ground_temperature", + "june_surface_ground_temperature", + "july_surface_ground_temperature", + "august_surface_ground_temperature", + "september_surface_ground_temperature", + "october_surface_ground_temperature", + "november_surface_ground_temperature", + "december_surface_ground_temperature"}; // Assign the ground temps to the variable - for (int i = 1; i <= 12; ++i) { - thisModel->surfaceGroundTemps[i - 1] = state.dataIPShortCut->rNumericArgs(i); + for (int i = 0; i < numMonths; ++i) { + thisModel->surfaceGroundTemps[i] = + inputProcessor->getRealFieldValue(groundTempsFields, groundTempsSchemaProps, std::string(fieldNames[i])); } state.dataEnvrn->GroundTempInputs[static_cast(DataEnvironment::GroundTempType::Shallow)] = true; diff --git a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc index a4cfefe7270..cd0c613ebb6 100644 --- a/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc +++ b/src/EnergyPlus/GroundTemperatureModeling/XingGroundTemperatureModel.cc @@ -51,7 +51,6 @@ // EnergyPlus headers #include #include -#include #include #include #include @@ -73,42 +72,42 @@ namespace GroundTemp { // SUBROUTINE LOCAL VARIABLE DECLARATIONS: bool found = false; - int NumNums; - int NumAlphas; - int IOStat; - // New shared pointer for this model object auto *thisModel = new XingGroundTempsModel(); ModelType modelType = ModelType::Xing; - std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNamesUC[(int)modelType]; - const int numCurrModels = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + std::string_view const cCurrentModuleObject = GroundTemp::modelTypeNames[(int)modelType]; + std::string const currentModuleObject(cCurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const modelInstances = inputProcessor->epJSON.find(currentModuleObject); + if (modelInstances == inputProcessor->epJSON.end()) { + ShowFatalError(state, fmt::format("{}--Errors getting input for ground temperature model", GroundTemp::modelTypeNames[(int)modelType])); + } + auto const &modelSchemaProps = inputProcessor->getObjectSchemaProps(state, currentModuleObject); thisModel->modelType = modelType; thisModel->Name = objectName; - for (int modelNum = 1; modelNum <= numCurrModels; ++modelNum) { - - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - modelNum, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNums, - IOStat); + for (auto const &modelInstance : modelInstances.value().items()) { + auto const modelName = Util::makeUPPER(modelInstance.key()); + auto const &modelFields = modelInstance.value(); - if (thisModel->Name == state.dataIPShortCut->cAlphaArgs(1)) { + if (thisModel->Name == modelName) { // Read remaining input into object here - thisModel->groundThermalDiffusivity = state.dataIPShortCut->rNumericArgs(1) / - (state.dataIPShortCut->rNumericArgs(2) * state.dataIPShortCut->rNumericArgs(3)) * + inputProcessor->markObjectAsUsed(currentModuleObject, modelInstance.key()); + thisModel->Name = modelName; + thisModel->groundThermalDiffusivity = inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_thermal_conductivity") / + (inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_density") * + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_specific_heat")) * Constant::rSecsInDay; - thisModel->aveGroundTemp = state.dataIPShortCut->rNumericArgs(4); - thisModel->surfTempAmplitude_1 = state.dataIPShortCut->rNumericArgs(5); - thisModel->surfTempAmplitude_2 = state.dataIPShortCut->rNumericArgs(6); - thisModel->phaseShift_1 = state.dataIPShortCut->rNumericArgs(7); - thisModel->phaseShift_2 = state.dataIPShortCut->rNumericArgs(8); + thisModel->aveGroundTemp = inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "average_soil_surface_temperature"); + thisModel->surfTempAmplitude_1 = + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_surface_temperature_amplitude_1"); + thisModel->surfTempAmplitude_2 = + inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "soil_surface_temperature_amplitude_2"); + thisModel->phaseShift_1 = inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "phase_shift_of_temperature_amplitude_1"); + thisModel->phaseShift_2 = inputProcessor->getRealFieldValue(modelFields, modelSchemaProps, "phase_shift_of_temperature_amplitude_2"); found = true; break; diff --git a/src/EnergyPlus/InputProcessing/InputProcessor.cc b/src/EnergyPlus/InputProcessing/InputProcessor.cc index 58e0efabef7..3ddd517b2cf 100644 --- a/src/EnergyPlus/InputProcessing/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessing/InputProcessor.cc @@ -622,8 +622,11 @@ std::string InputProcessor::getAlphaFieldValue(json const &ep_object, json const { // Return the value of fieldName in ep_object as a string. // If the field is not present in ep_object then return its default if there is one, or return an empty string - auto const &fprops = schema_obj_props[fieldName]; - assert(!fprops.empty()); // Check that field name exists in the schema for this object type + auto const fpropsIt = schema_obj_props.find(fieldName); + if (fpropsIt == schema_obj_props.end()) { + throw std::runtime_error("InputProcessor schema field lookup failed for string field \"" + fieldName + "\""); + } + auto const &fprops = fpropsIt.value(); uc = (fprops.find("retaincase") == fprops.end()); @@ -664,8 +667,11 @@ Real64 InputProcessor::getRealFieldValue(json const &ep_object, json const &sche } } - auto const &schema_field_obj = schema_obj_props[fieldName]; - assert(!schema_field_obj.empty()); // Check that field name exists in the schema for this object type + auto const schemaFieldIt = schema_obj_props.find(fieldName); + if (schemaFieldIt == schema_obj_props.end()) { + throw std::runtime_error("InputProcessor schema field lookup failed for numeric field \"" + fieldName + "\""); + } + auto const &schema_field_obj = schemaFieldIt.value(); auto const find_default = schema_field_obj.find("default"); if (find_default != schema_field_obj.end()) { @@ -687,8 +693,11 @@ int InputProcessor::getIntFieldValue(json const &ep_object, json const &schema_o // If the field value is a string, then assume autosize or autocalculate and return Constant::AutoCalculate(-99999). // If the field is not present in ep_object then return its default if there is one, or return 0 - auto const &schema_field_obj = schema_obj_props[fieldName]; - assert(!schema_field_obj.empty()); // Check that field name exists in the schema for this object type + auto const schemaFieldIt = schema_obj_props.find(fieldName); + if (schemaFieldIt == schema_obj_props.end()) { + throw std::runtime_error("InputProcessor schema field lookup failed for integer field \"" + fieldName + "\""); + } + auto const &schema_field_obj = schemaFieldIt.value(); int value = 0; Real64 defaultValue = 0.0; auto it = ep_object.find(fieldName); diff --git a/src/EnergyPlus/ZoneDehumidifier.cc b/src/EnergyPlus/ZoneDehumidifier.cc index ef13e293665..6e00c05b6e0 100644 --- a/src/EnergyPlus/ZoneDehumidifier.cc +++ b/src/EnergyPlus/ZoneDehumidifier.cc @@ -202,207 +202,208 @@ namespace ZoneDehumidifier { Real64 constexpr RatedInletAirRH(60.0); // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int ZoneDehumidIndex; // Loop index - int NumAlphas(0); // Number of Alphas to allocate arrays, then used for each GetObjectItem call - int NumNumbers(0); // Number of Numbers to allocate arrays, then used for each GetObjectItem call - int IOStatus; // Used in GetObjectItem - bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine - Array1D_string Alphas; // Alpha input items for object - Array1D_string cAlphaFields; // Alpha field names - Array1D_string cNumericFields; // Numeric field names - Array1D Numbers; // Numeric input items for object - Array1D_bool lAlphaBlanks; // Logical array, alpha field input BLANK = .TRUE. - Array1D_bool lNumericBlanks; // Logical array, numeric field input BLANK = .TRUE. - int TotalArgs(0); // Total number of alpha and numeric arguments (max) - - int NumDehumidifiers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject); + int ZoneDehumidIndex; // Loop index + bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine - state.dataZoneDehumidifier->ZoneDehumid.allocate(NumDehumidifiers); - - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, TotalArgs, NumAlphas, NumNumbers); - - Alphas.allocate(NumAlphas); - cAlphaFields.allocate(NumAlphas); - cNumericFields.allocate(NumNumbers); - Numbers.dimension(NumNumbers, 0.0); - lAlphaBlanks.dimension(NumAlphas, true); - lNumericBlanks.dimension(NumNumbers, true); - - for (ZoneDehumidIndex = 1; ZoneDehumidIndex <= NumDehumidifiers; ++ZoneDehumidIndex) { + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + int NumDehumidifiers = inputProcessor->getNumObjectsFound(state, CurrentModuleObject); - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - ZoneDehumidIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - IOStatus, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - - ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; - - auto &dehumid = state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex); - // A1, \field Name - dehumid.Name = Alphas(1); - dehumid.UnitType = CurrentModuleObject; // 'ZoneHVAC:Dehumidifier:DX' - - // A2, \field Availability Schedule Name - if (lAlphaBlanks(2)) { - dehumid.availSched = Sched::GetScheduleAlwaysOn(state); - } else if ((dehumid.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); - ErrorsFound = true; - } + state.dataZoneDehumidifier->ZoneDehumid.allocate(NumDehumidifiers); + auto const &objectSchemaProps = inputProcessor->getObjectSchemaProps(state, CurrentModuleObject); + auto const dehumidObjects = inputProcessor->epJSON.find(CurrentModuleObject); + ZoneDehumidIndex = 1; + + if (dehumidObjects != inputProcessor->epJSON.end()) { + for (auto const &dehumidInstance : dehumidObjects.value().items()) { + auto const &dehumidFields = dehumidInstance.value(); + auto const dehumidName = Util::makeUPPER(dehumidInstance.key()); + auto const availabilityScheduleName = + inputProcessor->getAlphaFieldValue(dehumidFields, objectSchemaProps, "availability_schedule_name"); + auto const airInletNodeName = inputProcessor->getAlphaFieldValue(dehumidFields, objectSchemaProps, "air_inlet_node_name"); + auto const airOutletNodeName = inputProcessor->getAlphaFieldValue(dehumidFields, objectSchemaProps, "air_outlet_node_name"); + auto const waterRemovalCurveName = inputProcessor->getAlphaFieldValue(dehumidFields, objectSchemaProps, "water_removal_curve_name"); + auto const energyFactorCurveName = inputProcessor->getAlphaFieldValue(dehumidFields, objectSchemaProps, "energy_factor_curve_name"); + auto const partLoadFractionCorrelationCurveName = + inputProcessor->getAlphaFieldValue(dehumidFields, objectSchemaProps, "part_load_fraction_correlation_curve_name"); + auto const condensateCollectionWaterStorageTankName = + inputProcessor->getAlphaFieldValue(dehumidFields, objectSchemaProps, "condensate_collection_water_storage_tank_name"); + + inputProcessor->markObjectAsUsed(CurrentModuleObject, dehumidInstance.key()); + + ErrorObjectHeader eoh{routineName, CurrentModuleObject, dehumidName}; + + auto &dehumid = state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidIndex); + // A1, \field Name + dehumid.Name = dehumidName; + dehumid.UnitType = CurrentModuleObject; // 'ZoneHVAC:Dehumidifier:DX' + + // A2, \field Availability Schedule Name + if (availabilityScheduleName.empty()) { + dehumid.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((dehumid.availSched = Sched::GetSchedule(state, availabilityScheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Availability Schedule Name", availabilityScheduleName); + ErrorsFound = true; + } - // A3 , \field Air Inlet Node Name - dehumid.AirInletNodeNum = GetOnlySingleNode(state, - Alphas(3), - ErrorsFound, - Node::ConnectionObjectType::ZoneHVACDehumidifierDX, - Alphas(1), - Node::FluidType::Air, - Node::ConnectionType::Inlet, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - - // A4 , \field Air Outlet Node Name - dehumid.AirOutletNodeNum = GetOnlySingleNode(state, - Alphas(4), - ErrorsFound, - Node::ConnectionObjectType::ZoneHVACDehumidifierDX, - Alphas(1), - Node::FluidType::Air, - Node::ConnectionType::Outlet, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - - // N1, \field Rated Water Removal - dehumid.RatedWaterRemoval = Numbers(1); - if (dehumid.RatedWaterRemoval <= 0.0) { - ShowSevereError(state, EnergyPlus::format("{} must be greater than zero.", cNumericFields(1))); - ShowContinueError(state, EnergyPlus::format("Value specified = {:.5T}", Numbers(1))); - ShowContinueError(state, EnergyPlus::format("Occurs in {} = {}", CurrentModuleObject, dehumid.Name)); - ErrorsFound = true; - } + // A3 , \field Air Inlet Node Name + dehumid.AirInletNodeNum = GetOnlySingleNode(state, + airInletNodeName, + ErrorsFound, + Node::ConnectionObjectType::ZoneHVACDehumidifierDX, + dehumidName, + Node::FluidType::Air, + Node::ConnectionType::Inlet, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); + + // A4 , \field Air Outlet Node Name + dehumid.AirOutletNodeNum = GetOnlySingleNode(state, + airOutletNodeName, + ErrorsFound, + Node::ConnectionObjectType::ZoneHVACDehumidifierDX, + dehumidName, + Node::FluidType::Air, + Node::ConnectionType::Outlet, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); + + // N1, \field Rated Water Removal + dehumid.RatedWaterRemoval = inputProcessor->getRealFieldValue(dehumidFields, objectSchemaProps, "rated_water_removal"); + if (dehumid.RatedWaterRemoval <= 0.0) { + ShowSevereError(state, "Rated Water Removal must be greater than zero."); + ShowContinueError(state, EnergyPlus::format("Value specified = {:.5T}", dehumid.RatedWaterRemoval)); + ShowContinueError(state, EnergyPlus::format("Occurs in {} = {}", CurrentModuleObject, dehumid.Name)); + ErrorsFound = true; + } - // N2, \field Rated Energy Factor - dehumid.RatedEnergyFactor = Numbers(2); - if (dehumid.RatedEnergyFactor <= 0.0) { - ShowSevereError(state, EnergyPlus::format("{} must be greater than zero.", cNumericFields(2))); - ShowContinueError(state, EnergyPlus::format("Value specified = {:.5T}", Numbers(2))); - ShowContinueError(state, EnergyPlus::format("Occurs in {} = {}", CurrentModuleObject, dehumid.Name)); - ErrorsFound = true; - } + // N2, \field Rated Energy Factor + dehumid.RatedEnergyFactor = inputProcessor->getRealFieldValue(dehumidFields, objectSchemaProps, "rated_energy_factor"); + if (dehumid.RatedEnergyFactor <= 0.0) { + ShowSevereError(state, "Rated Energy Factor must be greater than zero."); + ShowContinueError(state, EnergyPlus::format("Value specified = {:.5T}", dehumid.RatedEnergyFactor)); + ShowContinueError(state, EnergyPlus::format("Occurs in {} = {}", CurrentModuleObject, dehumid.Name)); + ErrorsFound = true; + } - // N3, \field Rated Air Flow Rate - dehumid.RatedAirVolFlow = Numbers(3); - if (dehumid.RatedAirVolFlow <= 0.0) { - ShowSevereError(state, EnergyPlus::format("{} must be greater than zero.", cNumericFields(3))); - ShowContinueError(state, EnergyPlus::format("Value specified = {:.5T}", Numbers(3))); - ShowContinueError(state, EnergyPlus::format("Occurs in {} = {}", CurrentModuleObject, dehumid.Name)); - ErrorsFound = true; - } + // N3, \field Rated Air Flow Rate + dehumid.RatedAirVolFlow = inputProcessor->getRealFieldValue(dehumidFields, objectSchemaProps, "rated_air_flow_rate"); + if (dehumid.RatedAirVolFlow <= 0.0) { + ShowSevereError(state, "Rated Air Flow Rate must be greater than zero."); + ShowContinueError(state, EnergyPlus::format("Value specified = {:.5T}", dehumid.RatedAirVolFlow)); + ShowContinueError(state, EnergyPlus::format("Occurs in {} = {}", CurrentModuleObject, dehumid.Name)); + ErrorsFound = true; + } - // A5, \field Water Removal Curve Name - if (lAlphaBlanks(5)) { - ShowSevereEmptyField(state, eoh, cAlphaFields(5)); - ErrorsFound = true; - } else if ((dehumid.WaterRemovalCurve = Curve::GetCurve(state, Alphas(5))) == nullptr) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); - ErrorsFound = true; - } else if (dehumid.WaterRemovalCurve->numDims != 2) { - Curve::ShowSevereCurveDims(state, eoh, cAlphaFields(5), Alphas(5), "2", dehumid.WaterRemovalCurve->numDims); - ErrorsFound = true; - } else { - Real64 CurveVal = dehumid.WaterRemovalCurve->value(state, RatedInletAirTemp, RatedInletAirRH); - if (CurveVal > 1.10 || CurveVal < 0.90) { - ShowWarningError(state, EnergyPlus::format("{} output is not equal to 1.0", cAlphaFields(5))); - ShowContinueError(state, EnergyPlus::format("(+ or -10%) at rated conditions for {} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, EnergyPlus::format("Curve output at rated conditions = {:.3T}", CurveVal)); + // A5, \field Water Removal Curve Name + if (waterRemovalCurveName.empty()) { + ShowSevereEmptyField(state, eoh, "Water Removal Curve Name"); + ErrorsFound = true; + } else if ((dehumid.WaterRemovalCurve = Curve::GetCurve(state, waterRemovalCurveName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Water Removal Curve Name", waterRemovalCurveName); + ErrorsFound = true; + } else if (dehumid.WaterRemovalCurve->numDims != 2) { + Curve::ShowSevereCurveDims( + state, eoh, "Water Removal Curve Name", waterRemovalCurveName, "2", dehumid.WaterRemovalCurve->numDims); + ErrorsFound = true; + } else { + Real64 CurveVal = dehumid.WaterRemovalCurve->value(state, RatedInletAirTemp, RatedInletAirRH); + if (CurveVal > 1.10 || CurveVal < 0.90) { + ShowWarningError(state, "Water Removal Curve Name output is not equal to 1.0"); + ShowContinueError(state, EnergyPlus::format("(+ or -10%) at rated conditions for {} = {}", CurrentModuleObject, dehumidName)); + ShowContinueError(state, EnergyPlus::format("Curve output at rated conditions = {:.3T}", CurveVal)); + } } - } - // A6, \field Energy Factor Curve Name - if (lAlphaBlanks(6)) { - ShowSevereEmptyField(state, eoh, cAlphaFields(6)); - ErrorsFound = true; - } else if ((dehumid.EnergyFactorCurve = Curve::GetCurve(state, Alphas(6))) == nullptr) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(6), Alphas(6)); - ErrorsFound = true; - } else if (dehumid.EnergyFactorCurve->numDims != 2) { - Curve::ShowSevereCurveDims(state, eoh, cAlphaFields(6), Alphas(6), "2", dehumid.EnergyFactorCurve->numDims); - ErrorsFound = true; - } else { - Real64 CurveVal = dehumid.EnergyFactorCurve->value(state, RatedInletAirTemp, RatedInletAirRH); - if (CurveVal > 1.10 || CurveVal < 0.90) { - ShowWarningError(state, EnergyPlus::format("{} output is not equal to 1.0", cAlphaFields(6))); - ShowContinueError(state, EnergyPlus::format("(+ or -10%) at rated conditions for {} = {}", CurrentModuleObject, Alphas(1))); - ShowContinueError(state, EnergyPlus::format("Curve output at rated conditions = {:.3T}", CurveVal)); + // A6, \field Energy Factor Curve Name + if (energyFactorCurveName.empty()) { + ShowSevereEmptyField(state, eoh, "Energy Factor Curve Name"); + ErrorsFound = true; + } else if ((dehumid.EnergyFactorCurve = Curve::GetCurve(state, energyFactorCurveName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Energy Factor Curve Name", energyFactorCurveName); + ErrorsFound = true; + } else if (dehumid.EnergyFactorCurve->numDims != 2) { + Curve::ShowSevereCurveDims( + state, eoh, "Energy Factor Curve Name", energyFactorCurveName, "2", dehumid.EnergyFactorCurve->numDims); + ErrorsFound = true; + } else { + Real64 CurveVal = dehumid.EnergyFactorCurve->value(state, RatedInletAirTemp, RatedInletAirRH); + if (CurveVal > 1.10 || CurveVal < 0.90) { + ShowWarningError(state, "Energy Factor Curve Name output is not equal to 1.0"); + ShowContinueError(state, EnergyPlus::format("(+ or -10%) at rated conditions for {} = {}", CurrentModuleObject, dehumidName)); + ShowContinueError(state, EnergyPlus::format("Curve output at rated conditions = {:.3T}", CurveVal)); + } } - } - // A7, \field Part Load Fraction Correlation Curve Name - if (lAlphaBlanks(7)) { - ShowSevereEmptyField(state, eoh, cAlphaFields(7)); - ErrorsFound = true; - } else if ((dehumid.PartLoadCurve = Curve::GetCurve(state, Alphas(7))) == nullptr) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(7), Alphas(7)); - ErrorsFound = true; - } else if (dehumid.PartLoadCurve->numDims != 1) { - Curve::ShowSevereCurveDims(state, eoh, cAlphaFields(7), Alphas(7), "1", dehumid.PartLoadCurve->numDims); - ErrorsFound = true; - } + // A7, \field Part Load Fraction Correlation Curve Name + if (partLoadFractionCorrelationCurveName.empty()) { + ShowSevereEmptyField(state, eoh, "Part Load Fraction Correlation Curve Name"); + ErrorsFound = true; + } else if ((dehumid.PartLoadCurve = Curve::GetCurve(state, partLoadFractionCorrelationCurveName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, "Part Load Fraction Correlation Curve Name", partLoadFractionCorrelationCurveName); + ErrorsFound = true; + } else if (dehumid.PartLoadCurve->numDims != 1) { + Curve::ShowSevereCurveDims(state, + eoh, + "Part Load Fraction Correlation Curve Name", + partLoadFractionCorrelationCurveName, + "1", + dehumid.PartLoadCurve->numDims); + ErrorsFound = true; + } - // N4, \field Minimum Dry-Bulb Temperature for Dehumidifier Operation - // N5, \field Maximum Dry-Bulb Temperature for Dehumidifier Operation - dehumid.MinInletAirTemp = Numbers(4); - dehumid.MaxInletAirTemp = Numbers(5); - - if (dehumid.MinInletAirTemp >= dehumid.MaxInletAirTemp) { - ShowSevereError(state, EnergyPlus::format("{} must be greater than {}", cNumericFields(5), cNumericFields(4))); - ShowContinueError(state, EnergyPlus::format("{} specified = {:.1T}", cNumericFields(5), Numbers(5))); - ShowContinueError(state, EnergyPlus::format("{} specified = {:.1T}", cNumericFields(4), Numbers(4))); - ShowContinueError(state, EnergyPlus::format("Occurs in {} = {}", CurrentModuleObject, dehumid.Name)); - ErrorsFound = true; - } + // N4, \field Minimum Dry-Bulb Temperature for Dehumidifier Operation + // N5, \field Maximum Dry-Bulb Temperature for Dehumidifier Operation + dehumid.MinInletAirTemp = + inputProcessor->getRealFieldValue(dehumidFields, objectSchemaProps, "minimum_dry_bulb_temperature_for_dehumidifier_operation"); + dehumid.MaxInletAirTemp = + inputProcessor->getRealFieldValue(dehumidFields, objectSchemaProps, "maximum_dry_bulb_temperature_for_dehumidifier_operation"); + + if (dehumid.MinInletAirTemp >= dehumid.MaxInletAirTemp) { + ShowSevereError(state, + "Maximum Dry-Bulb Temperature for Dehumidifier Operation must be greater than Minimum Dry-Bulb Temperature for " + "Dehumidifier Operation"); + ShowContinueError(state, + EnergyPlus::format("{} specified = {:.1T}", + "Maximum Dry-Bulb Temperature for Dehumidifier Operation", + dehumid.MaxInletAirTemp)); + ShowContinueError(state, + EnergyPlus::format("{} specified = {:.1T}", + "Minimum Dry-Bulb Temperature for Dehumidifier Operation", + dehumid.MinInletAirTemp)); + ShowContinueError(state, EnergyPlus::format("Occurs in {} = {}", CurrentModuleObject, dehumid.Name)); + ErrorsFound = true; + } - // N6, \field Off Cycle Parasitic Electric Load - dehumid.OffCycleParasiticLoad = Numbers(6); // Off Cycle Parasitic Load [W] + // N6, \field Off Cycle Parasitic Electric Load + dehumid.OffCycleParasiticLoad = inputProcessor->getRealFieldValue( + dehumidFields, objectSchemaProps, "off_cycle_parasitic_electric_load"); // Off Cycle Parasitic Load [W] - if (dehumid.OffCycleParasiticLoad < 0.0) { - ShowSevereError(state, EnergyPlus::format("{} must be >= zero.", cNumericFields(6))); - ShowContinueError(state, EnergyPlus::format("Value specified = {:.2T}", Numbers(6))); - ShowContinueError(state, EnergyPlus::format("Occurs in {} = {}", CurrentModuleObject, dehumid.Name)); - ErrorsFound = true; - } + if (dehumid.OffCycleParasiticLoad < 0.0) { + ShowSevereError(state, "Off-Cycle Parasitic Electric Load must be >= zero."); + ShowContinueError(state, EnergyPlus::format("Value specified = {:.2T}", dehumid.OffCycleParasiticLoad)); + ShowContinueError(state, EnergyPlus::format("Occurs in {} = {}", CurrentModuleObject, dehumid.Name)); + ErrorsFound = true; + } - // A8; \field Condensate Collection Water Storage Tank Name - dehumid.CondensateCollectName = Alphas(8); - if (lAlphaBlanks(8)) { - dehumid.CondensateCollectMode = CondensateOutlet::Discarded; - } else { - dehumid.CondensateCollectMode = CondensateOutlet::ToTank; - SetupTankSupplyComponent(state, - dehumid.Name, - CurrentModuleObject, - dehumid.CondensateCollectName, - ErrorsFound, - dehumid.CondensateTankID, - dehumid.CondensateTankSupplyARRID); - } + // A8; \field Condensate Collection Water Storage Tank Name + dehumid.CondensateCollectName = condensateCollectionWaterStorageTankName; + if (condensateCollectionWaterStorageTankName.empty()) { + dehumid.CondensateCollectMode = CondensateOutlet::Discarded; + } else { + dehumid.CondensateCollectMode = CondensateOutlet::ToTank; + SetupTankSupplyComponent(state, + dehumid.Name, + CurrentModuleObject, + condensateCollectionWaterStorageTankName, + ErrorsFound, + dehumid.CondensateTankID, + dehumid.CondensateTankSupplyARRID); + } - } // DO ZoneDehumidIndex=1,NumDehumidifiers + ++ZoneDehumidIndex; - Alphas.deallocate(); - cAlphaFields.deallocate(); - cNumericFields.deallocate(); - Numbers.deallocate(); - lAlphaBlanks.deallocate(); - lNumericBlanks.deallocate(); + } // DO ZoneDehumidIndex=1,NumDehumidifiers + } if (ErrorsFound) { ShowFatalError(state, EnergyPlus::format("{}:{}: Errors found in input.", routineName, CurrentModuleObject));