Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CppCheck HybridModel through various to IntegratedHeatPump #10686

Merged
merged 9 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 23 additions & 53 deletions src/EnergyPlus/HybridModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,57 +79,32 @@ namespace HybridModel {
// Using/Aliasing
using namespace DataHeatBalance;

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:

// Object Data

// Functions

void GetHybridModelZone(EnergyPlusData &state)
{

using ScheduleManager::GetScheduleIndex;

bool ErrorsFound(false); // If errors detected in input
Array1D_bool lAlphaFieldBlanks(16, false);
Array1D_bool lNumericFieldBlanks(4, false);
int NumAlphas; // Number of Alphas for each GetobjectItem call
int NumNumbers; // Number of Numbers for each GetobjectItem call
int IOStatus;
int ZonePtr; // Pointer to the zone
int ZoneListPtr; // Pointer to the zone list
std::string CurrentModuleObject; // to assist in getting input
Array1D_string cAlphaArgs(16); // Alpha input items for object
Array1D_string cAlphaFieldNames(16);
Array1D_string cNumericFieldNames(16);
Array1D<Real64> rNumericArgs(4); // Numeric input items for object
int HybridModelStartMonth(0); // Hybrid model start month
int HybridModelStartDate(0); // Hybrid model start date of month
int HybridModelEndMonth(0); // Hybrid model end month
int HybridModelEndDate(0); // Hybrid model end date of month
int HMStartDay(0);
int HMEndDay(0);

int TemperatureSchPtr(0); // Temperature schedule pointer
int HumidityRatioSchPtr(0); // Humidity ratio schedule pointer
int CO2ConcentrationSchPtr(0); // CO2 concentration schedule pointer

int PeopleActivityLevelSchPtr(0); // People activity level schedule pointer
int PeopleSensibleFractionSchPtr(0); // People sensible heat portion schedule pointer
int PeopleRadiantFractionSchPtr(0); // People radiant heat portion (of sensible heat) schedule pointer
int PeopleCO2GenRateSchPtr(0); // People CO2 generation rate schedule pointer

int SupplyAirTemperatureSchPtr(0);
int SupplyAirMassFlowRateSchPtr(0);
int SupplyAirHumidityRatioSchPtr(0);
int SupplyAirCO2ConcentrationSchPtr(0);

// Read hybrid model input
CurrentModuleObject = "HybridModel:Zone";
state.dataHybridModel->NumOfHybridModelZones = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);

if (state.dataHybridModel->NumOfHybridModelZones > 0) {
state.dataHybridModel->HybridModelZone.allocate(state.dataGlobal->NumOfZones);
bool ErrorsFound = false; // If errors detected in input
int NumAlphas = 0; // Number of Alphas for each GetobjectItem call
int NumNumbers = 0; // Number of Numbers for each GetobjectItem call
int IOStatus = 0;
int ZonePtr = 0;
for (int HybridModelNum = 1; HybridModelNum <= state.dataHybridModel->NumOfHybridModelZones; ++HybridModelNum) {

state.dataInputProcessing->inputProcessor->getObjectItem(state,
Expand All @@ -145,10 +120,7 @@ namespace HybridModel {
cAlphaFieldNames,
cNumericFieldNames);

ZoneListPtr = 0;
ZonePtr = Util::FindItemInList(cAlphaArgs(2), state.dataHeatBal->Zone); // "Zone" is a 1D array, cAlphaArgs(2) is the zone name
if (ZonePtr == 0 && state.dataHeatBal->NumOfZoneLists > 0)
ZoneListPtr = Util::FindItemInList(cAlphaArgs(2), state.dataHeatBal->ZoneList);
if (ZonePtr > 0) {
state.dataHybridModel->HybridModelZone(ZonePtr).Name = cAlphaArgs(1); // Zone HybridModel name
state.dataHybridModel->FlagHybridModel_TM = Util::SameString(cAlphaArgs(3), "Yes"); // Calculate thermal mass option
Expand All @@ -157,21 +129,21 @@ namespace HybridModel {

// Pointers used to help decide which unknown parameter to solve
// Zone Air Infiltration Rate and Zone Internal Thermal Mass calculations cannot be performed simultaneously
TemperatureSchPtr = GetScheduleIndex(state, cAlphaArgs(6));
HumidityRatioSchPtr = GetScheduleIndex(state, cAlphaArgs(7));
CO2ConcentrationSchPtr = GetScheduleIndex(state, cAlphaArgs(8));
int TemperatureSchPtr = GetScheduleIndex(state, cAlphaArgs(6));
int HumidityRatioSchPtr = GetScheduleIndex(state, cAlphaArgs(7));
int CO2ConcentrationSchPtr = GetScheduleIndex(state, cAlphaArgs(8));

// Not used for now
PeopleActivityLevelSchPtr = GetScheduleIndex(state, cAlphaArgs(9));
PeopleSensibleFractionSchPtr = GetScheduleIndex(state, cAlphaArgs(10));
PeopleRadiantFractionSchPtr = GetScheduleIndex(state, cAlphaArgs(11));
PeopleCO2GenRateSchPtr = GetScheduleIndex(state, cAlphaArgs(12));
int PeopleActivityLevelSchPtr = GetScheduleIndex(state, cAlphaArgs(9));
int PeopleSensibleFractionSchPtr = GetScheduleIndex(state, cAlphaArgs(10));
int PeopleRadiantFractionSchPtr = GetScheduleIndex(state, cAlphaArgs(11));
int PeopleCO2GenRateSchPtr = GetScheduleIndex(state, cAlphaArgs(12));

// Pointers used to help decide wheather to include system supply terms in the inverse algorithms
SupplyAirTemperatureSchPtr = GetScheduleIndex(state, cAlphaArgs(13));
SupplyAirMassFlowRateSchPtr = GetScheduleIndex(state, cAlphaArgs(14));
SupplyAirHumidityRatioSchPtr = GetScheduleIndex(state, cAlphaArgs(15));
SupplyAirCO2ConcentrationSchPtr = GetScheduleIndex(state, cAlphaArgs(16));
int SupplyAirTemperatureSchPtr = GetScheduleIndex(state, cAlphaArgs(13));
int SupplyAirMassFlowRateSchPtr = GetScheduleIndex(state, cAlphaArgs(14));
int SupplyAirHumidityRatioSchPtr = GetScheduleIndex(state, cAlphaArgs(15));
int SupplyAirCO2ConcentrationSchPtr = GetScheduleIndex(state, cAlphaArgs(16));

// Note: Internal thermal mass can be calculated only with measured temperature.
// Air infiltration rate can be calculated with either measured temperature, humifity ratio, or CO2
Expand Down Expand Up @@ -418,23 +390,21 @@ namespace HybridModel {
state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureEndMonth = rNumericArgs(3);
state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureEndDate = rNumericArgs(4);
{
int HMDayArr[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
int const HMDayArr[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};

HybridModelStartMonth = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureStartMonth;
HybridModelStartDate = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureStartDate;
HybridModelEndMonth = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureEndMonth;
HybridModelEndDate = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureEndDate;
int HybridModelStartMonth = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureStartMonth;
int HybridModelStartDate = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureStartDate;
int HybridModelEndMonth = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureEndMonth;
int HybridModelEndDate = state.dataHybridModel->HybridModelZone(ZonePtr).ZoneMeasuredTemperatureEndDate;

int HMStartDay = 0;
int HMEndDay = 0;
if (HybridModelStartMonth >= 1 && HybridModelStartMonth <= 12) {
HMStartDay = HMDayArr[HybridModelStartMonth - 1];
} else {
HMStartDay = 0;
}

if (HybridModelEndMonth >= 1 && HybridModelEndMonth <= 12) {
HMEndDay = HMDayArr[HybridModelEndMonth - 1];
} else {
HMEndDay = 0;
}

state.dataHybridModel->HybridModelZone(ZonePtr).HybridStartDayOfYear = HMStartDay + HybridModelStartDate;
Expand Down
27 changes: 9 additions & 18 deletions src/EnergyPlus/HybridUnitaryAirConditioners.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void SimZoneHybridUnitaryAirConditioners(EnergyPlusData &state,

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int CompNum;
bool errorsfound = false;
if (state.dataHybridUnitaryAC->GetInputZoneHybridEvap) {
bool errorsfound = false;
GetInputZoneHybridUnitaryAirConditioners(state, errorsfound);
state.dataHybridUnitaryAC->GetInputZoneHybridEvap = false;
}
Expand Down Expand Up @@ -184,7 +184,6 @@ void InitZoneHybridUnitaryAirConditioners(EnergyPlusData &state,
using DataZoneEquipment::CheckZoneEquipmentList;

// Locals
int Loop;
int InletNode;

if (state.dataHybridUnitaryAC->HybridCoolOneTimeFlag) {
Expand Down Expand Up @@ -231,7 +230,7 @@ void InitZoneHybridUnitaryAirConditioners(EnergyPlusData &state,
// need to check all zone outdoor air control units to see if they are on Zone Equipment List or issue warning
if (!state.dataHybridUnitaryAC->ZoneEquipmentListChecked && state.dataZoneEquip->ZoneEquipInputsFilled) {
state.dataHybridUnitaryAC->ZoneEquipmentListChecked = true;
for (Loop = 1; Loop <= state.dataHybridUnitaryAC->NumZoneHybridEvap; ++Loop) {
for (int Loop = 1; Loop <= state.dataHybridUnitaryAC->NumZoneHybridEvap; ++Loop) {
if (CheckZoneEquipmentList(state, "ZoneHVAC:HybridUnitaryHVAC", state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(Loop).Name)) {
state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(Loop).ZoneNodeNum = state.dataZoneEquip->ZoneEquipConfig(ZoneNum).ZoneNode;
} else {
Expand Down Expand Up @@ -394,10 +393,6 @@ void ReportZoneHybridUnitaryAirConditioners(EnergyPlusData &state, int const Uni
using namespace DataLoopNode;
using namespace Psychrometrics;

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int ZoneNodeNum;
ZoneNodeNum = state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(UnitNum).ZoneNodeNum;

state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(UnitNum).PrimaryMode =
state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(UnitNum).PrimaryMode;

Expand Down Expand Up @@ -462,10 +457,7 @@ void GetInputZoneHybridUnitaryAirConditioners(EnergyPlusData &state, bool &Error
int NumAlphas; // Number of Alphas for each GetObjectItem call
int NumNumbers; // Number of Numbers for each GetObjectItem call
int NumFields; // Total number of fields in object
int IOStatus; // Used in GetObjectItem
bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine
bool IsNotOK; // Flag to verify name
bool IsBlank; // Flag for blank name
int UnitLoop;

// SUBROUTINE PARAMETER DEFINITIONS:
Expand All @@ -482,12 +474,11 @@ void GetInputZoneHybridUnitaryAirConditioners(EnergyPlusData &state, bool &Error
cNumericFields.allocate(MaxNumbers);
lAlphaBlanks.dimension(MaxAlphas, true);
lNumericBlanks.dimension(MaxNumbers, true);
std::vector<std::string> test;
std::vector<bool> blanks;

if (state.dataHybridUnitaryAC->NumZoneHybridEvap > 0) {
state.dataHybridUnitaryAC->CheckZoneHybridEvapName.dimension(state.dataHybridUnitaryAC->NumZoneHybridEvap, true);
state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner.allocate(state.dataHybridUnitaryAC->NumZoneHybridEvap);
int IOStatus = 0;

for (UnitLoop = 1; UnitLoop <= state.dataHybridUnitaryAC->NumZoneHybridEvap; ++UnitLoop) {
state.dataInputProcessing->inputProcessor->getObjectItem(state,
Expand All @@ -503,8 +494,8 @@ void GetInputZoneHybridUnitaryAirConditioners(EnergyPlusData &state, bool &Error
cAlphaFields,
cNumericFields);

IsNotOK = false;
IsBlank = false;
bool IsNotOK = false;
bool IsBlank = false;
Util::VerifyName(state,
Alphas(1),
state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner,
Expand Down Expand Up @@ -1317,8 +1308,8 @@ void GetInputZoneHybridUnitaryAirConditioners(EnergyPlusData &state, bool &Error
}
int GetHybridUnitaryACOutAirNode(EnergyPlusData &state, int const CompNum)
{
bool errorsfound = false;
if (state.dataHybridUnitaryAC->GetInputZoneHybridEvap) {
bool errorsfound = false;
GetInputZoneHybridUnitaryAirConditioners(state, errorsfound);
state.dataHybridUnitaryAC->GetInputZoneHybridEvap = false;
}
Expand All @@ -1334,8 +1325,8 @@ int GetHybridUnitaryACOutAirNode(EnergyPlusData &state, int const CompNum)

int GetHybridUnitaryACZoneInletNode(EnergyPlusData &state, int const CompNum)
{
bool errorsfound = false;
if (state.dataHybridUnitaryAC->GetInputZoneHybridEvap) {
bool errorsfound = false;
GetInputZoneHybridUnitaryAirConditioners(state, errorsfound);
state.dataHybridUnitaryAC->GetInputZoneHybridEvap = false;
}
Expand All @@ -1351,8 +1342,8 @@ int GetHybridUnitaryACZoneInletNode(EnergyPlusData &state, int const CompNum)

int GetHybridUnitaryACReturnAirNode(EnergyPlusData &state, int const CompNum)
{
bool errorsfound = false;
if (state.dataHybridUnitaryAC->GetInputZoneHybridEvap) {
bool errorsfound = false;
GetInputZoneHybridUnitaryAirConditioners(state, errorsfound);
state.dataHybridUnitaryAC->GetInputZoneHybridEvap = false;
}
Expand All @@ -1368,8 +1359,8 @@ int GetHybridUnitaryACReturnAirNode(EnergyPlusData &state, int const CompNum)

int getHybridUnitaryACIndex(EnergyPlusData &state, std::string_view CompName)
{
bool errFlag = false;
if (state.dataHybridUnitaryAC->GetInputZoneHybridEvap) {
bool errFlag = false;
GetInputZoneHybridUnitaryAirConditioners(state, errFlag);
state.dataHybridUnitaryAC->GetInputZoneHybridEvap = false;
}
Expand Down
14 changes: 5 additions & 9 deletions src/EnergyPlus/IceThermalStorage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1301,8 +1301,6 @@ namespace IceThermalStorage {
// METHODOLOGY EMPLOYED:
// Initializes parameters based on current status flag values.

int CompNum; // local do loop index

if (this->MyPlantScanFlag) {
bool errFlag = false;
PlantUtilities::ScanPlantLoopsForObject(state, this->Name, DataPlant::PlantEquipmentType::TS_IceDetailed, this->plantLoc, errFlag);
Expand Down Expand Up @@ -1334,10 +1332,10 @@ namespace IceThermalStorage {
if ((state.dataPlnt->PlantLoop(this->plantLoc.loopNum).CommonPipeType == DataPlant::CommonPipeType::TwoWay) &&
(this->plantLoc.loopSideNum == DataPlant::LoopSideLocation::Supply)) {
// up flow priority of other components on the same branch as the Ice tank
for (CompNum = 1; CompNum <= state.dataPlnt->PlantLoop(this->plantLoc.loopNum)
.LoopSide(DataPlant::LoopSideLocation::Supply)
.Branch(this->plantLoc.branchNum)
.TotalComponents;
for (int CompNum = 1; CompNum <= state.dataPlnt->PlantLoop(this->plantLoc.loopNum)
.LoopSide(DataPlant::LoopSideLocation::Supply)
.Branch(this->plantLoc.branchNum)
.TotalComponents;
++CompNum) {
state.dataPlnt->PlantLoop(this->plantLoc.loopNum)
.LoopSide(DataPlant::LoopSideLocation::Supply)
Expand Down Expand Up @@ -1369,11 +1367,9 @@ namespace IceThermalStorage {
void SimpleIceStorageData::oneTimeInit(EnergyPlusData &state)
{

bool errFlag;

if (this->MyPlantScanFlag) {
// Locate the storage on the plant loops for later usage
errFlag = false;
bool errFlag = false;
PlantUtilities::ScanPlantLoopsForObject(
state, this->Name, DataPlant::PlantEquipmentType::TS_IceSimple, this->plantLoc, errFlag, _, _, _, _, _);
if (errFlag) {
Expand Down
Loading
Loading