Skip to content

Commit

Permalink
Pull request #226: Get Non-CO2 Emissions in GCAM-USA
Browse files Browse the repository at this point in the history
Merge in JGCRI/gcam-core from maw/feature/gcam-usa-non-co2-byu to master

Squashed commit of the following:

commit e6d53a0fa9c44adbea1ab46823d71b5b3ff5a061
Merge: 1b6ca6e1b ea406d0
Author: Pralit Patel <[email protected]>
Date:   Fri Jun 3 13:23:36 2022 -0400

    Merge remote-tracking branch 'origin/master' into maw/feature/gcam-usa-non-co2-byu

commit 1b6ca6e1bbc9ec2f995729c5e24a14ea1c228327
Author: marideeweber <[email protected]>
Date:   Thu Jun 2 13:55:55 2022 -0700

    Modifying L271.nonghg_trn_USA.R to extend the linear control into all future periods. This removes a warning from the slurm-XXXXXXXX.out file.

commit 5326b2c3ab63ed26d480091ca8a4baa9ed06710b
Author: marideeweber <[email protected]>
Date:   Thu Jun 2 11:51:51 2022 -0700

    Making electric generation disable linear control section more robust

commit 80878ad3b4a72d05312b31fb1a9b51a3421c8fcc
Author: marideeweber <[email protected]>
Date:   Wed Jun 1 16:23:03 2022 -0700

    Adding a disable emissions control for future years for electric generation to overcome warnings in the .out file

commit e15125f84b0b3b26e953d53bcd636d7f58c6439a
Author: marideeweber <[email protected]>
Date:   Wed Jun 1 16:22:25 2022 -0700

    Deleting energy final demand at the USA level for urban processes to remove a SEVERE ERROR in the .out file

commit ef74655d0fee63a5eac5d22a8a474ffb6abc630b
Author: marideeweber <[email protected]>
Date:   Thu May 26 08:55:46 2022 -0700

    Addressing PR comments: changing gcamusa.DUST to function using TRUE or FALSE

commit 24f1097253d25544a3d62f366a73a3fb00526a2c
Author: marideeweber <[email protected]>
Date:   Thu May 26 08:55:26 2022 -0700

    Removing an unused input

commit d350f12ef0d14d36f74f991f8e3efa94aaf5d463
Author: marideeweber <[email protected]>
Date:   Sun May 22 22:02:20 2022 -0700

    Addressing PR comments: NEI_to_GCAM function

commit e62a79b9a3e3282c69d686acf8d05d8fb5337293
Author: marideeweber <[email protected]>
Date:   Sun May 22 22:01:57 2022 -0700

    Addressing PR comments: changing constants to the GCAM convention

commit 04ec02589adae1148a65f3050c25cd166aa273cd
Author: enlochner <[email protected]>
Date:   Fri May 6 15:04:25 2022 -0500

    Update prebuilt and data map

commit 0d4b53b44fc09d8c873ae18649c80124cfcc17ea
Author: marideeweber <[email protected]>
Date:   Wed May 4 12:17:57 2022 -0700

    Get testing framework up to date

commit 4150e99c9b7272d8215f551d9b3cb99dff1d0c4e
Author: marideeweber <[email protected]>
Date:   Tue May 3 14:20:07 2022 -0700

    Revert "This is for a test. Will be reverted."

    This reverts commit 06d0b4b2502fa3a997d891f231fb4cdc704b053b.

commit 06d0b4b2502fa3a997d891f231fb4cdc704b053b
Author: marideeweber <[email protected]>
Date:   Tue May 3 12:46:38 2022 -0700

    This is for a test. Will be reverted.

commit b89a13918c06a02885222d3e4e68f8f859f37605
Author: marideeweber <[email protected]>
Date:   Tue May 3 09:36:37 2022 -0700

    Remove an unused input

commit d37b7febc1d9c8f6e41ba21e4b9622b022756a7a
Author: marideeweber <[email protected]>
Date:   Mon May 2 20:21:15 2022 -0700

    Changing "industry" to "other industry" for consistency with global detailed industry

commit 527f57083e15f6575ced9fdebd8edd5a8430c48d
Author: marideeweber <[email protected]>
Date:   Mon May 2 17:12:17 2022 -0700

    Changing "industrial energy use" to "other industrial energy use" for consistency with global detailed industry

