Skip to content

Commit

Permalink
PV Zone Multiplier Fix
Browse files Browse the repository at this point in the history
PV systems were not picking up the zone multiplier.  This now fixes the
problem.  The defect input file that uses the zone multiplier is now in
line with the file that has all of the zones defined.  Unit tests for
the fix are also included.
  • Loading branch information
RKStrand committed Aug 31, 2017
1 parent 46d706b commit 612f006
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/EnergyPlus/Photovoltaics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -856,55 +856,53 @@ namespace Photovoltaics {
// AUTHOR B. Griffith
// DATE WRITTEN Jan. 2004
// MODIFIED B. Griffith, Aug. 2008
// RE-ENGINEERED na

// PURPOSE OF THIS SUBROUTINE:
// collect statements that assign to variables tied to output variables

// METHODOLOGY EMPLOYED:
// <description>

// REFERENCES:
// na

// USE STATEMENTS:
// na
// Using/Aliasing
using DataHeatBalance::Zone;
using DataGlobals::NumOfZones;
using DataSurfaces::Surface;
using DataHeatBalFanSys::QPVSysSource;
using TranspiredCollector::SetUTSCQdotSource;

// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:

// SUBROUTINE PARAMETER DEFINITIONS:
// na

// INTERFACE BLOCK SPECIFICATIONS:
// na

// DERIVED TYPE DEFINITIONS:
// na
using InputProcessor::FindItemInList;

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int thisZone; // working index for zones
int thisSurface; // index for PV surface
Array1D< bool > PVarrayZoneInitialized; // avoid doing the zone check too often
bool FirstTimeThru( true );

PVarray( PVnum ).Report.DCEnergy = PVarray( PVnum ).Report.DCPower * ( TimeStepSys * SecInHour );

thisSurface = PVarray( PVnum ).SurfacePtr;

if ( FirstTimeThru ) {
PVarrayZoneInitialized.dimension( NumPVs, false );
FirstTimeThru = false;
}

if ( ! PVarrayZoneInitialized( PVnum ) ) {
if ( Surface( thisSurface ).Zone == 0 ) { // might need to get the zone number from the name
Surface( thisSurface ).Zone = FindItemInList( Surface( thisSurface ).ZoneName, Zone, NumOfZones );
}
PVarrayZoneInitialized( PVnum ) = true;
}

// add check for multiplier. if surface is attached to a zone that is on a multiplier
// then PV production should be multiplied out as well

if ( Surface( PVarray( PVnum ).SurfacePtr ).Zone != 0 ) { // might need to apply multiplier
thisZone = Surface( PVarray( PVnum ).SurfacePtr ).Zone;
if ( Surface( thisSurface ).Zone != 0 ) { // might need to apply multiplier
thisZone = Surface( thisSurface ).Zone;
PVarray( PVnum ).Report.DCEnergy *= ( Zone( thisZone ).Multiplier * Zone( thisZone ).ListMultiplier );
PVarray( PVnum ).Report.DCPower *= ( Zone( thisZone ).Multiplier * Zone( thisZone ).ListMultiplier );
}

{ auto const SELECT_CASE_var( PVarray( PVnum ).CellIntegrationMode );
// SurfaceSink is not multiplied...
if ( SELECT_CASE_var == iSurfaceOutsideFaceCellIntegration ) {
QPVSysSource( PVarray( PVnum ).SurfacePtr ) = -1.0 * PVarray( PVnum ).SurfaceSink;
QPVSysSource( thisSurface ) = -1.0 * PVarray( PVnum ).SurfaceSink;

} else if ( SELECT_CASE_var == iTranspiredCollectorCellIntegration ) {
SetUTSCQdotSource( PVarray( PVnum ).UTSCPtr, - 1.0 * PVarray( PVnum ).SurfaceSink );
Expand Down
63 changes: 63 additions & 0 deletions tst/EnergyPlus/unit/Photovoltaics.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@

// EnergyPlus Headers
#include <Photovoltaics.hh>
#include <DataPhotovoltaics.hh>
#include <DataHeatBalance.hh>
#include <DataSurfaces.hh>

#include "Fixtures/EnergyPlusFixture.hh"

Expand All @@ -73,3 +76,63 @@ TEST_F( EnergyPlusFixture, PV_Sandia_AirMassAtHighZenith )
EXPECT_NEAR( airMass, 26.24135, 0.1 );

}

TEST_F( EnergyPlusFixture, PV_ReportPV_ZoneIndexNonZero )
{
// unit test for issue #6222, test to make sure zone index in surface on which PV is placed is not zero so zone multiplier is applied properly

EnergyPlus::DataPhotovoltaics::PVarray.deallocate();
DataHeatBalance::Zone.deallocate();
DataSurfaces::Surface.deallocate();

EnergyPlus::DataPhotovoltaics::PVarray.allocate( 3 );
DataHeatBalance::Zone.allocate( 2 );
DataSurfaces::Surface.allocate( 3 );

DataGlobals::NumOfZones = 2;
DataHeatBalance::Zone( 1 ).Name = "Zone1";
DataHeatBalance::Zone( 1 ).ListMultiplier = 1.0;
DataHeatBalance::Zone( 1 ).Multiplier = 5.0;
DataHeatBalance::Zone( 2 ).Name = "Zone2";
DataHeatBalance::Zone( 2 ).ListMultiplier = 10.0;
DataHeatBalance::Zone( 2 ).Multiplier = 1.0;

EnergyPlus::DataPhotovoltaics::NumPVs = 3;
EnergyPlus::DataPhotovoltaics::PVarray( 1 ).SurfacePtr = 1;
EnergyPlus::DataPhotovoltaics::PVarray( 1 ).CellIntegrationMode = -9999;
EnergyPlus::DataPhotovoltaics::PVarray( 2 ).SurfacePtr = 2;
EnergyPlus::DataPhotovoltaics::PVarray( 2 ).CellIntegrationMode = -9999;
EnergyPlus::DataPhotovoltaics::PVarray( 3 ).SurfacePtr = 3;
EnergyPlus::DataPhotovoltaics::PVarray( 3 ).CellIntegrationMode = -9999;

DataSurfaces::Surface( 1 ).Zone = 1;
DataSurfaces::Surface( 1 ).ZoneName = "Zone1";
DataSurfaces::Surface( 2 ).Zone = 0;
DataSurfaces::Surface( 2 ).ZoneName = "Zone2";
DataSurfaces::Surface( 3 ).Zone = 0;
DataSurfaces::Surface( 3 ).ZoneName = "None";

// Test 1: Zone 1--PV has multiplier, Zone index already set
EnergyPlus::DataPhotovoltaics::PVarray( 1 ).Report.DCPower = 1000.0;
Photovoltaics::ReportPV( 1 );
EXPECT_NEAR( EnergyPlus::DataPhotovoltaics::PVarray( 1 ).Report.DCPower, 5000.0, 0.1 );

// Test 2: Zone 2--PV has multiplier, Zone index not set yet
EnergyPlus::DataPhotovoltaics::PVarray( 2 ).Report.DCPower = 1000.0;
Photovoltaics::ReportPV( 2 );
EXPECT_NEAR( EnergyPlus::DataPhotovoltaics::PVarray( 2 ).Report.DCPower, 10000.0, 0.1 );
EXPECT_EQ( DataSurfaces::Surface( 2 ).Zone, 2 );

// Test 3: Zone 2--PV has multiplier, Zone index set by previous pass through ReportPV
EnergyPlus::DataPhotovoltaics::PVarray( 2 ).Report.DCPower = 500.0;
Photovoltaics::ReportPV( 2 );
EXPECT_NEAR( EnergyPlus::DataPhotovoltaics::PVarray( 2 ).Report.DCPower, 5000.0, 0.1 );

// Test 4: Zone 3--PV not attached to any zone, Zone Index does not get reset
EnergyPlus::DataPhotovoltaics::PVarray( 3 ).Report.DCPower = 1000.0;
Photovoltaics::ReportPV( 3 );
EXPECT_NEAR( EnergyPlus::DataPhotovoltaics::PVarray( 3 ).Report.DCPower, 1000.0, 0.1 );
EXPECT_EQ( DataSurfaces::Surface( 3 ).Zone, 0 );

}

8 comments on commit 612f006

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

149930772-SurfacePVZoneMultiplierProblem (RKStrand) - i386-Windows-7-VisualStudio-14: OK (2749 of 2749 tests passed, 0 test warnings)

Build Badge Test Badge

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

149930772-SurfacePVZoneMultiplierProblem (RKStrand) - x86_64-MacOS-10.9-clang: OK (2749 of 2749 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.

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

149930772-SurfacePVZoneMultiplierProblem (RKStrand) - Win64-Windows-7-VisualStudio-14: OK (2749 of 2749 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.

149930772-SurfacePVZoneMultiplierProblem (RKStrand) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: 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.

149930772-SurfacePVZoneMultiplierProblem (RKStrand) - x86_64-Linux-Ubuntu-14.04-gcc-4.8-UnitTestsCoverage-Debug: OK (1535 of 1535 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.

149930772-SurfacePVZoneMultiplierProblem (RKStrand) - x86_64-Linux-Ubuntu-14.04-custom_check: 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.

149930772-SurfacePVZoneMultiplierProblem (RKStrand) - x86_64-Linux-Ubuntu-14.04-gcc-4.8-IntegrationCoverage-Debug: OK (2146 of 2146 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.