From ef22e9e58e6607ac94f6cd928553a7f882647733 Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Tue, 14 Apr 2026 10:14:54 -0400 Subject: [PATCH 01/19] Work on boilers --- src/EnergyPlus/Boilers.cc | 193 ++++++++++++++++++++------------------ 1 file changed, 102 insertions(+), 91 deletions(-) diff --git a/src/EnergyPlus/Boilers.cc b/src/EnergyPlus/Boilers.cc index 7f0c88cb00e..719f8744885 100644 --- a/src/EnergyPlus/Boilers.cc +++ b/src/EnergyPlus/Boilers.cc @@ -182,170 +182,181 @@ 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. From 7648c1e75f805753a77308cb013315aa3ca8f2fe Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Tue, 14 Apr 2026 11:13:26 -0400 Subject: [PATCH 02/19] Transition zone dehumidifiers --- src/EnergyPlus/ZoneDehumidifier.cc | 170 ++++++++++++++--------------- 1 file changed, 79 insertions(+), 91 deletions(-) diff --git a/src/EnergyPlus/ZoneDehumidifier.cc b/src/EnergyPlus/ZoneDehumidifier.cc index ef13e293665..ecd9ade5956 100644 --- a/src/EnergyPlus/ZoneDehumidifier.cc +++ b/src/EnergyPlus/ZoneDehumidifier.cc @@ -203,67 +203,53 @@ namespace ZoneDehumidifier { // 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); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + int NumDehumidifiers = inputProcessor->getNumObjectsFound(state, CurrentModuleObject); 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) { - - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - ZoneDehumidIndex, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - IOStatus, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - - ErrorObjectHeader eoh{routineName, CurrentModuleObject, Alphas(1)}; + 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 = Alphas(1); + dehumid.Name = dehumidName; dehumid.UnitType = CurrentModuleObject; // 'ZoneHVAC:Dehumidifier:DX' // A2, \field Availability Schedule Name - if (lAlphaBlanks(2)) { + if (availabilityScheduleName.empty()) { dehumid.availSched = Sched::GetScheduleAlwaysOn(state); - } else if ((dehumid.availSched = Sched::GetSchedule(state, Alphas(2))) == nullptr) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(2), Alphas(2)); + } 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), + airInletNodeName, ErrorsFound, Node::ConnectionObjectType::ZoneHVACDehumidifierDX, - Alphas(1), + dehumidName, Node::FluidType::Air, Node::ConnectionType::Inlet, Node::CompFluidStream::Primary, @@ -271,138 +257,140 @@ namespace ZoneDehumidifier { // A4 , \field Air Outlet Node Name dehumid.AirOutletNodeNum = GetOnlySingleNode(state, - Alphas(4), + airOutletNodeName, ErrorsFound, Node::ConnectionObjectType::ZoneHVACDehumidifierDX, - Alphas(1), + dehumidName, Node::FluidType::Air, Node::ConnectionType::Outlet, Node::CompFluidStream::Primary, Node::ObjectIsNotParent); // N1, \field Rated Water Removal - dehumid.RatedWaterRemoval = Numbers(1); + dehumid.RatedWaterRemoval = inputProcessor->getRealFieldValue(dehumidFields, objectSchemaProps, "rated_water_removal"); 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))); + 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); + dehumid.RatedEnergyFactor = inputProcessor->getRealFieldValue(dehumidFields, objectSchemaProps, "rated_energy_factor"); 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))); + 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); + dehumid.RatedAirVolFlow = inputProcessor->getRealFieldValue(dehumidFields, objectSchemaProps, "rated_air_flow_rate"); 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))); + 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)); + if (waterRemovalCurveName.empty()) { + ShowSevereEmptyField(state, eoh, "Water Removal Curve Name"); ErrorsFound = true; - } else if ((dehumid.WaterRemovalCurve = Curve::GetCurve(state, Alphas(5))) == nullptr) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(5), Alphas(5)); + } 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, cAlphaFields(5), Alphas(5), "2", dehumid.WaterRemovalCurve->numDims); + 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, EnergyPlus::format("{} output is not equal to 1.0", cAlphaFields(5))); - ShowContinueError(state, EnergyPlus::format("(+ or -10%) at rated conditions for {} = {}", CurrentModuleObject, Alphas(1))); + 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)); + if (energyFactorCurveName.empty()) { + ShowSevereEmptyField(state, eoh, "Energy Factor Curve Name"); ErrorsFound = true; - } else if ((dehumid.EnergyFactorCurve = Curve::GetCurve(state, Alphas(6))) == nullptr) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(6), Alphas(6)); + } 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, cAlphaFields(6), Alphas(6), "2", dehumid.EnergyFactorCurve->numDims); + 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, EnergyPlus::format("{} output is not equal to 1.0", cAlphaFields(6))); - ShowContinueError(state, EnergyPlus::format("(+ or -10%) at rated conditions for {} = {}", CurrentModuleObject, Alphas(1))); + 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)); + if (partLoadFractionCorrelationCurveName.empty()) { + ShowSevereEmptyField(state, eoh, "Part Load Fraction Correlation Curve Name"); ErrorsFound = true; - } else if ((dehumid.PartLoadCurve = Curve::GetCurve(state, Alphas(7))) == nullptr) { - ShowSevereItemNotFound(state, eoh, cAlphaFields(7), Alphas(7)); + } 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, cAlphaFields(7), Alphas(7), "1", dehumid.PartLoadCurve->numDims); + 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); + 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, 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))); + 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] + 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))); + 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.CondensateCollectName = condensateCollectionWaterStorageTankName; + if (condensateCollectionWaterStorageTankName.empty()) { dehumid.CondensateCollectMode = CondensateOutlet::Discarded; } else { dehumid.CondensateCollectMode = CondensateOutlet::ToTank; SetupTankSupplyComponent(state, dehumid.Name, CurrentModuleObject, - dehumid.CondensateCollectName, + 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)); From 4b0c164effe62edfd2e7b85af0eede0a07c10835 Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Tue, 14 Apr 2026 13:52:11 -0400 Subject: [PATCH 03/19] Initial pass on two more files --- src/EnergyPlus/BoilerSteam.cc | 226 ++++++++++++++------------- src/EnergyPlus/CoolTower.cc | 280 ++++++++++++++++------------------ 2 files changed, 241 insertions(+), 265 deletions(-) diff --git a/src/EnergyPlus/BoilerSteam.cc b/src/EnergyPlus/BoilerSteam.cc index d6d0155c57e..cfc9a97700f 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,119 @@ 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/CoolTower.cc b/src/EnergyPlus/CoolTower.cc index 1e2eced1df4..202a5a84398 100644 --- a/src/EnergyPlus/CoolTower.cc +++ b/src/EnergyPlus/CoolTower.cc @@ -147,176 +147,156 @@ 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)); } From fd7cdde343d9916d8dfcf2323ed2df1dab40587e Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Tue, 14 Apr 2026 14:09:44 -0400 Subject: [PATCH 04/19] Correct format and behavior --- src/EnergyPlus/BoilerSteam.cc | 46 ++-- src/EnergyPlus/Boilers.cc | 30 ++- src/EnergyPlus/CoolTower.cc | 24 +- src/EnergyPlus/ZoneDehumidifier.cc | 337 +++++++++++++++-------------- 4 files changed, 226 insertions(+), 211 deletions(-) diff --git a/src/EnergyPlus/BoilerSteam.cc b/src/EnergyPlus/BoilerSteam.cc index cfc9a97700f..636e24a9016 100644 --- a/src/EnergyPlus/BoilerSteam.cc +++ b/src/EnergyPlus/BoilerSteam.cc @@ -184,11 +184,8 @@ namespace BoilerSteam { 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"); + GlobalNames::VerifyUniqueBoilerName( + state, state.dataIPShortCut->cCurrentModuleObject, boilerName, ErrorsFound, state.dataIPShortCut->cCurrentModuleObject + " Name"); auto &thisBoiler = state.dataBoilerSteam->Boiler(BoilerNum); thisBoiler.Name = boilerName; @@ -202,7 +199,8 @@ namespace BoilerSteam { 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.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; @@ -210,39 +208,33 @@ namespace BoilerSteam { 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.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; } if ((thisBoiler.FullLoadCoef[0] + thisBoiler.FullLoadCoef[1] + thisBoiler.FullLoadCoef[2]) == 0.0) { - ShowSevereError( - state, - EnergyPlus::format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, boilerName)); + ShowSevereError(state, EnergyPlus::format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, boilerName)); ShowContinueError(state, " Sum of fuel use curve coefficients = 0.0"); ErrorsFound = true; } if (thisBoiler.MinPartLoadRat < 0.0) { - ShowSevereError( - state, - EnergyPlus::format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, boilerName)); + ShowSevereError(state, EnergyPlus::format("{}{}=\"{}\",", RoutineName, state.dataIPShortCut->cCurrentModuleObject, boilerName)); ShowContinueError(state, EnergyPlus::format("Invalid {}={:.3R}", "Minimum Part Load Ratio", thisBoiler.MinPartLoadRat)); 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)); + 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, @@ -263,12 +255,8 @@ namespace BoilerSteam { Node::ConnectionType::Outlet, Node::CompFluidStream::Primary, Node::ObjectIsNotParent); - Node::TestCompSet(state, - state.dataIPShortCut->cCurrentModuleObject, - boilerName, - waterInletNodeName, - steamOutletNodeName, - "Hot Steam Nodes"); + Node::TestCompSet( + state, state.dataIPShortCut->cCurrentModuleObject, boilerName, waterInletNodeName, steamOutletNodeName, "Hot Steam Nodes"); thisBoiler.fluid = Fluid::GetSteam(state); if (thisBoiler.fluid == nullptr && BoilerNum == 1) { diff --git a/src/EnergyPlus/Boilers.cc b/src/EnergyPlus/Boilers.cc index 719f8744885..c3995bbede2 100644 --- a/src/EnergyPlus/Boilers.cc +++ b/src/EnergyPlus/Boilers.cc @@ -195,10 +195,8 @@ void GetBoilerInput(EnergyPlusData &state) 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 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()); @@ -255,8 +253,12 @@ void GetBoilerInput(EnergyPlusData &state) 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, "Normalized Boiler Efficiency Curve Name", normalizedBoilerEfficiencyCurveName, "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 (thisBoiler.EfficiencyCurve->numDims == 2) { if (thisBoiler.CurveTempMode == TempMode::NOTSET) { @@ -295,11 +297,19 @@ void GetBoilerInput(EnergyPlusData &state) 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; + 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; + 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; }; diff --git a/src/EnergyPlus/CoolTower.cc b/src/EnergyPlus/CoolTower.cc index 202a5a84398..8d516a751c7 100644 --- a/src/EnergyPlus/CoolTower.cc +++ b/src/EnergyPlus/CoolTower.cc @@ -160,7 +160,8 @@ namespace CoolTower { 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 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"); @@ -227,7 +228,8 @@ namespace CoolTower { ShowWarningBadMin(state, eoh, "Maximum Water Flow Rate", coolTower.MaxWaterFlowRate, Clusive::In, MinimumWaterFlowRate); } - coolTower.TowerHeight = inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "effective_tower_height"); // Get effective tower height + 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); @@ -238,7 +240,8 @@ namespace CoolTower { ShowWarningBadMin(state, eoh, "Effective Tower Height", coolTower.TowerHeight, Clusive::In, MinHeight); } - coolTower.OutletArea = inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "airflow_outlet_area"); // Get outlet area + 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); @@ -248,8 +251,8 @@ namespace CoolTower { ShowWarningBadMin(state, eoh, "Airflow Outlet Area", coolTower.OutletArea, Clusive::In, MinValue); } - coolTower.MaxAirVolFlowRate = - inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "maximum_air_flow_rate"); // Maximum limit of air flow to the space + 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); @@ -259,8 +262,8 @@ namespace CoolTower { ShowWarningBadMin(state, eoh, "Maximum Air Flow Rate", coolTower.MaxAirVolFlowRate, Clusive::In, MinValue); } - coolTower.MinZoneTemp = - inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "minimum_indoor_temperature"); // Get minimum temp limit which gets this cooltower off + 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); @@ -281,8 +284,8 @@ namespace CoolTower { ShowWarningBadMin(state, eoh, "Fraction of Water Loss", coolTower.FracWaterLoss, Clusive::In, MinFrac); } - coolTower.FracFlowSched = - inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "fraction_of_flow_schedule"); // Fraction of loss of air flow + 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); @@ -292,7 +295,8 @@ namespace CoolTower { ShowWarningBadMin(state, eoh, "Fraction of Flow Schedule", coolTower.FracFlowSched, Clusive::In, MinFrac); } - coolTower.RatedPumpPower = inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "rated_power_consumption"); // Get rated pump power + coolTower.RatedPumpPower = + inputProcessor->getRealFieldValue(coolTowerFields, objectSchemaProps, "rated_power_consumption"); // Get rated pump power ++CoolTowerNum; } } diff --git a/src/EnergyPlus/ZoneDehumidifier.cc b/src/EnergyPlus/ZoneDehumidifier.cc index ecd9ade5956..6e00c05b6e0 100644 --- a/src/EnergyPlus/ZoneDehumidifier.cc +++ b/src/EnergyPlus/ZoneDehumidifier.cc @@ -202,8 +202,8 @@ namespace ZoneDehumidifier { Real64 constexpr RatedInletAirRH(60.0); // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int ZoneDehumidIndex; // Loop index - bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine + int ZoneDehumidIndex; // Loop index + bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); int NumDehumidifiers = inputProcessor->getNumObjectsFound(state, CurrentModuleObject); @@ -215,179 +215,192 @@ namespace ZoneDehumidifier { 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; - } + 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, - 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; - } + // 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 = 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; - } + // 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 = 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; - } + // 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 (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)); + // 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 (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)); + // 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 (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; - } + // 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 = - 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; - } + // 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 = - inputProcessor->getRealFieldValue(dehumidFields, objectSchemaProps, "off_cycle_parasitic_electric_load"); // 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, "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; - } + 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 = condensateCollectionWaterStorageTankName; - if (condensateCollectionWaterStorageTankName.empty()) { - dehumid.CondensateCollectMode = CondensateOutlet::Discarded; - } else { - dehumid.CondensateCollectMode = CondensateOutlet::ToTank; - SetupTankSupplyComponent(state, - dehumid.Name, - CurrentModuleObject, - condensateCollectionWaterStorageTankName, - 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); + } - ++ZoneDehumidIndex; + ++ZoneDehumidIndex; } // DO ZoneDehumidIndex=1,NumDehumidifiers } From 809688ecbc68d450555933abc4228dfe19158081 Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Tue, 14 Apr 2026 16:44:15 -0400 Subject: [PATCH 05/19] A couple more refactors, this one may need further cleanup --- src/EnergyPlus/CTElectricGenerator.cc | 374 +++++++++++--------- src/EnergyPlus/DemandManager.cc | 2 +- src/EnergyPlus/ExteriorEnergyUse.cc | 486 ++++++++++++-------------- 3 files changed, 439 insertions(+), 423 deletions(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index 17c66d14413..06798dbce56 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 = 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/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) { From e614b8a0a24ca2a16d3751c488f2adcd6dfa7960 Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Wed, 15 Apr 2026 13:16:20 -0400 Subject: [PATCH 06/19] Correct some issues in the refactor --- src/EnergyPlus/CTElectricGenerator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/CTElectricGenerator.cc b/src/EnergyPlus/CTElectricGenerator.cc index 06798dbce56..11ce62bf83b 100644 --- a/src/EnergyPlus/CTElectricGenerator.cc +++ b/src/EnergyPlus/CTElectricGenerator.cc @@ -170,7 +170,7 @@ namespace CTElectricGenerator { int genNum = 1; for (auto const &generatorInstance : generatorObjects.value().items()) { auto const &generatorFields = generatorInstance.value(); - auto const generatorName = generatorInstance.key(); + auto const generatorName = Util::makeUPPER(generatorInstance.key()); auto const electricCircuitNodeName = inputProcessor->getAlphaFieldValue(generatorFields, objectSchemaProps, "electric_circuit_node_name"); auto const partLoadBasedFuelInputCurveName = From 45e903d8593282b807f42ddcf0c2b2b1854b5d27 Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Wed, 15 Apr 2026 12:34:08 -0400 Subject: [PATCH 07/19] Two more refactors --- src/EnergyPlus/BaseboardElectric.cc | 229 ++++---- src/EnergyPlus/EarthTube.cc | 792 +++++++++++++++------------- 2 files changed, 524 insertions(+), 497 deletions(-) diff --git a/src/EnergyPlus/BaseboardElectric.cc b/src/EnergyPlus/BaseboardElectric.cc index 13208c6f5d6..a7e0c043db7 100644 --- a/src/EnergyPlus/BaseboardElectric.cc +++ b/src/EnergyPlus/BaseboardElectric.cc @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -177,7 +176,7 @@ namespace BaseboardElectric { 3); // get input index to baseboard heating capacity sizing as fraction of autosized heating capacity auto &baseboard = state.dataBaseboardElectric; - std::string_view cCurrentModuleObject = cCMO_BBRadiator_Electric; + std::string const cCurrentModuleObject{cCMO_BBRadiator_Electric}; int NumConvElecBaseboards = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); @@ -185,139 +184,135 @@ namespace BaseboardElectric { if (NumConvElecBaseboards > 0) { // Get the data for cooling schemes bool ErrorsFound(false); // If errors detected in input - int NumAlphas = 0; - int NumNums = 0; - int IOStat = 0; int BaseboardNum = 0; - auto &s_ipsc = state.dataIPShortCut; - for (int ConvElecBBNum = 1; ConvElecBBNum <= NumConvElecBaseboards; ++ConvElecBBNum) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - ConvElecBBNum, - s_ipsc->cAlphaArgs, - NumAlphas, - s_ipsc->rNumericArgs, - NumNums, - IOStat, - s_ipsc->lNumericFieldBlanks, - s_ipsc->lAlphaFieldBlanks, - s_ipsc->cAlphaFieldNames, - s_ipsc->cNumericFieldNames); - - baseboard->baseboards(ConvElecBBNum).FieldNames.assign(s_ipsc->cNumericFieldNames.begin(), s_ipsc->cNumericFieldNames.end()); - - ErrorObjectHeader eoh{routineName, cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; - - // ErrorsFound will be set to True if problem was found, left untouched otherwise - VerifyUniqueBaseboardName( - state, cCurrentModuleObject, s_ipsc->cAlphaArgs(1), ErrorsFound, EnergyPlus::format("{} Name", cCurrentModuleObject)); - - ++BaseboardNum; - auto &thisBaseboard = baseboard->baseboards(BaseboardNum); - thisBaseboard.EquipName = s_ipsc->cAlphaArgs(1); // name of this baseboard - thisBaseboard.EquipType = Util::makeUPPER(cCurrentModuleObject); // the type of baseboard-rename change - thisBaseboard.Schedule = s_ipsc->cAlphaArgs(2); - if (s_ipsc->lAlphaFieldBlanks(2)) { - thisBaseboard.availSched = Sched::GetScheduleAlwaysOn(state); - } else if ((thisBaseboard.availSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { - ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); - ErrorsFound = true; - } - // get inlet node number - thisBaseboard.BaseboardEfficiency = s_ipsc->rNumericArgs(4); - - // Determine baseboard electric heating design capacity sizing method - if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "HeatingDesignCapacity")) { - thisBaseboard.HeatingCapMethod = HeatingDesignCapacity; - if (!s_ipsc->lNumericFieldBlanks(iHeatDesignCapacityNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum); - if (thisBaseboard.ScaledHeatingCapacity < 0.0 && thisBaseboard.ScaledHeatingCapacity != AutoSize) { - ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); - ShowContinueError(state, - EnergyPlus::format("Illegal {} = {:.7T}", - s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum), - s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum))); - ErrorsFound = true; - } - } else { - ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); - ShowContinueError(state, - EnergyPlus::format("Input for {} = {}", - s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), - s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); - ShowContinueError( - state, EnergyPlus::format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum))); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const &baseboardSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); + auto const baseboardObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + static constexpr std::array numericFieldNames = { + "Heating Design Capacity", "Heating Design Capacity Per Floor Area", "Fraction of Autosized Heating Design Capacity", "Efficiency"}; + static constexpr std::string_view availabilityScheduleFieldName = "Availability Schedule Name"; + static constexpr std::string_view heatingDesignCapacityMethodFieldName = "Heating Design Capacity Method"; + + if (baseboardObjects != inputProcessor->epJSON.end()) { + for (auto const &baseboardInstance : baseboardObjects.value().items()) { + auto const &baseboardFields = baseboardInstance.value(); + auto const baseboardName = Util::makeUPPER(baseboardInstance.key()); + auto const availabilityScheduleName = + inputProcessor->getAlphaFieldValue(baseboardFields, baseboardSchemaProps, "availability_schedule_name"); + auto const heatingDesignCapacityMethod = + inputProcessor->getAlphaFieldValue(baseboardFields, baseboardSchemaProps, "heating_design_capacity_method"); + + inputProcessor->markObjectAsUsed(cCurrentModuleObject, baseboardInstance.key()); + + baseboard->baseboards(BaseboardNum + 1).FieldNames.assign(numericFieldNames.begin(), numericFieldNames.end()); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, baseboardName}; + + VerifyUniqueBaseboardName( + state, cCurrentModuleObject, baseboardName, ErrorsFound, EnergyPlus::format("{} Name", cCurrentModuleObject)); + + ++BaseboardNum; + auto &thisBaseboard = baseboard->baseboards(BaseboardNum); + thisBaseboard.EquipName = baseboardName; + thisBaseboard.EquipType = Util::makeUPPER(cCurrentModuleObject); + thisBaseboard.Schedule = availabilityScheduleName; + if (availabilityScheduleName.empty()) { + thisBaseboard.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisBaseboard.availSched = Sched::GetSchedule(state, availabilityScheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, availabilityScheduleFieldName, availabilityScheduleName); ErrorsFound = true; } - } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "CapacityPerFloorArea")) { - thisBaseboard.HeatingCapMethod = CapacityPerFloorArea; - if (!s_ipsc->lNumericFieldBlanks(iHeatCapacityPerFloorAreaNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); - if (thisBaseboard.ScaledHeatingCapacity <= 0.0) { + thisBaseboard.BaseboardEfficiency = inputProcessor->getRealFieldValue(baseboardFields, baseboardSchemaProps, "efficiency"); + + if (Util::SameString(heatingDesignCapacityMethod, "HeatingDesignCapacity")) { + thisBaseboard.HeatingCapMethod = HeatingDesignCapacity; + auto const heatingDesignCapacityField = baseboardFields.find("heating_design_capacity"); + if (heatingDesignCapacityField != baseboardFields.end()) { + thisBaseboard.ScaledHeatingCapacity = + inputProcessor->getRealFieldValue(baseboardFields, baseboardSchemaProps, "heating_design_capacity"); + if (thisBaseboard.ScaledHeatingCapacity < 0.0 && thisBaseboard.ScaledHeatingCapacity != AutoSize) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); + ShowContinueError(state, + EnergyPlus::format("Illegal {} = {:.7T}", + numericFieldNames[iHeatDesignCapacityNumericNum - 1], + thisBaseboard.ScaledHeatingCapacity)); + ErrorsFound = true; + } + } else { ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); - ShowContinueError(state, - EnergyPlus::format("Input for {} = {}", - s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), - s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); - ShowContinueError(state, - EnergyPlus::format("Illegal {} = {:.7T}", - s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum), - s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum))); + ShowContinueError( + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatDesignCapacityNumericNum - 1])); ErrorsFound = true; - } else if (thisBaseboard.ScaledHeatingCapacity == AutoSize) { + } + } else if (Util::SameString(heatingDesignCapacityMethod, "CapacityPerFloorArea")) { + thisBaseboard.HeatingCapMethod = CapacityPerFloorArea; + auto const heatingDesignCapacityPerFloorAreaField = baseboardFields.find("heating_design_capacity_per_floor_area"); + if (heatingDesignCapacityPerFloorAreaField != baseboardFields.end()) { + thisBaseboard.ScaledHeatingCapacity = + inputProcessor->getRealFieldValue(baseboardFields, baseboardSchemaProps, "heating_design_capacity_per_floor_area"); + if (thisBaseboard.ScaledHeatingCapacity <= 0.0) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); + ShowContinueError( + state, + EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError(state, + EnergyPlus::format("Illegal {} = {:.7T}", + numericFieldNames[iHeatCapacityPerFloorAreaNumericNum - 1], + thisBaseboard.ScaledHeatingCapacity)); + ErrorsFound = true; + } else if (thisBaseboard.ScaledHeatingCapacity == AutoSize) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); + ShowContinueError( + state, + EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, EnergyPlus::format("Illegal {} = AutoSize", numericFieldNames[iHeatCapacityPerFloorAreaNumericNum - 1])); + ErrorsFound = true; + } + } else { ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); - ShowContinueError(state, - EnergyPlus::format("Input for {} = {}", - s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), - s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError( - state, EnergyPlus::format("Illegal {} = AutoSize", s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, + EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatCapacityPerFloorAreaNumericNum - 1])); ErrorsFound = true; } - } else { - ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); - ShowContinueError(state, - EnergyPlus::format("Input for {} = {}", - s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), - s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); - ShowContinueError( - state, - EnergyPlus::format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); - ErrorsFound = true; - } - } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "FractionOfAutosizedHeatingCapacity")) { - thisBaseboard.HeatingCapMethod = FractionOfAutosizedHeatingCapacity; - if (!s_ipsc->lNumericFieldBlanks(iHeatFracOfAutosizedCapacityNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); - if (thisBaseboard.ScaledHeatingCapacity < 0.0) { + } else if (Util::SameString(heatingDesignCapacityMethod, "FractionOfAutosizedHeatingCapacity")) { + thisBaseboard.HeatingCapMethod = FractionOfAutosizedHeatingCapacity; + auto const fractionOfAutosizedHeatingCapacityField = baseboardFields.find("fraction_of_autosized_heating_design_capacity"); + if (fractionOfAutosizedHeatingCapacityField != baseboardFields.end()) { + thisBaseboard.ScaledHeatingCapacity = inputProcessor->getRealFieldValue( + baseboardFields, baseboardSchemaProps, "fraction_of_autosized_heating_design_capacity"); + if (thisBaseboard.ScaledHeatingCapacity < 0.0) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); + ShowContinueError(state, + EnergyPlus::format("Illegal {} = {:.7T}", + numericFieldNames[iHeatFracOfAutosizedCapacityNumericNum - 1], + thisBaseboard.ScaledHeatingCapacity)); + ErrorsFound = true; + } + } else { ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); - ShowContinueError(state, - EnergyPlus::format("Illegal {} = {:.7T}", - s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum), - s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum))); + ShowContinueError( + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, + EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatFracOfAutosizedCapacityNumericNum - 1])); ErrorsFound = true; } } else { ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); ShowContinueError(state, - EnergyPlus::format("Input for {} = {}", - s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), - s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); - ShowContinueError( - state, - EnergyPlus::format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum))); + EnergyPlus::format("Illegal {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); ErrorsFound = true; } - } else { - ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, thisBaseboard.EquipName)); - ShowContinueError( - state, - EnergyPlus::format("Illegal {} = {}", s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); - ErrorsFound = true; - } - thisBaseboard.ZonePtr = DataZoneEquipment::GetZoneEquipControlledZoneNum( - state, DataZoneEquipment::ZoneEquipType::BaseboardConvectiveElectric, thisBaseboard.EquipName); + thisBaseboard.ZonePtr = DataZoneEquipment::GetZoneEquipControlledZoneNum( + state, DataZoneEquipment::ZoneEquipType::BaseboardConvectiveElectric, thisBaseboard.EquipName); + } } if (ErrorsFound) { diff --git a/src/EnergyPlus/EarthTube.cc b/src/EnergyPlus/EarthTube.cc index 77413c8dfc4..b708e75d979 100644 --- a/src/EnergyPlus/EarthTube.cc +++ b/src/EnergyPlus/EarthTube.cc @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -148,11 +147,31 @@ void GetEarthTube(EnergyPlusData &state, bool &ErrorsFound) // If errors found i // SUBROUTINE PARAMETER DEFINITIONS: Real64 constexpr EarthTubeTempLimit(100.0); // degrees Celsius + std::string const earthTubeParametersModuleObject = "ZoneEarthtube:Parameters"; + std::string const earthTubeModuleObject = "ZoneEarthtube"; + std::string_view constexpr earthTubeModelParametersNameFieldName = "Earth Tube Model Parameters Name"; + std::string_view constexpr zoneNameFieldName = "Zone Name"; + std::string_view constexpr scheduleNameFieldName = "Schedule Name"; + std::array constexpr numericFieldNames = {"Design Flow Rate", + "Minimum Zone Temperature when Cooling", + "Maximum Zone Temperature when Heating", + "Delta Temperature", + "Fan Pressure Rise", + "Fan Total Efficiency", + "Pipe Radius", + "Pipe Thickness", + "Pipe Length", + "Pipe Thermal Conductivity", + "Pipe Depth Under Ground Surface", + "Average Soil Surface Temperature", + "Amplitude of Soil Surface Temperature", + "Phase Constant of Soil Surface Temperature", + "Constant Term Flow Coefficient", + "Temperature Term Flow Coefficient", + "Velocity Term Flow Coefficient", + "Velocity Squared Term Flow Coefficient"}; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int NumAlpha; - int NumNumber; - int IOStat; int Loop; Array1D_bool RepVarSet; @@ -161,420 +180,433 @@ void GetEarthTube(EnergyPlusData &state, bool &ErrorsFound) // If errors found i // Following used for reporting state.dataEarthTube->ZnRptET.allocate(state.dataGlobal->NumOfZones); - auto &s_ipsc = state.dataIPShortCut; + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); - s_ipsc->cCurrentModuleObject = "ZoneEarthtube:Parameters"; - - int totEarthTubePars = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + int totEarthTubePars = inputProcessor->getNumObjectsFound(state, earthTubeParametersModuleObject); state.dataEarthTube->EarthTubePars.allocate(totEarthTubePars); - - for (Loop = 1; Loop <= totEarthTubePars; ++Loop) { - auto &thisEarthTubePars = state.dataEarthTube->EarthTubePars(Loop); - state.dataInputProcessing->inputProcessor->getObjectItem(state, - s_ipsc->cCurrentModuleObject, - Loop, - s_ipsc->cAlphaArgs, - NumAlpha, - s_ipsc->rNumericArgs, - NumNumber, - IOStat, - s_ipsc->lNumericFieldBlanks, - s_ipsc->lAlphaFieldBlanks, - s_ipsc->cAlphaFieldNames, - s_ipsc->cNumericFieldNames); - - thisEarthTubePars.nameParameters = s_ipsc->cAlphaArgs(1); - // Check to make sure name is unique - for (int otherParams = 1; otherParams < Loop; ++otherParams) { - if (Util::SameString(thisEarthTubePars.nameParameters, state.dataEarthTube->EarthTubePars(otherParams).nameParameters)) { - ShowSevereError( - state, - EnergyPlus::format( - "{}: {} = {} is not a unique name.", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1))); - ShowContinueError(state, EnergyPlus::format("Check the other {} names for a duplicate.", s_ipsc->cCurrentModuleObject)); - ErrorsFound = true; + auto const &earthTubeParametersSchemaProps = inputProcessor->getObjectSchemaProps(state, earthTubeParametersModuleObject); + auto const earthTubeParameterObjects = inputProcessor->epJSON.find(earthTubeParametersModuleObject); + + Loop = 0; + if (earthTubeParameterObjects != inputProcessor->epJSON.end()) { + for (auto const &earthTubeParameterInstance : earthTubeParameterObjects.value().items()) { + auto &thisEarthTubePars = state.dataEarthTube->EarthTubePars(++Loop); + auto const &earthTubeParameterFields = earthTubeParameterInstance.value(); + thisEarthTubePars.nameParameters = + inputProcessor->getAlphaFieldValue(earthTubeParameterFields, earthTubeParametersSchemaProps, "earth_tube_model_parameters_name"); + inputProcessor->markObjectAsUsed(earthTubeParametersModuleObject, earthTubeParameterInstance.key()); + + for (int otherParams = 1; otherParams < Loop; ++otherParams) { + if (Util::SameString(thisEarthTubePars.nameParameters, state.dataEarthTube->EarthTubePars(otherParams).nameParameters)) { + ShowSevereError(state, + EnergyPlus::format("{}: {} = {} is not a unique name.", + earthTubeParametersModuleObject, + earthTubeModelParametersNameFieldName, + thisEarthTubePars.nameParameters)); + ShowContinueError(state, EnergyPlus::format("Check the other {} names for a duplicate.", earthTubeParametersModuleObject)); + ErrorsFound = true; + } } - } - thisEarthTubePars.numNodesAbove = s_ipsc->rNumericArgs(1); - thisEarthTubePars.numNodesBelow = s_ipsc->rNumericArgs(2); - thisEarthTubePars.dimBoundAbove = s_ipsc->rNumericArgs(3); - thisEarthTubePars.dimBoundBelow = s_ipsc->rNumericArgs(4); - thisEarthTubePars.width = s_ipsc->rNumericArgs(5); + thisEarthTubePars.numNodesAbove = + inputProcessor->getIntFieldValue(earthTubeParameterFields, earthTubeParametersSchemaProps, "nodes_above_earth_tube"); + thisEarthTubePars.numNodesBelow = + inputProcessor->getIntFieldValue(earthTubeParameterFields, earthTubeParametersSchemaProps, "nodes_below_earth_tube"); + thisEarthTubePars.dimBoundAbove = inputProcessor->getRealFieldValue( + earthTubeParameterFields, earthTubeParametersSchemaProps, "earth_tube_dimensionless_boundary_above"); + thisEarthTubePars.dimBoundBelow = inputProcessor->getRealFieldValue( + earthTubeParameterFields, earthTubeParametersSchemaProps, "earth_tube_dimensionless_boundary_below"); + thisEarthTubePars.width = + inputProcessor->getRealFieldValue(earthTubeParameterFields, earthTubeParametersSchemaProps, "earth_tube_solution_space_width"); + } } - s_ipsc->cCurrentModuleObject = "ZoneEarthtube"; - totEarthTube = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + totEarthTube = inputProcessor->getNumObjectsFound(state, earthTubeModuleObject); state.dataEarthTube->EarthTubeSys.allocate(totEarthTube); - for (Loop = 1; Loop <= totEarthTube; ++Loop) { - auto &thisEarthTube = state.dataEarthTube->EarthTubeSys(Loop); - state.dataInputProcessing->inputProcessor->getObjectItem(state, - s_ipsc->cCurrentModuleObject, - Loop, - s_ipsc->cAlphaArgs, - NumAlpha, - s_ipsc->rNumericArgs, - NumNumber, - IOStat, - s_ipsc->lNumericFieldBlanks, - s_ipsc->lAlphaFieldBlanks, - s_ipsc->cAlphaFieldNames, - s_ipsc->cNumericFieldNames); - - ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; - - // First Alpha is Zone Name - thisEarthTube.ZonePtr = Util::FindItemInList(s_ipsc->cAlphaArgs(1), state.dataHeatBal->Zone); - if (thisEarthTube.ZonePtr == 0) { - ShowSevereError( - state, EnergyPlus::format("{}: {} not found={}", s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1))); - ErrorsFound = true; - } - - // Second Alpha is Schedule Name - if (s_ipsc->lAlphaFieldBlanks(2)) { - ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(2)); - ErrorsFound = true; - } else if ((thisEarthTube.availSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { - ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); - ErrorsFound = true; - } - - // Overall parameters and their limits - thisEarthTube.DesignLevel = s_ipsc->rNumericArgs(1); - - thisEarthTube.MinTemperature = s_ipsc->rNumericArgs(2); - if ((thisEarthTube.MinTemperature < -EarthTubeTempLimit) || (thisEarthTube.MinTemperature > EarthTubeTempLimit)) { - ShowSevereError(state, - EnergyPlus::format("{}: {}={} must have a minimum temperature between -{:.0R}C and {:.0R}C", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - s_ipsc->cAlphaArgs(1), - EarthTubeTempLimit, - EarthTubeTempLimit)); - ShowContinueError(state, EnergyPlus::format("Entered value={:.0R}", thisEarthTube.MinTemperature)); - ErrorsFound = true; - } - - thisEarthTube.MaxTemperature = s_ipsc->rNumericArgs(3); - if ((thisEarthTube.MaxTemperature < -EarthTubeTempLimit) || (thisEarthTube.MaxTemperature > EarthTubeTempLimit)) { - ShowSevereError(state, - EnergyPlus::format("{}: {}={} must have a maximum temperature between -{:.0R}C and {:.0R}C", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - s_ipsc->cAlphaArgs(1), - EarthTubeTempLimit, - EarthTubeTempLimit)); - ShowContinueError(state, EnergyPlus::format("Entered value={:.0R}", thisEarthTube.MaxTemperature)); - ErrorsFound = true; - } - - thisEarthTube.DelTemperature = s_ipsc->rNumericArgs(4); // 3/12/03 Negative del temp now allowed COP + auto const &earthTubeSchemaProps = inputProcessor->getObjectSchemaProps(state, earthTubeModuleObject); + auto const earthTubeObjects = inputProcessor->epJSON.find(earthTubeModuleObject); + std::string lastZoneName; + + Loop = 0; + if (earthTubeObjects != inputProcessor->epJSON.end()) { + for (auto const &earthTubeInstance : earthTubeObjects.value().items()) { + auto &thisEarthTube = state.dataEarthTube->EarthTubeSys(++Loop); + auto const &earthTubeFields = earthTubeInstance.value(); + auto const zoneName = inputProcessor->getAlphaFieldValue(earthTubeFields, earthTubeSchemaProps, "zone_name"); + auto const scheduleName = inputProcessor->getAlphaFieldValue(earthTubeFields, earthTubeSchemaProps, "schedule_name"); + auto const earthTubeType = inputProcessor->getAlphaFieldValue(earthTubeFields, earthTubeSchemaProps, "earthtube_type"); + auto const soilCondition = inputProcessor->getAlphaFieldValue(earthTubeFields, earthTubeSchemaProps, "soil_condition"); + auto const earthTubeModelType = inputProcessor->getAlphaFieldValue(earthTubeFields, earthTubeSchemaProps, "earth_tube_model_type"); + auto const earthTubeModelParameters = + inputProcessor->getAlphaFieldValue(earthTubeFields, earthTubeSchemaProps, "earth_tube_model_parameters"); + + inputProcessor->markObjectAsUsed(earthTubeModuleObject, earthTubeInstance.key()); + + ErrorObjectHeader eoh{routineName, earthTubeModuleObject, zoneName}; + lastZoneName = zoneName; + + // First Alpha is Zone Name + thisEarthTube.ZonePtr = Util::FindItemInList(zoneName, state.dataHeatBal->Zone); + if (thisEarthTube.ZonePtr == 0) { + ShowSevereError(state, EnergyPlus::format("{}: {} not found={}", earthTubeModuleObject, zoneNameFieldName, zoneName)); + ErrorsFound = true; + } - // if we have a blank, then just set it to the Natural type, otherwise, search on it - if (s_ipsc->cAlphaArgs(3).empty()) { - thisEarthTube.FanType = Ventilation::Natural; - } else { - thisEarthTube.FanType = static_cast(getEnumValue(ventilationNamesUC, s_ipsc->cAlphaArgs(3))); - if (thisEarthTube.FanType == Ventilation::Invalid) { - ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(3), s_ipsc->cAlphaArgs(3)); + // Second Alpha is Schedule Name + if (scheduleName.empty()) { + ShowSevereEmptyField(state, eoh, scheduleNameFieldName); + ErrorsFound = true; + } else if ((thisEarthTube.availSched = Sched::GetSchedule(state, scheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, scheduleNameFieldName, scheduleName); ErrorsFound = true; } - } - thisEarthTube.FanPressure = s_ipsc->rNumericArgs(5); - if (thisEarthTube.FanPressure < 0.0) { - ShowSevereError(state, - EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - s_ipsc->cAlphaArgs(1), - s_ipsc->cNumericFieldNames(5), - thisEarthTube.FanPressure)); - ErrorsFound = true; - } + // Overall parameters and their limits + thisEarthTube.DesignLevel = inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "design_flow_rate"); + + thisEarthTube.MinTemperature = + inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "minimum_zone_temperature_when_cooling"); + if ((thisEarthTube.MinTemperature < -EarthTubeTempLimit) || (thisEarthTube.MinTemperature > EarthTubeTempLimit)) { + ShowSevereError(state, + EnergyPlus::format("{}: {}={} must have a minimum temperature between -{:.0R}C and {:.0R}C", + earthTubeModuleObject, + zoneNameFieldName, + zoneName, + EarthTubeTempLimit, + EarthTubeTempLimit)); + ShowContinueError(state, EnergyPlus::format("Entered value={:.0R}", thisEarthTube.MinTemperature)); + ErrorsFound = true; + } - thisEarthTube.FanEfficiency = s_ipsc->rNumericArgs(6); - if ((thisEarthTube.FanEfficiency <= 0.0) || (thisEarthTube.FanEfficiency > 1.0)) { - ShowSevereError(state, - EnergyPlus::format("{}: {}={}, {} must be greater than zero and less than or equal to one, entered value={:.2R}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - s_ipsc->cAlphaArgs(1), - s_ipsc->cNumericFieldNames(6), - thisEarthTube.FanEfficiency)); - ErrorsFound = true; - } + thisEarthTube.MaxTemperature = + inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "maximum_zone_temperature_when_heating"); + if ((thisEarthTube.MaxTemperature < -EarthTubeTempLimit) || (thisEarthTube.MaxTemperature > EarthTubeTempLimit)) { + ShowSevereError(state, + EnergyPlus::format("{}: {}={} must have a maximum temperature between -{:.0R}C and {:.0R}C", + earthTubeModuleObject, + zoneNameFieldName, + zoneName, + EarthTubeTempLimit, + EarthTubeTempLimit)); + ShowContinueError(state, EnergyPlus::format("Entered value={:.0R}", thisEarthTube.MaxTemperature)); + ErrorsFound = true; + } - thisEarthTube.r1 = s_ipsc->rNumericArgs(7); - if (thisEarthTube.r1 <= 0.0) { - ShowSevereError(state, - EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - s_ipsc->cAlphaArgs(1), - s_ipsc->cNumericFieldNames(7), - thisEarthTube.r1)); - ErrorsFound = true; - } + thisEarthTube.DelTemperature = inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "delta_temperature"); - thisEarthTube.r2 = s_ipsc->rNumericArgs(8); - if (thisEarthTube.r2 <= 0.0) { - ShowSevereError(state, - EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - s_ipsc->cAlphaArgs(1), - s_ipsc->cNumericFieldNames(8), - thisEarthTube.r2)); - ErrorsFound = true; - } + // if we have a blank, then just set it to the Natural type, otherwise, search on it + if (earthTubeType.empty()) { + thisEarthTube.FanType = Ventilation::Natural; + } else { + thisEarthTube.FanType = static_cast(getEnumValue(ventilationNamesUC, earthTubeType)); + if (thisEarthTube.FanType == Ventilation::Invalid) { + ShowSevereInvalidKey(state, eoh, "Earthtube Type", earthTubeType); + ErrorsFound = true; + } + } - thisEarthTube.r3 = 2.0 * thisEarthTube.r1; - - thisEarthTube.PipeLength = s_ipsc->rNumericArgs(9); - if (thisEarthTube.PipeLength <= 0.0) { - ShowSevereError(state, - EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - s_ipsc->cAlphaArgs(1), - s_ipsc->cNumericFieldNames(9), - thisEarthTube.PipeLength)); - ErrorsFound = true; - } + thisEarthTube.FanPressure = inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "fan_pressure_rise"); + if (thisEarthTube.FanPressure < 0.0) { + ShowSevereError(state, + EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", + earthTubeModuleObject, + zoneNameFieldName, + zoneName, + numericFieldNames[4], + thisEarthTube.FanPressure)); + ErrorsFound = true; + } - thisEarthTube.PipeThermCond = s_ipsc->rNumericArgs(10); - if (thisEarthTube.PipeThermCond <= 0.0) { - ShowSevereError(state, - EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - s_ipsc->cAlphaArgs(1), - s_ipsc->cNumericFieldNames(10), - thisEarthTube.PipeThermCond)); - ErrorsFound = true; - } + thisEarthTube.FanEfficiency = inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "fan_total_efficiency"); + if ((thisEarthTube.FanEfficiency <= 0.0) || (thisEarthTube.FanEfficiency > 1.0)) { + ShowSevereError(state, + EnergyPlus::format("{}: {}={}, {} must be greater than zero and less than or equal to one, entered value={:.2R}", + earthTubeModuleObject, + zoneNameFieldName, + zoneName, + numericFieldNames[5], + thisEarthTube.FanEfficiency)); + ErrorsFound = true; + } - thisEarthTube.z = s_ipsc->rNumericArgs(11); - if (thisEarthTube.z <= 0.0) { - ShowSevereError(state, - EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - s_ipsc->cAlphaArgs(1), - s_ipsc->cNumericFieldNames(11), - thisEarthTube.z)); - ErrorsFound = true; - } - if (thisEarthTube.z <= (thisEarthTube.r1 + thisEarthTube.r2 + thisEarthTube.r3)) { - // Note that code in initEarthTubeVertical assumes that this check remains in place--if this ever gets changed, - // code in initEarthTubeVertical must be modified - ShowSevereError(state, - EnergyPlus::format("{}: {}={}, {} must be greater than 3*{} + {} entered value={:.2R} ref sum={:.2R}", - s_ipsc->cCurrentModuleObject, - s_ipsc->cAlphaFieldNames(1), - s_ipsc->cAlphaArgs(1), - s_ipsc->cNumericFieldNames(11), - s_ipsc->cNumericFieldNames(7), - s_ipsc->cNumericFieldNames(8), - thisEarthTube.z, - thisEarthTube.r1 + thisEarthTube.r2 + thisEarthTube.r3)); - ErrorsFound = true; - } + thisEarthTube.r1 = inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "pipe_radius"); + if (thisEarthTube.r1 <= 0.0) { + ShowSevereError(state, + EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", + earthTubeModuleObject, + zoneNameFieldName, + zoneName, + numericFieldNames[6], + thisEarthTube.r1)); + ErrorsFound = true; + } - SoilType soilType = static_cast(getEnumValue(soilTypeNamesUC, s_ipsc->cAlphaArgs(4))); - constexpr std::array(SoilType::Num)> thermalDiffusivity = {0.0781056, 0.055728, 0.0445824, 0.024192}; - constexpr std::array(SoilType::Num)> thermalConductivity = {2.42, 1.3, 0.865, 0.346}; - if (soilType == SoilType::Invalid) { - ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(4), s_ipsc->cAlphaArgs(4)); - ErrorsFound = true; - } else { - thisEarthTube.SoilThermDiff = thermalDiffusivity[static_cast(soilType)]; - thisEarthTube.SoilThermCond = thermalConductivity[static_cast(soilType)]; - } + thisEarthTube.r2 = inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "pipe_thickness"); + if (thisEarthTube.r2 <= 0.0) { + ShowSevereError(state, + EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", + earthTubeModuleObject, + zoneNameFieldName, + zoneName, + numericFieldNames[7], + thisEarthTube.r2)); + ErrorsFound = true; + } - thisEarthTube.AverSoilSurTemp = s_ipsc->rNumericArgs(12); - thisEarthTube.ApmlSoilSurTemp = s_ipsc->rNumericArgs(13); - thisEarthTube.SoilSurPhaseConst = int(s_ipsc->rNumericArgs(14)); + thisEarthTube.r3 = 2.0 * thisEarthTube.r1; + + thisEarthTube.PipeLength = inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "pipe_length"); + if (thisEarthTube.PipeLength <= 0.0) { + ShowSevereError(state, + EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", + earthTubeModuleObject, + zoneNameFieldName, + zoneName, + numericFieldNames[8], + thisEarthTube.PipeLength)); + ErrorsFound = true; + } - // Override any user input for cases where natural ventilation is being used - if (thisEarthTube.FanType == Ventilation::Natural) { - thisEarthTube.FanPressure = 0.0; - thisEarthTube.FanEfficiency = 1.0; - } + thisEarthTube.PipeThermCond = inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "pipe_thermal_conductivity"); + if (thisEarthTube.PipeThermCond <= 0.0) { + ShowSevereError(state, + EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", + earthTubeModuleObject, + zoneNameFieldName, + zoneName, + numericFieldNames[9], + thisEarthTube.PipeThermCond)); + ErrorsFound = true; + } - thisEarthTube.ConstantTermCoef = s_ipsc->rNumericArgs(15); - thisEarthTube.TemperatureTermCoef = s_ipsc->rNumericArgs(16); - thisEarthTube.VelocityTermCoef = s_ipsc->rNumericArgs(17); - thisEarthTube.VelocitySQTermCoef = s_ipsc->rNumericArgs(18); + thisEarthTube.z = inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "pipe_depth_under_ground_surface"); + if (thisEarthTube.z <= 0.0) { + ShowSevereError(state, + EnergyPlus::format("{}: {}={}, {} must be positive, entered value={:.2R}", + earthTubeModuleObject, + zoneNameFieldName, + zoneName, + numericFieldNames[10], + thisEarthTube.z)); + ErrorsFound = true; + } + if (thisEarthTube.z <= (thisEarthTube.r1 + thisEarthTube.r2 + thisEarthTube.r3)) { + // Note that code in initEarthTubeVertical assumes that this check remains in place--if this ever gets changed, + // code in initEarthTubeVertical must be modified + ShowSevereError(state, + EnergyPlus::format("{}: {}={}, {} must be greater than 3*{} + {} entered value={:.2R} ref sum={:.2R}", + earthTubeModuleObject, + zoneNameFieldName, + zoneName, + numericFieldNames[10], + numericFieldNames[6], + numericFieldNames[7], + thisEarthTube.z, + thisEarthTube.r1 + thisEarthTube.r2 + thisEarthTube.r3)); + ErrorsFound = true; + } - // cAlphaArgs(5)--Model type: basic or vertical - // only process cAlphaArgs(6) if cAlphaArgs(5) is "Vertical" - if (s_ipsc->cAlphaArgs(5).empty()) { - thisEarthTube.ModelType = EarthTubeModelType::Basic; - } else { - thisEarthTube.ModelType = static_cast(getEnumValue(solutionTypeNamesUC, s_ipsc->cAlphaArgs(5))); - if (thisEarthTube.ModelType == EarthTubeModelType::Invalid) { - ShowSevereInvalidKey(state, eoh, s_ipsc->cAlphaFieldNames(5), s_ipsc->cAlphaArgs(5)); + SoilType soilType = static_cast(getEnumValue(soilTypeNamesUC, soilCondition)); + constexpr std::array(SoilType::Num)> thermalDiffusivity = {0.0781056, 0.055728, 0.0445824, 0.024192}; + constexpr std::array(SoilType::Num)> thermalConductivity = {2.42, 1.3, 0.865, 0.346}; + if (soilType == SoilType::Invalid) { + ShowSevereInvalidKey(state, eoh, "Soil Condition", soilCondition); ErrorsFound = true; + } else { + thisEarthTube.SoilThermDiff = thermalDiffusivity[static_cast(soilType)]; + thisEarthTube.SoilThermCond = thermalConductivity[static_cast(soilType)]; } - } - if (thisEarthTube.ModelType == EarthTubeModelType::Vertical) { - thisEarthTube.r3 = 0.0; // Vertical model does not use this parameter--reset to zero (keep because r3=0 necessary so Rs=0 in calc routine) - // Process the parameters based on the name (link via index) - thisEarthTube.vertParametersPtr = 0; - for (int parIndex = 1; parIndex <= totEarthTubePars; ++parIndex) { - if (Util::SameString(s_ipsc->cAlphaArgs(6), state.dataEarthTube->EarthTubePars(parIndex).nameParameters)) { - thisEarthTube.vertParametersPtr = parIndex; - break; - } + thisEarthTube.AverSoilSurTemp = + inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "average_soil_surface_temperature"); + thisEarthTube.ApmlSoilSurTemp = + inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "amplitude_of_soil_surface_temperature"); + thisEarthTube.SoilSurPhaseConst = + int(inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "phase_constant_of_soil_surface_temperature")); + + // Override any user input for cases where natural ventilation is being used + if (thisEarthTube.FanType == Ventilation::Natural) { + thisEarthTube.FanPressure = 0.0; + thisEarthTube.FanEfficiency = 1.0; } - if (thisEarthTube.vertParametersPtr == 0) { // didn't find a match - ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(6), s_ipsc->cAlphaArgs(6)); - ErrorsFound = true; + + thisEarthTube.ConstantTermCoef = + inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "constant_term_flow_coefficient"); + thisEarthTube.TemperatureTermCoef = + inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "temperature_term_flow_coefficient"); + thisEarthTube.VelocityTermCoef = + inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "velocity_term_flow_coefficient"); + thisEarthTube.VelocitySQTermCoef = + inputProcessor->getRealFieldValue(earthTubeFields, earthTubeSchemaProps, "velocity_squared_term_flow_coefficient"); + + // Model type: basic or vertical + // only process the parameter link if model type is Vertical + if (earthTubeModelType.empty()) { + thisEarthTube.ModelType = EarthTubeModelType::Basic; + } else { + thisEarthTube.ModelType = static_cast(getEnumValue(solutionTypeNamesUC, earthTubeModelType)); + if (thisEarthTube.ModelType == EarthTubeModelType::Invalid) { + ShowSevereInvalidKey(state, eoh, "Earth Tube Model Type", earthTubeModelType); + ErrorsFound = true; + } } - } - if (thisEarthTube.ZonePtr > 0) { - if (RepVarSet(thisEarthTube.ZonePtr)) { - RepVarSet(thisEarthTube.ZonePtr) = false; - auto &zone = state.dataHeatBal->Zone(thisEarthTube.ZonePtr); - auto &thisZnRptET = state.dataEarthTube->ZnRptET(thisEarthTube.ZonePtr); + if (thisEarthTube.ModelType == EarthTubeModelType::Vertical) { + thisEarthTube.r3 = + 0.0; // Vertical model does not use this parameter--reset to zero (keep because r3=0 necessary so Rs=0 in calc routine) + // Process the parameters based on the name (link via index) + thisEarthTube.vertParametersPtr = 0; + for (int parIndex = 1; parIndex <= totEarthTubePars; ++parIndex) { + if (Util::SameString(earthTubeModelParameters, state.dataEarthTube->EarthTubePars(parIndex).nameParameters)) { + thisEarthTube.vertParametersPtr = parIndex; + break; + } + } + if (thisEarthTube.vertParametersPtr == 0) { // didn't find a match + ShowSevereItemNotFound(state, eoh, "Earth Tube Model Parameters", earthTubeModelParameters); + ErrorsFound = true; + } + } - SetupOutputVariable(state, - "Earth Tube Zone Sensible Cooling Energy", - Constant::Units::J, - thisZnRptET.EarthTubeHeatLoss, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Sum, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Zone Sensible Cooling Rate", - Constant::Units::W, - thisZnRptET.EarthTubeHeatLossRate, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Zone Sensible Heating Energy", - Constant::Units::J, - thisZnRptET.EarthTubeHeatGain, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Sum, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Zone Sensible Heating Rate", - Constant::Units::W, - thisZnRptET.EarthTubeHeatGainRate, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Air Flow Volume", - Constant::Units::m3, - thisZnRptET.EarthTubeVolume, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Sum, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Current Density Air Volume Flow Rate", - Constant::Units::m3_s, - thisZnRptET.EarthTubeVolFlowRate, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Standard Density Air Volume Flow Rate", - Constant::Units::m3_s, - thisZnRptET.EarthTubeVolFlowRateStd, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Air Flow Mass", - Constant::Units::kg, - thisZnRptET.EarthTubeMass, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Sum, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Air Mass Flow Rate", - Constant::Units::kg_s, - thisZnRptET.EarthTubeMassFlowRate, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Water Mass Flow Rate", - Constant::Units::kg_s, - thisZnRptET.EarthTubeWaterMassFlowRate, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Fan Electricity Energy", - Constant::Units::J, - thisZnRptET.EarthTubeFanElec, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Sum, - zone.Name, - Constant::eResource::Electricity, - OutputProcessor::Group::Building); - SetupOutputVariable(state, - "Earth Tube Fan Electricity Rate", - Constant::Units::W, - thisZnRptET.EarthTubeFanElecPower, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Zone Inlet Air Temperature", - Constant::Units::C, - thisZnRptET.EarthTubeAirTemp, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Ground Interface Temperature", - Constant::Units::C, - thisEarthTube.GroundTempt, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Outdoor Air Heat Transfer Rate", - Constant::Units::W, - thisZnRptET.EarthTubeOATreatmentPower, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Zone Inlet Wet Bulb Temperature", - Constant::Units::C, - thisZnRptET.EarthTubeWetBulbTemp, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); - SetupOutputVariable(state, - "Earth Tube Zone Inlet Humidity Ratio", - Constant::Units::kgWater_kgDryAir, - thisZnRptET.EarthTubeHumRat, - OutputProcessor::TimeStepType::System, - OutputProcessor::StoreType::Average, - zone.Name); + if (thisEarthTube.ZonePtr > 0) { + if (RepVarSet(thisEarthTube.ZonePtr)) { + RepVarSet(thisEarthTube.ZonePtr) = false; + auto &zone = state.dataHeatBal->Zone(thisEarthTube.ZonePtr); + auto &thisZnRptET = state.dataEarthTube->ZnRptET(thisEarthTube.ZonePtr); + + SetupOutputVariable(state, + "Earth Tube Zone Sensible Cooling Energy", + Constant::Units::J, + thisZnRptET.EarthTubeHeatLoss, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Sum, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Zone Sensible Cooling Rate", + Constant::Units::W, + thisZnRptET.EarthTubeHeatLossRate, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Zone Sensible Heating Energy", + Constant::Units::J, + thisZnRptET.EarthTubeHeatGain, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Sum, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Zone Sensible Heating Rate", + Constant::Units::W, + thisZnRptET.EarthTubeHeatGainRate, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Air Flow Volume", + Constant::Units::m3, + thisZnRptET.EarthTubeVolume, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Sum, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Current Density Air Volume Flow Rate", + Constant::Units::m3_s, + thisZnRptET.EarthTubeVolFlowRate, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Standard Density Air Volume Flow Rate", + Constant::Units::m3_s, + thisZnRptET.EarthTubeVolFlowRateStd, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Air Flow Mass", + Constant::Units::kg, + thisZnRptET.EarthTubeMass, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Sum, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Air Mass Flow Rate", + Constant::Units::kg_s, + thisZnRptET.EarthTubeMassFlowRate, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Water Mass Flow Rate", + Constant::Units::kg_s, + thisZnRptET.EarthTubeWaterMassFlowRate, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Fan Electricity Energy", + Constant::Units::J, + thisZnRptET.EarthTubeFanElec, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Sum, + zone.Name, + Constant::eResource::Electricity, + OutputProcessor::Group::Building); + SetupOutputVariable(state, + "Earth Tube Fan Electricity Rate", + Constant::Units::W, + thisZnRptET.EarthTubeFanElecPower, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Zone Inlet Air Temperature", + Constant::Units::C, + thisZnRptET.EarthTubeAirTemp, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Ground Interface Temperature", + Constant::Units::C, + thisEarthTube.GroundTempt, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Outdoor Air Heat Transfer Rate", + Constant::Units::W, + thisZnRptET.EarthTubeOATreatmentPower, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Zone Inlet Wet Bulb Temperature", + Constant::Units::C, + thisZnRptET.EarthTubeWetBulbTemp, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + SetupOutputVariable(state, + "Earth Tube Zone Inlet Humidity Ratio", + Constant::Units::kgWater_kgDryAir, + thisZnRptET.EarthTubeHumRat, + OutputProcessor::TimeStepType::System, + OutputProcessor::StoreType::Average, + zone.Name); + } } } } - CheckEarthTubesInZones(state, s_ipsc->cAlphaArgs(1), s_ipsc->cCurrentModuleObject, ErrorsFound); + CheckEarthTubesInZones(state, lastZoneName, earthTubeModuleObject, ErrorsFound); if (ErrorsFound) { - ShowFatalError(state, EnergyPlus::format("{}: Errors getting input. Program terminates.", s_ipsc->cCurrentModuleObject)); + ShowFatalError(state, EnergyPlus::format("{}: Errors getting input. Program terminates.", earthTubeModuleObject)); } } From 8c189e80561a7f664ec2d1a48483d273b3ccf2ce Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Thu, 16 Apr 2026 11:33:54 -0400 Subject: [PATCH 08/19] Remove unused variable --- src/EnergyPlus/BaseboardElectric.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/EnergyPlus/BaseboardElectric.cc b/src/EnergyPlus/BaseboardElectric.cc index a7e0c043db7..fbea4cb0563 100644 --- a/src/EnergyPlus/BaseboardElectric.cc +++ b/src/EnergyPlus/BaseboardElectric.cc @@ -169,7 +169,6 @@ namespace BaseboardElectric { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName("GetBaseboardInput: "); // include trailing blank space static constexpr std::string_view routineName = "GetBaseboardInput"; - int constexpr iHeatCAPMAlphaNum(3); // get input index to baseboard heating capacity sizing method int constexpr iHeatDesignCapacityNumericNum(1); // get input index to baseboard heating capacity int constexpr iHeatCapacityPerFloorAreaNumericNum(2); // get input index to baseboard heating capacity per floor area sizing int constexpr iHeatFracOfAutosizedCapacityNumericNum( From d8a45a17583460c594853017f1ab47403be56281 Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Wed, 15 Apr 2026 12:42:02 -0400 Subject: [PATCH 09/19] Initial unchecked refactor of two more files --- src/EnergyPlus/BaseboardRadiator.cc | 297 ++++++++++++++-------------- src/EnergyPlus/DataSurfaceColors.cc | 106 +++++----- 2 files changed, 199 insertions(+), 204 deletions(-) diff --git a/src/EnergyPlus/BaseboardRadiator.cc b/src/EnergyPlus/BaseboardRadiator.cc index c585e324e83..d5c38bfb3b9 100644 --- a/src/EnergyPlus/BaseboardRadiator.cc +++ b/src/EnergyPlus/BaseboardRadiator.cc @@ -59,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -228,11 +227,9 @@ namespace BaseboardRadiator { int constexpr iHeatCapacityPerFloorAreaNumericNum = 2; // index to baseboard Radiator system electric heating capacity per floor area sizing int constexpr iHeatFracOfAutosizedCapacityNumericNum = 3; // index to baseboard heating capacity fraction of autosized heating capacity - auto &s_ipsc = state.dataIPShortCut; + std::string const cCurrentModuleObject = cCMO_BBRadiator_Water; - s_ipsc->cCurrentModuleObject = cCMO_BBRadiator_Water; - - int NumConvHWBaseboards = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + int NumConvHWBaseboards = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); // Calculate total number of baseboard units @@ -240,168 +237,172 @@ namespace BaseboardRadiator { if (NumConvHWBaseboards > 0) { // Get the data for cooling schemes bool ErrorsFound(false); // If errors detected in input - for (int ConvHWBaseboardNum = 1; ConvHWBaseboardNum <= NumConvHWBaseboards; ++ConvHWBaseboardNum) { - int NumAlphas = 0; - int NumNums = 0; - int IOStat = 0; - - state.dataInputProcessing->inputProcessor->getObjectItem(state, - s_ipsc->cCurrentModuleObject, - ConvHWBaseboardNum, - 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 &thisBaseboard = state.dataBaseboardRadiator->baseboards(ConvHWBaseboardNum); - thisBaseboard.FieldNames.assign(s_ipsc->cNumericFieldNames.begin(), s_ipsc->cNumericFieldNames.end()); - - // ErrorsFound will be set to True if problem was found, left untouched otherwise - VerifyUniqueBaseboardName( - state, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject + " Name"); - - thisBaseboard.EquipID = s_ipsc->cAlphaArgs(1); // name of this baseboard - thisBaseboard.EquipType = DataPlant::PlantEquipmentType::Baseboard_Conv_Water; - thisBaseboard.Schedule = s_ipsc->cAlphaArgs(2); - if (s_ipsc->lAlphaFieldBlanks(2)) { - thisBaseboard.availSched = Sched::GetScheduleAlwaysOn(state); - } else if ((thisBaseboard.availSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { - ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); - ErrorsFound = true; - } - // get inlet node number - thisBaseboard.WaterInletNode = GetOnlySingleNode(state, - s_ipsc->cAlphaArgs(3), - ErrorsFound, - Node::ConnectionObjectType::ZoneHVACBaseboardConvectiveWater, - s_ipsc->cAlphaArgs(1), - Node::FluidType::Water, - Node::ConnectionType::Inlet, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - // get outlet node number - thisBaseboard.WaterOutletNode = GetOnlySingleNode(state, - s_ipsc->cAlphaArgs(4), - ErrorsFound, - Node::ConnectionObjectType::ZoneHVACBaseboardConvectiveWater, - s_ipsc->cAlphaArgs(1), - Node::FluidType::Water, - Node::ConnectionType::Outlet, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - - Node::TestCompSet( - state, cCMO_BBRadiator_Water, s_ipsc->cAlphaArgs(1), s_ipsc->cAlphaArgs(3), s_ipsc->cAlphaArgs(4), "Hot Water Nodes"); - - // Determine steam baseboard radiator system heating design capacity sizing method - if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "HeatingDesignCapacity")) { - thisBaseboard.HeatingCapMethod = HeatingDesignCapacity; - if (!s_ipsc->lNumericFieldBlanks(iHeatDesignCapacityNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum); - if (thisBaseboard.ScaledHeatingCapacity < 0.0 && thisBaseboard.ScaledHeatingCapacity != AutoSize) { - ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); - ShowContinueError(state, - EnergyPlus::format("Illegal {} = {:.7T}", - s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum), - s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum))); - ErrorsFound = true; - } - } else { - ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); - ShowContinueError(state, - EnergyPlus::format("Input for {} = {}", - s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), - s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); - ShowContinueError( - state, EnergyPlus::format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum))); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const &baseboardSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); + auto const baseboardObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + static constexpr std::array numericFieldNames = {"Heating Design Capacity", + "Heating Design Capacity Per Floor Area", + "Fraction of Autosized Heating Design Capacity", + "U-Factor Times Area Value", + "Maximum Water Flow Rate", + "Convergence Tolerance"}; + static constexpr std::string_view availabilityScheduleFieldName = "Availability Schedule Name"; + static constexpr std::string_view inletNodeFieldName = "Inlet Node Name"; + static constexpr std::string_view outletNodeFieldName = "Outlet Node Name"; + static constexpr std::string_view heatingDesignCapacityMethodFieldName = "Heating Design Capacity Method"; + + int ConvHWBaseboardNum = 0; + if (baseboardObjects != inputProcessor->epJSON.end()) { + for (auto const &baseboardInstance : baseboardObjects.value().items()) { + auto const &baseboardFields = baseboardInstance.value(); + auto const baseboardName = Util::makeUPPER(baseboardInstance.key()); + auto const availabilityScheduleName = + inputProcessor->getAlphaFieldValue(baseboardFields, baseboardSchemaProps, "availability_schedule_name"); + auto const inletNodeName = inputProcessor->getAlphaFieldValue(baseboardFields, baseboardSchemaProps, "inlet_node_name"); + auto const outletNodeName = inputProcessor->getAlphaFieldValue(baseboardFields, baseboardSchemaProps, "outlet_node_name"); + auto const heatingDesignCapacityMethod = + inputProcessor->getAlphaFieldValue(baseboardFields, baseboardSchemaProps, "heating_design_capacity_method"); + + inputProcessor->markObjectAsUsed(cCurrentModuleObject, baseboardInstance.key()); + + ++ConvHWBaseboardNum; + auto &thisBaseboard = state.dataBaseboardRadiator->baseboards(ConvHWBaseboardNum); + thisBaseboard.FieldNames.assign(numericFieldNames.begin(), numericFieldNames.end()); + + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, baseboardName}; + + VerifyUniqueBaseboardName(state, cCurrentModuleObject, baseboardName, ErrorsFound, cCurrentModuleObject + " Name"); + + thisBaseboard.EquipID = baseboardName; + thisBaseboard.EquipType = DataPlant::PlantEquipmentType::Baseboard_Conv_Water; + thisBaseboard.Schedule = availabilityScheduleName; + if (availabilityScheduleName.empty()) { + thisBaseboard.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((thisBaseboard.availSched = Sched::GetSchedule(state, availabilityScheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, availabilityScheduleFieldName, availabilityScheduleName); ErrorsFound = true; } - } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "CapacityPerFloorArea")) { - thisBaseboard.HeatingCapMethod = CapacityPerFloorArea; - if (!s_ipsc->lNumericFieldBlanks(iHeatCapacityPerFloorAreaNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); - if (thisBaseboard.ScaledHeatingCapacity <= 0.0) { + thisBaseboard.WaterInletNode = GetOnlySingleNode(state, + inletNodeName, + ErrorsFound, + Node::ConnectionObjectType::ZoneHVACBaseboardConvectiveWater, + baseboardName, + Node::FluidType::Water, + Node::ConnectionType::Inlet, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); + thisBaseboard.WaterOutletNode = GetOnlySingleNode(state, + outletNodeName, + ErrorsFound, + Node::ConnectionObjectType::ZoneHVACBaseboardConvectiveWater, + baseboardName, + Node::FluidType::Water, + Node::ConnectionType::Outlet, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); + + Node::TestCompSet(state, cCMO_BBRadiator_Water, baseboardName, inletNodeName, outletNodeName, "Hot Water Nodes"); + + if (Util::SameString(heatingDesignCapacityMethod, "HeatingDesignCapacity")) { + thisBaseboard.HeatingCapMethod = HeatingDesignCapacity; + auto const heatingDesignCapacityField = baseboardFields.find("heating_design_capacity"); + if (heatingDesignCapacityField != baseboardFields.end()) { + thisBaseboard.ScaledHeatingCapacity = + inputProcessor->getRealFieldValue(baseboardFields, baseboardSchemaProps, "heating_design_capacity"); + if (thisBaseboard.ScaledHeatingCapacity < 0.0 && thisBaseboard.ScaledHeatingCapacity != AutoSize) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); + ShowContinueError(state, + EnergyPlus::format("Illegal {} = {:.7T}", + numericFieldNames[iHeatDesignCapacityNumericNum - 1], + thisBaseboard.ScaledHeatingCapacity)); + ErrorsFound = true; + } + } else { ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); - ShowContinueError(state, - EnergyPlus::format("Input for {} = {}", - s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), - s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); - ShowContinueError(state, - EnergyPlus::format("Illegal {} = {:.7T}", - s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum), - s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum))); + ShowContinueError( + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatDesignCapacityNumericNum - 1])); ErrorsFound = true; - } else if (thisBaseboard.ScaledHeatingCapacity == AutoSize) { + } + } else if (Util::SameString(heatingDesignCapacityMethod, "CapacityPerFloorArea")) { + thisBaseboard.HeatingCapMethod = CapacityPerFloorArea; + auto const heatingDesignCapacityPerFloorAreaField = baseboardFields.find("heating_design_capacity_per_floor_area"); + if (heatingDesignCapacityPerFloorAreaField != baseboardFields.end()) { + thisBaseboard.ScaledHeatingCapacity = + inputProcessor->getRealFieldValue(baseboardFields, baseboardSchemaProps, "heating_design_capacity_per_floor_area"); + if (thisBaseboard.ScaledHeatingCapacity <= 0.0) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); + ShowContinueError( + state, + EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError(state, + EnergyPlus::format("Illegal {} = {:.7T}", + numericFieldNames[iHeatCapacityPerFloorAreaNumericNum - 1], + thisBaseboard.ScaledHeatingCapacity)); + ErrorsFound = true; + } else if (thisBaseboard.ScaledHeatingCapacity == AutoSize) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); + ShowContinueError( + state, + EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, EnergyPlus::format("Illegal {} = Autosize", numericFieldNames[iHeatCapacityPerFloorAreaNumericNum - 1])); + ErrorsFound = true; + } + } else { ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); - ShowContinueError(state, - EnergyPlus::format("Input for {} = {}", - s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), - s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); ShowContinueError( - state, EnergyPlus::format("Illegal {} = Autosize", s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, + EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatCapacityPerFloorAreaNumericNum - 1])); ErrorsFound = true; } - } else { - ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); - ShowContinueError(state, - EnergyPlus::format("Input for {} = {}", - s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), - s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); - ShowContinueError( - state, - EnergyPlus::format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum))); - ErrorsFound = true; - } - } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "FractionOfAutosizedHeatingCapacity")) { - thisBaseboard.HeatingCapMethod = FractionOfAutosizedHeatingCapacity; - if (!s_ipsc->lNumericFieldBlanks(iHeatFracOfAutosizedCapacityNumericNum)) { - thisBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); - if (thisBaseboard.ScaledHeatingCapacity < 0.0) { + } else if (Util::SameString(heatingDesignCapacityMethod, "FractionOfAutosizedHeatingCapacity")) { + thisBaseboard.HeatingCapMethod = FractionOfAutosizedHeatingCapacity; + auto const fractionOfAutosizedHeatingCapacityField = baseboardFields.find("fraction_of_autosized_heating_design_capacity"); + if (fractionOfAutosizedHeatingCapacityField != baseboardFields.end()) { + thisBaseboard.ScaledHeatingCapacity = inputProcessor->getRealFieldValue( + baseboardFields, baseboardSchemaProps, "fraction_of_autosized_heating_design_capacity"); + if (thisBaseboard.ScaledHeatingCapacity < 0.0) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); + ShowContinueError(state, + EnergyPlus::format("Illegal {} = {:.7T}", + numericFieldNames[iHeatFracOfAutosizedCapacityNumericNum - 1], + thisBaseboard.ScaledHeatingCapacity)); + ErrorsFound = true; + } + } else { ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); - ShowContinueError(state, - EnergyPlus::format("Illegal {} = {:.7T}", - s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum), - s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum))); + ShowContinueError( + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, + EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatFracOfAutosizedCapacityNumericNum - 1])); ErrorsFound = true; } } else { ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); ShowContinueError(state, - EnergyPlus::format("Input for {} = {}", - s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), - s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); - ShowContinueError( - state, - EnergyPlus::format("Blank field not allowed for {}", s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum))); + EnergyPlus::format("Illegal {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); ErrorsFound = true; } - } else { - ShowSevereError(state, EnergyPlus::format("{} = {}", cCMO_BBRadiator_Water, thisBaseboard.EquipID)); - ShowContinueError( - state, - EnergyPlus::format("Illegal {} = {}", s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum), s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum))); - ErrorsFound = true; - } - thisBaseboard.UA = s_ipsc->rNumericArgs(4); - thisBaseboard.WaterVolFlowRateMax = s_ipsc->rNumericArgs(5); - thisBaseboard.Offset = s_ipsc->rNumericArgs(6); - // Set default convergence tolerance - if (thisBaseboard.Offset <= 0.0) { - thisBaseboard.Offset = 0.001; - } + thisBaseboard.UA = inputProcessor->getRealFieldValue(baseboardFields, baseboardSchemaProps, "u_factor_times_area_value"); + thisBaseboard.WaterVolFlowRateMax = + inputProcessor->getRealFieldValue(baseboardFields, baseboardSchemaProps, "maximum_water_flow_rate"); + thisBaseboard.Offset = inputProcessor->getRealFieldValue(baseboardFields, baseboardSchemaProps, "convergence_tolerance"); + // Set default convergence tolerance + if (thisBaseboard.Offset <= 0.0) { + thisBaseboard.Offset = 0.001; + } - thisBaseboard.ZonePtr = DataZoneEquipment::GetZoneEquipControlledZoneNum( - state, DataZoneEquipment::ZoneEquipType::BaseboardConvectiveWater, thisBaseboard.EquipID); + thisBaseboard.ZonePtr = DataZoneEquipment::GetZoneEquipControlledZoneNum( + state, DataZoneEquipment::ZoneEquipType::BaseboardConvectiveWater, thisBaseboard.EquipID); - thisBaseboard.checkForZoneSizing(state); // check if any autosizing is being done + thisBaseboard.checkForZoneSizing(state); // check if any autosizing is being done + } } if (ErrorsFound) { diff --git a/src/EnergyPlus/DataSurfaceColors.cc b/src/EnergyPlus/DataSurfaceColors.cc index 8bae1941a33..d041826429b 100644 --- a/src/EnergyPlus/DataSurfaceColors.cc +++ b/src/EnergyPlus/DataSurfaceColors.cc @@ -137,66 +137,60 @@ void SetUpSchemeColors(EnergyPlusData &state, std::string const &SchemeName, std state.dataSurfColor->DXFcolorno = DataSurfaceColors::defaultcolorno; - // first see if there is a scheme name - int numptr = state.dataInputProcessing->inputProcessor->getObjectItemNum(state, CurrentModuleObject, SchemeName); - if (numptr > 0) { - - int NumAlphas; - int numNumbers; - int numargs; - int status; - Array1D_string cAlphas; - Array1D_string cAlphaFields; - Array1D_string cNumericFields; - Array1D_bool lAlphaBlanks; - Array1D_bool lNumericBlanks; - Array1D rNumerics; - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, numargs, NumAlphas, numNumbers); - - cAlphas.allocate(NumAlphas); - cAlphaFields.allocate(NumAlphas); - lAlphaBlanks.allocate(NumAlphas); - rNumerics.allocate(numNumbers); - cNumericFields.allocate(numNumbers); - lNumericBlanks.allocate(numNumbers); - - cAlphas({1, NumAlphas}) = ""; - rNumerics({1, numNumbers}) = 0.0; - - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject, - numptr, - cAlphas, - NumAlphas, - rNumerics, - numNumbers, - status, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - for (numargs = 1; numargs <= numNumbers; ++numargs) { - numptr = rNumerics(numargs); // set to integer - if (lNumericBlanks(numargs)) { - if (!lAlphaBlanks(numargs + 1)) { + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const surfaceColorSchemes = inputProcessor->epJSON.find(std::string(CurrentModuleObject)); + if (surfaceColorSchemes != inputProcessor->epJSON.end()) { + auto matchedScheme = surfaceColorSchemes.value().end(); + for (auto it = surfaceColorSchemes.value().begin(); it != surfaceColorSchemes.value().end(); ++it) { + if (Util::SameString(it.key(), SchemeName)) { + matchedScheme = it; + break; + } + } + + if (matchedScheme != surfaceColorSchemes.value().end()) { + auto const &schemeFields = matchedScheme.value(); + inputProcessor->markObjectAsUsed(std::string(CurrentModuleObject), matchedScheme.key()); + + for (int numargs = 1;; ++numargs) { + auto const drawingElementKey = EnergyPlus::format("drawing_element_{}_type", numargs); + auto const colorKey = EnergyPlus::format("color_for_drawing_element_{}", numargs); + auto const drawingElementIt = schemeFields.find(drawingElementKey); + auto const colorIt = schemeFields.find(colorKey); + + if (drawingElementIt == schemeFields.end() && colorIt == schemeFields.end()) { + break; + } + + std::string const drawingElementFieldName = EnergyPlus::format("Drawing Element {} Type", numargs); + std::string const colorFieldName = EnergyPlus::format("Color for Drawing Element {}", numargs); + std::string const drawingElement = (drawingElementIt != schemeFields.end()) ? drawingElementIt->get() : ""; + + if (colorIt == schemeFields.end()) { + if (!drawingElement.empty()) { + ShowWarningError(state, + EnergyPlus::format("SetUpSchemeColors: {}={}, {}={}, {} was blank. Default color retained.", + "Name", + SchemeName, + drawingElementFieldName, + drawingElement, + colorFieldName)); + } + continue; + } + + int const numptr = colorIt->get(); + if (!MatchAndSetColorTextString(state, drawingElement, numptr, ColorType)) { ShowWarningError(state, - EnergyPlus::format("SetUpSchemeColors: {}={}, {}={}, {} was blank. Default color retained.", - cAlphaFields(1), + EnergyPlus::format("SetUpSchemeColors: {}={}, {}={}, is invalid. No color set.", + "Name", SchemeName, - cAlphaFields(numargs + 1), - cAlphas(numargs + 1), - cNumericFields(numargs))); + drawingElementFieldName, + drawingElement)); } - continue; - } - if (!MatchAndSetColorTextString(state, cAlphas(numargs + 1), numptr, ColorType)) { - ShowWarningError(state, - EnergyPlus::format("SetUpSchemeColors: {}={}, {}={}, is invalid. No color set.", - cAlphaFields(1), - SchemeName, - cAlphaFields(numargs + 1), - cAlphas(numargs + 1))); } + } else { + ShowWarningError(state, EnergyPlus::format("SetUpSchemeColors: Name={} not on input file. Default colors will be used.", SchemeName)); } } else { ShowWarningError(state, EnergyPlus::format("SetUpSchemeColors: Name={} not on input file. Default colors will be used.", SchemeName)); From 394925e620e686669d541a7778a81b0e1bd5f0f6 Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Thu, 16 Apr 2026 17:43:22 -0400 Subject: [PATCH 10/19] Remove more unused variables --- src/EnergyPlus/BaseboardRadiator.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/EnergyPlus/BaseboardRadiator.cc b/src/EnergyPlus/BaseboardRadiator.cc index d5c38bfb3b9..5911f843832 100644 --- a/src/EnergyPlus/BaseboardRadiator.cc +++ b/src/EnergyPlus/BaseboardRadiator.cc @@ -222,7 +222,6 @@ namespace BaseboardRadiator { // SUBROUTINE PARAMETER DEFINITIONS: static constexpr std::string_view RoutineName = "GetBaseboardInput: "; // include trailing blank space static constexpr std::string_view routineName = "GetBaseboardInput"; - int constexpr iHeatCAPMAlphaNum = 5; // get input index to water baseboard Radiator system heating capacity sizing method int constexpr iHeatDesignCapacityNumericNum = 1; // get input index to water baseboard Radiator system electric heating capacity int constexpr iHeatCapacityPerFloorAreaNumericNum = 2; // index to baseboard Radiator system electric heating capacity per floor area sizing int constexpr iHeatFracOfAutosizedCapacityNumericNum = 3; // index to baseboard heating capacity fraction of autosized heating capacity @@ -247,8 +246,6 @@ namespace BaseboardRadiator { "Maximum Water Flow Rate", "Convergence Tolerance"}; static constexpr std::string_view availabilityScheduleFieldName = "Availability Schedule Name"; - static constexpr std::string_view inletNodeFieldName = "Inlet Node Name"; - static constexpr std::string_view outletNodeFieldName = "Outlet Node Name"; static constexpr std::string_view heatingDesignCapacityMethodFieldName = "Heating Design Capacity Method"; int ConvHWBaseboardNum = 0; From 7452bc2995630820cbf9bdafde5ffca7911d0cc4 Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Wed, 15 Apr 2026 14:51:00 -0400 Subject: [PATCH 11/19] Another set of unchecked refactors --- src/EnergyPlus/CostEstimateManager.cc | 146 +++++---- src/EnergyPlus/ElectricBaseboardRadiator.cc | 322 +++++++++++--------- 2 files changed, 260 insertions(+), 208 deletions(-) diff --git a/src/EnergyPlus/CostEstimateManager.cc b/src/EnergyPlus/CostEstimateManager.cc index 8d4b94a2b3d..c258782df1e 100644 --- a/src/EnergyPlus/CostEstimateManager.cc +++ b/src/EnergyPlus/CostEstimateManager.cc @@ -61,7 +61,6 @@ #include // #include #include -#include #include #include #include @@ -150,15 +149,14 @@ namespace CostEstimateManager { // Using/Aliasing // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int Item; // Item to be "gotten" + int Item; int NumCostAdjust; int NumRefAdjust; - 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 - int NumLineItems = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ComponentCost:LineItem"); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + + int NumLineItems = inputProcessor->getNumObjectsFound(state, "ComponentCost:LineItem"); if (NumLineItems == 0) { state.dataCostEstimateManager->DoCostEstimate = false; @@ -170,52 +168,69 @@ namespace CostEstimateManager { if (!allocated(state.dataCostEstimateManager->CostLineItem)) { state.dataCostEstimateManager->CostLineItem.allocate(NumLineItems); } - auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; + std::string cCurrentModuleObject; cCurrentModuleObject = "ComponentCost:LineItem"; - for (Item = 1; Item <= NumLineItems; ++Item) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - Item, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNumbers, - IOStatus); - state.dataCostEstimateManager->CostLineItem(Item).LineName = state.dataIPShortCut->cAlphaArgs(1); - state.dataCostEstimateManager->CostLineItem(Item).ParentObjType = - static_cast(getEnumValue(ParentObjectNamesUC, state.dataIPShortCut->cAlphaArgs(3))); - state.dataCostEstimateManager->CostLineItem(Item).ParentObjName = state.dataIPShortCut->cAlphaArgs(4); - state.dataCostEstimateManager->CostLineItem(Item).PerEach = state.dataIPShortCut->rNumericArgs(1); - state.dataCostEstimateManager->CostLineItem(Item).PerSquareMeter = state.dataIPShortCut->rNumericArgs(2); - state.dataCostEstimateManager->CostLineItem(Item).PerKiloWattCap = state.dataIPShortCut->rNumericArgs(3); - state.dataCostEstimateManager->CostLineItem(Item).PerKWCapPerCOP = state.dataIPShortCut->rNumericArgs(4); - state.dataCostEstimateManager->CostLineItem(Item).PerCubicMeter = state.dataIPShortCut->rNumericArgs(5); - state.dataCostEstimateManager->CostLineItem(Item).PerCubMeterPerSec = state.dataIPShortCut->rNumericArgs(6); - state.dataCostEstimateManager->CostLineItem(Item).PerUAinWattperDelK = state.dataIPShortCut->rNumericArgs(7); - state.dataCostEstimateManager->CostLineItem(Item).Qty = state.dataIPShortCut->rNumericArgs(8); + auto const &lineItemSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); + auto const lineItemObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + Item = 0; + if (lineItemObjects != inputProcessor->epJSON.end()) { + for (auto const &lineItemInstance : lineItemObjects.value().items()) { + auto const &lineItemFields = lineItemInstance.value(); + + inputProcessor->markObjectAsUsed(cCurrentModuleObject, lineItemInstance.key()); + + ++Item; + auto &costLineItem = state.dataCostEstimateManager->CostLineItem(Item); + costLineItem.LineName = Util::makeUPPER(lineItemInstance.key()); + costLineItem.ParentObjType = static_cast( + getEnumValue(ParentObjectNamesUC, inputProcessor->getAlphaFieldValue(lineItemFields, lineItemSchemaProps, "line_item_type"))); + costLineItem.ParentObjName = + Util::makeUPPER(inputProcessor->getAlphaFieldValue(lineItemFields, lineItemSchemaProps, "item_name")); + costLineItem.PerEach = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_each"); + costLineItem.PerSquareMeter = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_area"); + costLineItem.PerKiloWattCap = + inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_unit_of_output_capacity"); + costLineItem.PerKWCapPerCOP = + inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_unit_of_output_capacity_per_cop"); + costLineItem.PerCubicMeter = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_volume"); + costLineItem.PerCubMeterPerSec = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_volume_rate"); + costLineItem.PerUAinWattperDelK = + inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_energy_per_temperature_difference"); + auto const quantityField = lineItemFields.find("quantity"); + costLineItem.Qty = + (quantityField != lineItemFields.end()) ? inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "quantity") : 0.0; + } } // most input error checking to be performed later within Case construct in Calc routine. cCurrentModuleObject = "ComponentCost:Adjustments"; - NumCostAdjust = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + NumCostAdjust = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (NumCostAdjust == 1) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - 1, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNumbers, - IOStatus); - state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter = state.dataIPShortCut->rNumericArgs(1); - state.dataCostEstimateManager->CurntBldg.DesignFeeFrac = state.dataIPShortCut->rNumericArgs(2); - state.dataCostEstimateManager->CurntBldg.ContractorFeeFrac = state.dataIPShortCut->rNumericArgs(3); - state.dataCostEstimateManager->CurntBldg.ContingencyFrac = state.dataIPShortCut->rNumericArgs(4); - state.dataCostEstimateManager->CurntBldg.BondCostFrac = state.dataIPShortCut->rNumericArgs(5); - state.dataCostEstimateManager->CurntBldg.CommissioningFrac = state.dataIPShortCut->rNumericArgs(6); - state.dataCostEstimateManager->CurntBldg.RegionalModifier = state.dataIPShortCut->rNumericArgs(7); + auto const &costAdjustSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); + auto const costAdjustObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + if (costAdjustObjects != inputProcessor->epJSON.end()) { + auto const &costAdjustInstance = *costAdjustObjects.value().items().begin(); + auto const &costAdjustFields = costAdjustInstance.value(); + + inputProcessor->markObjectAsUsed(cCurrentModuleObject, costAdjustInstance.key()); + + state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter = + inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "miscellaneous_cost_per_conditioned_area"); + state.dataCostEstimateManager->CurntBldg.DesignFeeFrac = + inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "design_and_engineering_fees"); + state.dataCostEstimateManager->CurntBldg.ContractorFeeFrac = + inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "contractor_fee"); + state.dataCostEstimateManager->CurntBldg.ContingencyFrac = + inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "contingency"); + state.dataCostEstimateManager->CurntBldg.BondCostFrac = + inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "permits_bonding_and_insurance"); + state.dataCostEstimateManager->CurntBldg.CommissioningFrac = + inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "commissioning_fee"); + state.dataCostEstimateManager->CurntBldg.RegionalModifier = + inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "regional_adjustment_factor"); + } } else if (NumCostAdjust > 1) { ShowSevereError(state, EnergyPlus::format("{}: Only one instance of this object is allowed.", cCurrentModuleObject)); @@ -223,24 +238,33 @@ namespace CostEstimateManager { } cCurrentModuleObject = "ComponentCost:Reference"; - NumRefAdjust = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + NumRefAdjust = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (NumRefAdjust == 1) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - 1, - state.dataIPShortCut->cAlphaArgs, - NumAlphas, - state.dataIPShortCut->rNumericArgs, - NumNumbers, - IOStatus); - state.dataCostEstimateManager->RefrncBldg.LineItemTot = state.dataIPShortCut->rNumericArgs(1); - state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter = state.dataIPShortCut->rNumericArgs(2); - state.dataCostEstimateManager->RefrncBldg.DesignFeeFrac = state.dataIPShortCut->rNumericArgs(3); - state.dataCostEstimateManager->RefrncBldg.ContractorFeeFrac = state.dataIPShortCut->rNumericArgs(4); - state.dataCostEstimateManager->RefrncBldg.ContingencyFrac = state.dataIPShortCut->rNumericArgs(5); - state.dataCostEstimateManager->RefrncBldg.BondCostFrac = state.dataIPShortCut->rNumericArgs(6); - state.dataCostEstimateManager->RefrncBldg.CommissioningFrac = state.dataIPShortCut->rNumericArgs(7); - state.dataCostEstimateManager->RefrncBldg.RegionalModifier = state.dataIPShortCut->rNumericArgs(8); + auto const &referenceSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); + auto const referenceObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + if (referenceObjects != inputProcessor->epJSON.end()) { + auto const &referenceInstance = *referenceObjects.value().items().begin(); + auto const &referenceFields = referenceInstance.value(); + + inputProcessor->markObjectAsUsed(cCurrentModuleObject, referenceInstance.key()); + + state.dataCostEstimateManager->RefrncBldg.LineItemTot = + inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_line_item_costs"); + state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter = inputProcessor->getRealFieldValue( + referenceFields, referenceSchemaProps, "reference_building_miscellaneous_cost_per_conditioned_area"); + state.dataCostEstimateManager->RefrncBldg.DesignFeeFrac = + inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_design_and_engineering_fees"); + state.dataCostEstimateManager->RefrncBldg.ContractorFeeFrac = + inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_contractor_fee"); + state.dataCostEstimateManager->RefrncBldg.ContingencyFrac = + inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_contingency"); + state.dataCostEstimateManager->RefrncBldg.BondCostFrac = inputProcessor->getRealFieldValue( + referenceFields, referenceSchemaProps, "reference_building_permits_bonding_and_insurance"); + state.dataCostEstimateManager->RefrncBldg.CommissioningFrac = + inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_commissioning_fee"); + state.dataCostEstimateManager->RefrncBldg.RegionalModifier = + inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_regional_adjustment_factor"); + } } else if (NumRefAdjust > 1) { ShowSevereError(state, EnergyPlus::format("{} : Only one instance of this object is allowed.", cCurrentModuleObject)); diff --git a/src/EnergyPlus/ElectricBaseboardRadiator.cc b/src/EnergyPlus/ElectricBaseboardRadiator.cc index f92cc6af329..3a8991ec790 100644 --- a/src/EnergyPlus/ElectricBaseboardRadiator.cc +++ b/src/EnergyPlus/ElectricBaseboardRadiator.cc @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -184,146 +183,170 @@ namespace ElectricBaseboardRadiator { 3); // get input index to HW baseboard heating capacity sizing as fraction of autosized heating capacity // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int NumAlphas; - int NumNumbers; - int IOStat; bool ErrorsFound(false); // If errors detected in input - auto &s_ipsc = state.dataIPShortCut; - - s_ipsc->cCurrentModuleObject = state.dataElectBaseboardRad->cCMO_BBRadiator_Electric; + auto const cCurrentModuleObject = state.dataElectBaseboardRad->cCMO_BBRadiator_Electric; // Update Num in state and make local convenience copy int NumElecBaseboards = state.dataElectBaseboardRad->NumElecBaseboards = - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); // object is extensible, no max args needed as IPShortCuts being used auto &ElecBaseboardNumericFields = state.dataElectBaseboardRad->ElecBaseboardNumericFields; state.dataElectBaseboardRad->ElecBaseboard.allocate(NumElecBaseboards); ElecBaseboardNumericFields.allocate(NumElecBaseboards); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + auto const &elecBaseboardSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); + auto const elecBaseboardObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + static constexpr std::array numericFieldNames = {"Heating Design Capacity", + "Heating Design Capacity Per Floor Area", + "Fraction of Autosized Heating Design Capacity", + "Efficiency", + "Fraction Radiant", + "Fraction of Radiant Energy Incident on People"}; + static constexpr std::string_view availabilityScheduleFieldName = "Availability Schedule Name"; + static constexpr std::string_view heatingDesignCapacityMethodFieldName = "Heating Design Capacity Method"; + static constexpr std::string_view radiantSurfaceFractionFieldName = "Fraction of Radiant Energy to Surface"; + auto const &surfaceFractionSchemaProps = elecBaseboardSchemaProps.at("surface_fractions").at("items").at("properties"); + + int BaseboardNum = 0; + if (elecBaseboardObjects != inputProcessor->epJSON.end()) { + for (auto const &elecBaseboardInstance : elecBaseboardObjects.value().items()) { + auto const &elecBaseboardFields = elecBaseboardInstance.value(); + auto const elecBaseboardName = Util::makeUPPER(elecBaseboardInstance.key()); + auto const availabilityScheduleName = + inputProcessor->getAlphaFieldValue(elecBaseboardFields, elecBaseboardSchemaProps, "availability_schedule_name"); + auto const heatingDesignCapacityMethod = + inputProcessor->getAlphaFieldValue(elecBaseboardFields, elecBaseboardSchemaProps, "heating_design_capacity_method"); + auto const surfaceFractionsField = elecBaseboardFields.find("surface_fractions"); + + inputProcessor->markObjectAsUsed(cCurrentModuleObject, elecBaseboardInstance.key()); + + ++BaseboardNum; + auto &elecBaseboard = state.dataElectBaseboardRad->ElecBaseboard(BaseboardNum); + + int numSurfaceFractions = 0; + if (surfaceFractionsField != elecBaseboardFields.end()) { + numSurfaceFractions = static_cast(surfaceFractionsField->size()); + } - for (int BaseboardNum = 1; BaseboardNum <= NumElecBaseboards; ++BaseboardNum) { - auto &elecBaseboard = state.dataElectBaseboardRad->ElecBaseboard(BaseboardNum); + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, elecBaseboardName}; - state.dataInputProcessing->inputProcessor->getObjectItem(state, - s_ipsc->cCurrentModuleObject, - BaseboardNum, - s_ipsc->cAlphaArgs, - NumAlphas, - s_ipsc->rNumericArgs, - NumNumbers, - IOStat, - s_ipsc->lNumericFieldBlanks, - s_ipsc->lAlphaFieldBlanks, - s_ipsc->cAlphaFieldNames, - s_ipsc->cNumericFieldNames); - - ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; - - ElecBaseboardNumericFields(BaseboardNum).FieldNames.allocate(NumNumbers); - ElecBaseboardNumericFields(BaseboardNum).FieldNames = ""; - ElecBaseboardNumericFields(BaseboardNum).FieldNames = s_ipsc->cNumericFieldNames; - - // ErrorsFound will be set to True if problem was found, left untouched otherwise - GlobalNames::VerifyUniqueBaseboardName( - state, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1), ErrorsFound, s_ipsc->cCurrentModuleObject + " Name"); - - elecBaseboard.EquipName = s_ipsc->cAlphaArgs(1); // name of this baseboard - elecBaseboard.Schedule = s_ipsc->cAlphaArgs(2); - if (s_ipsc->lAlphaFieldBlanks(2)) { - elecBaseboard.availSched = Sched::GetScheduleAlwaysOn(state); - } else if ((elecBaseboard.availSched = Sched::GetSchedule(state, s_ipsc->cAlphaArgs(2))) == nullptr) { - ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(2), s_ipsc->cAlphaArgs(2)); - ErrorsFound = true; - } + ElecBaseboardNumericFields(BaseboardNum).FieldNames.allocate(6 + numSurfaceFractions); + ElecBaseboardNumericFields(BaseboardNum).FieldNames = ""; + for (int fieldNum = 1; fieldNum <= 6; ++fieldNum) { + ElecBaseboardNumericFields(BaseboardNum).FieldNames(fieldNum) = numericFieldNames[fieldNum - 1]; + } + for (int fieldNum = 1; fieldNum <= numSurfaceFractions; ++fieldNum) { + ElecBaseboardNumericFields(BaseboardNum).FieldNames(fieldNum + 6) = radiantSurfaceFractionFieldName; + } - // Determine HW radiant baseboard heating design capacity sizing method - if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "HeatingDesignCapacity")) { - elecBaseboard.HeatingCapMethod = DataSizing::HeatingDesignCapacity; + GlobalNames::VerifyUniqueBaseboardName(state, cCurrentModuleObject, elecBaseboardName, ErrorsFound, cCurrentModuleObject + " Name"); - if (!s_ipsc->lNumericFieldBlanks(iHeatDesignCapacityNumericNum)) { - elecBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum); - if (elecBaseboard.ScaledHeatingCapacity < 0.0 && elecBaseboard.ScaledHeatingCapacity != DataSizing::AutoSize) { - ShowSevereError(state, EnergyPlus::format("{} = {}", s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName)); - ShowContinueError(state, - EnergyPlus::format("Illegal {} = {:.7T}", - s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum), - s_ipsc->rNumericArgs(iHeatDesignCapacityNumericNum))); - ErrorsFound = true; - } - } else { - ShowSevereError(state, EnergyPlus::format("{} = {}", s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName)); - ShowContinueError(state, - "Input for " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); - ShowContinueError(state, "Blank field not allowed for " + s_ipsc->cNumericFieldNames(iHeatDesignCapacityNumericNum)); + elecBaseboard.EquipName = elecBaseboardName; + elecBaseboard.Schedule = availabilityScheduleName; + if (availabilityScheduleName.empty()) { + elecBaseboard.availSched = Sched::GetScheduleAlwaysOn(state); + } else if ((elecBaseboard.availSched = Sched::GetSchedule(state, availabilityScheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, availabilityScheduleFieldName, availabilityScheduleName); ErrorsFound = true; } - } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "CapacityPerFloorArea")) { - elecBaseboard.HeatingCapMethod = DataSizing::CapacityPerFloorArea; - if (!s_ipsc->lNumericFieldBlanks(iHeatCapacityPerFloorAreaNumericNum)) { - elecBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum); - if (elecBaseboard.ScaledHeatingCapacity <= 0.0) { - ShowSevereError(state, EnergyPlus::format("{} = {}", s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName)); - ShowContinueError(state, - "Input for " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); - ShowContinueError(state, - EnergyPlus::format("Illegal {} = {:.7T}", - s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum), - s_ipsc->rNumericArgs(iHeatCapacityPerFloorAreaNumericNum))); + + if (Util::SameString(heatingDesignCapacityMethod, "HeatingDesignCapacity")) { + elecBaseboard.HeatingCapMethod = DataSizing::HeatingDesignCapacity; + auto const heatingDesignCapacityField = elecBaseboardFields.find("heating_design_capacity"); + if (heatingDesignCapacityField != elecBaseboardFields.end()) { + elecBaseboard.ScaledHeatingCapacity = + inputProcessor->getRealFieldValue(elecBaseboardFields, elecBaseboardSchemaProps, "heating_design_capacity"); + if (elecBaseboard.ScaledHeatingCapacity < 0.0 && elecBaseboard.ScaledHeatingCapacity != DataSizing::AutoSize) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, elecBaseboard.EquipName)); + ShowContinueError(state, + EnergyPlus::format("Illegal {} = {:.7T}", + numericFieldNames[iHeatDesignCapacityNumericNum - 1], + elecBaseboard.ScaledHeatingCapacity)); + ErrorsFound = true; + } + } else { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, elecBaseboard.EquipName)); + ShowContinueError( + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatDesignCapacityNumericNum - 1])); ErrorsFound = true; - } else if (elecBaseboard.ScaledHeatingCapacity == DataSizing::AutoSize) { - ShowSevereError(state, EnergyPlus::format("{} = {}", s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName)); - ShowContinueError(state, - "Input for " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); - ShowContinueError(state, "Illegal " + s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum) + " = Autosize"); + } + } else if (Util::SameString(heatingDesignCapacityMethod, "CapacityPerFloorArea")) { + elecBaseboard.HeatingCapMethod = DataSizing::CapacityPerFloorArea; + auto const heatingDesignCapacityPerFloorAreaField = elecBaseboardFields.find("heating_design_capacity_per_floor_area"); + if (heatingDesignCapacityPerFloorAreaField != elecBaseboardFields.end()) { + elecBaseboard.ScaledHeatingCapacity = inputProcessor->getRealFieldValue( + elecBaseboardFields, elecBaseboardSchemaProps, "heating_design_capacity_per_floor_area"); + if (elecBaseboard.ScaledHeatingCapacity <= 0.0) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, elecBaseboard.EquipName)); + ShowContinueError( + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError(state, + EnergyPlus::format("Illegal {} = {:.7T}", + numericFieldNames[iHeatCapacityPerFloorAreaNumericNum - 1], + elecBaseboard.ScaledHeatingCapacity)); + ErrorsFound = true; + } else if (elecBaseboard.ScaledHeatingCapacity == DataSizing::AutoSize) { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, elecBaseboard.EquipName)); + ShowContinueError( + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, EnergyPlus::format("Illegal {} = Autosize", numericFieldNames[iHeatCapacityPerFloorAreaNumericNum - 1])); + ErrorsFound = true; + } + } else { + ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, elecBaseboard.EquipName)); + ShowContinueError( + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatCapacityPerFloorAreaNumericNum - 1])); ErrorsFound = true; } - } else { - ShowSevereError(state, EnergyPlus::format(s_ipsc->cCurrentModuleObject, elecBaseboard.EquipName)); - ShowContinueError(state, - "Input for " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); - ShowContinueError(state, "Blank field not allowed for " + s_ipsc->cNumericFieldNames(iHeatCapacityPerFloorAreaNumericNum)); - ErrorsFound = true; - } - } else if (Util::SameString(s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum), "FractionOfAutosizedHeatingCapacity")) { - elecBaseboard.HeatingCapMethod = DataSizing::FractionOfAutosizedHeatingCapacity; - if (!s_ipsc->lNumericFieldBlanks(iHeatFracOfAutosizedCapacityNumericNum)) { - elecBaseboard.ScaledHeatingCapacity = s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum); - if (elecBaseboard.ScaledHeatingCapacity < 0.0) { - ShowSevereError(state, s_ipsc->cCurrentModuleObject + " = " + elecBaseboard.EquipName); - ShowContinueError(state, - EnergyPlus::format("Illegal {} = {:.7T}", - s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum), - s_ipsc->rNumericArgs(iHeatFracOfAutosizedCapacityNumericNum))); + } else if (Util::SameString(heatingDesignCapacityMethod, "FractionOfAutosizedHeatingCapacity")) { + elecBaseboard.HeatingCapMethod = DataSizing::FractionOfAutosizedHeatingCapacity; + auto const fractionOfAutosizedCapacityField = elecBaseboardFields.find("fraction_of_autosized_heating_design_capacity"); + if (fractionOfAutosizedCapacityField != elecBaseboardFields.end()) { + elecBaseboard.ScaledHeatingCapacity = inputProcessor->getRealFieldValue( + elecBaseboardFields, elecBaseboardSchemaProps, "fraction_of_autosized_heating_design_capacity"); + if (elecBaseboard.ScaledHeatingCapacity < 0.0) { + ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowContinueError(state, + EnergyPlus::format("Illegal {} = {:.7T}", + numericFieldNames[iHeatFracOfAutosizedCapacityNumericNum - 1], + elecBaseboard.ScaledHeatingCapacity)); + ErrorsFound = true; + } + } else { + ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowContinueError( + state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError( + state, EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatFracOfAutosizedCapacityNumericNum - 1])); ErrorsFound = true; } } else { - ShowSevereError(state, s_ipsc->cCurrentModuleObject + " = " + elecBaseboard.EquipName); - ShowContinueError(state, - "Input for " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); - ShowContinueError(state, "Blank field not allowed for " + s_ipsc->cNumericFieldNames(iHeatFracOfAutosizedCapacityNumericNum)); + ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowContinueError(state, EnergyPlus::format("Illegal {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); ErrorsFound = true; } - } else { - ShowSevereError(state, s_ipsc->cCurrentModuleObject + " = " + elecBaseboard.EquipName); - ShowContinueError(state, "Illegal " + s_ipsc->cAlphaFieldNames(iHeatCAPMAlphaNum) + " = " + s_ipsc->cAlphaArgs(iHeatCAPMAlphaNum)); - ErrorsFound = true; - } - elecBaseboard.BaseboardEfficiency = s_ipsc->rNumericArgs(4); - elecBaseboard.FracRadiant = s_ipsc->rNumericArgs(5); + elecBaseboard.BaseboardEfficiency = inputProcessor->getRealFieldValue(elecBaseboardFields, elecBaseboardSchemaProps, "efficiency"); + elecBaseboard.FracRadiant = inputProcessor->getRealFieldValue(elecBaseboardFields, elecBaseboardSchemaProps, "fraction_radiant"); if (elecBaseboard.FracRadiant < MinFraction) { ShowWarningError(state, - std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + - s_ipsc->cNumericFieldNames(5) + " was lower than the allowable minimum."); + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{numericFieldNames[4]} + " was lower than the allowable minimum."); ShowContinueError(state, EnergyPlus::format("...reset to minimum value=[{:.2R}].", MinFraction)); elecBaseboard.FracRadiant = MinFraction; } if (elecBaseboard.FracRadiant > MaxFraction) { ShowWarningError(state, - std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + - s_ipsc->cNumericFieldNames(5) + " was higher than the allowable maximum."); + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{numericFieldNames[4]} + " was higher than the allowable maximum."); ShowContinueError(state, EnergyPlus::format("...reset to maximum value=[{:.2R}].", MaxFraction)); elecBaseboard.FracRadiant = MaxFraction; } @@ -331,7 +354,7 @@ namespace ElectricBaseboardRadiator { // Remaining fraction is added to the zone as convective heat transfer if (elecBaseboard.FracRadiant > MaxFraction) { ShowWarningError(state, - std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", Fraction Radiant was higher than the allowable maximum."); elecBaseboard.FracRadiant = MaxFraction; elecBaseboard.FracConvect = 0.0; @@ -339,31 +362,32 @@ namespace ElectricBaseboardRadiator { elecBaseboard.FracConvect = 1.0 - elecBaseboard.FracRadiant; } - elecBaseboard.FracDistribPerson = s_ipsc->rNumericArgs(6); + elecBaseboard.FracDistribPerson = inputProcessor->getRealFieldValue( + elecBaseboardFields, elecBaseboardSchemaProps, "fraction_of_radiant_energy_incident_on_people"); if (elecBaseboard.FracDistribPerson < MinFraction) { ShowWarningError(state, - std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + - s_ipsc->cNumericFieldNames(6) + " was lower than the allowable minimum."); + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{numericFieldNames[5]} + " was lower than the allowable minimum."); ShowContinueError(state, EnergyPlus::format("...reset to minimum value=[{:.2R}].", MinFraction)); elecBaseboard.FracDistribPerson = MinFraction; } if (elecBaseboard.FracDistribPerson > MaxFraction) { ShowWarningError(state, - std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + - s_ipsc->cNumericFieldNames(6) + " was higher than the allowable maximum."); + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{numericFieldNames[5]} + " was higher than the allowable maximum."); ShowContinueError(state, EnergyPlus::format("...reset to maximum value=[{:.2R}].", MaxFraction)); elecBaseboard.FracDistribPerson = MaxFraction; } - elecBaseboard.TotSurfToDistrib = NumNumbers - 6; + elecBaseboard.TotSurfToDistrib = numSurfaceFractions; if ((elecBaseboard.TotSurfToDistrib < MinDistribSurfaces) && (elecBaseboard.FracRadiant > MinFraction)) { ShowSevereError(state, - std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", the number of surface/radiant fraction groups entered was less than the allowable minimum."); ShowContinueError(state, EnergyPlus::format("...the minimum that must be entered=[{}].", MinDistribSurfaces)); ErrorsFound = true; - elecBaseboard.TotSurfToDistrib = 0; // error + elecBaseboard.TotSurfToDistrib = 0; } elecBaseboard.SurfaceName.allocate(elecBaseboard.TotSurfToDistrib); @@ -373,32 +397,35 @@ namespace ElectricBaseboardRadiator { elecBaseboard.FracDistribToSurf.allocate(elecBaseboard.TotSurfToDistrib); elecBaseboard.FracDistribToSurf = 0.0; - elecBaseboard.ZonePtr = - DataZoneEquipment::GetZoneEquipControlledZoneNum(state, DataZoneEquipment::ZoneEquipType::BaseboardElectric, elecBaseboard.EquipName); + elecBaseboard.ZonePtr = + DataZoneEquipment::GetZoneEquipControlledZoneNum(state, DataZoneEquipment::ZoneEquipType::BaseboardElectric, elecBaseboard.EquipName); Real64 AllFracsSummed = elecBaseboard.FracDistribPerson; for (int SurfNum = 1; SurfNum <= elecBaseboard.TotSurfToDistrib; ++SurfNum) { - elecBaseboard.SurfaceName(SurfNum) = s_ipsc->cAlphaArgs(SurfNum + 3); - elecBaseboard.SurfacePtr(SurfNum) = HeatBalanceIntRadExchange::GetRadiantSystemSurface(state, - s_ipsc->cCurrentModuleObject, - elecBaseboard.EquipName, - elecBaseboard.ZonePtr, - elecBaseboard.SurfaceName(SurfNum), - ErrorsFound); - elecBaseboard.FracDistribToSurf(SurfNum) = s_ipsc->rNumericArgs(SurfNum + 6); + auto const &surfaceFraction = (*surfaceFractionsField)[SurfNum - 1]; + elecBaseboard.SurfaceName(SurfNum) = + inputProcessor->getAlphaFieldValue(surfaceFraction, surfaceFractionSchemaProps, "surface_name"); + elecBaseboard.SurfacePtr(SurfNum) = HeatBalanceIntRadExchange::GetRadiantSystemSurface(state, + cCurrentModuleObject, + elecBaseboard.EquipName, + elecBaseboard.ZonePtr, + elecBaseboard.SurfaceName(SurfNum), + ErrorsFound); + elecBaseboard.FracDistribToSurf(SurfNum) = + inputProcessor->getRealFieldValue(surfaceFraction, surfaceFractionSchemaProps, "fraction_of_radiant_energy_to_surface"); if (elecBaseboard.FracDistribToSurf(SurfNum) > MaxFraction) { ShowWarningError(state, - std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + - s_ipsc->cNumericFieldNames(SurfNum + 6) + "was greater than the allowable maximum."); + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{radiantSurfaceFractionFieldName} + " was greater than the allowable maximum."); ShowContinueError(state, EnergyPlus::format("...reset to maximum value=[{:.2R}].", MaxFraction)); - elecBaseboard.TotSurfToDistrib = MaxFraction; + elecBaseboard.FracDistribToSurf(SurfNum) = MaxFraction; } if (elecBaseboard.FracDistribToSurf(SurfNum) < MinFraction) { ShowWarningError(state, - std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + "\", " + - s_ipsc->cNumericFieldNames(SurfNum + 6) + "was less than the allowable minimum."); - ShowContinueError(state, EnergyPlus::format("...reset to maximum value=[{:.2R}].", MinFraction)); - elecBaseboard.TotSurfToDistrib = MinFraction; + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{radiantSurfaceFractionFieldName} + " was less than the allowable minimum."); + ShowContinueError(state, EnergyPlus::format("...reset to minimum value=[{:.2R}].", MinFraction)); + elecBaseboard.FracDistribToSurf(SurfNum) = MinFraction; } if (elecBaseboard.SurfacePtr(SurfNum) != 0) { state.dataSurface->surfIntConv(elecBaseboard.SurfacePtr(SurfNum)).getsRadiantHeat = true; @@ -408,23 +435,24 @@ namespace ElectricBaseboardRadiator { AllFracsSummed += elecBaseboard.FracDistribToSurf(SurfNum); } // Surfaces - if (AllFracsSummed > (MaxFraction + 0.01)) { - ShowSevereError(state, - std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + - "\", Summed radiant fractions for people + surface groups > 1.0"); - ErrorsFound = true; - } - if ((AllFracsSummed < (MaxFraction - 0.01)) && - (elecBaseboard.FracRadiant > MinFraction)) { // User didn't distribute all of the | radiation warn that some will be lost - ShowWarningError(state, - std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "=\"" + s_ipsc->cAlphaArgs(1) + - "\", Summed radiant fractions for people + surface groups < 1.0"); - ShowContinueError(state, "The rest of the radiant energy delivered by the baseboard heater will be lost"); + if (AllFracsSummed > (MaxFraction + 0.01)) { + ShowSevereError(state, + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + + "\", Summed radiant fractions for people + surface groups > 1.0"); + ErrorsFound = true; + } + if ((AllFracsSummed < (MaxFraction - 0.01)) && + (elecBaseboard.FracRadiant > MinFraction)) { // User didn't distribute all of the | radiation warn that some will be lost + ShowWarningError(state, + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + + "\", Summed radiant fractions for people + surface groups < 1.0"); + ShowContinueError(state, "The rest of the radiant energy delivered by the baseboard heater will be lost"); + } } } if (ErrorsFound) { - ShowFatalError(state, std::string{RoutineName} + s_ipsc->cCurrentModuleObject + "Errors found getting input. Program terminates."); + ShowFatalError(state, std::string{RoutineName} + cCurrentModuleObject + "Errors found getting input. Program terminates."); } for (auto &elecBaseboard : state.dataElectBaseboardRad->ElecBaseboard) { From d8a7100ea65bb06f04537fced4e7552a2eed6f3d Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Thu, 16 Apr 2026 21:15:52 -0400 Subject: [PATCH 12/19] Minor cleanup --- src/EnergyPlus/ElectricBaseboardRadiator.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/EnergyPlus/ElectricBaseboardRadiator.cc b/src/EnergyPlus/ElectricBaseboardRadiator.cc index 3a8991ec790..cdeb3fb8139 100644 --- a/src/EnergyPlus/ElectricBaseboardRadiator.cc +++ b/src/EnergyPlus/ElectricBaseboardRadiator.cc @@ -176,7 +176,6 @@ namespace ElectricBaseboardRadiator { Real64 constexpr MinFraction(0.0); // Minimum limit of fractional values // INTEGER,PARAMETER :: MaxDistribSurfaces = 20 ! Maximum number of surfaces that a baseboard heater can radiate to int constexpr MinDistribSurfaces(1); // Minimum number of surfaces that a baseboard heater can radiate to - int constexpr iHeatCAPMAlphaNum(3); // get input index to HW baseboard heating capacity sizing method int constexpr iHeatDesignCapacityNumericNum(1); // get input index to HW baseboard heating capacity int constexpr iHeatCapacityPerFloorAreaNumericNum(2); // get input index to HW baseboard heating capacity per floor area sizing int constexpr iHeatFracOfAutosizedCapacityNumericNum( From 578624468493244dbe3c96c85ce605185cf7409f Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Thu, 16 Apr 2026 21:43:11 -0400 Subject: [PATCH 13/19] Two more files and formatting --- src/EnergyPlus/CostEstimateManager.cc | 12 +- src/EnergyPlus/DataSurfaceLists.cc | 387 +++++++++----------- src/EnergyPlus/ElectricBaseboardRadiator.cc | 186 +++++----- src/EnergyPlus/GeneratorFuelSupply.cc | 210 ++++++----- 4 files changed, 389 insertions(+), 406 deletions(-) diff --git a/src/EnergyPlus/CostEstimateManager.cc b/src/EnergyPlus/CostEstimateManager.cc index c258782df1e..0c856c018cd 100644 --- a/src/EnergyPlus/CostEstimateManager.cc +++ b/src/EnergyPlus/CostEstimateManager.cc @@ -185,8 +185,7 @@ namespace CostEstimateManager { costLineItem.LineName = Util::makeUPPER(lineItemInstance.key()); costLineItem.ParentObjType = static_cast( getEnumValue(ParentObjectNamesUC, inputProcessor->getAlphaFieldValue(lineItemFields, lineItemSchemaProps, "line_item_type"))); - costLineItem.ParentObjName = - Util::makeUPPER(inputProcessor->getAlphaFieldValue(lineItemFields, lineItemSchemaProps, "item_name")); + costLineItem.ParentObjName = Util::makeUPPER(inputProcessor->getAlphaFieldValue(lineItemFields, lineItemSchemaProps, "item_name")); costLineItem.PerEach = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_each"); costLineItem.PerSquareMeter = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_area"); costLineItem.PerKiloWattCap = @@ -198,8 +197,9 @@ namespace CostEstimateManager { costLineItem.PerUAinWattperDelK = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_energy_per_temperature_difference"); auto const quantityField = lineItemFields.find("quantity"); - costLineItem.Qty = - (quantityField != lineItemFields.end()) ? inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "quantity") : 0.0; + costLineItem.Qty = (quantityField != lineItemFields.end()) + ? inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "quantity") + : 0.0; } } @@ -258,8 +258,8 @@ namespace CostEstimateManager { inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_contractor_fee"); state.dataCostEstimateManager->RefrncBldg.ContingencyFrac = inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_contingency"); - state.dataCostEstimateManager->RefrncBldg.BondCostFrac = inputProcessor->getRealFieldValue( - referenceFields, referenceSchemaProps, "reference_building_permits_bonding_and_insurance"); + state.dataCostEstimateManager->RefrncBldg.BondCostFrac = + inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_permits_bonding_and_insurance"); state.dataCostEstimateManager->RefrncBldg.CommissioningFrac = inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_commissioning_fee"); state.dataCostEstimateManager->RefrncBldg.RegionalModifier = diff --git a/src/EnergyPlus/DataSurfaceLists.cc b/src/EnergyPlus/DataSurfaceLists.cc index d9f68cf4b9f..6a1365c515f 100644 --- a/src/EnergyPlus/DataSurfaceLists.cc +++ b/src/EnergyPlus/DataSurfaceLists.cc @@ -86,21 +86,9 @@ void GetSurfaceListsInputs(EnergyPlusData &state) Real64 constexpr SurfListMinFlowFrac(0.001); // Minimum allowed flow fraction (to avoid divide by zero) // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Array1D_string Alphas; // Alpha items for object - Array1D_string cAlphaFields; // Alpha field names - Array1D_string cNumericFields; // Numeric field names - int MaxAlphas; // Maximum number of alphas for these input keywords - int MaxNumbers; // Maximum number of numbers for these input keywords - int NameConflict; // Used to see if a surface name matches the name of a surface list (not allowed) - Array1D Numbers; // Numeric items for object - int NumAlphas; // Number of Alphas for each GetObjectItem call - int NumArgs; // Unused variable that is part of a subroutine call - int NumNumbers; // Number of Numbers for each GetObjectItem call - Real64 SumOfAllFractions; // Summation of all of the fractions for splitting flow (must sum to 1) - Array1D_bool lAlphaBlanks; // Logical array, alpha field input BLANK = .TRUE. - Array1D_bool lNumericBlanks; // Logical array, numeric field input BLANK = .TRUE. + int NameConflict; // Used to see if a surface name matches the name of a surface list (not allowed) + Real64 SumOfAllFractions; // Summation of all of the fractions for splitting flow (must sum to 1) bool ErrorsFound; - int IOStatus; // Obtain all of the user data related to surface lists. Need to get // this before getting the radiant system or ventilated slab data. @@ -110,236 +98,219 @@ void GetSurfaceListsInputs(EnergyPlusData &state) ErrorsFound = false; + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + // Update Num in state and make local convenience copy - int NumOfSurfaceLists = state.dataSurfLists->NumOfSurfaceLists = - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject1); - int NumOfSurfListVentSlab = state.dataSurfLists->NumOfSurfListVentSlab = - state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject2); + int NumOfSurfaceLists = state.dataSurfLists->NumOfSurfaceLists = inputProcessor->getNumObjectsFound(state, CurrentModuleObject1); + int NumOfSurfListVentSlab = state.dataSurfLists->NumOfSurfListVentSlab = inputProcessor->getNumObjectsFound(state, CurrentModuleObject2); SurfList.allocate(NumOfSurfaceLists); SlabList.allocate(NumOfSurfListVentSlab); if (NumOfSurfaceLists > 0) { + auto const &surfaceGroupSchemaProps = inputProcessor->getObjectSchemaProps(state, std::string(CurrentModuleObject1)); + auto const &surfaceFractionSchemaProps = surfaceGroupSchemaProps.at("surface_fractions").at("items").at("properties"); + auto const surfaceGroupObjects = inputProcessor->epJSON.find(std::string(CurrentModuleObject1)); + static constexpr std::string_view surfaceNameFieldName = "Surface Name"; + if (surfaceGroupObjects != inputProcessor->epJSON.end()) { + int Item = 0; + for (auto const &surfaceGroupInstance : surfaceGroupObjects.value().items()) { + auto const &surfaceGroupFields = surfaceGroupInstance.value(); + auto const surfaceGroupName = Util::makeUPPER(surfaceGroupInstance.key()); + auto const surfaceFractionsField = surfaceGroupFields.find("surface_fractions"); + + inputProcessor->markObjectAsUsed(std::string(CurrentModuleObject1), surfaceGroupInstance.key()); + + ++Item; + SurfList(Item).Name = surfaceGroupName; + SurfList(Item).NumOfSurfaces = + (surfaceFractionsField != surfaceGroupFields.end()) ? static_cast(surfaceFractionsField->size()) : 0; + + NameConflict = Util::FindItemInList(SurfList(Item).Name, state.dataSurface->Surface); + if (NameConflict > 0) { // A surface list has the same name as a surface--not allowed + ShowSevereError(state, + EnergyPlus::format("{}{}", + CurrentModuleObject1, + " = " + SurfList(Item).Name + " has the same name as a surface; this is not allowed.")); + ErrorsFound = true; + } - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject1, NumArgs, MaxAlphas, MaxNumbers); - Alphas.allocate(MaxAlphas); - lAlphaBlanks.dimension(MaxAlphas, false); - cAlphaFields.allocate(MaxAlphas); - Numbers.dimension(MaxNumbers, 0.0); - cNumericFields.allocate(MaxNumbers); - lNumericBlanks.dimension(MaxNumbers, false); - - for (int Item = 1; Item <= NumOfSurfaceLists; ++Item) { - - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject1, - Item, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - IOStatus, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - - SurfList(Item).Name = Alphas(1); - SurfList(Item).NumOfSurfaces = NumAlphas - 1; - - NameConflict = Util::FindItemInList(SurfList(Item).Name, state.dataSurface->Surface); - if (NameConflict > 0) { // A surface list has the same name as a surface--not allowed - ShowSevereError(state, - EnergyPlus::format("{}{}", - CurrentModuleObject1, - " = " + SurfList(Item).Name + " has the same name as a surface; this is not allowed.")); - ErrorsFound = true; - } - - if (SurfList(Item).NumOfSurfaces < 1) { - ShowSevereError( - state, EnergyPlus::format("{}{}", CurrentModuleObject1, " = " + SurfList(Item).Name + " does not have any surfaces listed.")); - ErrorsFound = true; - } else { - SurfList(Item).SurfName.allocate(SurfList(Item).NumOfSurfaces); - SurfList(Item).SurfPtr.allocate(SurfList(Item).NumOfSurfaces); - SurfList(Item).SurfFlowFrac.allocate(SurfList(Item).NumOfSurfaces); - } - - SumOfAllFractions = 0.0; - bool showSameZoneWarning = true; - int ZoneForSurface = 0; // Zone number that first surface is attached to - for (int SurfNum = 1; SurfNum <= SurfList(Item).NumOfSurfaces; ++SurfNum) { - SurfList(Item).SurfName(SurfNum) = Alphas(SurfNum + 1); - SurfList(Item).SurfPtr(SurfNum) = Util::FindItemInList(Alphas(SurfNum + 1), state.dataSurface->Surface); - if (SurfList(Item).SurfPtr(SurfNum) == 0) { + if (SurfList(Item).NumOfSurfaces < 1) { ShowSevereError( - state, - fmt::format( - "{} in {} statement not found = {}", cAlphaFields(SurfNum + 1), CurrentModuleObject1, SurfList(Item).SurfName(SurfNum))); + state, EnergyPlus::format("{}{}", CurrentModuleObject1, " = " + SurfList(Item).Name + " does not have any surfaces listed.")); ErrorsFound = true; - } else { // Make sure that all of the surfaces are located in the same zone - state.dataSurface->SurfIsRadSurfOrVentSlabOrPool(SurfList(Item).SurfPtr(SurfNum)) = true; - if (SurfNum == 1) { - ZoneForSurface = state.dataSurface->Surface(SurfList(Item).SurfPtr(SurfNum)).Zone; - } - if (SurfNum > 1) { - if (ZoneForSurface != state.dataSurface->Surface(SurfList(Item).SurfPtr(SurfNum)).Zone && showSameZoneWarning) { - ShowWarningError( - state, EnergyPlus::format("Not all surfaces in same zone for {} = {}", CurrentModuleObject1, SurfList(Item).Name)); - if (!state.dataGlobal->DisplayExtraWarnings) { - ShowContinueError(state, "If this is intentionally a radiant system with surfaces in more than one thermal zone,"); - ShowContinueError(state, - "then ignore this warning message. Use Output:Diagnostics,DisplayExtraWarnings for more details."); + } else { + SurfList(Item).SurfName.allocate(SurfList(Item).NumOfSurfaces); + SurfList(Item).SurfPtr.allocate(SurfList(Item).NumOfSurfaces); + SurfList(Item).SurfFlowFrac.allocate(SurfList(Item).NumOfSurfaces); + } + + SumOfAllFractions = 0.0; + bool showSameZoneWarning = true; + int ZoneForSurface = 0; // Zone number that first surface is attached to + for (int SurfNum = 1; SurfNum <= SurfList(Item).NumOfSurfaces; ++SurfNum) { + auto const &surfaceFraction = (*surfaceFractionsField)[SurfNum - 1]; + SurfList(Item).SurfName(SurfNum) = + Util::makeUPPER(inputProcessor->getAlphaFieldValue(surfaceFraction, surfaceFractionSchemaProps, "surface_name")); + SurfList(Item).SurfPtr(SurfNum) = Util::FindItemInList(SurfList(Item).SurfName(SurfNum), state.dataSurface->Surface); + if (SurfList(Item).SurfPtr(SurfNum) == 0) { + ShowSevereError( + state, + fmt::format( + "{} in {} statement not found = {}", surfaceNameFieldName, CurrentModuleObject1, SurfList(Item).SurfName(SurfNum))); + ErrorsFound = true; + } else { // Make sure that all of the surfaces are located in the same zone + state.dataSurface->SurfIsRadSurfOrVentSlabOrPool(SurfList(Item).SurfPtr(SurfNum)) = true; + if (SurfNum == 1) { + ZoneForSurface = state.dataSurface->Surface(SurfList(Item).SurfPtr(SurfNum)).Zone; + } + if (SurfNum > 1) { + if (ZoneForSurface != state.dataSurface->Surface(SurfList(Item).SurfPtr(SurfNum)).Zone && showSameZoneWarning) { + ShowWarningError( + state, + EnergyPlus::format("Not all surfaces in same zone for {} = {}", CurrentModuleObject1, SurfList(Item).Name)); + if (!state.dataGlobal->DisplayExtraWarnings) { + ShowContinueError(state, + "If this is intentionally a radiant system with surfaces in more than one thermal zone,"); + ShowContinueError( + state, "then ignore this warning message. Use Output:Diagnostics,DisplayExtraWarnings for more details."); + } + showSameZoneWarning = false; } - showSameZoneWarning = false; } } + SurfList(Item).SurfFlowFrac(SurfNum) = + inputProcessor->getRealFieldValue(surfaceFraction, surfaceFractionSchemaProps, "flow_fraction_for_surface"); + if (SurfList(Item).SurfFlowFrac(SurfNum) < SurfListMinFlowFrac) { + ShowSevereError(state, + EnergyPlus::format("The Flow Fraction for Surface {} in Surface Group {} is too low", + SurfList(Item).SurfName(SurfNum), + SurfList(Item).Name)); + ShowContinueError(state, + EnergyPlus::format("Flow fraction of {:.6R} is less than minimum criteria = {:.6R}", + SurfList(Item).SurfFlowFrac(SurfNum), + SurfListMinFlowFrac)); + ShowContinueError(state, + "Zero or extremely low flow fractions are not allowed. Remove this surface from the surface group or " + "combine small surfaces together."); + ErrorsFound = true; + } + SumOfAllFractions += SurfList(Item).SurfFlowFrac(SurfNum); } - SurfList(Item).SurfFlowFrac(SurfNum) = Numbers(SurfNum); - if (SurfList(Item).SurfFlowFrac(SurfNum) < SurfListMinFlowFrac) { - ShowSevereError(state, - EnergyPlus::format("The Flow Fraction for Surface {} in Surface Group {} is too low", - SurfList(Item).SurfName(SurfNum), - SurfList(Item).Name)); - ShowContinueError(state, - EnergyPlus::format("Flow fraction of {:.6R} is less than minimum criteria = {:.6R}", - SurfList(Item).SurfFlowFrac(SurfNum), - SurfListMinFlowFrac)); - ShowContinueError(state, - "Zero or extremely low flow fractions are not allowed. Remove this surface from the surface group or " - "combine small surfaces together."); + + if (std::abs(SumOfAllFractions - 1.0) > FlowFractionTolerance) { + ShowSevereError( + state, EnergyPlus::format("{}{}", CurrentModuleObject1, " flow fractions do not add up to unity for " + SurfList(Item).Name)); ErrorsFound = true; } - SumOfAllFractions += SurfList(Item).SurfFlowFrac(SurfNum); - } - - if (std::abs(SumOfAllFractions - 1.0) > FlowFractionTolerance) { - ShowSevereError( - state, EnergyPlus::format("{}{}", CurrentModuleObject1, " flow fractions do not add up to unity for " + SurfList(Item).Name)); - ErrorsFound = true; } } - Alphas.deallocate(); - lAlphaBlanks.deallocate(); - cAlphaFields.deallocate(); - Numbers.deallocate(); - cNumericFields.deallocate(); - lNumericBlanks.deallocate(); - if (ErrorsFound) { ShowSevereError(state, EnergyPlus::format("{}{}", CurrentModuleObject1, " errors found getting input. Program will terminate.")); } } if (NumOfSurfListVentSlab > 0) { - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject2, NumArgs, MaxAlphas, MaxNumbers); - Alphas.allocate(MaxAlphas); - lAlphaBlanks.dimension(MaxAlphas, false); - cAlphaFields.allocate(MaxAlphas); - Numbers.dimension(MaxNumbers, 0.0); - cNumericFields.allocate(MaxNumbers); - lNumericBlanks.dimension(MaxNumbers, false); - - for (int Item = 1; Item <= NumOfSurfListVentSlab; ++Item) { - - state.dataInputProcessing->inputProcessor->getObjectItem(state, - CurrentModuleObject2, - Item, - Alphas, - NumAlphas, - Numbers, - NumNumbers, - IOStatus, - lNumericBlanks, - lAlphaBlanks, - cAlphaFields, - cNumericFields); - - SlabList(Item).Name = Alphas(1); - SlabList(Item).NumOfSurfaces = ((NumAlphas - 1) / 4); - - NameConflict = Util::FindItemInList(SlabList(Item).Name, state.dataSurface->Surface); - if (NameConflict > 0) { // A surface list has the same name as a surface--not allowed - ShowSevereError(state, - EnergyPlus::format("{}{}", - CurrentModuleObject2, - " = " + SlabList(Item).Name + " has the same name as a slab; this is not allowed.")); - ErrorsFound = true; - } - - if (SlabList(Item).NumOfSurfaces < 1) { - ShowSevereError(state, - EnergyPlus::format("{}{}", CurrentModuleObject2, " = " + SlabList(Item).Name + " does not have any slabs listed.")); - ErrorsFound = true; - } else { - SlabList(Item).ZoneName.allocate(SlabList(Item).NumOfSurfaces); - SlabList(Item).ZonePtr.allocate(SlabList(Item).NumOfSurfaces); - SlabList(Item).SurfName.allocate(SlabList(Item).NumOfSurfaces); - SlabList(Item).SurfPtr.allocate(SlabList(Item).NumOfSurfaces); - SlabList(Item).CoreDiameter.allocate(SlabList(Item).NumOfSurfaces); - SlabList(Item).CoreLength.allocate(SlabList(Item).NumOfSurfaces); - SlabList(Item).CoreNumbers.allocate(SlabList(Item).NumOfSurfaces); - SlabList(Item).SlabInNodeName.allocate(SlabList(Item).NumOfSurfaces); - SlabList(Item).SlabOutNodeName.allocate(SlabList(Item).NumOfSurfaces); - } - - int AlphaArray = 2; - int NumArray = 1; - for (int SurfNum = 1; SurfNum <= SlabList(Item).NumOfSurfaces; ++SurfNum) { - SlabList(Item).ZoneName(SurfNum) = Alphas(AlphaArray); - SlabList(Item).ZonePtr = Util::FindItemInList(Alphas(AlphaArray), state.dataHeatBal->Zone); - if (SlabList(Item).ZonePtr(SurfNum) == 0) { - ShowSevereError( - state, - fmt::format( - "{} in {} Zone not found = {}", cAlphaFields(AlphaArray + 1), CurrentModuleObject2, SlabList(Item).SurfName(SurfNum))); + auto const &slabGroupSchemaProps = inputProcessor->getObjectSchemaProps(state, std::string(CurrentModuleObject2)); + auto const &slabGroupDataSchemaProps = slabGroupSchemaProps.at("data").at("items").at("properties"); + auto const slabGroupObjects = inputProcessor->epJSON.find(std::string(CurrentModuleObject2)); + static constexpr std::string_view zoneNameFieldName = "Zone Name"; + static constexpr std::string_view slabSurfaceNameFieldName = "Surface Name"; + + if (slabGroupObjects != inputProcessor->epJSON.end()) { + int Item = 0; + for (auto const &slabGroupInstance : slabGroupObjects.value().items()) { + auto const &slabGroupFields = slabGroupInstance.value(); + auto const slabGroupName = Util::makeUPPER(slabGroupInstance.key()); + auto const slabGroupDataField = slabGroupFields.find("data"); + + inputProcessor->markObjectAsUsed(std::string(CurrentModuleObject2), slabGroupInstance.key()); + + ++Item; + SlabList(Item).Name = slabGroupName; + SlabList(Item).NumOfSurfaces = (slabGroupDataField != slabGroupFields.end()) ? static_cast(slabGroupDataField->size()) : 0; + + NameConflict = Util::FindItemInList(SlabList(Item).Name, state.dataSurface->Surface); + if (NameConflict > 0) { // A surface list has the same name as a surface--not allowed + ShowSevereError(state, + EnergyPlus::format("{}{}", + CurrentModuleObject2, + " = " + SlabList(Item).Name + " has the same name as a slab; this is not allowed.")); ErrorsFound = true; } - SlabList(Item).SurfName(SurfNum) = Alphas(AlphaArray + 1); - SlabList(Item).SurfPtr(SurfNum) = Util::FindItemInList(Alphas(AlphaArray + 1), state.dataSurface->Surface); - if (SlabList(Item).SurfPtr(SurfNum) == 0) { - ShowSevereError(state, - fmt::format("{} in {} statement not found = {}", - cAlphaFields(AlphaArray + 1), - CurrentModuleObject2, - SlabList(Item).SurfName(SurfNum))); + if (SlabList(Item).NumOfSurfaces < 1) { + ShowSevereError( + state, EnergyPlus::format("{}{}", CurrentModuleObject2, " = " + SlabList(Item).Name + " does not have any slabs listed.")); ErrorsFound = true; + } else { + SlabList(Item).ZoneName.allocate(SlabList(Item).NumOfSurfaces); + SlabList(Item).ZonePtr.allocate(SlabList(Item).NumOfSurfaces); + SlabList(Item).SurfName.allocate(SlabList(Item).NumOfSurfaces); + SlabList(Item).SurfPtr.allocate(SlabList(Item).NumOfSurfaces); + SlabList(Item).CoreDiameter.allocate(SlabList(Item).NumOfSurfaces); + SlabList(Item).CoreLength.allocate(SlabList(Item).NumOfSurfaces); + SlabList(Item).CoreNumbers.allocate(SlabList(Item).NumOfSurfaces); + SlabList(Item).SlabInNodeName.allocate(SlabList(Item).NumOfSurfaces); + SlabList(Item).SlabOutNodeName.allocate(SlabList(Item).NumOfSurfaces); } - for (int SrfList = 1; SrfList <= NumOfSurfaceLists; ++SrfList) { - NameConflict = - Util::FindItemInList(SlabList(Item).SurfName(SurfNum), SurfList(SrfList).SurfName, SurfList(SrfList).NumOfSurfaces); - if (NameConflict > 0) { // A slab list includes a surface on a surface list--not allowed + + for (int SurfNum = 1; SurfNum <= SlabList(Item).NumOfSurfaces; ++SurfNum) { + auto const &slabGroupData = (*slabGroupDataField)[SurfNum - 1]; + SlabList(Item).ZoneName(SurfNum) = + Util::makeUPPER(inputProcessor->getAlphaFieldValue(slabGroupData, slabGroupDataSchemaProps, "zone_name")); + SlabList(Item).ZonePtr(SurfNum) = Util::FindItemInList(SlabList(Item).ZoneName(SurfNum), state.dataHeatBal->Zone); + if (SlabList(Item).ZonePtr(SurfNum) == 0) { ShowSevereError( - state, EnergyPlus::format("{}{}", CurrentModuleObject2, "=\"" + SlabList(Item).Name + "\", invalid surface specified.")); - ShowContinueError(state, EnergyPlus::format("Surface=\"{}\" is also on a Surface List.", SlabList(Item).SurfName(SurfNum))); - ShowContinueError( - state, EnergyPlus::format("{}{}", CurrentModuleObject1, "=\"" + SurfList(SrfList).Name + "\" has this surface also.")); - ShowContinueError(state, "A surface cannot be on both lists. The models cannot operate correctly."); + state, + fmt::format("{} in {} Zone not found = {}", zoneNameFieldName, CurrentModuleObject2, SlabList(Item).ZoneName(SurfNum))); ErrorsFound = true; } + + SlabList(Item).SurfName(SurfNum) = + Util::makeUPPER(inputProcessor->getAlphaFieldValue(slabGroupData, slabGroupDataSchemaProps, "surface_name")); + SlabList(Item).SurfPtr(SurfNum) = Util::FindItemInList(SlabList(Item).SurfName(SurfNum), state.dataSurface->Surface); + if (SlabList(Item).SurfPtr(SurfNum) == 0) { + ShowSevereError(state, + fmt::format("{} in {} statement not found = {}", + slabSurfaceNameFieldName, + CurrentModuleObject2, + SlabList(Item).SurfName(SurfNum))); + ErrorsFound = true; + } + for (int SrfList = 1; SrfList <= NumOfSurfaceLists; ++SrfList) { + NameConflict = + Util::FindItemInList(SlabList(Item).SurfName(SurfNum), SurfList(SrfList).SurfName, SurfList(SrfList).NumOfSurfaces); + if (NameConflict > 0) { // A slab list includes a surface on a surface list--not allowed + ShowSevereError( + state, + EnergyPlus::format("{}{}", CurrentModuleObject2, "=\"" + SlabList(Item).Name + "\", invalid surface specified.")); + ShowContinueError(state, + EnergyPlus::format("Surface=\"{}\" is also on a Surface List.", SlabList(Item).SurfName(SurfNum))); + ShowContinueError( + state, + EnergyPlus::format("{}{}", CurrentModuleObject1, "=\"" + SurfList(SrfList).Name + "\" has this surface also.")); + ShowContinueError(state, "A surface cannot be on both lists. The models cannot operate correctly."); + ErrorsFound = true; + } + } + state.dataSurface->SurfIsRadSurfOrVentSlabOrPool(SlabList(Item).SurfPtr(SurfNum)) = true; + + SlabList(Item).CoreDiameter(SurfNum) = + inputProcessor->getRealFieldValue(slabGroupData, slabGroupDataSchemaProps, "core_diameter_for_surface"); + SlabList(Item).CoreLength(SurfNum) = + inputProcessor->getRealFieldValue(slabGroupData, slabGroupDataSchemaProps, "core_length_for_surface"); + SlabList(Item).CoreNumbers(SurfNum) = + inputProcessor->getRealFieldValue(slabGroupData, slabGroupDataSchemaProps, "core_numbers_for_surface"); + SlabList(Item).SlabInNodeName(SurfNum) = Util::makeUPPER( + inputProcessor->getAlphaFieldValue(slabGroupData, slabGroupDataSchemaProps, "slab_inlet_node_name_for_surface")); + SlabList(Item).SlabOutNodeName(SurfNum) = Util::makeUPPER( + inputProcessor->getAlphaFieldValue(slabGroupData, slabGroupDataSchemaProps, "slab_outlet_node_name_for_surface")); } - state.dataSurface->SurfIsRadSurfOrVentSlabOrPool(SlabList(Item).SurfPtr(SurfNum)) = true; - - SlabList(Item).CoreDiameter(SurfNum) = Numbers(NumArray); - SlabList(Item).CoreLength(SurfNum) = Numbers(NumArray + 1); - SlabList(Item).CoreNumbers(SurfNum) = Numbers(NumArray + 2); - SlabList(Item).SlabInNodeName(SurfNum) = Alphas(AlphaArray + 2); - SlabList(Item).SlabOutNodeName(SurfNum) = Alphas(AlphaArray + 3); - AlphaArray = 2 * (SurfNum + 1) + 2 * ((SurfNum + 1) - 1); - NumArray = 2 * SurfNum + (SurfNum + 1); } } - Alphas.deallocate(); - lAlphaBlanks.deallocate(); - cAlphaFields.deallocate(); - Numbers.deallocate(); - cNumericFields.deallocate(); - lNumericBlanks.deallocate(); - if (ErrorsFound) { ShowSevereError(state, EnergyPlus::format("{}{}", CurrentModuleObject2, " errors found getting input. Program will terminate.")); } diff --git a/src/EnergyPlus/ElectricBaseboardRadiator.cc b/src/EnergyPlus/ElectricBaseboardRadiator.cc index cdeb3fb8139..5d2d45ea7cf 100644 --- a/src/EnergyPlus/ElectricBaseboardRadiator.cc +++ b/src/EnergyPlus/ElectricBaseboardRadiator.cc @@ -268,10 +268,10 @@ namespace ElectricBaseboardRadiator { } } else { ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, elecBaseboard.EquipName)); - ShowContinueError( - state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); - ShowContinueError( - state, EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatDesignCapacityNumericNum - 1])); + ShowContinueError(state, + EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError(state, + EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatDesignCapacityNumericNum - 1])); ErrorsFound = true; } } else if (Util::SameString(heatingDesignCapacityMethod, "CapacityPerFloorArea")) { @@ -299,8 +299,8 @@ namespace ElectricBaseboardRadiator { } } else { ShowSevereError(state, EnergyPlus::format("{} = {}", cCurrentModuleObject, elecBaseboard.EquipName)); - ShowContinueError( - state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError(state, + EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); ShowContinueError( state, EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatCapacityPerFloorAreaNumericNum - 1])); ErrorsFound = true; @@ -321,118 +321,116 @@ namespace ElectricBaseboardRadiator { } } else { ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); + ShowContinueError(state, + EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); ShowContinueError( - state, EnergyPlus::format("Input for {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); - ShowContinueError( - state, EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatFracOfAutosizedCapacityNumericNum - 1])); + state, + EnergyPlus::format("Blank field not allowed for {}", numericFieldNames[iHeatFracOfAutosizedCapacityNumericNum - 1])); ErrorsFound = true; } } else { ShowSevereError(state, cCurrentModuleObject + " = " + elecBaseboard.EquipName); - ShowContinueError(state, EnergyPlus::format("Illegal {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); + ShowContinueError(state, + EnergyPlus::format("Illegal {} = {}", heatingDesignCapacityMethodFieldName, heatingDesignCapacityMethod)); ErrorsFound = true; } elecBaseboard.BaseboardEfficiency = inputProcessor->getRealFieldValue(elecBaseboardFields, elecBaseboardSchemaProps, "efficiency"); elecBaseboard.FracRadiant = inputProcessor->getRealFieldValue(elecBaseboardFields, elecBaseboardSchemaProps, "fraction_radiant"); - if (elecBaseboard.FracRadiant < MinFraction) { - ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + - std::string{numericFieldNames[4]} + " was lower than the allowable minimum."); - ShowContinueError(state, EnergyPlus::format("...reset to minimum value=[{:.2R}].", MinFraction)); - elecBaseboard.FracRadiant = MinFraction; - } - if (elecBaseboard.FracRadiant > MaxFraction) { - ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + - std::string{numericFieldNames[4]} + " was higher than the allowable maximum."); - ShowContinueError(state, EnergyPlus::format("...reset to maximum value=[{:.2R}].", MaxFraction)); - elecBaseboard.FracRadiant = MaxFraction; - } + if (elecBaseboard.FracRadiant < MinFraction) { + ShowWarningError(state, + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{numericFieldNames[4]} + " was lower than the allowable minimum."); + ShowContinueError(state, EnergyPlus::format("...reset to minimum value=[{:.2R}].", MinFraction)); + elecBaseboard.FracRadiant = MinFraction; + } + if (elecBaseboard.FracRadiant > MaxFraction) { + ShowWarningError(state, + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{numericFieldNames[4]} + " was higher than the allowable maximum."); + ShowContinueError(state, EnergyPlus::format("...reset to maximum value=[{:.2R}].", MaxFraction)); + elecBaseboard.FracRadiant = MaxFraction; + } - // Remaining fraction is added to the zone as convective heat transfer - if (elecBaseboard.FracRadiant > MaxFraction) { - ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + - "\", Fraction Radiant was higher than the allowable maximum."); - elecBaseboard.FracRadiant = MaxFraction; - elecBaseboard.FracConvect = 0.0; - } else { - elecBaseboard.FracConvect = 1.0 - elecBaseboard.FracRadiant; - } + // Remaining fraction is added to the zone as convective heat transfer + if (elecBaseboard.FracRadiant > MaxFraction) { + ShowWarningError(state, + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + + "\", Fraction Radiant was higher than the allowable maximum."); + elecBaseboard.FracRadiant = MaxFraction; + elecBaseboard.FracConvect = 0.0; + } else { + elecBaseboard.FracConvect = 1.0 - elecBaseboard.FracRadiant; + } - elecBaseboard.FracDistribPerson = inputProcessor->getRealFieldValue( - elecBaseboardFields, elecBaseboardSchemaProps, "fraction_of_radiant_energy_incident_on_people"); - if (elecBaseboard.FracDistribPerson < MinFraction) { - ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + - std::string{numericFieldNames[5]} + " was lower than the allowable minimum."); - ShowContinueError(state, EnergyPlus::format("...reset to minimum value=[{:.2R}].", MinFraction)); - elecBaseboard.FracDistribPerson = MinFraction; - } - if (elecBaseboard.FracDistribPerson > MaxFraction) { - ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + - std::string{numericFieldNames[5]} + " was higher than the allowable maximum."); - ShowContinueError(state, EnergyPlus::format("...reset to maximum value=[{:.2R}].", MaxFraction)); - elecBaseboard.FracDistribPerson = MaxFraction; - } + elecBaseboard.FracDistribPerson = + inputProcessor->getRealFieldValue(elecBaseboardFields, elecBaseboardSchemaProps, "fraction_of_radiant_energy_incident_on_people"); + if (elecBaseboard.FracDistribPerson < MinFraction) { + ShowWarningError(state, + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{numericFieldNames[5]} + " was lower than the allowable minimum."); + ShowContinueError(state, EnergyPlus::format("...reset to minimum value=[{:.2R}].", MinFraction)); + elecBaseboard.FracDistribPerson = MinFraction; + } + if (elecBaseboard.FracDistribPerson > MaxFraction) { + ShowWarningError(state, + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{numericFieldNames[5]} + " was higher than the allowable maximum."); + ShowContinueError(state, EnergyPlus::format("...reset to maximum value=[{:.2R}].", MaxFraction)); + elecBaseboard.FracDistribPerson = MaxFraction; + } elecBaseboard.TotSurfToDistrib = numSurfaceFractions; - if ((elecBaseboard.TotSurfToDistrib < MinDistribSurfaces) && (elecBaseboard.FracRadiant > MinFraction)) { - ShowSevereError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + - "\", the number of surface/radiant fraction groups entered was less than the allowable minimum."); - ShowContinueError(state, EnergyPlus::format("...the minimum that must be entered=[{}].", MinDistribSurfaces)); - ErrorsFound = true; - elecBaseboard.TotSurfToDistrib = 0; - } + if ((elecBaseboard.TotSurfToDistrib < MinDistribSurfaces) && (elecBaseboard.FracRadiant > MinFraction)) { + ShowSevereError(state, + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + + "\", the number of surface/radiant fraction groups entered was less than the allowable minimum."); + ShowContinueError(state, EnergyPlus::format("...the minimum that must be entered=[{}].", MinDistribSurfaces)); + ErrorsFound = true; + elecBaseboard.TotSurfToDistrib = 0; + } - elecBaseboard.SurfaceName.allocate(elecBaseboard.TotSurfToDistrib); - elecBaseboard.SurfaceName = ""; - elecBaseboard.SurfacePtr.allocate(elecBaseboard.TotSurfToDistrib); - elecBaseboard.SurfacePtr = 0; - elecBaseboard.FracDistribToSurf.allocate(elecBaseboard.TotSurfToDistrib); - elecBaseboard.FracDistribToSurf = 0.0; + elecBaseboard.SurfaceName.allocate(elecBaseboard.TotSurfToDistrib); + elecBaseboard.SurfaceName = ""; + elecBaseboard.SurfacePtr.allocate(elecBaseboard.TotSurfToDistrib); + elecBaseboard.SurfacePtr = 0; + elecBaseboard.FracDistribToSurf.allocate(elecBaseboard.TotSurfToDistrib); + elecBaseboard.FracDistribToSurf = 0.0; - elecBaseboard.ZonePtr = - DataZoneEquipment::GetZoneEquipControlledZoneNum(state, DataZoneEquipment::ZoneEquipType::BaseboardElectric, elecBaseboard.EquipName); + elecBaseboard.ZonePtr = DataZoneEquipment::GetZoneEquipControlledZoneNum( + state, DataZoneEquipment::ZoneEquipType::BaseboardElectric, elecBaseboard.EquipName); - Real64 AllFracsSummed = elecBaseboard.FracDistribPerson; - for (int SurfNum = 1; SurfNum <= elecBaseboard.TotSurfToDistrib; ++SurfNum) { + Real64 AllFracsSummed = elecBaseboard.FracDistribPerson; + for (int SurfNum = 1; SurfNum <= elecBaseboard.TotSurfToDistrib; ++SurfNum) { auto const &surfaceFraction = (*surfaceFractionsField)[SurfNum - 1]; elecBaseboard.SurfaceName(SurfNum) = inputProcessor->getAlphaFieldValue(surfaceFraction, surfaceFractionSchemaProps, "surface_name"); - elecBaseboard.SurfacePtr(SurfNum) = HeatBalanceIntRadExchange::GetRadiantSystemSurface(state, - cCurrentModuleObject, - elecBaseboard.EquipName, - elecBaseboard.ZonePtr, - elecBaseboard.SurfaceName(SurfNum), - ErrorsFound); + elecBaseboard.SurfacePtr(SurfNum) = HeatBalanceIntRadExchange::GetRadiantSystemSurface( + state, cCurrentModuleObject, elecBaseboard.EquipName, elecBaseboard.ZonePtr, elecBaseboard.SurfaceName(SurfNum), ErrorsFound); elecBaseboard.FracDistribToSurf(SurfNum) = inputProcessor->getRealFieldValue(surfaceFraction, surfaceFractionSchemaProps, "fraction_of_radiant_energy_to_surface"); - if (elecBaseboard.FracDistribToSurf(SurfNum) > MaxFraction) { - ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + - std::string{radiantSurfaceFractionFieldName} + " was greater than the allowable maximum."); - ShowContinueError(state, EnergyPlus::format("...reset to maximum value=[{:.2R}].", MaxFraction)); - elecBaseboard.FracDistribToSurf(SurfNum) = MaxFraction; - } - if (elecBaseboard.FracDistribToSurf(SurfNum) < MinFraction) { - ShowWarningError(state, - std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + - std::string{radiantSurfaceFractionFieldName} + " was less than the allowable minimum."); - ShowContinueError(state, EnergyPlus::format("...reset to minimum value=[{:.2R}].", MinFraction)); - elecBaseboard.FracDistribToSurf(SurfNum) = MinFraction; - } - if (elecBaseboard.SurfacePtr(SurfNum) != 0) { - state.dataSurface->surfIntConv(elecBaseboard.SurfacePtr(SurfNum)).getsRadiantHeat = true; - state.dataSurface->allGetsRadiantHeatSurfaceList.emplace_back(elecBaseboard.SurfacePtr(SurfNum)); - } + if (elecBaseboard.FracDistribToSurf(SurfNum) > MaxFraction) { + ShowWarningError(state, + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{radiantSurfaceFractionFieldName} + " was greater than the allowable maximum."); + ShowContinueError(state, EnergyPlus::format("...reset to maximum value=[{:.2R}].", MaxFraction)); + elecBaseboard.FracDistribToSurf(SurfNum) = MaxFraction; + } + if (elecBaseboard.FracDistribToSurf(SurfNum) < MinFraction) { + ShowWarningError(state, + std::string{RoutineName} + cCurrentModuleObject + "=\"" + elecBaseboardName + "\", " + + std::string{radiantSurfaceFractionFieldName} + " was less than the allowable minimum."); + ShowContinueError(state, EnergyPlus::format("...reset to minimum value=[{:.2R}].", MinFraction)); + elecBaseboard.FracDistribToSurf(SurfNum) = MinFraction; + } + if (elecBaseboard.SurfacePtr(SurfNum) != 0) { + state.dataSurface->surfIntConv(elecBaseboard.SurfacePtr(SurfNum)).getsRadiantHeat = true; + state.dataSurface->allGetsRadiantHeatSurfaceList.emplace_back(elecBaseboard.SurfacePtr(SurfNum)); + } - AllFracsSummed += elecBaseboard.FracDistribToSurf(SurfNum); - } // Surfaces + AllFracsSummed += elecBaseboard.FracDistribToSurf(SurfNum); + } // Surfaces if (AllFracsSummed > (MaxFraction + 0.01)) { ShowSevereError(state, diff --git a/src/EnergyPlus/GeneratorFuelSupply.cc b/src/EnergyPlus/GeneratorFuelSupply.cc index 3cd46b0c14f..3b67128e177 100644 --- a/src/EnergyPlus/GeneratorFuelSupply.cc +++ b/src/EnergyPlus/GeneratorFuelSupply.cc @@ -57,7 +57,6 @@ #include #include #include -#include #include #include #include @@ -101,18 +100,16 @@ namespace GeneratorFuelSupply { // reuse with both Annex 42 models, static constexpr std::string_view routineName = "GetGeneratorFuelSupplyInput"; - // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - // INTEGER :: GeneratorNum !Generator counter - Array1D_string AlphArray(25); // character string data - Array1D NumArray(200); // numeric data TODO deal with allocatable for extensible - if (state.dataGeneratorFuelSupply->MyOneTimeFlag) { - 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; std::string const cCurrentModuleObject = "Generator:FuelSupply"; - int NumGeneratorFuelSups = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); + int NumGeneratorFuelSups = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + auto const &fuelSupplySchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); + static constexpr std::string_view fuelTemperatureModelingModeFieldName = "Fuel Temperature Modeling Mode"; + static constexpr std::string_view fuelTemperatureScheduleNameFieldName = "Fuel Temperature Schedule Name"; + static constexpr std::string_view compressorPowerCurveFieldName = "Compressor Power Multiplier Function of Fuel Rate Curve Name"; + static constexpr std::string_view fuelTypeFieldName = "Fuel Type"; if (NumGeneratorFuelSups <= 0) { ShowSevereError(state, EnergyPlus::format("No {} equipment specified in input file", cCurrentModuleObject)); @@ -120,104 +117,121 @@ namespace GeneratorFuelSupply { } state.dataGenerator->FuelSupply.allocate(NumGeneratorFuelSups); - - for (int FuelSupNum = 1; FuelSupNum <= NumGeneratorFuelSups; ++FuelSupNum) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, - cCurrentModuleObject, - FuelSupNum, - AlphArray, - NumAlphas, - NumArray, - NumNums, - IOStat, - _, - _, - state.dataIPShortCut->cAlphaFieldNames, - state.dataIPShortCut->cNumericFieldNames); - - ErrorObjectHeader eoh{routineName, cCurrentModuleObject, AlphArray(1)}; - state.dataGenerator->FuelSupply(FuelSupNum).Name = AlphArray(1); - if (Util::SameString("TemperatureFromAirNode", AlphArray(2))) { - state.dataGenerator->FuelSupply(FuelSupNum).FuelTempMode = DataGenerators::FuelTemperatureMode::FuelInTempFromNode; - } else if (Util::SameString("Scheduled", AlphArray(2))) { - state.dataGenerator->FuelSupply(FuelSupNum).FuelTempMode = DataGenerators::FuelTemperatureMode::FuelInTempSchedule; - } else { - ShowSevereError(state, EnergyPlus::format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(2), AlphArray(2))); - ShowContinueError(state, EnergyPlus::format("Entered in {}={}", cCurrentModuleObject, AlphArray(1))); - ErrorsFound = true; - } - - state.dataGenerator->FuelSupply(FuelSupNum).NodeName = AlphArray(3); - state.dataGenerator->FuelSupply(FuelSupNum).NodeNum = Node::GetOnlySingleNode(state, - AlphArray(3), - ErrorsFound, - Node::ConnectionObjectType::GeneratorFuelSupply, - AlphArray(1), - Node::FluidType::Air, - Node::ConnectionType::Sensor, - Node::CompFluidStream::Primary, - Node::ObjectIsNotParent); - - if (state.dataGenerator->FuelSupply(FuelSupNum).FuelTempMode == DataGenerators::FuelTemperatureMode::FuelInTempSchedule) { - if ((state.dataGenerator->FuelSupply(FuelSupNum).sched = Sched::GetSchedule(state, AlphArray(4))) == nullptr) { - ShowSevereItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(4), AlphArray(4)); + auto const fuelSupplyObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + if (fuelSupplyObjects != inputProcessor->epJSON.end()) { + int FuelSupNum = 0; + for (auto const &fuelSupplyInstance : fuelSupplyObjects.value().items()) { + auto const &fuelSupplyFields = fuelSupplyInstance.value(); + auto const fuelSupplyName = Util::makeUPPER(fuelSupplyInstance.key()); + auto const fuelTemperatureModelingMode = + inputProcessor->getAlphaFieldValue(fuelSupplyFields, fuelSupplySchemaProps, "fuel_temperature_modeling_mode"); + auto const fuelTemperatureReferenceNodeName = Util::makeUPPER( + inputProcessor->getAlphaFieldValue(fuelSupplyFields, fuelSupplySchemaProps, "fuel_temperature_reference_node_name")); + auto const fuelTemperatureScheduleName = Util::makeUPPER( + inputProcessor->getAlphaFieldValue(fuelSupplyFields, fuelSupplySchemaProps, "fuel_temperature_schedule_name")); + auto const compressorPowerCurveName = Util::makeUPPER(inputProcessor->getAlphaFieldValue( + fuelSupplyFields, fuelSupplySchemaProps, "compressor_power_multiplier_function_of_fuel_rate_curve_name")); + auto const fuelType = inputProcessor->getAlphaFieldValue(fuelSupplyFields, fuelSupplySchemaProps, "fuel_type"); + + inputProcessor->markObjectAsUsed(cCurrentModuleObject, fuelSupplyInstance.key()); + + ++FuelSupNum; + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, fuelSupplyName}; + auto &fuelSupply = state.dataGenerator->FuelSupply(FuelSupNum); + fuelSupply.Name = fuelSupplyName; + if (Util::SameString("TemperatureFromAirNode", fuelTemperatureModelingMode)) { + fuelSupply.FuelTempMode = DataGenerators::FuelTemperatureMode::FuelInTempFromNode; + } else if (Util::SameString("Scheduled", fuelTemperatureModelingMode)) { + fuelSupply.FuelTempMode = DataGenerators::FuelTemperatureMode::FuelInTempSchedule; + } else { + ShowSevereError(state, + EnergyPlus::format("Invalid, {} = {}", fuelTemperatureModelingModeFieldName, fuelTemperatureModelingMode)); + ShowContinueError(state, EnergyPlus::format("Entered in {}={}", cCurrentModuleObject, fuelSupplyName)); ErrorsFound = true; } - } - - state.dataGenerator->FuelSupply(FuelSupNum).CompPowerCurveID = Curve::GetCurveIndex(state, AlphArray(5)); - if (state.dataGenerator->FuelSupply(FuelSupNum).CompPowerCurveID == 0) { - ShowSevereError(state, EnergyPlus::format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(5), AlphArray(5))); - ShowContinueError(state, EnergyPlus::format("Entered in {}={}", cCurrentModuleObject, AlphArray(1))); - ShowContinueError(state, "Curve named was not found "); - ErrorsFound = true; - } - - for (auto &e : state.dataGenerator->FuelSupply) { - e.CompPowerLossFactor = NumArray(1); - } - - if (Util::SameString(AlphArray(6), "GaseousConstituents")) { - state.dataGenerator->FuelSupply(FuelSupNum).FuelTypeMode = DataGenerators::FuelMode::GaseousConstituents; - } else if (Util::SameString(AlphArray(6), "LiquidGeneric")) { - state.dataGenerator->FuelSupply(FuelSupNum).FuelTypeMode = DataGenerators::FuelMode::GenericLiquid; - } else { - ShowSevereError(state, EnergyPlus::format("Invalid, {} = {}", state.dataIPShortCut->cAlphaFieldNames(6), AlphArray(6))); - ShowContinueError(state, EnergyPlus::format("Entered in {}={}", cCurrentModuleObject, AlphArray(1))); - ErrorsFound = true; - } - - state.dataGenerator->FuelSupply(FuelSupNum).LHVliquid = NumArray(2) * 1000.0; // generic liquid LHV (kJ/kG input converted to J/kG ) - state.dataGenerator->FuelSupply(FuelSupNum).HHV = NumArray(3) * 1000.0; // generic liquid HHV (kJ/kG input converted to J/kG ) - state.dataGenerator->FuelSupply(FuelSupNum).MW = NumArray(4); - state.dataGenerator->FuelSupply(FuelSupNum).eCO2 = NumArray(5); - if (state.dataGenerator->FuelSupply(FuelSupNum).FuelTypeMode == DataGenerators::FuelMode::GaseousConstituents) { - int NumFuelConstit = NumArray(6); - state.dataGenerator->FuelSupply(FuelSupNum).NumConstituents = NumFuelConstit; - - if (NumFuelConstit > 12) { - ShowSevereError(state, EnergyPlus::format("{} model not set up for more than 12 fuel constituents", cCurrentModuleObject)); - ErrorsFound = true; + fuelSupply.NodeName = fuelTemperatureReferenceNodeName; + fuelSupply.NodeNum = Node::GetOnlySingleNode(state, + fuelTemperatureReferenceNodeName, + ErrorsFound, + Node::ConnectionObjectType::GeneratorFuelSupply, + fuelSupplyName, + Node::FluidType::Air, + Node::ConnectionType::Sensor, + Node::CompFluidStream::Primary, + Node::ObjectIsNotParent); + + if (fuelSupply.FuelTempMode == DataGenerators::FuelTemperatureMode::FuelInTempSchedule) { + if ((fuelSupply.sched = Sched::GetSchedule(state, fuelTemperatureScheduleName)) == nullptr) { + ShowSevereItemNotFound(state, eoh, fuelTemperatureScheduleNameFieldName, fuelTemperatureScheduleName); + ErrorsFound = true; + } } - if (NumFuelConstit < 1) { - ShowSevereError(state, EnergyPlus::format("{} model needs at least one fuel constituent", cCurrentModuleObject)); + + fuelSupply.CompPowerCurveID = Curve::GetCurveIndex(state, compressorPowerCurveName); + if (fuelSupply.CompPowerCurveID == 0) { + ShowSevereError(state, EnergyPlus::format("Invalid, {} = {}", compressorPowerCurveFieldName, compressorPowerCurveName)); + ShowContinueError(state, EnergyPlus::format("Entered in {}={}", cCurrentModuleObject, fuelSupplyName)); + ShowContinueError(state, "Curve named was not found "); ErrorsFound = true; } - for (int ConstitNum = 1; ConstitNum <= NumFuelConstit; ++ConstitNum) { - state.dataGenerator->FuelSupply(FuelSupNum).ConstitName(ConstitNum) = AlphArray(ConstitNum + 6); - state.dataGenerator->FuelSupply(FuelSupNum).ConstitMolalFract(ConstitNum) = NumArray(ConstitNum + 6); - } + fuelSupply.CompPowerLossFactor = + inputProcessor->getRealFieldValue(fuelSupplyFields, fuelSupplySchemaProps, "compressor_heat_loss_factor"); - // check for molar fractions summing to 1.0. - if (std::abs(sum(state.dataGenerator->FuelSupply(FuelSupNum).ConstitMolalFract) - 1.0) > 0.0001) { - ShowSevereError(state, EnergyPlus::format("{} molar fractions do not sum to 1.0", cCurrentModuleObject)); - ShowContinueError(state, - EnergyPlus::format("Sum was={:.5R}", sum(state.dataGenerator->FuelSupply(FuelSupNum).ConstitMolalFract))); - ShowContinueError(state, EnergyPlus::format("Entered in {} = {}", cCurrentModuleObject, AlphArray(1))); + if (Util::SameString(fuelType, "GaseousConstituents")) { + fuelSupply.FuelTypeMode = DataGenerators::FuelMode::GaseousConstituents; + } else if (Util::SameString(fuelType, "LiquidGeneric")) { + fuelSupply.FuelTypeMode = DataGenerators::FuelMode::GenericLiquid; + } else { + ShowSevereError(state, EnergyPlus::format("Invalid, {} = {}", fuelTypeFieldName, fuelType)); + ShowContinueError(state, EnergyPlus::format("Entered in {}={}", cCurrentModuleObject, fuelSupplyName)); ErrorsFound = true; } + + fuelSupply.LHVliquid = + inputProcessor->getRealFieldValue(fuelSupplyFields, fuelSupplySchemaProps, "liquid_generic_fuel_lower_heating_value") * + 1000.0; // generic liquid LHV (kJ/kG input converted to J/kG ) + fuelSupply.HHV = + inputProcessor->getRealFieldValue(fuelSupplyFields, fuelSupplySchemaProps, "liquid_generic_fuel_higher_heating_value") * + 1000.0; // generic liquid HHV (kJ/kG input converted to J/kG ) + fuelSupply.MW = + inputProcessor->getRealFieldValue(fuelSupplyFields, fuelSupplySchemaProps, "liquid_generic_fuel_molecular_weight"); + fuelSupply.eCO2 = + inputProcessor->getRealFieldValue(fuelSupplyFields, fuelSupplySchemaProps, "liquid_generic_fuel_co2_emission_factor"); + + if (fuelSupply.FuelTypeMode == DataGenerators::FuelMode::GaseousConstituents) { + int const NumFuelConstit = inputProcessor->getIntFieldValue( + fuelSupplyFields, fuelSupplySchemaProps, "number_of_constituents_in_gaseous_constituent_fuel_supply"); + fuelSupply.NumConstituents = NumFuelConstit; + + if (NumFuelConstit > 12) { + ShowSevereError(state, + EnergyPlus::format("{} model not set up for more than 12 fuel constituents", cCurrentModuleObject)); + ErrorsFound = true; + } + if (NumFuelConstit < 1) { + ShowSevereError(state, EnergyPlus::format("{} model needs at least one fuel constituent", cCurrentModuleObject)); + ErrorsFound = true; + } + + for (int ConstitNum = 1; ConstitNum <= NumFuelConstit; ++ConstitNum) { + auto const constituentNameFieldName = EnergyPlus::format("constituent_{}_name", ConstitNum); + auto const constituentMolarFractionFieldName = EnergyPlus::format("constituent_{}_molar_fraction", ConstitNum); + fuelSupply.ConstitName(ConstitNum) = + inputProcessor->getAlphaFieldValue(fuelSupplyFields, fuelSupplySchemaProps, constituentNameFieldName); + fuelSupply.ConstitMolalFract(ConstitNum) = + inputProcessor->getRealFieldValue(fuelSupplyFields, fuelSupplySchemaProps, constituentMolarFractionFieldName); + } + + // check for molar fractions summing to 1.0. + if (std::abs(sum(fuelSupply.ConstitMolalFract) - 1.0) > 0.0001) { + ShowSevereError(state, EnergyPlus::format("{} molar fractions do not sum to 1.0", cCurrentModuleObject)); + ShowContinueError(state, EnergyPlus::format("Sum was={:.5R}", sum(fuelSupply.ConstitMolalFract))); + ShowContinueError(state, EnergyPlus::format("Entered in {} = {}", cCurrentModuleObject, fuelSupplyName)); + ErrorsFound = true; + } + } } } From e66c091cb3fe5a80472016fc08b4c9ffe5176a6d Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Thu, 16 Apr 2026 22:02:11 -0400 Subject: [PATCH 14/19] Repair an issue not found by MSVC --- src/EnergyPlus/CostEstimateManager.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/CostEstimateManager.cc b/src/EnergyPlus/CostEstimateManager.cc index 0c856c018cd..adfc775c69b 100644 --- a/src/EnergyPlus/CostEstimateManager.cc +++ b/src/EnergyPlus/CostEstimateManager.cc @@ -211,7 +211,8 @@ namespace CostEstimateManager { auto const &costAdjustSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); auto const costAdjustObjects = inputProcessor->epJSON.find(cCurrentModuleObject); if (costAdjustObjects != inputProcessor->epJSON.end()) { - auto const &costAdjustInstance = *costAdjustObjects.value().items().begin(); + auto const costAdjustItems = costAdjustObjects.value().items(); + auto const &costAdjustInstance = *costAdjustItems.begin(); auto const &costAdjustFields = costAdjustInstance.value(); inputProcessor->markObjectAsUsed(cCurrentModuleObject, costAdjustInstance.key()); @@ -243,7 +244,8 @@ namespace CostEstimateManager { auto const &referenceSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); auto const referenceObjects = inputProcessor->epJSON.find(cCurrentModuleObject); if (referenceObjects != inputProcessor->epJSON.end()) { - auto const &referenceInstance = *referenceObjects.value().items().begin(); + auto const referenceItems = referenceObjects.value().items(); + auto const &referenceInstance = *referenceItems.begin(); auto const &referenceFields = referenceInstance.value(); inputProcessor->markObjectAsUsed(cCurrentModuleObject, referenceInstance.key()); From 1d2bf2dc3b89a926168e88aae92e9322636a079d Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Fri, 17 Apr 2026 00:16:17 -0400 Subject: [PATCH 15/19] One last file --- .../PhaseChangeModeling/HysteresisModel.cc | 85 +++++++++---------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc index e43eeb3915a..cc14a14ff24 100644 --- a/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc +++ b/src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc @@ -49,7 +49,6 @@ #include #include -#include #include #include #include @@ -299,50 +298,40 @@ namespace Material { { static constexpr std::string_view routineName = "GetHysteresisData"; - auto &s_ipsc = state.dataIPShortCut; auto &s_ip = state.dataInputProcessing->inputProcessor; auto &s_mat = state.dataMaterial; // convenience variables - s_ipsc->cCurrentModuleObject = "MaterialProperty:PhaseChangeHysteresis"; - int numPhaseChangeModels = s_ip->getNumObjectsFound(state, s_ipsc->cCurrentModuleObject); + std::string const currentModuleObject = "MaterialProperty:PhaseChangeHysteresis"; + auto const &hysteresisSchemaProps = s_ip->getObjectSchemaProps(state, currentModuleObject); + auto const hysteresisObjects = s_ip->epJSON.find(currentModuleObject); + static constexpr std::string_view nameFieldName = "Name"; // loop over all hysteresis input instances, if zero, this will simply not do anything - for (int hmNum = 1; hmNum <= numPhaseChangeModels; ++hmNum) { - - // just a few vars to pass in and out to GetObjectItem - int ioStatus; - int numAlphas; - int numNumbers; - - // get the input data and store it in the Shortcuts structures - s_ip->getObjectItem(state, - s_ipsc->cCurrentModuleObject, - hmNum, - s_ipsc->cAlphaArgs, - numAlphas, - s_ipsc->rNumericArgs, - numNumbers, - ioStatus, - s_ipsc->lNumericFieldBlanks, - s_ipsc->lAlphaFieldBlanks, - s_ipsc->cAlphaFieldNames, - s_ipsc->cNumericFieldNames); - - ErrorObjectHeader eoh{routineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1)}; + if (hysteresisObjects == s_ip->epJSON.end()) { + return; + } + + for (auto const &hysteresisInstance : hysteresisObjects.value().items()) { + auto const &hysteresisFields = hysteresisInstance.value(); + auto const materialName = Util::makeUPPER(hysteresisInstance.key()); + + s_ip->markObjectAsUsed(currentModuleObject, hysteresisInstance.key()); + + ErrorObjectHeader eoh{routineName, currentModuleObject, materialName}; // the input processor validates the numeric inputs based on the IDD definition // still validate the name to make sure there aren't any duplicates or blanks // blanks are easy: fatal if blank - if (s_ipsc->lAlphaFieldBlanks(1)) { - ShowSevereEmptyField(state, eoh, s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1)); + if (materialName.empty()) { + ShowSevereEmptyField(state, eoh, nameFieldName, materialName); ErrorsFound = true; continue; } - int matNum = GetMaterialNum(state, s_ipsc->cAlphaArgs(1)); + int matNum = GetMaterialNum(state, materialName); if (matNum == 0) { - ShowSevereItemNotFound(state, eoh, s_ipsc->cAlphaFieldNames(1), s_ipsc->cAlphaArgs(1)); + ShowSevereItemNotFound(state, eoh, nameFieldName, materialName); ErrorsFound = true; continue; } @@ -355,8 +344,7 @@ namespace Material { } if (mat->hasPCM) { - ShowSevereCustom( - state, eoh, EnergyPlus::format("Material {} already has {} properties defined.", mat->Name, s_ipsc->cCurrentModuleObject)); + ShowSevereCustom(state, eoh, EnergyPlus::format("Material {} already has {} properties defined.", mat->Name, currentModuleObject)); ErrorsFound = true; continue; } @@ -381,19 +369,26 @@ namespace Material { s_mat->materials(matNum) = matPC; // now build out a new hysteresis instance and add it to the vector - matPC->totalLatentHeat = s_ipsc->rNumericArgs(1); - matPC->fullyLiquidThermalConductivity = s_ipsc->rNumericArgs(2); - matPC->fullyLiquidDensity = s_ipsc->rNumericArgs(3); - matPC->specificHeatLiquid = s_ipsc->rNumericArgs(4); - matPC->deltaTempMeltingHigh = s_ipsc->rNumericArgs(5); - matPC->peakTempMelting = s_ipsc->rNumericArgs(6); - matPC->deltaTempMeltingLow = s_ipsc->rNumericArgs(7); - matPC->fullySolidThermalConductivity = s_ipsc->rNumericArgs(8); - matPC->fullySolidDensity = s_ipsc->rNumericArgs(9); - matPC->specificHeatSolid = s_ipsc->rNumericArgs(10); - matPC->deltaTempFreezingHigh = s_ipsc->rNumericArgs(11); - matPC->peakTempFreezing = s_ipsc->rNumericArgs(12); - matPC->deltaTempFreezingLow = s_ipsc->rNumericArgs(13); + matPC->totalLatentHeat = + s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "latent_heat_during_the_entire_phase_change_process"); + matPC->fullyLiquidThermalConductivity = + s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "liquid_state_thermal_conductivity"); + matPC->fullyLiquidDensity = s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "liquid_state_density"); + matPC->specificHeatLiquid = s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "liquid_state_specific_heat"); + matPC->deltaTempMeltingHigh = + s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "high_temperature_difference_of_melting_curve"); + matPC->peakTempMelting = s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "peak_melting_temperature"); + matPC->deltaTempMeltingLow = + s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "low_temperature_difference_of_melting_curve"); + matPC->fullySolidThermalConductivity = + s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "solid_state_thermal_conductivity"); + matPC->fullySolidDensity = s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "solid_state_density"); + matPC->specificHeatSolid = s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "solid_state_specific_heat"); + matPC->deltaTempFreezingHigh = + s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "high_temperature_difference_of_freezing_curve"); + matPC->peakTempFreezing = s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "peak_freezing_temperature"); + matPC->deltaTempFreezingLow = + s_ip->getRealFieldValue(hysteresisFields, hysteresisSchemaProps, "low_temperature_difference_of_freezing_curve"); matPC->specHeatTransition = (matPC->specificHeatSolid + matPC->specificHeatLiquid) / 2.0; matPC->CpOld = matPC->specificHeatSolid; matPC->hasPCM = true; From 31b9459ab824e419306eb8fca8d78fac2e9d9b71 Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Fri, 17 Apr 2026 09:29:33 -0400 Subject: [PATCH 16/19] One (hopefully) final fix --- src/EnergyPlus/CostEstimateManager.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/EnergyPlus/CostEstimateManager.cc b/src/EnergyPlus/CostEstimateManager.cc index adfc775c69b..346ac5519c1 100644 --- a/src/EnergyPlus/CostEstimateManager.cc +++ b/src/EnergyPlus/CostEstimateManager.cc @@ -211,11 +211,11 @@ namespace CostEstimateManager { auto const &costAdjustSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); auto const costAdjustObjects = inputProcessor->epJSON.find(cCurrentModuleObject); if (costAdjustObjects != inputProcessor->epJSON.end()) { - auto const costAdjustItems = costAdjustObjects.value().items(); - auto const &costAdjustInstance = *costAdjustItems.begin(); - auto const &costAdjustFields = costAdjustInstance.value(); + auto const costAdjustIt = costAdjustObjects.value().begin(); + auto const costAdjustKey = std::string(costAdjustIt.key()); + auto const &costAdjustFields = costAdjustIt.value(); - inputProcessor->markObjectAsUsed(cCurrentModuleObject, costAdjustInstance.key()); + inputProcessor->markObjectAsUsed(cCurrentModuleObject, costAdjustKey); state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter = inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "miscellaneous_cost_per_conditioned_area"); @@ -244,11 +244,11 @@ namespace CostEstimateManager { auto const &referenceSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); auto const referenceObjects = inputProcessor->epJSON.find(cCurrentModuleObject); if (referenceObjects != inputProcessor->epJSON.end()) { - auto const referenceItems = referenceObjects.value().items(); - auto const &referenceInstance = *referenceItems.begin(); - auto const &referenceFields = referenceInstance.value(); + auto const referenceIt = referenceObjects.value().begin(); + auto const referenceKey = std::string(referenceIt.key()); + auto const &referenceFields = referenceIt.value(); - inputProcessor->markObjectAsUsed(cCurrentModuleObject, referenceInstance.key()); + inputProcessor->markObjectAsUsed(cCurrentModuleObject, referenceKey); state.dataCostEstimateManager->RefrncBldg.LineItemTot = inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_line_item_costs"); From 46e8d627f5adc584f67be6cb19537ce77aef3fcf Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Fri, 17 Apr 2026 10:32:49 -0400 Subject: [PATCH 17/19] Attempt another fix Something went wrong with the changes to CostEstimateManager.cc, git was acting funny and I didn't realize something was up until after a push. So this is the last attempt to fix this one before I just revert those changes out. --- src/EnergyPlus/CostEstimateManager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/CostEstimateManager.cc b/src/EnergyPlus/CostEstimateManager.cc index 346ac5519c1..a4d5e83188b 100644 --- a/src/EnergyPlus/CostEstimateManager.cc +++ b/src/EnergyPlus/CostEstimateManager.cc @@ -185,7 +185,7 @@ namespace CostEstimateManager { costLineItem.LineName = Util::makeUPPER(lineItemInstance.key()); costLineItem.ParentObjType = static_cast( getEnumValue(ParentObjectNamesUC, inputProcessor->getAlphaFieldValue(lineItemFields, lineItemSchemaProps, "line_item_type"))); - costLineItem.ParentObjName = Util::makeUPPER(inputProcessor->getAlphaFieldValue(lineItemFields, lineItemSchemaProps, "item_name")); + costLineItem.ParentObjName = inputProcessor->getAlphaFieldValue(lineItemFields, lineItemSchemaProps, "item_name"); costLineItem.PerEach = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_each"); costLineItem.PerSquareMeter = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_area"); costLineItem.PerKiloWattCap = From f3e7492bc8b0a58b5516c9de6868ecacbcc7b58a Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Fri, 17 Apr 2026 11:32:47 -0400 Subject: [PATCH 18/19] Revert CostEstimateManager input refactor --- src/EnergyPlus/CostEstimateManager.cc | 148 +++++++++++--------------- 1 file changed, 61 insertions(+), 87 deletions(-) diff --git a/src/EnergyPlus/CostEstimateManager.cc b/src/EnergyPlus/CostEstimateManager.cc index a4d5e83188b..8d4b94a2b3d 100644 --- a/src/EnergyPlus/CostEstimateManager.cc +++ b/src/EnergyPlus/CostEstimateManager.cc @@ -61,6 +61,7 @@ #include // #include #include +#include #include #include #include @@ -149,14 +150,15 @@ namespace CostEstimateManager { // Using/Aliasing // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int Item; + int Item; // Item to be "gotten" int NumCostAdjust; int NumRefAdjust; + 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 - auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); - - int NumLineItems = inputProcessor->getNumObjectsFound(state, "ComponentCost:LineItem"); + int NumLineItems = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "ComponentCost:LineItem"); if (NumLineItems == 0) { state.dataCostEstimateManager->DoCostEstimate = false; @@ -168,70 +170,52 @@ namespace CostEstimateManager { if (!allocated(state.dataCostEstimateManager->CostLineItem)) { state.dataCostEstimateManager->CostLineItem.allocate(NumLineItems); } - std::string cCurrentModuleObject; + auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject; cCurrentModuleObject = "ComponentCost:LineItem"; - auto const &lineItemSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); - auto const lineItemObjects = inputProcessor->epJSON.find(cCurrentModuleObject); - Item = 0; - if (lineItemObjects != inputProcessor->epJSON.end()) { - for (auto const &lineItemInstance : lineItemObjects.value().items()) { - auto const &lineItemFields = lineItemInstance.value(); - - inputProcessor->markObjectAsUsed(cCurrentModuleObject, lineItemInstance.key()); - - ++Item; - auto &costLineItem = state.dataCostEstimateManager->CostLineItem(Item); - costLineItem.LineName = Util::makeUPPER(lineItemInstance.key()); - costLineItem.ParentObjType = static_cast( - getEnumValue(ParentObjectNamesUC, inputProcessor->getAlphaFieldValue(lineItemFields, lineItemSchemaProps, "line_item_type"))); - costLineItem.ParentObjName = inputProcessor->getAlphaFieldValue(lineItemFields, lineItemSchemaProps, "item_name"); - costLineItem.PerEach = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_each"); - costLineItem.PerSquareMeter = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_area"); - costLineItem.PerKiloWattCap = - inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_unit_of_output_capacity"); - costLineItem.PerKWCapPerCOP = - inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_unit_of_output_capacity_per_cop"); - costLineItem.PerCubicMeter = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_volume"); - costLineItem.PerCubMeterPerSec = inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_volume_rate"); - costLineItem.PerUAinWattperDelK = - inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "cost_per_energy_per_temperature_difference"); - auto const quantityField = lineItemFields.find("quantity"); - costLineItem.Qty = (quantityField != lineItemFields.end()) - ? inputProcessor->getRealFieldValue(lineItemFields, lineItemSchemaProps, "quantity") - : 0.0; - } + for (Item = 1; Item <= NumLineItems; ++Item) { + state.dataInputProcessing->inputProcessor->getObjectItem(state, + cCurrentModuleObject, + Item, + state.dataIPShortCut->cAlphaArgs, + NumAlphas, + state.dataIPShortCut->rNumericArgs, + NumNumbers, + IOStatus); + state.dataCostEstimateManager->CostLineItem(Item).LineName = state.dataIPShortCut->cAlphaArgs(1); + state.dataCostEstimateManager->CostLineItem(Item).ParentObjType = + static_cast(getEnumValue(ParentObjectNamesUC, state.dataIPShortCut->cAlphaArgs(3))); + state.dataCostEstimateManager->CostLineItem(Item).ParentObjName = state.dataIPShortCut->cAlphaArgs(4); + state.dataCostEstimateManager->CostLineItem(Item).PerEach = state.dataIPShortCut->rNumericArgs(1); + state.dataCostEstimateManager->CostLineItem(Item).PerSquareMeter = state.dataIPShortCut->rNumericArgs(2); + state.dataCostEstimateManager->CostLineItem(Item).PerKiloWattCap = state.dataIPShortCut->rNumericArgs(3); + state.dataCostEstimateManager->CostLineItem(Item).PerKWCapPerCOP = state.dataIPShortCut->rNumericArgs(4); + state.dataCostEstimateManager->CostLineItem(Item).PerCubicMeter = state.dataIPShortCut->rNumericArgs(5); + state.dataCostEstimateManager->CostLineItem(Item).PerCubMeterPerSec = state.dataIPShortCut->rNumericArgs(6); + state.dataCostEstimateManager->CostLineItem(Item).PerUAinWattperDelK = state.dataIPShortCut->rNumericArgs(7); + state.dataCostEstimateManager->CostLineItem(Item).Qty = state.dataIPShortCut->rNumericArgs(8); } // most input error checking to be performed later within Case construct in Calc routine. cCurrentModuleObject = "ComponentCost:Adjustments"; - NumCostAdjust = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + NumCostAdjust = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (NumCostAdjust == 1) { - auto const &costAdjustSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); - auto const costAdjustObjects = inputProcessor->epJSON.find(cCurrentModuleObject); - if (costAdjustObjects != inputProcessor->epJSON.end()) { - auto const costAdjustIt = costAdjustObjects.value().begin(); - auto const costAdjustKey = std::string(costAdjustIt.key()); - auto const &costAdjustFields = costAdjustIt.value(); - - inputProcessor->markObjectAsUsed(cCurrentModuleObject, costAdjustKey); - - state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter = - inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "miscellaneous_cost_per_conditioned_area"); - state.dataCostEstimateManager->CurntBldg.DesignFeeFrac = - inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "design_and_engineering_fees"); - state.dataCostEstimateManager->CurntBldg.ContractorFeeFrac = - inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "contractor_fee"); - state.dataCostEstimateManager->CurntBldg.ContingencyFrac = - inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "contingency"); - state.dataCostEstimateManager->CurntBldg.BondCostFrac = - inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "permits_bonding_and_insurance"); - state.dataCostEstimateManager->CurntBldg.CommissioningFrac = - inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "commissioning_fee"); - state.dataCostEstimateManager->CurntBldg.RegionalModifier = - inputProcessor->getRealFieldValue(costAdjustFields, costAdjustSchemaProps, "regional_adjustment_factor"); - } + state.dataInputProcessing->inputProcessor->getObjectItem(state, + cCurrentModuleObject, + 1, + state.dataIPShortCut->cAlphaArgs, + NumAlphas, + state.dataIPShortCut->rNumericArgs, + NumNumbers, + IOStatus); + state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter = state.dataIPShortCut->rNumericArgs(1); + state.dataCostEstimateManager->CurntBldg.DesignFeeFrac = state.dataIPShortCut->rNumericArgs(2); + state.dataCostEstimateManager->CurntBldg.ContractorFeeFrac = state.dataIPShortCut->rNumericArgs(3); + state.dataCostEstimateManager->CurntBldg.ContingencyFrac = state.dataIPShortCut->rNumericArgs(4); + state.dataCostEstimateManager->CurntBldg.BondCostFrac = state.dataIPShortCut->rNumericArgs(5); + state.dataCostEstimateManager->CurntBldg.CommissioningFrac = state.dataIPShortCut->rNumericArgs(6); + state.dataCostEstimateManager->CurntBldg.RegionalModifier = state.dataIPShortCut->rNumericArgs(7); } else if (NumCostAdjust > 1) { ShowSevereError(state, EnergyPlus::format("{}: Only one instance of this object is allowed.", cCurrentModuleObject)); @@ -239,34 +223,24 @@ namespace CostEstimateManager { } cCurrentModuleObject = "ComponentCost:Reference"; - NumRefAdjust = inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); + NumRefAdjust = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); if (NumRefAdjust == 1) { - auto const &referenceSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); - auto const referenceObjects = inputProcessor->epJSON.find(cCurrentModuleObject); - if (referenceObjects != inputProcessor->epJSON.end()) { - auto const referenceIt = referenceObjects.value().begin(); - auto const referenceKey = std::string(referenceIt.key()); - auto const &referenceFields = referenceIt.value(); - - inputProcessor->markObjectAsUsed(cCurrentModuleObject, referenceKey); - - state.dataCostEstimateManager->RefrncBldg.LineItemTot = - inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_line_item_costs"); - state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter = inputProcessor->getRealFieldValue( - referenceFields, referenceSchemaProps, "reference_building_miscellaneous_cost_per_conditioned_area"); - state.dataCostEstimateManager->RefrncBldg.DesignFeeFrac = - inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_design_and_engineering_fees"); - state.dataCostEstimateManager->RefrncBldg.ContractorFeeFrac = - inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_contractor_fee"); - state.dataCostEstimateManager->RefrncBldg.ContingencyFrac = - inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_contingency"); - state.dataCostEstimateManager->RefrncBldg.BondCostFrac = - inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_permits_bonding_and_insurance"); - state.dataCostEstimateManager->RefrncBldg.CommissioningFrac = - inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_commissioning_fee"); - state.dataCostEstimateManager->RefrncBldg.RegionalModifier = - inputProcessor->getRealFieldValue(referenceFields, referenceSchemaProps, "reference_building_regional_adjustment_factor"); - } + state.dataInputProcessing->inputProcessor->getObjectItem(state, + cCurrentModuleObject, + 1, + state.dataIPShortCut->cAlphaArgs, + NumAlphas, + state.dataIPShortCut->rNumericArgs, + NumNumbers, + IOStatus); + state.dataCostEstimateManager->RefrncBldg.LineItemTot = state.dataIPShortCut->rNumericArgs(1); + state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter = state.dataIPShortCut->rNumericArgs(2); + state.dataCostEstimateManager->RefrncBldg.DesignFeeFrac = state.dataIPShortCut->rNumericArgs(3); + state.dataCostEstimateManager->RefrncBldg.ContractorFeeFrac = state.dataIPShortCut->rNumericArgs(4); + state.dataCostEstimateManager->RefrncBldg.ContingencyFrac = state.dataIPShortCut->rNumericArgs(5); + state.dataCostEstimateManager->RefrncBldg.BondCostFrac = state.dataIPShortCut->rNumericArgs(6); + state.dataCostEstimateManager->RefrncBldg.CommissioningFrac = state.dataIPShortCut->rNumericArgs(7); + state.dataCostEstimateManager->RefrncBldg.RegionalModifier = state.dataIPShortCut->rNumericArgs(8); } else if (NumRefAdjust > 1) { ShowSevereError(state, EnergyPlus::format("{} : Only one instance of this object is allowed.", cCurrentModuleObject)); From 7448d56dddcb6d8268e0077463dc6ef2e9ded6ae Mon Sep 17 00:00:00 2001 From: "Jason W. DeGraw" Date: Wed, 22 Apr 2026 16:25:41 -0400 Subject: [PATCH 19/19] Re-impose ordering --- src/EnergyPlus/BaseboardElectric.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/BaseboardElectric.cc b/src/EnergyPlus/BaseboardElectric.cc index fbea4cb0563..5702f736b74 100644 --- a/src/EnergyPlus/BaseboardElectric.cc +++ b/src/EnergyPlus/BaseboardElectric.cc @@ -187,21 +187,27 @@ namespace BaseboardElectric { auto *inputProcessor = state.dataInputProcessing->inputProcessor.get(); auto const &baseboardSchemaProps = inputProcessor->getObjectSchemaProps(state, cCurrentModuleObject); auto const baseboardObjects = inputProcessor->epJSON.find(cCurrentModuleObject); + auto const orderedBaseboardKeys = inputProcessor->getIDFOrderedKeys(state, cCurrentModuleObject); static constexpr std::array numericFieldNames = { "Heating Design Capacity", "Heating Design Capacity Per Floor Area", "Fraction of Autosized Heating Design Capacity", "Efficiency"}; static constexpr std::string_view availabilityScheduleFieldName = "Availability Schedule Name"; static constexpr std::string_view heatingDesignCapacityMethodFieldName = "Heating Design Capacity Method"; if (baseboardObjects != inputProcessor->epJSON.end()) { - for (auto const &baseboardInstance : baseboardObjects.value().items()) { + for (auto const &baseboardKey : orderedBaseboardKeys) { + auto const baseboardInstance = baseboardObjects.value().find(baseboardKey); + if (baseboardInstance == baseboardObjects.value().end()) { + continue; + } + auto const &baseboardFields = baseboardInstance.value(); - auto const baseboardName = Util::makeUPPER(baseboardInstance.key()); + auto const baseboardName = Util::makeUPPER(baseboardKey); auto const availabilityScheduleName = inputProcessor->getAlphaFieldValue(baseboardFields, baseboardSchemaProps, "availability_schedule_name"); auto const heatingDesignCapacityMethod = inputProcessor->getAlphaFieldValue(baseboardFields, baseboardSchemaProps, "heating_design_capacity_method"); - inputProcessor->markObjectAsUsed(cCurrentModuleObject, baseboardInstance.key()); + inputProcessor->markObjectAsUsed(cCurrentModuleObject, baseboardKey); baseboard->baseboards(BaseboardNum + 1).FieldNames.assign(numericFieldNames.begin(), numericFieldNames.end());