Skip to content

Commit

Permalink
Merge pull request #57 in JGCRI/gcam-core from feature/negative-emiss…
Browse files Browse the repository at this point in the history
…ions to master

* commit '2550b19c2120f09957ed4ad6b4933d68b36d7ac3': (22 commits)
  Address PR comments which are tweaks to make the code more readable.
  Update Visual Studio project for CTaxInput and NegativeEmissionsFinalDemand
  Update Xcode project for CTaxInput and NegativeEmissionsFinalDemand
  Reduce the forcing target tolerance as in practice it leads to 2-3 extra model runs for very little gain.
  Bump max tax in forcing targets as (at least for the 2.6) we could actually need to surpass the current value.
  Add negative emissions budget constraint to L270.limits proceesing file.
  Revert code we ended up not using
  Fixes to MarketDependencyFinder to ensure all dependencies for "global" activities are made and not just in single region ones.  This only affects unsolved "global" activities which currently only consists of unlimited resources and soon negative emissions final demands.
  Tweaks to help keep solution stable when prices go off the rails
  Changes to help the negative net emissions contraints solve better
  Adjust solver config and remove obsolete config file.
  Expand the range of price in unconventional oil supply curves.
  Fix line endings on all csv files in energy-data/assumptions.
  Adjust input_tax for negative emissions constraints
  Switch logit to absolute for LDV_4W
  Add constraints on oil in industrial feedstocks.
  Use the constraint value for solved TAX markets as the forcast demand which hopefully helps solve when policies switch from mostly non-binding to binding.
  Code for first cut at limiting negative emissions with budget constraints by food expenditures or total negative emissions.
  Add RES policy to limit non-oil use for oil electricity
  Switch transportation to absolute cost logit
  ...
  • Loading branch information