commit 68d0246a5855354f82cba920918dbf6d2ee198e0
Author: marideeweber <[email protected]>
Date:   Mon May 2 14:45:56 2022 -0700

    Changing "industrial energy use" to "other industrial energy use" for consistency with global detailed industry changes

commit c9d08f8c0f50748a1b26cd63079ddb583ce4957d
Author: marideeweber <[email protected]>
Date:   Mon May 2 11:52:00 2022 -0700

    Revising zchunk_L112.ceds_ghg_en_R_S_T_Y.R to reassign a table that was assigned to itself, complicating a chunk downstream.

commit e97d30109cbafb45e96adcb6ae334ecf8a5414e4
Author: marideeweber <[email protected]>
Date:   Sun May 1 22:30:20 2022 -0700

    Revert "Delete Main_queries.xml"

    This reverts commit 9f73aea15af365f23647105ca09dea62d3e0a119.

commit 9f73aea15af365f23647105ca09dea62d3e0a119
Author: marideeweber <[email protected]>
Date:   Sun May 1 22:26:57 2022 -0700

    Delete Main_queries.xml

... and 213 more commits
  • Loading branch information
pralitp committed Jun 3, 2022
1 parent ea406d0 commit 631cf61
Show file tree
Hide file tree
Showing 75 changed files with 263,372 additions and 64 deletions.
3 changes: 3 additions & 0 deletions cvs/objects/emissions/include/linear_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class LinearControl: public AEmissionsControl {
//! Final emissions coefficient
DEFINE_VARIABLE( SIMPLE, "final-emissions-coefficient", mFinalEmCoefficient, Value ),

//! Emissions redution percentage (alternative to specifying emissions coefficient)
DEFINE_VARIABLE( SIMPLE, "control-percentage", mControlFraction, Value ),

//! Flag if wish to allow emissions factor increase
DEFINE_VARIABLE( SIMPLE, "allow-ef-increase", mAllowIncrease, bool )
)
Expand Down
63 changes: 36 additions & 27 deletions cvs/objects/emissions/source/linear_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* CONTRACTOR MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY
* LIABILITY FOR THE USE OF THIS SOFTWARE. This notice including this
* sentence must appear on any copies of this computer software.
*
*
* EXPORT CONTROL
* User agrees that the Software will not be shipped, transferred or
* exported into any country or used in any manner prohibited by the
Expand All @@ -21,17 +21,17 @@
* (including without limitation Iran, Syria, Sudan, Cuba, and North Korea)
* and that User is not otherwise prohibited
* under the Export Laws from receiving the Software.
*
*
* Copyright 2011 Battelle Memorial Institute. All Rights Reserved.
* Distributed as open-source under the terms of the Educational Community
* Distributed as open-source under the terms of the Educational Community
* License version 2.0 (ECL 2.0). http://www.opensource.org/licenses/ecl2.php
*
*
* For further details, see: http://www.globalchange.umd.edu/models/gcam/
*
*/


