JGCRI / gcam-core

GCAM -- The Global Change Analysis Model
http://jgcri.github.io/gcam-doc/
Other
275 stars 162 forks source link

Error Processing `cumulative-target-gas` in GCAM #229

Open ecwood opened 2 years ago

ecwood commented 2 years ago

When I use this policy file:

<?xml version="1.0" encoding="UTF-8"?>
<policy-target-runner name="emissions_limit">
    <!-- tax-name | default: CO2 | The market name to change the price on --> 
    <tax-name>CO2_LTG</tax-name> 
    <!-- target-value | no default | The target value such as concentration 
         or forcing.
     -->
    <target-value>400</target-value>
    <!-- target-tolerance | default: 0.01 | The solution tolerance -->
    <target-tolerance>5</target-tolerance> 
    <!-- path-discount-rate | default: 0.05 | The hotelling rate -->
    <path-discount-rate>0.03</path-discount-rate>
    <!-- max-iterations | default: 100 | The maximum  number of attempts to
         solve any given period.
     -->
    <max-iterations>100</max-iterations>
    <!-- target-type | default: concentration | The climate parameter which
         we are targeting.  The available ones are:
            concentration | CO2 (or possibly other gasses via the configuration
                            string: concentration-target-gas)
            forcing | Total radiative forcing
            stabilization | Stabilize CO2 (or possibly other gasses via the
                           configuration string: concentration-target-gas)
                           with disregards to what that concentration might be
            kyoto-forcing | Radiative forcing from Kyoto GHGs only
            rcp-forcing | Radiative forcing using the RCP definition (MAGICC only)
            temperature | Global mean temperature
            cumulative-emissions | Reach a cumulative emission goal for CO2
                                   emissions (or possibly other gasses via the
                                   configuration string: cumulative-target-gas)
     -->
    <target-type>cumulative-emissions</target-type>
    <cumulative-target-gas>CO2</cumulative-target-gas>
    <!-- first-tax-year | default: 2020 | The first year to start a tax in -->
    <first-tax-year>2025</first-tax-year>
    <!-- initial-tax-guess | default: 5 | The first tax value to try, if a user
                                          can provide a good initial guess it may
                                          cut down on the total number of iterations
                                          significantly.
     -->
    <initial-tax-guess>5.0</initial-tax-guess>
    <!-- forward-look | default: 0 | Allow forward looking behavior by skipping
         this many periods.
     -->
    <forward-look>1</forward-look>
    <!-- stabilization | This is the default behavior is to stabilize the target
         overshoot year="2100" | Allow for an overshoot to hit in the target in
                                 given year.  If the year is not provided the 
                                 last model year will be assumed.  If it is 
                                 provided and before the last model year then 
                                 it will have to stay on target after that year.
     --> 
    <stabilization />
    <!-- max-tax | default: 4999 | Set a maximum tax to try in any given period
                                   to avoid extremely large taxes for which GCAM
                                   may have trouble solving.  Note that it may
                                   be possible the algorithm finds a solution
                                   with tax values capped at max-target for some
                                   years in which case the user should increase
                                   the max-tax.  If the actual solution price
                                   lies above max-tax the algorithm will fail.
     -->
    <max-tax>7999</max-tax>
</policy-target-runner>

I get the following errors when I run the scenario:

Parsing ../input/policy/2025_target_finder.xml scenario component.
XML parsing complete.
Starting new scenario: GCAM-USA_Reference
Thu Jul 28 19:53:52 2022:WARNING:printLogHeader: hector version 2.5.0
Thu Jul 28 19:53:52 2022:WARNING:setData: Disabling onelineocean
Thu Jul 28 19:53:52 2022:WARNING:printLogHeader: hector version 2.5.0
Thu Jul 28 19:53:52 2022:WARNING:setData: Disabling onelineocean
Thu Jul 28 19:53:52 2022:WARNING:prepareToRun: Disabling onelineocean
Reading advanced target finder configuration file ../input/policy/emissions_limit.xml
Unknown tag: cumulative-target-gas encountered while processing policy-target-runner
Could not find String: cumulative-target-gas
Policy Target Runner:  scenario dispatch #0

I believe the Unknown tag error comes from this code section: https://github.com/JGCRI/gcam-core/blob/f8138153e52b5e875b1775406d2de70868587149/cvs/objects/target_finder/source/policy_target_runner.cpp#L114-L174

Then, when getString is called in this code snippet https://github.com/JGCRI/gcam-core/blob/8d00382cde133119b0beca9716e8494506a8fc9c/cvs/objects/target_finder/source/cumulative_emissions_target.cpp#L61-L70 it encounters an error with this code: https://github.com/JGCRI/gcam-core/blob/f8138153e52b5e875b1775406d2de70868587149/cvs/objects/util/base/source/configuration.cpp#L284-L297

Is this expected behavior? Is there a way to avoid these errors?

pkyle commented 2 years ago

I haven't run this kind of policy before but the string cumulative-target-gas doesn't go in the policy file; I think it's supposed to be a string in the configuration. So, I'd recommend removing that line from the emissions_limit.xml file, and insert the following into the "Strings" section of the configuration:

        <Value name="cumulative-target-gas">CO2</Value>