kvcalvin committed Oct 31, 2017
2 parents 58c56b5 + 2550b19 commit 4d57644
Show file tree
Hide file tree
Showing 204 changed files with 4,942 additions and 848 deletions.
1 change: 0 additions & 1 deletion cvs/objects/build/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,4 @@ clean :
-$(MAKE) -C ../../ccarbon_model/source clean
-$(MAKE) -C ../../policy/source clean
-$(MAKE) -C ../../parallel/source clean
-$(MAKE) -C ../../testing/source clean
-$(MAKE) -C ../../main/source clean
4 changes: 4 additions & 0 deletions cvs/objects/build/vc10/objects.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@
<ClCompile Include="..\..\functions\source\building_node_input.cpp" />
<ClCompile Include="..\..\functions\source\building_service_function.cpp" />
<ClCompile Include="..\..\functions\source\building_service_input.cpp" />
<ClCompile Include="..\..\functions\source\ctax_input.cpp" />
<ClCompile Include="..\..\functions\source\discrete_choice_factory.cpp" />
<ClCompile Include="..\..\functions\source\relative_cost_logit.cpp" />
<ClCompile Include="..\..\functions\source\satiation_demand_function.cpp" />
Expand Down Expand Up @@ -634,6 +635,7 @@
<ClCompile Include="..\..\sectors\source\factor_supply.cpp" />
<ClCompile Include="..\..\sectors\source\final_demand_sector.cpp" />
<ClCompile Include="..\..\sectors\source\more_sector_info.cpp" />
<ClCompile Include="..\..\sectors\source\negative_emissions_final_demand.cpp" />
<ClCompile Include="..\..\sectors\source\pass_through_sector.cpp" />
<ClCompile Include="..\..\sectors\source\production_sector.cpp" />
<ClCompile Include="..\..\sectors\source\sector.cpp" />
Expand Down Expand Up @@ -910,6 +912,7 @@
<ClInclude Include="..\..\functions\include\building_node_input.h" />
<ClInclude Include="..\..\functions\include\building_service_function.h" />
<ClInclude Include="..\..\functions\include\building_service_input.h" />
<ClInclude Include="..\..\functions\include\ctax_input.h" />
<ClInclude Include="..\..\functions\include\discrete_choice_factory.hpp" />
<ClInclude Include="..\..\functions\include\idiscrete_choice.hpp" />
<ClInclude Include="..\..\functions\include\relative_cost_logit.hpp" />
Expand Down Expand Up @@ -965,6 +968,7 @@
<ClInclude Include="..\..\sectors\include\final_demand_sector.h" />
<ClInclude Include="..\..\sectors\include\ibackup_calculator.h" />
<ClInclude Include="..\..\sectors\include\more_sector_info.h" />
<ClInclude Include="..\..\sectors\include\negative_emissions_final_demand.h" />
<ClInclude Include="..\..\sectors\include\pass_through_sector.h" />
<ClInclude Include="..\..\sectors\include\production_sector.h" />
<ClInclude Include="..\..\sectors\include\sector.h" />
Expand Down
12 changes: 12 additions & 0 deletions cvs/objects/build/vc10/objects.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,12 @@
<ClCompile Include="..\..\util\base\source\manage_state_variables.cpp">
<Filter>Source Files\util\base</Filter>
</ClCompile>
<ClCompile Include="..\..\functions\source\ctax_input.cpp">
<Filter>Source Files\functions</Filter>
</ClCompile>
<ClCompile Include="..\..\sectors\source\negative_emissions_final_demand.cpp">
<Filter>Source Files\sectors</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\containers\include\batch_runner.h">
Expand Down Expand Up @@ -2233,5 +2239,11 @@
<ClInclude Include="..\..\util\base\include\manage_state_variables.hpp">
<Filter>Header Files\util\base</Filter>
</ClInclude>
<ClInclude Include="..\..\functions\include\ctax_input.h">
<Filter>Header Files\functions</Filter>
</ClInclude>
<ClInclude Include="..\..\sectors\include\negative_emissions_final_demand.h">
<Filter>Header Files\sectors</Filter>
</ClInclude>
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions cvs/objects/build/xcode3/objects.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@
CD6B455519B1388F0020AC72 /* has_market_flag_solution_info_filter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD6B455419B1388F0020AC72 /* has_market_flag_solution_info_filter.cpp */; };
CD83E61614F4584900A1D301 /* linked_market.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD83E61514F4584900A1D301 /* linked_market.cpp */; };
CD83E63A14F54B1000A1D301 /* linked_ghg_policy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD83E63914F54B1000A1D301 /* linked_ghg_policy.cpp */; };
CD8DFFD91FA8D1F000CB3719 /* ctax_input.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD8DFFD81FA8D1F000CB3719 /* ctax_input.cpp */; };
CD8DFFDC1FA8D21700CB3719 /* negative_emissions_final_demand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD8DFFDB1FA8D21700CB3719 /* negative_emissions_final_demand.cpp */; };
CD8FDEC91C0647140099C752 /* pass_through_sector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD8FDEC81C0647140099C752 /* pass_through_sector.cpp */; };
CD8FDECC1C0647A20099C752 /* pass_through_technology.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD8FDECB1C0647A20099C752 /* pass_through_technology.cpp */; };
CD966E751D92F1CD00A93938 /* libhector-lib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CD966E721D92F1BB00A93938 /* libhector-lib.a */; };
Expand Down Expand Up @@ -1012,6 +1014,10 @@
CD83E61514F4584900A1D301 /* linked_market.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = linked_market.cpp; sourceTree = "<group>"; };
CD83E63814F548E000A1D301 /* linked_ghg_policy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = linked_ghg_policy.h; sourceTree = "<group>"; };
CD83E63914F54B1000A1D301 /* linked_ghg_policy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = linked_ghg_policy.cpp; sourceTree = "<group>"; };
CD8DFFD51FA8D1D900CB3719 /* ctax_input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ctax_input.h; sourceTree = "<group>"; };
CD8DFFD81FA8D1F000CB3719 /* ctax_input.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ctax_input.cpp; sourceTree = "<group>"; };
CD8DFFDA1FA8D20600CB3719 /* negative_emissions_final_demand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = negative_emissions_final_demand.h; sourceTree = "<group>"; };
CD8DFFDB1FA8D21700CB3719 /* negative_emissions_final_demand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = negative_emissions_final_demand.cpp; sourceTree = "<group>"; };
CD8FDEC71C0647050099C752 /* pass_through_sector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pass_through_sector.h; sourceTree = "<group>"; };
CD8FDEC81C0647140099C752 /* pass_through_sector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pass_through_sector.cpp; sourceTree = "<group>"; };
CD8FDECA1C0647640099C752 /* pass_through_technology.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pass_through_technology.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1500,6 +1506,7 @@
CD4884CE122873C100F5A88A /* include */ = {
isa = PBXGroup;
children = (
CD8DFFD51FA8D1D900CB3719 /* ctax_input.h */,
CD693FA41AF02DC200805384 /* discrete_choice_factory.hpp */,
CD693FA11AEFF09200805384 /* absolute_cost_logit.hpp */,
CD693F9E1AEFE09200805384 /* relative_cost_logit.hpp */,
Expand Down Expand Up @@ -1553,6 +1560,7 @@
CD4884F4122873C100F5A88A /* source */ = {
isa = PBXGroup;
children = (
CD8DFFD81FA8D1F000CB3719 /* ctax_input.cpp */,
CD693FA51AF0315E00805384 /* discrete_choice_factory.cpp */,
CD693FA21AEFF0A100805384 /* absolute_cost_logit.cpp */,
CD693F9F1AEFE0CE00805384 /* relative_cost_logit.cpp */,
Expand Down Expand Up @@ -1892,6 +1900,7 @@
CD4885E4122873C200F5A88A /* include */ = {
isa = PBXGroup;
children = (
CD8DFFDA1FA8D20600CB3719 /* negative_emissions_final_demand.h */,
CD8FDEC71C0647050099C752 /* pass_through_sector.h */,
CD4885E5122873C200F5A88A /* afinal_demand.h */,
CD4885E6122873C200F5A88A /* ag_supply_sector.h */,
Expand Down Expand Up @@ -1920,6 +1929,7 @@
CD488600122873C200F5A88A /* source */ = {
isa = PBXGroup;
children = (
CD8DFFDB1FA8D21700CB3719 /* negative_emissions_final_demand.cpp */,
CD8FDEC81C0647140099C752 /* pass_through_sector.cpp */,
CD488601122873C200F5A88A /* ag_supply_sector.cpp */,
CD488602122873C200F5A88A /* ag_supply_subsector.cpp */,
Expand Down Expand Up @@ -2602,6 +2612,7 @@
CD48875D122873C200F5A88A /* input_output_driver.cpp in Sources */,
CD48875E122873C200F5A88A /* output_driver.cpp in Sources */,
CD488762122873C200F5A88A /* ademand_function.cpp in Sources */,
CD8DFFDC1FA8D21700CB3719 /* negative_emissions_final_demand.cpp in Sources */,
CD488763122873C200F5A88A /* aproduction_function.cpp in Sources */,
CD488765122873C200F5A88A /* ces_production_function.cpp in Sources */,
CD488766122873C200F5A88A /* demand_input.cpp in Sources */,
Expand Down Expand Up @@ -2698,6 +2709,7 @@
CD4887C4122873C200F5A88A /* capacity_limit_backup_calculator.cpp in Sources */,
CD3B52C61BFE0E2800179FDD /* hector_model.cpp in Sources */,
CD4887C5122873C200F5A88A /* CSP_backup_calculator.cpp in Sources */,
CD8DFFD91FA8D1F000CB3719 /* ctax_input.cpp in Sources */,
CD4887C6122873C200F5A88A /* energy_final_demand.cpp in Sources */,
CD4887C7122873C200F5A88A /* export_sector.cpp in Sources */,
CD4887C8122873C200F5A88A /* factor_supply.cpp in Sources */,
Expand Down
30 changes: 28 additions & 2 deletions cvs/objects/containers/source/market_dependency_finder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ void MarketDependencyFinder::createOrdering() {
// been created so now we may create an ordering.

// First associate markets to their corresponding dependency items
map<int, DependencyItemSet> marketDepGrouping;
for( CItemIterator it = mDependencyItems.begin(); it != mDependencyItems.end(); ++it ) {
// locate the market by name
int marketNumber = mMarketplace->mMarketLocator->getMarketNumber( (*it)->mLocatedInRegion, (*it)->mName );
Expand Down Expand Up @@ -434,6 +435,29 @@ void MarketDependencyFinder::createOrdering() {
isSolved = mMarketplace->mMarkets[ marketNumber ]->getMarket( period )->isSolvable();
}
(*it)->mIsSolved = isSolved;
// we don't need to wory about grouping solved markets since they will just
// get disconnected anyways
if( !isSolved ) {
marketDepGrouping[ marketNumber ].insert( *it );
}
}
}

// Ajust dependencies for multi-region dependencies (such as global markets ) since a dependency
// on an activity in just one region should actually apply to all regions in the market. Note
// we have excluded solved markets from this list for simplicitly since they will just drop the
// dependencies anyways.
for( auto depGrouping : marketDepGrouping ) {
// skip groupings that are not multi-region
if( depGrouping.second.size() > 1 ) {
// add dependencies from any one of the regions to all of the others
for( auto currDep : depGrouping.second ) {
for( auto otherDep : depGrouping.second ) {
// note mDependentList is a set so we don't need to worry about
// duplicates which will happen a bunch but oh well..
currDep->mDependentList.insert( otherDep->mDependentList.begin(), otherDep->mDependentList.end() );
}
}
}
}

Expand Down Expand Up @@ -540,8 +564,10 @@ void MarketDependencyFinder::createOrdering() {
++numDependencies[ (*dependIt)->getFirstPriceVertex() ];
}
}
(*dependIt)->getLastDemandVertex()->mOutEdges.push_back( (*it)->getFirstDemandVertex() );
++numDependencies[ (*it)->getFirstDemandVertex() ];
if( !(*dependIt)->mDemandVertices.empty()) {
(*dependIt)->getLastDemandVertex()->mOutEdges.push_back( (*it)->getFirstDemandVertex() );
++numDependencies[ (*it)->getFirstDemandVertex() ];
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions cvs/objects/containers/source/region_minicam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#include "sectors/include/production_sector.h"
#include "sectors/include/ag_supply_sector.h"
#include "sectors/include/energy_final_demand.h"
#include "sectors/include/negative_emissions_final_demand.h"
#include "sectors/include/export_sector.h"
#include "sectors/include/pass_through_sector.h"

Expand Down Expand Up @@ -179,6 +180,9 @@ bool RegionMiniCAM::XMLDerivedClassParse( const std::string& nodeName, const xer
else if( nodeName == EnergyFinalDemand::getXMLNameStatic() ){
parseContainerNode( curr, mFinalDemands, new EnergyFinalDemand );
}
else if( nodeName == NegativeEmissionsFinalDemand::getXMLNameStatic() ){
parseContainerNode( curr, mFinalDemands, new NegativeEmissionsFinalDemand );
}
else if( nodeName == GCAMConsumer::getXMLNameStatic() ) {
parseContainerNode( curr, mConsumers, new GCAMConsumer );
}
Expand Down
168 changes: 168 additions & 0 deletions cvs/objects/functions/include/ctax_input.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#ifndef _CTAX_INPUT_H_
#define _CTAX_INPUT_H_
#if defined(_MSC_VER)
#pragma once
#endif

/*
* LEGAL NOTICE
* This computer software was prepared by Battelle Memorial Institute,
* hereinafter the Contractor, under Contract No. DE-AC05-76RL0 1830
* with the Department of Energy (DOE). NEITHER THE GOVERNMENT NOR THE
* 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
* United States Export Administration Act or any other applicable
* export laws, restrictions or regulations (collectively the "Export Laws").
* Export of the Software may require some form of license or other
* authority from the U.S. Government, and failure to obtain such
* export control license may result in criminal liability under
* U.S. laws. In addition, if the Software is identified as export controlled
* items under the Export Laws, User represents and warrants that User
* is not a citizen, or otherwise located within, an embargoed nation
* (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
* 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 ctax_input.h
* \ingroup Objects
* \brief CTaxInput class header file.
* \author Pralit Patel
*/

#include <string>
#include <xercesc/dom/DOMNode.hpp>
#include "functions/include/minicam_input.h"
#include <memory>

class Tabs;

/*!
* \ingroup Objects
* \brief Defines a tax input which is applied relative to a carbon price.
* \details This class only applies some price of a policy that is related
* to the carbon price. It does not add to the supply or demand of
* any constraint. The intended use would be from something such as
* a constraint on net negative emisssions.
*
* <b>XML specification for CTaxInput</b>
* - XML name: \c ctax-input
* - Contained by: Technology
* - Parsing inherited from class: MiniCAMInput
* - Attributes:
* - \c name MiniCAMInput::mName
* - Elements:
* - \c mFuelName String indicating the name of the fuel to look up the
* carbon coefficient of. Generally the same as the fuel
* name of the primary input to the containing technology.
*
* \author Pralit Patel
*/
class CTaxInput: public MiniCAMInput
{
friend class InputFactory;
public:

CTaxInput();

virtual ~CTaxInput();

virtual CTaxInput* clone() const;

static const std::string& getXMLNameStatic();

virtual const std::string& getXMLReportingName() const;

virtual void XMLParse( const xercesc::DOMNode* aNode );

virtual bool isSameType( const std::string& aType ) const;

virtual void toInputXML( std::ostream& aOut,
Tabs* aTabs ) const;

virtual void toDebugXML( const int aPeriod,
std::ostream& aOut,
Tabs* aTabs ) const;

virtual void copyParam( const IInput* aInput,
const int aPeriod );

virtual void completeInit( const std::string& aRegionName,
const std::string& aSectorName,
const std::string& aSubsectorName,
const std::string& aTechName,
const IInfo* aTechInfo );

virtual void initCalc( const std::string& aRegionName,
const std::string& aSectorName,
const bool aIsNewInvestmentPeriod,
const bool aIsTrade,
const IInfo* aTechInfo,
const int aPeriod );

virtual double getCO2EmissionsCoefficient( const std::string& aGHGName,
const int aPeriod ) const;

virtual double getPhysicalDemand( const int aPeriod ) const;

virtual double getCarbonContent( const int aPeriod ) const;

virtual double getPrice( const std::string& aRegionName,
const int aPeriod ) const;

virtual void setPrice( const std::string& aRegionName,
const double aPrice,
const int aPeriod );

virtual void setPhysicalDemand( const double aPhysicalDemand,
const std::string& aRegionName,
const int aPeriod );

virtual double getCoefficient( const int aPeriod ) const;

virtual void setCoefficient( const double aCoefficient,
const int aPeriod );

virtual double getCalibrationQuantity( const int aPeriod ) const;

virtual bool hasTypeFlag( const int aTypeFlag ) const;

virtual double getIncomeElasticity( const int aPeriod ) const;

virtual double getPriceElasticity( const int aPeriod ) const;

virtual double getTechChange( const int aPeriod ) const;

protected:
CTaxInput( const CTaxInput& aOther );

// Define data such that introspection utilities can process the data from this
// subclass together with the data members of the parent classes.
DEFINE_DATA_WITH_PARENT(
MiniCAMInput,

//! The name of the fuel to use to look up the C coef
//! typically the name of the primary input into the
//! containing technology
DEFINE_VARIABLE( SIMPLE, "fuel-name", mFuelName, std::string ),

//! The C coef associated with mFuelName
DEFINE_VARIABLE( SIMPLE, "fuel-C-coef", mCachedCCoef, double )
)
};

#endif // _CTAX_INPUT_H_
3 changes: 2 additions & 1 deletion cvs/objects/functions/include/iinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class InputTax;
class InputOMVar;
class InputOMFixed;
class InputCapital;
class CTaxInput;

/*!
* \ingroup Objects
Expand Down Expand Up @@ -513,7 +514,7 @@ class IInput: public INamed, public IVisitable, private boost::noncopyable {
*/
DEFINE_SUBCLASS_FAMILY( IInput, MiniCAMInput, EnergyInput, NonEnergyInput,
RenewableInput, InputSubsidy, InputTax, InputOMVar,
InputOMFixed, InputCapital )
InputOMFixed, InputCapital, CTaxInput )
)
};

Expand Down
Loading

0 comments on commit 4d57644

Please sign in to comment.