Skip to content

Commit

Permalink
Merge pull request #58 in JGCRI/gcam-core from feature/capacity-facto…
Browse files Browse the repository at this point in the history
…r-usa to master

* commit '3f8f06abdc5c9d7bfd0d33b8497b448f284ca3b5':
  write out capacity factor
  additional conflicts resolved
  capacity factor fix for GCAM-USA and code cleanup
  • Loading branch information
kvcalvin committed Nov 1, 2017
2 parents 4d57644 + 3f8f06a commit 24e2007
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 102 deletions.
3 changes: 3 additions & 0 deletions cvs/objects/reporting/source/xml_db_outputter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,9 @@ void XMLDBOutputter::startVisitTechnology( const Technology* aTechnology, const
XMLWriteElement( aTechnology->getShareWeight(), "share-weight", *childBuffer, mTabs.get() );
}

// Do not write out default capacity factor of 1
XMLWriteElementCheckDefault( aTechnology->getCapacityFactor(), "capacity-factor", *childBuffer, mTabs.get() , 1.0 );

// children of technology go in the child buffer
for( int curr = 0; curr <= aPeriod; ++curr ){
// Write out total cost which includes fuel and non-energy costs
Expand Down
4 changes: 2 additions & 2 deletions cvs/objects/resources/include/renewable_subresource.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ class IInfo;
*/
class SubRenewableResource: public SubResource {
friend class CalibrateResourceVisitor;
public:

public:
SubRenewableResource();
virtual void completeInit( const IInfo* aSectorInfo );
virtual void cumulsupply(double prc,int per);
virtual void annualsupply( int per, const GDP* gdp, double price1, double price2 );
virtual double getVariance() const;
virtual double getMaxSubResource() const;
virtual double getAverageCapacityFactor() const;
//! Return the XML tag name
static const std::string& getXMLNameStatic( void );
virtual void accept( IVisitor* aVisitor, const int aPeriod ) const;
Expand Down
1 change: 0 additions & 1 deletion cvs/objects/resources/include/unlimited_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
* - Attributes: name UnlimitedResource::mName
* - Elements:
* - \c market UnlimitedResource::mMarket
* - \c capacity-factor UnlimitedResource::mCapacityFactor
* - \c variance UnlimitedResource::mVariance
* - \c price UnlimitedResource::mFixedPrices
* - Attributes: year Year
Expand Down
16 changes: 1 addition & 15 deletions cvs/objects/resources/source/renewable_subresource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ SubRenewableResource::SubRenewableResource(){
mMaxSubResource = 0;
mGdpSupplyElasticity = 0;
mSubResourceVariance = 0;
mSubResourceCapacityFactor = 1;
}

//! Performs XML read-in that is specific to this derived class
Expand All @@ -77,10 +76,6 @@ bool SubRenewableResource::XMLDerivedClassParse( const string& nodeName, const D
mSubResourceVariance = XMLHelper<double>::getValue( node );
didParse = true;
}
else if( nodeName == "subResourceCapacityFactor" ){
mSubResourceCapacityFactor = XMLHelper<double>::getValue( node );
didParse = true;
}
else if( nodeName == "gdpSupplyElast" ){
mGdpSupplyElasticity = XMLHelper<double>::getValue( node );
didParse = true;
Expand Down Expand Up @@ -119,9 +114,8 @@ void SubRenewableResource::completeInit( const IInfo* aSectorInfo ) {
//! Write out to XML variables specific to this derived class
void SubRenewableResource::toXMLforDerivedClass( ostream& out, Tabs* tabs ) const {
XMLWriteElementCheckDefault( mMaxSubResource, "maxSubResource", out, tabs, 0.0 );
XMLWriteElementCheckDefault( mGdpSupplyElasticity, "gdpSupplyElast", out, tabs, 0.0 );
XMLWriteElementCheckDefault( mGdpSupplyElasticity, "gdpSupplyElast", out, tabs, 0.0 );
XMLWriteElementCheckDefault( mSubResourceVariance, "subResourceVariance", out, tabs, 0.0 );
XMLWriteElementCheckDefault( mSubResourceCapacityFactor, "subResourceCapacityFactor", out, tabs, 1.0 );
}

//! Cumulative Production
Expand Down Expand Up @@ -198,14 +192,6 @@ double SubRenewableResource::getVariance() const {
return mSubResourceVariance;
}

/*! \brief Get the average capacity factor.
* \details Return the capacity factor for this subresource.
* \return The average capacity factor.
*/
double SubRenewableResource::getAverageCapacityFactor() const {
return mSubResourceCapacityFactor;
}

double SubRenewableResource::getMaxSubResource() const {
return mMaxSubResource;
}
Expand Down
10 changes: 0 additions & 10 deletions cvs/objects/resources/source/unlimited_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ void UnlimitedResource::XMLParse( const DOMNode* node ){
XMLHelper<Value>::insertValueIntoVector( curr, mFixedPrices,
scenario->getModeltime() );
}
else if( nodeName == "capacity-factor" ){
mCapacityFactor = XMLHelper<double>::getValue( curr );
}
else if( nodeName == "variance" ){
mVariance = XMLHelper<double>::getValue( curr );
}
Expand All @@ -141,9 +138,6 @@ void UnlimitedResource::toInputXML( ostream& aOut, Tabs* aTabs ) const {
XMLWriteElement( mMarket, "market", aOut, aTabs );

const Value VALUE_DEFAULT( 0.0 );
XMLWriteElementCheckDefault( mCapacityFactor, "capacity-factor", aOut,
aTabs, VALUE_DEFAULT );

XMLWriteElementCheckDefault( mVariance, "variance", aOut,
aTabs, VALUE_DEFAULT );

Expand All @@ -165,7 +159,6 @@ void UnlimitedResource::toDebugXML( const int aPeriod,
XMLWriteElement( mOutputUnit, "output-unit", aOut, aTabs );
XMLWriteElement( mPriceUnit, "price-unit", aOut, aTabs );
XMLWriteElement( mMarket, "market", aOut, aTabs );
XMLWriteElement( mCapacityFactor, "capacity-factor", aOut, aTabs );
XMLWriteElement( mVariance, "variance", aOut, aTabs );

// Write out resource prices for debugging period.
Expand Down Expand Up @@ -207,9 +200,6 @@ void UnlimitedResource::initCalc( const string& aRegionName,
IInfo* marketInfo = marketplace->getMarketInfo( mName, aRegionName, aPeriod, true );
assert( marketInfo );

if( mCapacityFactor.isInited() ){
marketInfo->setDouble( "resourceCapacityFactor", mCapacityFactor );
}
if( mVariance.isInited() ){
marketInfo->setDouble( "resourceVariance", mVariance );
}
Expand Down
1 change: 1 addition & 0 deletions cvs/objects/sectors/include/CSP_backup_calculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class CSPBackupCalculator: public IBackupCalculator {
const std::string& aElectricSector,
const std::string& aResource,
const std::string& aRegion,
const double aTechCapacityFactor,
const double aReserveMargin,
const double aAverageGridCapacityFactor,
const int aPeriod ) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class CapacityLimitBackupCalculator: public IBackupCalculator {
const std::string& aElectricSector,
const std::string& aResource,
const std::string& aRegion,
const double aTechCapacityFactor,
const double aReserveMargin,
const double aAverageGridCapacityFactor,
const int aPeriod ) const;
Expand Down
4 changes: 0 additions & 4 deletions cvs/objects/sectors/include/sector_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ class SectorUtils {

static int getDemandNormPeriod( const int aPeriod );

static double getCapacityFactor( const std::string& aResourceName,
const std::string& aRegionName,
const int aPeriod );

static double convertEnergyToCapacity( const double aCapacityFactor,
const double aEnergy );

Expand Down
3 changes: 2 additions & 1 deletion cvs/objects/sectors/source/CSP_backup_calculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ double CSPBackupCalculator::getAverageBackupCapacity( const string& aSector,
// Determine the intermittent share of output.
// Note that this method in CSP differs as it is based on energy share not capacity
double elecShare = calcIntermittentShare( aSector, aElectricSector, aResource,
aRegion, aReserveMargin, aAverageGridCapacityFactor,
aRegion, aTechCapacityFactor, aReserveMargin, aAverageGridCapacityFactor,
aPeriod );

// No backup required for zero share.
Expand Down Expand Up @@ -251,6 +251,7 @@ double CSPBackupCalculator::calcIntermittentShare( const string& aSector,
const string& aElectricSector,
const string& aResource,
const string& aRegion,
const double aTechCapacityFactor,
const double aReserveMargin,
const double aAverageGridCapacityFactor,
const int aPeriod ) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ double CapacityLimitBackupCalculator::calcIntermittentShare( const string& aSect
const string& aElectricSector,
const string& aResource,
const string& aRegion,
const double aTechCapacityFactor,
const double aReserveMargin,
const double aAverageGridCapacityFactor,
const int aPeriod ) const
{

double capacityShare = std::min( std::max( SectorUtils::getTrialSupply( aRegion, aSector, aPeriod ), 0.0 ), 1.0 ) *
aAverageGridCapacityFactor /
SectorUtils::getCapacityFactor( aResource, aRegion, aPeriod );
double capacityShare = std::min( std::max( SectorUtils::getTrialSupply( aRegion, aSector, aPeriod ), 0.0 ), 1.0 ) *
aAverageGridCapacityFactor / aTechCapacityFactor;
return capacityShare;
}
28 changes: 0 additions & 28 deletions cvs/objects/sectors/source/sector_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,34 +362,6 @@ double SectorUtils::getVariance( const string& aResourceName,
return variance;
}

/*!
* \brief Get the capacity factor of the resource.
* \details Queries the market-info of the good for the capacity factor.
* Returns zero if the market does not exist or does not have a
* capacity factor set.
* \param aResource Resource for which to get the capacity factor.
* \param aRegion Region for which to get the capacity factor.
* \param aPeriod Model period.
* \return The resource capacity factor.
*/
double SectorUtils::getCapacityFactor( const string& aResourceName,
const string& aRegionName,
const int aPeriod )
{
// Get resource capacity factor from market info for the sector.
const Marketplace* marketplace = scenario->getMarketplace();
const IInfo* resourceInfo =
marketplace->getMarketInfo( aResourceName, aRegionName, aPeriod, true );

double resourceCapacityFactor = resourceInfo ?
resourceInfo->getDouble( "resourceCapacityFactor", true ) :
util::getLargeNumber();

// Resource capacity factor must be between 0 and 1 inclusive.
assert( resourceCapacityFactor >= 0 && resourceCapacityFactor <= 1 );
return resourceCapacityFactor;
}

/*!
* \brief Converts energy to capacity using a given capacity factor.
* \param aCapacityFactor Capacity factor to use in the conversion.
Expand Down
3 changes: 3 additions & 0 deletions cvs/objects/technologies/include/technology.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ class Technology: public ITechnology
const int aPeriod ) const;

double getShareWeight() const;

double getCapacityFactor() const;

virtual Value getParsedShareWeight() const;

virtual int getNumbGHGs() const;
Expand Down
21 changes: 21 additions & 0 deletions cvs/objects/technologies/source/technology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ void Technology::completeInit( const string& aRegionName,
mPMultiplier = 1;
}

// Capacity factor must be valid
if( (mCapacityFactor <= 0) && (mCapacityFactor > 1) ){
ILogger& mainLog = ILogger::getLogger( "main_log" );
mainLog.setLevel( ILogger::ERROR );
mainLog << "Capacity factor is not within valid range (0 < CF <= 1). CF = " << mCapacityFactor
<< " region: " << aRegionName << " sector: " << aSectorName << " technology: " << mName << endl;
}

// Create the primary output for this technology. All technologies will have
// a primary output. Always insert the primary output at position 0.
mOutputs.insert( mOutputs.begin(), new PrimaryOutput( aSectorName ) );
Expand Down Expand Up @@ -1082,6 +1090,19 @@ double Technology::getShareWeight() const
return mShareWeight;
}

/*! \brief returns the capacity factor for this Technology
*
* \author Sonny Kim
* \return capacity factor
*/
double Technology::getCapacityFactor() const
{
/*! \post Capacity factor is a valid number and 0 < CF <= 1. */
assert( util::isValidNumber( mCapacityFactor ) && ( (mCapacityFactor > 0) && (mCapacityFactor <= 0) ) );

return mCapacityFactor;
}

/*!
* \brief Gets the share weight value which was parsed by the user.
* \return Parsed share weight value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#Resources
names_DepRsrc <- c( "region", "depresource", "output.unit", "price.unit", "market" )
names_RenewRsrc <- c( "region", "renewresource", "output.unit", "price.unit", "market" )
names_UnlimitRsrc <- c( "region", "unlimited.resource", "output.unit", "price.unit", "market", "capacity.factor" )
names_UnlimitRsrc <- c( "region", "unlimited.resource", "output.unit", "price.unit", "market" )
names_DepRsrcPrice <- c( "region", "depresource", "year", "price" )
names_RenewRsrcPrice <- c( "region", "renewresource", "year", "price" )
names_UnlimitRsrcPrice <- c( "region", "unlimited.resource", "year", "price" )
Expand Down Expand Up @@ -56,8 +56,8 @@ names_TechCost <- c( names_TechYr, "minicam.non.energy.input", "input.cost" )
names_CarbonCapture <- c( names_TechYr, "storage.market", "remove.fraction" )
names_ImportTech <- c( names_TechYr ) #indicates a renewable input; nothing is specified in the table however
names_FixedOutput <- c( names_TechYr, "fixedOutput" )
names_TechCapital <- c( names_TechYr, "input.capital", "capital.overnight", "fixed.charge.rate", "capacity.factor" )
names_TechOMfixed <- c( names_TechYr, "input.OM.fixed", "OM.fixed", "capacity.factor" )
names_TechCapital <- c( names_TechYr, "input.capital", "capital.overnight", "fixed.charge.rate" )
names_TechOMfixed <- c( names_TechYr, "input.OM.fixed", "OM.fixed" )
names_TechOMvar <- c( names_TechYr, "input.OM.var", "OM.var" )
names_TechSCurve <- c( names_TechYr, "lifetime", "steepness", "half.life" )

Expand Down
3 changes: 0 additions & 3 deletions input/gcam-data-system/_common/headers/ENERGY_header.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ convert_rsrc_to_L2 <- function( data, resource_type, subresource_type=NA ) {
if( any( names( data ) == "gdpSupplyElast" ) ) {
data_new$gdpSupplyElast = round( data$gdpSupplyElast, digits_gdpSupplyElast )
}
if( any( names( data ) == "subResourceCapacityFactor" ) ) {
data_new$subResourceCapacityFactor = round( data$subResourceCapacityFactor, digits_capacity.factor )
}
}
if( resource_type == "renewresource" & subresource_type == "sub-renewable-resource") {
data_new <- data.frame(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# GCAM 3.0 rooftop PV supply curves,,,,,,,
region_GCAM3,resource,subresource,maxSubResource,mid-price,curve-exponent,gdpSupplyElast,subResourceCapacityFactor
USA,distributed_solar,distributed_solar,4.718453352,13.40917456,4.240486051,0.1,0.2
Canada,distributed_solar,distributed_solar,0.374144475,16.52819307,4.240486051,0.1,0.2
Western Europe,distributed_solar,distributed_solar,5.302743618,16.06949292,4.240486051,0.1,0.2
Japan,distributed_solar,distributed_solar,1.126882043,14.43122184,4.240486051,0.1,0.2
Australia_NZ,distributed_solar,distributed_solar,0.3841428,11.52252602,4.240486051,0.1,0.2
Former Soviet Union,distributed_solar,distributed_solar,2.889066662,16.75512477,4.240486051,0.1,0.2
China,distributed_solar,distributed_solar,16.06862022,13.62132187,4.240486051,0.1,0.2
Middle East,distributed_solar,distributed_solar,1.912899244,10.11638903,4.240486051,0.1,0.2
Africa,distributed_solar,distributed_solar,9.101716856,10.02533587,4.240486051,0.1,0.2
Latin America,distributed_solar,distributed_solar,5.862118428,10.99167946,4.240486051,0.1,0.2
Southeast Asia,distributed_solar,distributed_solar,7.952781714,11.01447492,4.240486051,0.1,0.2
Eastern Europe,distributed_solar,distributed_solar,1.616168252,16.58376593,4.240486051,0.1,0.2
Korea,distributed_solar,distributed_solar,0.570043404,13.47928694,4.240486051,0.1,0.2
India,distributed_solar,distributed_solar,10.49707023,11.16173708,4.240486051,0.1,0.2
# GCAM 3.0 rooftop PV supply curves,,,,,,
region_GCAM3,resource,subresource,maxSubResource,mid-price,curve-exponent,gdpSupplyElast
USA,distributed_solar,distributed_solar,4.718453352,13.40917456,4.240486051,0.1
Canada,distributed_solar,distributed_solar,0.374144475,16.52819307,4.240486051,0.1
Western Europe,distributed_solar,distributed_solar,5.302743618,16.06949292,4.240486051,0.1
Japan,distributed_solar,distributed_solar,1.126882043,14.43122184,4.240486051,0.1
Australia_NZ,distributed_solar,distributed_solar,0.3841428,11.52252602,4.240486051,0.1
Former Soviet Union,distributed_solar,distributed_solar,2.889066662,16.75512477,4.240486051,0.1
China,distributed_solar,distributed_solar,16.06862022,13.62132187,4.240486051,0.1
Middle East,distributed_solar,distributed_solar,1.912899244,10.11638903,4.240486051,0.1
Africa,distributed_solar,distributed_solar,9.101716856,10.02533587,4.240486051,0.1
Latin America,distributed_solar,distributed_solar,5.862118428,10.99167946,4.240486051,0.1
Southeast Asia,distributed_solar,distributed_solar,7.952781714,11.01447492,4.240486051,0.1
Eastern Europe,distributed_solar,distributed_solar,1.616168252,16.58376593,4.240486051,0.1
Korea,distributed_solar,distributed_solar,0.570043404,13.47928694,4.240486051,0.1
India,distributed_solar,distributed_solar,10.49707023,11.16173708,4.240486051,0.1
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ L115.RsrcCurves_EJ_R_roofPV$maxSubResource <- L115.roofPV_maxSubResource_R$maxSu
L115.RsrcCurves_EJ_R_roofPV$mid.price <- L115.roofPV_midprice_R$mid.price[ match( L115.RsrcCurves_EJ_R_roofPV[[R]], L115.roofPV_midprice_R[[R]] ) ]
L115.RsrcCurves_EJ_R_roofPV$curve.exponent <- A15.roofPV_curves$curve.exponent[1] #assuming that all regions have the same curve exponent
L115.RsrcCurves_EJ_R_roofPV$gdpSupplyElast <- A15.roofPV_curves$gdpSupplyElast[1] #assuming that all regions have the same GDP supply elasticity
L115.RsrcCurves_EJ_R_roofPV$subResourceCapacityFactor <- A15.roofPV_curves$subResourceCapacityFactor[1] #assuming that all regions have the same capacity factor

# 2b. Prices (assumed, no processing necessary)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ L119.CapFacScaler_CSP_state <- data.frame(
sector = "electricity generation",
fuel = "solar CSP",
scaler = NREL_us_re_capacity_factors$CSP_scaler[ match( states, NREL_us_re_capacity_factors$state ) ] )
# Null CSP capacity factor implies that CSP is not suitable in the state.
# Set capacity factor to small number (0.001) to prevent divide by 0 error in GCAM.
L119.CapFacScaler_CSP_state$scaler <- ifelse( L119.CapFacScaler_CSP_state$scaler > 0, L119.CapFacScaler_CSP_state$scaler, 0.001 )

# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# 3. Output
#Add comments for each table
comments.L119.CapFacScaler_PV_state <- c( "Solar PV capacity factor adjustment by state","Unitless" )
Expand Down
Loading

0 comments on commit 24e2007

Please sign in to comment.