Skip to content

Commit

Permalink
Remove uses of FluidIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir Roth committed Jan 8, 2025
1 parent 41374d2 commit 42f9e68
Show file tree
Hide file tree
Showing 51 changed files with 34 additions and 317 deletions.
2 changes: 0 additions & 2 deletions src/EnergyPlus/BoilerSteam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ namespace BoilerSteam {
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
int SteamFluidIndex; // Fluid Index for Steam
bool ErrorsFound(false);

SteamFluidIndex = 0;
state.dataIPShortCut->cCurrentModuleObject = "Boiler:Steam";
int numBoilers = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, state.dataIPShortCut->cCurrentModuleObject);

Expand Down
108 changes: 6 additions & 102 deletions src/EnergyPlus/FluidProperties.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4852,27 +4852,6 @@ namespace Fluid {

//*****************************************************************************

bool CheckFluidPropertyName(EnergyPlusData const &state,
std::string const &name) // Name from input(?) to be checked against valid FluidPropertyNames
{

// FUNCTION INFORMATION:
// AUTHOR Linda K. Lawrie
// DATE WRITTEN October 2002

// PURPOSE OF THIS FUNCTION:
// This function checks on an input fluid property to make sure it is valid.
auto const &df = state.dataFluid;

auto foundRefrig = std::find_if(df->refrigs.begin(), df->refrigs.end(), [name](RefrigProps const *refrig) { return refrig->Name == name; });
if (foundRefrig != df->refrigs.end()) return true;

auto foundGlycol = std::find_if(df->glycols.begin(), df->glycols.end(), [name](GlycolProps const *glycol) { return glycol->Name == name; });
if (foundGlycol != df->glycols.end()) return true;

return false;
}

void ReportOrphanFluids(EnergyPlusData &state)
{

Expand Down Expand Up @@ -4930,93 +4909,18 @@ namespace Fluid {
}
}

void GetFluidDensityTemperatureLimits(EnergyPlusData &state, int const FluidIndex, Real64 &MinTempLimit, Real64 &MaxTempLimit)
void GlycolProps::getDensityTemperatureLimits(EnergyPlusData &state, Real64 &MinTempLimit, Real64 &MaxTempLimit)
{
if (FluidIndex > 0) {
auto const &df = state.dataFluid->glycols(FluidIndex);
MinTempLimit = df->RhoLowTempValue;
MaxTempLimit = df->RhoHighTempValue;
}
MinTempLimit = this->RhoLowTempValue;
MaxTempLimit = this->RhoHighTempValue;
}

void GetFluidSpecificHeatTemperatureLimits(EnergyPlusData &state, int const FluidIndex, Real64 &MinTempLimit, Real64 &MaxTempLimit)
void GlycolProps::getSpecificHeatTemperatureLimits(EnergyPlusData &state, Real64 &MinTempLimit, Real64 &MaxTempLimit)
{
if (FluidIndex > 0) {
auto const &df = state.dataFluid->glycols(FluidIndex);
MinTempLimit = df->CpLowTempValue;
MaxTempLimit = df->CpHighTempValue;
}
MinTempLimit = this->CpLowTempValue;
MaxTempLimit = this->CpHighTempValue;
}

#ifdef GET_OUT
GlycolAPI::GlycolAPI(EnergyPlusData &state, std::string const &glycolName)
{
this->glycolName = EnergyPlus::Util::makeUPPER(glycolName);
this->glycolIndex = 0;
this->cf = "GlycolAPI:Instance";
if (this->glycolName != "WATER") {
EnergyPlus::ShowFatalError(state, "Can only do water right now");
}
}
Real64 GlycolAPI::specificHeat(EnergyPlusData &state, Real64 temperature)
{
return Fluid::GetSpecificHeatGlycol(state, this->glycolName, temperature, this->glycolIndex, this->cf);
}
Real64 GlycolAPI::density(EnergyPlusData &state, Real64 temperature)
{
return Fluid::GetDensityGlycol(state, this->glycolName, temperature, this->glycolIndex, this->cf);
}
Real64 GlycolAPI::conductivity(EnergyPlusData &state, Real64 temperature)
{
return Fluid::GetConductivityGlycol(state, this->glycolName, temperature, this->glycolIndex, this->cf);
}
Real64 GlycolAPI::viscosity(EnergyPlusData &state, Real64 temperature)
{
return Fluid::GetViscosityGlycol(state, this->glycolName, temperature, this->glycolIndex, this->cf);
}

RefrigerantAPI::RefrigerantAPI(EnergyPlusData &state, std::string const &refrigName)
{
this->rName = EnergyPlus::Util::makeUPPER(refrigName);
this->rIndex = 0;
this->cf = "RefrigerantAPI:Instance";
if (this->rName != "STEAM") {
EnergyPlus::ShowFatalError(state, "Can only do steam right now");
}
}
Real64 RefrigerantAPI::saturationPressure(EnergyPlusData &state, Real64 temperature)
{
return Fluid::GetSatPressureRefrig(state, this->rName, temperature, this->rIndex, this->cf);
}
Real64 RefrigerantAPI::saturationTemperature(EnergyPlusData &state, Real64 pressure)
{
return Fluid::GetSatTemperatureRefrig(state, this->rName, pressure, this->rIndex, this->cf);
}
Real64 RefrigerantAPI::saturatedEnthalpy(EnergyPlusData &state, Real64 temperature, Real64 quality)
{
return Fluid::GetSatEnthalpyRefrig(state, this->rName, temperature, quality, this->rIndex, this->cf);
}
Real64 RefrigerantAPI::saturatedDensity(EnergyPlusData &state, Real64 temperature, Real64 quality)
{
return Fluid::GetSatDensityRefrig(state, this->rName, temperature, quality, this->rIndex, this->cf);
}
Real64 RefrigerantAPI::saturatedSpecificHeat(EnergyPlusData &state, Real64 temperature, Real64 quality)
{
return Fluid::GetSatSpecificHeatRefrig(state, this->rName, temperature, quality, this->rIndex, this->cf);
}
Real64 RefrigerantAPI::superHeatedEnthalpy(EnergyPlusData &state, Real64 temperature, Real64 pressure)
{
return Fluid::GetSupHeatEnthalpyRefrig(state, this->rName, temperature, pressure, this->rIndex, this->cf);
}
Real64 RefrigerantAPI::superHeatedPressure(EnergyPlusData &state, Real64 temperature, Real64 enthalpy)
{
return Fluid::GetSupHeatPressureRefrig(state, this->rName, temperature, enthalpy, this->rIndex, this->cf);
}
Real64 RefrigerantAPI::superHeatedDensity(EnergyPlusData &state, Real64 temperature, Real64 pressure)
{
return Fluid::GetSupHeatDensityRefrig(state, this->rName, temperature, pressure, this->rIndex, this->cf);
}
#endif // GET_OUT

#ifdef UNUSED_FLUID_PROPS
static constexpr std::array<std::array<Real64, DefaultNumSteamSuperheatedTemps>, DefaultNumSteamSuperheatedPressure>
Expand Down
61 changes: 13 additions & 48 deletions src/EnergyPlus/FluidProperties.hh
Original file line number Diff line number Diff line change
Expand Up @@ -375,18 +375,23 @@ namespace Fluid {
Real64 getViscosity(EnergyPlusData &state,
Real64 Temperature, // actual temperature given as input
std::string_view CalledFrom); // routine this function was called from (error messages)

void getDensityTemperatureLimits(EnergyPlusData &state,
Real64 &MinTempLimit,
Real64 &MaxTempLimit);

void getSpecificHeatTemperatureLimits(EnergyPlusData &state,
Real64 &MinTempLimit,
Real64 &MaxTempLimit);


};

struct cached_tsh
{
// Members
std::uint64_t iT;
Real64 sh;

// Default Constructor
cached_tsh() : iT(1000), sh(0.0)
{
}
std::uint64_t iT = 1000;
Real64 sh = 0.0;
};

void GetFluidPropertiesData(EnergyPlusData &state);
Expand Down Expand Up @@ -571,48 +576,8 @@ namespace Fluid {
int UpperBound // Valid values upper bound (set by calling program)
);

bool CheckFluidPropertyName(EnergyPlusData const &state,
std::string const &NameToCheck); // Name from input(?) to be checked against valid FluidPropertyNames

void ReportOrphanFluids(EnergyPlusData &state);

void GetFluidDensityTemperatureLimits(EnergyPlusData &state, int FluidIndex, Real64 &MinTempLimit, Real64 &MaxTempLimit);

void GetFluidSpecificHeatTemperatureLimits(EnergyPlusData &state, int FluidIndex, Real64 &MinTempLimit, Real64 &MaxTempLimit);

#ifdef GET_OUT
struct GlycolAPI
{
std::string glycolName;
int glycolIndex;
std::string cf;
explicit GlycolAPI(EnergyPlusData &state, std::string const &glycolName);
~GlycolAPI() = default;
Real64 specificHeat(EnergyPlusData &state, Real64 temperature);
Real64 density(EnergyPlusData &state, Real64 temperature);
Real64 conductivity(EnergyPlusData &state, Real64 temperature);
Real64 viscosity(EnergyPlusData &state, Real64 temperature);
};

struct RefrigerantAPI
{
std::string rName;
int rIndex;
std::string cf;
explicit RefrigerantAPI(EnergyPlusData &state, std::string const &refrigName);
~RefrigerantAPI() = default;
Real64 saturationPressure(EnergyPlusData &state, Real64 temperature);
Real64 saturationTemperature(EnergyPlusData &state, Real64 pressure);
Real64 saturatedEnthalpy(EnergyPlusData &state, Real64 temperature, Real64 quality);
Real64 saturatedDensity(EnergyPlusData &state, Real64 temperature, Real64 quality);
Real64 saturatedSpecificHeat(EnergyPlusData &state, Real64 temperature, Real64 quality);
Real64 superHeatedEnthalpy(EnergyPlusData &state, Real64 temperature, Real64 pressure);
Real64 superHeatedPressure(EnergyPlusData &state, Real64 temperature, Real64 enthalpy);
Real64 superHeatedDensity(EnergyPlusData &state, Real64 temperature, Real64 pressure);
};
#endif // GET_OUT

} // namespace FluidProperties
} // namespace Fluid

