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

Photovoltaic Thermal Collector Plant Component Refactor #7652

Merged
merged 16 commits into from
Dec 19, 2019
10 changes: 6 additions & 4 deletions src/EnergyPlus/MixedAir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
#include <EnergyPlus/OutAirNodeManager.hh>
#include <EnergyPlus/OutputProcessor.hh>
#include <EnergyPlus/OutputReportPredefined.hh>
#include <EnergyPlus/Plant/PlantLocation.hh>
#include <EnergyPlus/PhotovoltaicThermalCollectors.hh>
#include <EnergyPlus/Psychrometrics.hh>
#include <EnergyPlus/ReportSizingManager.hh>
Expand Down Expand Up @@ -458,7 +459,7 @@ namespace MixedAir {
OACoolCoil,
OAHX);
}
// now simulate again propogate current temps back through OA system
// now simulate again propigate current temps back through OA system
Copy link
Member

Choose a reason for hiding this comment

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

"propagate" 😄

for (CompNum = 1; CompNum <= OutsideAirSys(OASysNum).NumComponents; ++CompNum) {
CompType = OutsideAirSys(OASysNum).ComponentType(CompNum);
CompName = OutsideAirSys(OASysNum).ComponentName(CompNum);
Expand Down Expand Up @@ -599,8 +600,6 @@ namespace MixedAir {
using HVACDXSystem::SimDXCoolingSystem;
using HVACHXAssistedCoolingCoil::HXAssistedCoil;
using HVACHXAssistedCoolingCoil::SimHXAssistedCoolingCoil;
using PhotovoltaicThermalCollectors::CalledFromOutsideAirSystem;
using PhotovoltaicThermalCollectors::SimPVTcollectors;
using SimAirServingZones::SolveWaterCoilController;
using SteamCoils::SimulateSteamCoilComponents;
using TranspiredCollector::SimTranspiredCollector;
Expand Down Expand Up @@ -831,7 +830,10 @@ namespace MixedAir {
// Air-based Photovoltaic-thermal flat plate collector
} else if (SELECT_CASE_var == PVT_AirBased) { // 'SolarCollector:FlatPlate:PhotovoltaicThermal'
if (Sim) {
SimPVTcollectors(CompIndex, FirstHVACIteration, CalledFromOutsideAirSystem, CompName);
if (CompIndex == 0) {
CompIndex = PhotovoltaicThermalCollectors::getPVTindexFromName(CompName);
}
PhotovoltaicThermalCollectors::simPVTfromOASys(CompIndex, FirstHVACIteration);
Copy link
Member

Choose a reason for hiding this comment

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

Much better, thanks!

}

// Evaporative Cooler Types
Expand Down
1,458 changes: 575 additions & 883 deletions src/EnergyPlus/PhotovoltaicThermalCollectors.cc

Large diffs are not rendered by default.

163 changes: 68 additions & 95 deletions src/EnergyPlus/PhotovoltaicThermalCollectors.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,67 +50,42 @@

// ObjexxFCL Headers
#include <ObjexxFCL/Array1D.hh>
#include <ObjexxFCL/Optional.hh>

// EnergyPlus Headers
#include <EnergyPlus/DataGlobals.hh>
#include <EnergyPlus/EnergyPlus.hh>
#include <EnergyPlus/PlantComponent.hh>

namespace EnergyPlus {

namespace PhotovoltaicThermalCollectors {

// Using/Aliasing

// Data
// MODULE PARAMETER DEFINITIONS:
extern int const SimplePVTmodel;
extern int const LayerByLayerPVTmodel;

extern int const ScheduledThermEffic; // mode for thermal efficiency is to use schedule
extern int const FixedThermEffic; // mode for thermal efficiency is to use fixed value

extern int const LiquidWorkingFluid;
extern int const AirWorkingFluid;

extern int const CalledFromPlantLoopEquipMgr;
extern int const CalledFromOutsideAirSystem;

extern Real64 const SimplePVTWaterSizeFactor; // [ m3/s/m2 ] average of collectors in SolarCollectors.idf

// DERIVED TYPE DEFINITIONS:

// MODULE VARIABLE DECLARATIONS:
extern Array1D_bool CheckEquipName;
extern int NumPVT; // count of all types of PVT in input file
extern int NumSimplePVTPerform; // count of simple PVT performance objects in input file

// SUBROUTINE SPECIFICATIONS FOR MODULE:
// Driver/Manager Routines

// Utility routines for module
// these would be public such as:
// PUBLIC GetPVTIncidentSolarForInternalPVLayer
// PUBLIC GetPVTCellTemp
enum struct WorkingFluidEnum
{
LIQUID,
AIR
};

// Types
enum struct ThermEfficEnum
{
SCHEDULED,
FIXED
};
Copy link
Member

Choose a reason for hiding this comment

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

enum struct, seems so unusual compared to enum class; but hey, they are exactly the same, so whatever!


struct SimplePVTModelStruct
{
// Members
std::string Name;
Real64 ThermalActiveFract; // fraction of surface area with active thermal collection
int ThermEfficMode; // setting for how therm effic is determined
Real64 ThermEffic; // fixed or current Therm efficiency
int ThermEffSchedNum; // pointer to schedule for therm effic (if any)
Real64 SurfEmissivity; // surface emittance in long wave IR
Real64 LastCollectorTemp; // store previous temperature
Real64 CollectorTemp; // average solar collector temp.
Real64 ThermalActiveFract; // fraction of surface area with active thermal collection
ThermEfficEnum ThermEfficMode; // setting for how therm effic is determined
Real64 ThermEffic; // fixed or current Therm efficiency
int ThermEffSchedNum; // pointer to schedule for therm effic (if any)
Real64 SurfEmissivity; // surface emittance in long wave IR
Real64 LastCollectorTemp; // store previous temperature
Real64 CollectorTemp; // average solar collector temp.

// Default Constructor
SimplePVTModelStruct()
: ThermalActiveFract(0.0), ThermEfficMode(0), ThermEffic(0.0), ThermEffSchedNum(0), SurfEmissivity(0.0), LastCollectorTemp(0.0),
CollectorTemp(0.0)
: ThermalActiveFract(0.0), ThermEfficMode(ThermEfficEnum::FIXED), ThermEffic(0.0), ThermEffSchedNum(0), SurfEmissivity(0.0),
LastCollectorTemp(0.0), CollectorTemp(0.0)
{
}
};
Expand All @@ -136,88 +111,86 @@ namespace PhotovoltaicThermalCollectors {
}
};

struct PVTCollectorStruct
struct PVTCollectorStruct : PlantComponent
Copy link
Member

Choose a reason for hiding this comment

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

👍

{
// Members
// input
std::string Name; // Name of PVT collector
int TypeNum; // Plant Side Connection: 'TypeOf_Num' assigned in DataPlant !DSU
int WLoopNum; // Water plant loop index number !DSU
int WLoopSideNum; // Water plant loop side index !DSU
int WLoopBranchNum; // Water plant loop branch index !DSU
int WLoopCompNum; // Water plant loop component index !DSU
bool EnvrnInit; // manage begin environmen inits
bool SizingInit; // manage when sizing is complete
std::string PVTModelName; // Name of PVT performance object
int PVTModelType; // model type indicator, only simple avail now
int SurfNum; // surface index
std::string PVname; // named Generator:Photovoltaic object
int PVnum; // PV index
bool PVfound; // init, need to delay get input until PV gotten
// INTEGER :: PlantLoopNum = 0 ! needed for sizing and control
// INTEGER :: PlantLoopSide = 0 ! needed for sizing, demand vs. supply sided
std::string Name; // Name of PVT collector
int TypeNum; // Plant Side Connection: 'TypeOf_Num' assigned in DataPlant
int WLoopNum; // Water plant loop index number
int WLoopSideNum; // Water plant loop side index
int WLoopBranchNum; // Water plant loop branch index
int WLoopCompNum; // Water plant loop component index
bool EnvrnInit; // manage begin environment inits
bool SizingInit; // manage when sizing is complete
std::string PVTModelName; // Name of PVT performance object
int PVTModelType; // model type indicator, only simple avail now
int SurfNum; // surface index
std::string PVname; // named Generator:Photovoltaic object
int PVnum; // PV index
bool PVfound; // init, need to delay get input until PV gotten
SimplePVTModelStruct Simple; // performance data structure.
int WorkingFluidType;
WorkingFluidEnum WorkingFluidType;
int PlantInletNodeNum;
int PlantOutletNodeNum;
int HVACInletNodeNum;
int HVACOutletNodeNum;
Real64 DesignVolFlowRate;
bool DesignVolFlowRateWasAutoSized; // true if design volume flow rate was autosize on input
Real64 MaxMassFlowRate;
Real64 MassFlowRate; // DSU
Real64 MassFlowRate;
Real64 AreaCol;
bool BypassDamperOff;
bool CoolingUseful;
bool HeatingUseful;
PVTReportStruct Report;
bool MySetPointCheckFlag;
bool MyOneTimeFlag;
bool SetLoopIndexFlag;

// Default Constructor
PVTCollectorStruct()
: WLoopNum(0), WLoopSideNum(0), WLoopBranchNum(0), WLoopCompNum(0), EnvrnInit(true), SizingInit(true), PVTModelType(0), SurfNum(0),
PVnum(0), PVfound(false), WorkingFluidType(0), PlantInletNodeNum(0), PlantOutletNodeNum(0), HVACInletNodeNum(0), HVACOutletNodeNum(0),
DesignVolFlowRate(0.0), DesignVolFlowRateWasAutoSized(false), MaxMassFlowRate(0.0), MassFlowRate(0.0), AreaCol(0.0),
BypassDamperOff(true), CoolingUseful(false), HeatingUseful(false)
: TypeNum(0), WLoopNum(0), WLoopSideNum(0), WLoopBranchNum(0), WLoopCompNum(0), EnvrnInit(true), SizingInit(true), PVTModelType(0),
SurfNum(0), PVnum(0), PVfound(false), WorkingFluidType(WorkingFluidEnum::LIQUID), PlantInletNodeNum(0), PlantOutletNodeNum(0),
HVACInletNodeNum(0), HVACOutletNodeNum(0), DesignVolFlowRate(0.0), DesignVolFlowRateWasAutoSized(false), MaxMassFlowRate(0.0),
MassFlowRate(0.0), AreaCol(0.0), BypassDamperOff(true), CoolingUseful(false), HeatingUseful(false), MySetPointCheckFlag(true),
MyOneTimeFlag(true), SetLoopIndexFlag(true)
{
}
};

// Object Data
extern Array1D<PVTCollectorStruct> PVT;
static PlantComponent *factory(std::string const &objectName);

// Functions
void onInitLoopEquip(const PlantLocation &calledFromLocation) override;

void SimPVTcollectors(int &PVTnum, // index to PVT array.
bool const FirstHVACIteration,
int const CalledFrom,
Optional_string_const PVTName = _,
Optional_bool_const InitLoopEquip = _);
void simulate(const PlantLocation &calledFromLocation, bool FirstHVACIteration, Real64 &CurLoad, bool RunFlag) override;

void GetPVTcollectorsInput();
void setupReportVars();

void initialize(bool FirstHVACIteration);

void size();

void InitPVTcollectors(int const PVTnum, bool const FirstHVACIteration);
void control();
Copy link
Member

Choose a reason for hiding this comment

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

Yes, great naming!


void SizePVT(int const PVTnum);
void calculate();

void ControlPVTcollector(int const PVTnum);
void update();
};

extern Array1D<PVTCollectorStruct> PVT;

void clear_state();

void GetPVTcollectorsInput();

void CalcPVTcollectors(int const PVTnum);
void simPVTfromOASys(int index, bool FirstHVACIteration);

void UpdatePVTcollectors(int const PVTnum);
int getPVTindexFromName(std::string const &name);

void GetPVTThermalPowerProduction(int const PVindex, // index of PV generator (not PVT collector)
Real64 &ThermalPower,
Real64 &ThermalEnergy);
int GetAirInletNodeNum(std::string const &PVTName,
bool &ErrorsFound
);
void GetPVTThermalPowerProduction(int PVindex, Real64 &ThermalPower, Real64 &ThermalEnergy);

int GetAirOutletNodeNum(std::string const &PVTName,
bool &ErrorsFound
);
int GetAirInletNodeNum(std::string const &PVTName, bool &ErrorsFound);

//===================== Utility/Other routines for module.
// Insert as appropriate
int GetAirOutletNodeNum(std::string const &PVTName, bool &ErrorsFound);

} // namespace PhotovoltaicThermalCollectors

Expand Down
2 changes: 2 additions & 0 deletions src/EnergyPlus/Plant/PlantManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
#include <EnergyPlus/MicroCHPElectricGenerator.hh>
#include <EnergyPlus/OutputProcessor.hh>
#include <EnergyPlus/OutsideEnergySources.hh>
#include <EnergyPlus/PhotovoltaicThermalCollectors.hh>
#include <EnergyPlus/PipeHeatTransfer.hh>
#include <EnergyPlus/Pipes.hh>
#include <EnergyPlus/Plant/PlantLoopSolver.hh>
Expand Down Expand Up @@ -1341,6 +1342,7 @@ namespace EnergyPlus {
} else if (LoopSideNum == SupplySide) {
this_comp.CurOpSchemeType = UnknownStatusOpSchemeType;
}
this_comp.compPtr = PhotovoltaicThermalCollectors::PVTCollectorStruct::factory(CompNames(CompNum));
} else if (UtilityRoutines::SameString(this_comp_type, "CentralHeatPumpSystem")) {
this_comp.TypeOf_Num = TypeOf_CentralGroundSourceHeatPump;
this_comp.GeneralEquipType = GenEquipTypes_CentralHeatPumpSystem;
Expand Down
12 changes: 1 addition & 11 deletions src/EnergyPlus/PlantLoopEquip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,6 @@ namespace PlantLoopEquip {
using BaseboardRadiator::UpdateBaseboardPlantConnection;
using HVACVariableRefrigerantFlow::SimVRFCondenserPlant;
using HWBaseboardRadiator::UpdateHWBaseboardPlantConnection;
using PhotovoltaicThermalCollectors::CalledFromPlantLoopEquipMgr;
using PhotovoltaicThermalCollectors::SimPVTcollectors;
using RefrigeratedCase::SimRefrigCondenser;
using SteamBaseboardRadiator::UpdateSteamBaseboardPlantConnection;
using UserDefinedComponents::SimUserDefinedPlantComponent;
Expand Down Expand Up @@ -868,17 +866,9 @@ namespace PlantLoopEquip {

sim_component.compPtr->simulate(sim_component_location, FirstHVACIteration, CurLoad, RunFlag);

if (InitLoopEquip) {
sim_component.CompNum = EquipNum;
}

} else if (EquipTypeNum == TypeOf_PVTSolarCollectorFlatPlate) {

SimPVTcollectors(EquipNum, FirstHVACIteration, CalledFromPlantLoopEquipMgr, sim_component.Name, InitLoopEquip);

if (InitLoopEquip) {
sim_component.CompNum = EquipNum;
}
sim_component.compPtr->simulate(sim_component_location, FirstHVACIteration, CurLoad, RunFlag);

} else {
ShowSevereError("SimPlantEquip: Invalid Solar Collector Type=" + sim_component.TypeOf);
Expand Down
Loading