/*!
/*!
* \file mac_control.cpp
* \ingroup Objects
* \brief LinearControl class source file.
Expand Down Expand Up @@ -94,6 +94,7 @@ void LinearControl::copy( const LinearControl& aOther ){
mTargetYear = aOther.mTargetYear;
mStartYear = aOther.mStartYear;
mFinalEmCoefficient = aOther.mFinalEmCoefficient;
mControlFraction = aOther.mControlFraction;
mAllowIncrease = aOther.mAllowIncrease;
}

Expand All @@ -117,6 +118,7 @@ const string& LinearControl::getXMLNameStatic(){
void LinearControl::toDebugXMLDerived( const int aPeriod, ostream& aOut, Tabs* aTabs ) const {
const Modeltime* modeltime = scenario->getModeltime();
XMLWriteElement( mFinalEmCoefficient, "final-emissions-coefficient", aOut, aTabs);
XMLWriteElement( mControlFraction, "control-percentage", aOut, aTabs);
XMLWriteElement( mTargetYear, "end-year", aOut, aTabs);
XMLWriteElementCheckDefault( mStartYear, "start-year", aOut, aTabs,
modeltime->getper_to_yr( modeltime->getFinalCalibrationPeriod() ) );
Expand All @@ -128,13 +130,13 @@ void LinearControl::completeInit( const string& aRegionName, const string& aSect
const IInfo* aTechInfo )
{

if ( ( mTargetYear == 0 ) || !mFinalEmCoefficient.isInited() && !mDisableEmControl ) {
if ( !mDisableEmControl && (( mTargetYear == 0 ) || (!mFinalEmCoefficient.isInited() && !mControlFraction.isInited()))) {
ILogger& mainLog = ILogger::getLogger( "main_log" );
mainLog.setLevel( ILogger::ERROR );
mainLog << "Linear control function " << getName() << " has not been parameterized. " << endl;
abort();
}

}

void LinearControl::initCalc( const string& aRegionName,
Expand All @@ -151,7 +153,7 @@ void LinearControl::initCalc( const string& aRegionName,
mainLog << "Linear control function improperly parameterized. Target year <= last calibration year." << endl;
abort();
}

// Make sure start year is not before final calibration year
if ( mStartYear < finalCalibYr && !mDisableEmControl ) {
ILogger& mainLog = ILogger::getLogger( "main_log" );
Expand All @@ -160,11 +162,11 @@ void LinearControl::initCalc( const string& aRegionName,
<< " before final calibration year, resetting to " << finalCalibYr << endl;
mStartYear = finalCalibYr;
}

// Make sure start year is not before the first model period for this object.
int thisModelYear = scenario->getModeltime()->getper_to_yr( aPeriod );
if ( aTechInfo->getBoolean( "new-vintage-tech", true ) && mStartYear < thisModelYear ) {

// But don't warn if the current object has been disabled via user input
if ( !mDisableEmControl ) {
ILogger& mainLog = ILogger::getLogger( "main_log" );
Expand All @@ -174,8 +176,8 @@ void LinearControl::initCalc( const string& aRegionName,
}
mStartYear = thisModelYear;
}
// Need to get the emissions coefficient from start period to serve as starting point

// Need to get the emissions coefficient from start period to serve as starting point
// for linear decline.
int startPeriod = scenario->getModeltime()->getyr_to_per( mStartYear );
if ( mDisableEmControl ) {
Expand All @@ -188,12 +190,12 @@ void LinearControl::initCalc( const string& aRegionName,
calcEmissionsReductionInternal( baseEmissionsCoef, aPeriod );
}
}
// Note, the emissions driver in NonCO2Emissions::calcEmission for input driver is
// defined as the sum of all physical inputs (e.g. getPhysicalDemandSum). This means
// that the emissions factor has an unusual definition for quantities with more than

// Note, the emissions driver in NonCO2Emissions::calcEmission for input driver is
// defined as the sum of all physical inputs (e.g. getPhysicalDemandSum). This means
// that the emissions factor has an unusual definition for quantities with more than
// one input. This function should be used with caution in these cases.
// Fortunately, these cases are currently rare. If multiple inputs become more common
// Fortunately, these cases are currently rare. If multiple inputs become more common
// changes, a means of specifying the appropriate input would need to be added.
// Electricity inputs, for example, should never be associated with non-CO2 emissions.
}
Expand All @@ -207,7 +209,7 @@ void LinearControl::calcEmissionsReduction( const std::string& aRegionName, cons

/*!
* \brief Calculate a linear reduction in the emissions factor and save it to mReduction.
* \details The reduction is calculated from the given aBaseEmissionsCoef and the
* \details The reduction is calculated from the given aBaseEmissionsCoef and the
* parsed parameters that define the start/end year and final value. We
* only allow the emissions factor to increase if the mAllowIncrease flag
* was explicitly set.
Expand All @@ -220,31 +222,38 @@ void LinearControl::calcEmissionsReductionInternal( const double aBaseEmissionsC
const int aPeriod )
{
double reduction = 0.0;

double thisYear = scenario->getModeltime()->getper_to_yr( aPeriod );

// Don't bother if no emissions or haven't passed starting point yet
if ( aBaseEmissionsCoef > 0 && thisYear > mStartYear && mFinalEmCoefficient.isInited() ) {

if ( aBaseEmissionsCoef > 0 && thisYear > mStartYear &&
( mFinalEmCoefficient.isInited() || mControlFraction.isInited() ) ) {

// Derivation of emission reduction formula below
// newEF = baseEF - (baseEF - targetEF) * ( year - baseYear ) / ( targetYear - baseYear )
// newEF = baseEF * ( 1 - reduction ) therefore reduction = 1 - newEF / baseEF
// reduction = ( 1 - targetEF / baseEF ) * ( year - baseYear ) / ( targetYear - baseYear )

// This is the final reduction
reduction = ( 1 - mFinalEmCoefficient / aBaseEmissionsCoef );

// Emissions coefficient takes precidence if control fraction is also inited
// Note, have already established that at least one of these is defined.
if ( mFinalEmCoefficient.isInited() ) {
reduction = ( 1 - mFinalEmCoefficient / aBaseEmissionsCoef );
} else {
reduction = mControlFraction;
}

// If not at final year yet, phase this in linearly
if ( thisYear < mTargetYear ) {
reduction *= static_cast<double>( thisYear - mStartYear ) /
static_cast<double>( mTargetYear - mStartYear );
}

// Ensure that reduction is not negative unless user specifically requires this
if ( reduction < 0.0 && !mAllowIncrease ) {
reduction = 0.0;
}
}

setEmissionsReduction( reduction );
}
28 changes: 27 additions & 1 deletion exe/configuration_usa.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Value write-output="0" append-scenario-name="0" name="landAllocatorGraphName">LandAllocatorGraph.dot</Value>
</Files>
<ScenarioComponents>
<Value name = "climate">../input/gcamdata/xml/no_climate_model.xml</Value>
<Value name = "climate">../input/gcamdata/xml/hector.xml</Value>
<Value name = "socioeconomics">../input/gcamdata/xml/socioeconomics_gSSP2.xml</Value>

<Value name = "resources">../input/gcamdata/xml/resources.xml</Value>
Expand Down Expand Up @@ -127,6 +127,32 @@
<!--GHG EMISSIONS USA-->
<Value name = "ghg_usa">../input/gcamdata/xml/ghg_emissions_USA.xml</Value>
<Value name = "ghg_usa">../input/gcamdata/xml/elecS_ghg_emissions_water_USA.xml</Value>
<Value name = "ghg_usa">../input/gcamdata/xml/trn_ghg_emissions_USA.xml</Value>

<!-- Global nonCO2 GHG files -->
<Value name = "ind_urb_proc">../input/gcamdata/xml/ind_urb_processing_sectors.xml</Value>
<Value name = "nonco2_energy">../input/gcamdata/xml/all_energy_emissions.xml</Value>
<Value name = "nonco2_fgas">../input/gcamdata/xml/all_fgas_emissions.xml</Value>
<Value name = "nonco2_unmgd">../input/gcamdata/xml/all_unmgd_emissions.xml</Value>
<Value name = "nonco2_aglu">../input/gcamdata/xml/all_aglu_emissions_IRR_MGMT.xml</Value>
<Value name = "nonco2_aglu_prot">../input/gcamdata/xml/all_protected_unmgd_emissions.xml</Value>

<!-- Global nonCO2 GHG MAC files -->
<Value name = "nonco2_energy">../input/gcamdata/xml/all_energy_emissions_MAC.xml</Value>
<Value name = "nonco2_fgas">../input/gcamdata/xml/all_fgas_emissions_MAC.xml</Value>
<Value name = "nonco2_aglu">../input/gcamdata/xml/all_aglu_emissions_IRR_MGMT_MAC.xml</Value>
<Value name = "nonco2_proc">../input/gcamdata/xml/ind_urb_processing_sectors_MAC.xml</Value>

<!-- USA nonGHG files -->
<Value name = "bld_emiss_USA">../input/gcamdata/xml/bld_emissions_USA.xml</Value>
<Value name = "othertrn_emiss_USA">../input/gcamdata/xml/othertrn_emissions_USA.xml</Value>
<Value name = "indenergy_emiss_USA">../input/gcamdata/xml/indenergy_emissions_USA.xml</Value>
<Value name = "elc_emiss_USA">../input/gcamdata/xml/elc_emissions_USA.xml</Value>
<Value name = "transport_emiss_USA">../input/gcamdata/xml/transport_emissions_USA.xml</Value>
<Value name = "prc_usa">../input/gcamdata/xml/ind_urb_processing_sectors_USA.xml</Value>
<Value name = "process_emiss_USA">../input/gcamdata/xml/ind_urb_proc_emissions_USA.xml</Value>
<Value name = "refining_emiss_USA">../input/gcamdata/xml/refinery_emissions_USA.xml</Value>

<Value name = "ghg_usa">../input/gcamdata/xml/trn_ghg_emissions_USA.xml</Value>

<Value name = "solver">../input/solution/cal_broyden_config.xml</Value>
Expand Down
Loading

0 comments on commit 631cf61

Please sign in to comment.