struct FluidData : BaseGlobalStruct
{
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyPlus/OutdoorAirUnit.hh
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ namespace OutdoorAirUnit {
int CoilWaterOutletNode;
DataPlant::PlantEquipmentType CoilType;
PlantLocation plantLoc;
int FluidIndex; // used in Steam...
int FluidIndex = 0;
Real64 MaxVolWaterFlow;
Real64 MaxWaterMassFlow;
Real64 MinVolWaterFlow;
Expand All @@ -162,7 +162,7 @@ namespace OutdoorAirUnit {
// Default Constructor
OAEquipList()
: Type(CompType::Invalid), ComponentIndex(0), CoilAirInletNode(0), CoilAirOutletNode(0), CoilWaterInletNode(0), CoilWaterOutletNode(0),
CoilType(DataPlant::PlantEquipmentType::Invalid), plantLoc{}, FluidIndex(0), MaxVolWaterFlow(0.0), MaxWaterMassFlow(0.0),
CoilType(DataPlant::PlantEquipmentType::Invalid), plantLoc{}, MaxVolWaterFlow(0.0), MaxWaterMassFlow(0.0),
MinVolWaterFlow(0.0), MinWaterMassFlow(0.0), FirstPass(true)
{
}
Expand Down
12 changes: 4 additions & 8 deletions src/EnergyPlus/PackagedThermalStorageCoil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,6 @@ void GetTESCoilInput(EnergyPlusData &state)
// Using/Aliasing
using BranchNodeConnections::TestCompSet;
using DataZoneEquipment::FindControlledZoneIndexFromSystemNodeNumberForZone;
using Fluid::CheckFluidPropertyName;
using Fluid::GetFluidDensityTemperatureLimits;
using Fluid::GetFluidSpecificHeatTemperatureLimits;
using GlobalNames::VerifyUniqueCoilName;
using NodeInputManager::GetOnlySingleNode;
using ScheduleManager::GetScheduleIndex;
Expand Down Expand Up @@ -290,7 +287,6 @@ void GetTESCoilInput(EnergyPlusData &state)
break;
case MediaType::Water:
thisTESCoil.StorageFluidName = "WATER";
thisTESCoil.StorageFluidIndex = Fluid::GetGlycolNum(state, "WATER");
thisTESCoil.glycol = Fluid::GetWater(state);
break;
default:
Expand Down Expand Up @@ -1549,15 +1545,15 @@ void GetTESCoilInput(EnergyPlusData &state)
if (!state.dataIPShortCut->lNumericFieldBlanks(42)) {
thisTESCoil.MinimumFluidTankTempLimit = state.dataIPShortCut->rNumericArgs(42);
} else {
GetFluidDensityTemperatureLimits(state, thisTESCoil.StorageFluidIndex, TminRho, TmaxRho);
GetFluidSpecificHeatTemperatureLimits(state, thisTESCoil.StorageFluidIndex, TminCp, TmaxCp);
thisTESCoil.glycol->getDensityTemperatureLimits(state, TminRho, TmaxRho);
thisTESCoil.glycol->getSpecificHeatTemperatureLimits(state, TminCp, TmaxCp);
thisTESCoil.MinimumFluidTankTempLimit = max(TminRho, TminCp);
}
if (!state.dataIPShortCut->lNumericFieldBlanks(43)) {
thisTESCoil.MaximumFluidTankTempLimit = state.dataIPShortCut->rNumericArgs(43);
} else {
GetFluidDensityTemperatureLimits(state, thisTESCoil.StorageFluidIndex, TminRho, TmaxRho);
GetFluidSpecificHeatTemperatureLimits(state, thisTESCoil.StorageFluidIndex, TminCp, TmaxCp);
thisTESCoil.glycol->getDensityTemperatureLimits(state, TminRho, TmaxRho);
thisTESCoil.glycol->getSpecificHeatTemperatureLimits(state, TminCp, TmaxCp);
thisTESCoil.MaximumFluidTankTempLimit = min(TmaxRho, TmaxCp);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/EnergyPlus/PackagedThermalStorageCoil.hh
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ namespace PackagedThermalStorageCoil {
// TES tank
MediaType StorageMedia; // water/fluid or ice based TES
std::string StorageFluidName; // if user defined, name of fluid type
int StorageFluidIndex = 0; // if user defined, index of fluid type
Fluid::GlycolProps *glycol = nullptr;

Real64 FluidStorageVolume; // volume of water in storage tank for water systems [m3/s]
Expand Down Expand Up @@ -422,7 +421,7 @@ namespace PackagedThermalStorageCoil {
CondInletTemp(0.0), EvapCondPumpElecNomPower(0.0), EvapCondPumpElecEnergy(0.0), BasinHeaterPowerFTempDiff(0.0),
BasinHeaterAvailSchedNum(0), BasinHeaterSetpointTemp(0.0), EvapWaterSupplyMode(EvapWaterSupply::WaterSupplyFromMains),
EvapWaterSupTankID(0), EvapWaterTankDemandARRID(0), CondensateCollectMode(CondensateAction::Discard), CondensateTankID(0),
CondensateTankSupplyARRID(0), StorageMedia(MediaType::Invalid), StorageFluidIndex(0), FluidStorageVolume(0.0), IceStorageCapacity(0.0),
CondensateTankSupplyARRID(0), StorageMedia(MediaType::Invalid), FluidStorageVolume(0.0), IceStorageCapacity(0.0),
StorageCapacitySizingFactor(0.0), MinimumFluidTankTempLimit(0.0), MaximumFluidTankTempLimit(100.0), RatedFluidTankTemp(0.0),
StorageAmbientNodeNum(0), StorageUA(0.0), TESPlantConnectionAvailable(false), TESPlantInletNodeNum(0), TESPlantOutletNodeNum(0),
TESPlantLoopNum(0), TESPlantLoopSideNum(DataPlant::LoopSideLocation::Invalid), TESPlantBranchNum(0), TESPlantCompNum(0),
Expand Down
4 changes: 0 additions & 4 deletions src/EnergyPlus/PlantPressureSystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ void BranchPressureDrop(EnergyPlusData &state,
static constexpr std::string_view RoutineName("CalcPlantPressureSystem");

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int FluidIndex; // Plant loop level Fluid Index
int InletNodeNum; // Component inlet node number
DataBranchAirLoopPlant::PressureCurveType pressureCurveType; // Type of curve used to evaluate pressure drop
int PressureCurveIndex; // Curve index for PerfCurve structure
Expand All @@ -392,7 +391,6 @@ void BranchPressureDrop(EnergyPlusData &state,
}

// Get data from data structure
FluidIndex = state.dataPlnt->PlantLoop(LoopNum).FluidIndex;
InletNodeNum = state.dataPlnt->PlantLoop(LoopNum).LoopSide(LoopSideNum).Branch(BranchNum).NodeNumIn;
pressureCurveType = state.dataPlnt->PlantLoop(LoopNum).LoopSide(LoopSideNum).Branch(BranchNum).PressureCurveType;
PressureCurveIndex = state.dataPlnt->PlantLoop(LoopNum).LoopSide(LoopSideNum).Branch(BranchNum).PressureCurveIndex;
Expand Down Expand Up @@ -845,7 +843,6 @@ Real64 ResolveLoopFlowVsPressure(EnergyPlusData &state,
Real64 PhiPump;
Real64 PhiSystem;
Real64 PsiPump;
int FluidIndex;
int Iteration;
Real64 LocalSystemMassFlow;
Real64 LoopEffectiveK;
Expand All @@ -856,7 +853,6 @@ Real64 ResolveLoopFlowVsPressure(EnergyPlusData &state,
Real64 DampingFactor;

// Get loop level data
FluidIndex = state.dataPlnt->PlantLoop(LoopNum).FluidIndex;
LoopEffectiveK = state.dataPlnt->PlantLoop(LoopNum).PressureEffectiveK;
SystemPressureDrop = LoopEffectiveK * pow_2(SystemMassFlow);

Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/RefrigeratedCase.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,6 @@ namespace RefrigeratedCase {
bool CoilFlag = false; // Flag to show if coil type load on secondary system
std::string Name; // Name of refrigeration system
std::string FluidName; // Name of circulating fluid
int FluidIndex = 0; // Numerical ID used for calls to properties subroutine
Fluid::GlycolProps *glycol = nullptr;
Fluid::RefrigProps *refrig = nullptr;
std::string EndUseSubcategory; // Used for reporting purposes
Expand Down
3 changes: 1 addition & 2 deletions src/EnergyPlus/SingleDuct.hh
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ namespace SingleDuct {
Action DamperHeatingAction;
Real64 DamperPosition;
int ADUNum; // index of corresponding air distribution unit
int FluidIndex; // Refrigerant index
int ErrCount1; // iteration limit exceeded in Hot Water Flow Calc
int ErrCount1c; // iteration limit exceeded in Hot Water Flow Calc - continue
int ErrCount2; // bad iterations limits in hot water flow calc
Expand Down Expand Up @@ -232,7 +231,7 @@ namespace SingleDuct {
ReheatAirOutletNode(0), MaxReheatWaterVolFlow(0.0), MaxReheatSteamVolFlow(0.0), MaxReheatWaterFlow(0.0), MaxReheatSteamFlow(0.0),
MinReheatWaterVolFlow(0.0), MinReheatSteamVolFlow(0.0), MinReheatWaterFlow(0.0), MinReheatSteamFlow(0.0), ControllerOffset(0.0),
MaxReheatTemp(0.0), MaxReheatTempSetByUser(false), DamperHeatingAction(Action::HeatingNotUsed), DamperPosition(0.0), ADUNum(0),
FluidIndex(0), ErrCount1(0), ErrCount1c(0), ErrCount2(0), ZoneFloorArea(0.0), CtrlZoneNum(0), CtrlZoneInNodeIndex(0),
ErrCount1(0), ErrCount1c(0), ErrCount2(0), ZoneFloorArea(0.0), CtrlZoneNum(0), CtrlZoneInNodeIndex(0),
MaxAirVolFlowRateDuringReheat(0.0), MaxAirVolFractionDuringReheat(0.0), AirMassFlowDuringReheatMax(0.0), ZoneOutdoorAirMethod(0),
OutdoorAirFlowRate(0.0), NoOAFlowInputFromUser(true), OARequirementsPtr(0), AirLoopNum(0), HWplantLoc{}, SecInNode(0),
IterationLimit(0), IterationFailed(0), OAPerPersonMode(DataZoneEquipment::PerPersonVentRateMode::Invalid), EMSOverrideAirFlow(false),
Expand Down
2 changes: 0 additions & 2 deletions src/EnergyPlus/SurfaceGroundHeatExchanger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ namespace SurfaceGroundHeatExchanger {

// Using/Aliasing
using BranchNodeConnections::TestCompSet;
using Fluid::CheckFluidPropertyName;

using NodeInputManager::GetOnlySingleNode;
using namespace DataLoopNode;

Expand Down
1 change: 0 additions & 1 deletion src/EnergyPlus/WaterToAirHeatPump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ namespace WaterToAirHeatPump {
// Using/Aliasing
using namespace NodeInputManager;
using BranchNodeConnections::TestCompSet;
using Fluid::CheckFluidPropertyName;
using GlobalNames::VerifyUniqueCoilName;
using PlantUtilities::RegisterPlantCompDesignFlow;
using namespace OutputReportPredefined;
Expand Down
Loading

3 comments on commit 42f9e68

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FluidAPI2 (Unknown) - x86_64-Linux-Ubuntu-24.04-gcc-13.3: OK (2919 of 2919 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FluidAPI2 (Unknown) - x86_64-Linux-Ubuntu-24.04-gcc-13.3-UnitTestsCoverage-RelWithDebInfo: OK (2101 of 2101 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FluidAPI2 (Unknown) - x86_64-Linux-Ubuntu-24.04-gcc-13.3-IntegrationCoverage-RelWithDebInfo: OK (801 of 801 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.