Skip to content

Commit

Permalink
Merge branch 'develop' into plantCompUsrDefRefactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Myoldmopar authored Dec 19, 2019
2 parents a2eddc3 + 24427ed commit e4af92b
Show file tree
Hide file tree
Showing 11 changed files with 955 additions and 1,031 deletions.
2 changes: 1 addition & 1 deletion src/EnergyPlus/HeatBalanceManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ namespace HeatBalanceManager {
auto const SELECT_CASE_var(AlphaName(1));
if ((SELECT_CASE_var == "REGULAFALSI")) {
HVACSystemRootFinding.HVACSystemRootSolver = DataHVACGlobals::HVACSystemRootSolverAlgorithm::RegulaFalsi;
} else if (SELECT_CASE_var == "BiSECTION") {
} else if (SELECT_CASE_var == "BISECTION") {
HVACSystemRootFinding.HVACSystemRootSolver = DataHVACGlobals::HVACSystemRootSolverAlgorithm::Bisection;
} else if (SELECT_CASE_var == "BISECTIONTHENREGULAFALSI") {
HVACSystemRootFinding.HVACSystemRootSolver = DataHVACGlobals::HVACSystemRootSolverAlgorithm::BisectionThenRegulaFalsi;
Expand Down
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
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);
}

// 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
};

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
{
// 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();

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 @@ -1342,6 +1343,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 WaterCoils::UpdateWaterToAirCoilPlantConnection;
Expand Down Expand Up @@ -867,17 +865,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
6 changes: 3 additions & 3 deletions src/EnergyPlus/UnitarySystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4242,9 +4242,6 @@ namespace UnitarySystems {
thisSys.m_CoolingCoilType_Num = DataHVACGlobals::Coil_CoolingWaterToAirHPVSEquationFit;
} else if (UtilityRoutines::SameString(loc_coolingCoilType, "Coil:Cooling:DX:SingleSpeed")) {
thisSys.m_CoolingCoilType_Num = DataHVACGlobals::CoilDX_CoolingSingleSpeed;
if (DataGlobals::DoCoilDirectSolutions) {
DXCoils::DisableLatentDegradation(thisSys.m_CoolingCoilIndex);
}
} else if (UtilityRoutines::SameString(loc_coolingCoilType, "Coil:Cooling:DX:TwoSpeed")) {
thisSys.m_CoolingCoilType_Num = DataHVACGlobals::CoilDX_CoolingTwoSpeed;
} else if (UtilityRoutines::SameString(loc_coolingCoilType, "Coil:UserDefined")) {
Expand Down Expand Up @@ -4273,6 +4270,9 @@ namespace UnitarySystems {
ShowContinueError("Occurs in " + cCurrentModuleObject + " = " + thisObjectName);
errorsFound = true;
}
if (DataGlobals::DoCoilDirectSolutions && thisSys.m_CoolingCoilType_Num == DataHVACGlobals::CoilDX_CoolingSingleSpeed) {
DXCoils::DisableLatentDegradation(thisSys.m_CoolingCoilIndex);
}

thisSys.m_CoolingCoilAvailSchPtr = DXCoils::GetDXCoilAvailSchPtr(loc_coolingCoilType, loc_m_CoolingCoilName, errFlag);

Expand Down
Loading

7 comments on commit e4af92b

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

plantCompUsrDefRefactor (Myoldmopar) - x86_64-MacOS-10.13-clang: OK (2596 of 2596 tests passed, 1 test warnings)

Messages:\n

  • 1 test had: BND diffs.
  • 1 test had: EIO diffs.
  • 1 test had: EDD diffs.
  • 1 test had: ESO small diffs.
  • 1 test had: MTR small diffs.
  • 1 test had: Table small diffs.

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

plantCompUsrDefRefactor (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.4: OK (2636 of 2636 tests passed, 1 test warnings)

Messages:\n

  • 1 test had: BND diffs.
  • 1 test had: EDD diffs.
  • 1 test had: ESO small diffs.
  • 1 test had: MTR small diffs.

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.

plantCompUsrDefRefactor (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-custom_check: OK (11 of 11 tests passed, 0 test warnings)

Build Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

plantCompUsrDefRefactor (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-cppcheck: OK (0 of 0 tests passed, 0 test warnings)

Build 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.

plantCompUsrDefRefactor (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.4-UnitTestsCoverage-Debug: OK (1254 of 1254 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

plantCompUsrDefRefactor (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2596 of 2596 tests passed, 1 test warnings)

Messages:\n

  • 1 test had: BND diffs.
  • 1 test had: EIO diffs.
  • 1 test had: EDD diffs.
  • 1 test had: ESO small diffs.
  • 1 test had: MTR small diffs.
  • 1 test had: Table small diffs.

Build Badge Test Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

plantCompUsrDefRefactor (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.4-IntegrationCoverage-Debug: OK (674 of 675 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 674
  • Timeout: 1

Build Badge Test Badge Coverage Badge

Please sign in to comment.