OSeMOSYS / osemosys_global

A global power system model generator for OSeMOSYS
https://osemosys-global.readthedocs.io/
GNU Affero General Public License v3.0
27 stars 17 forks source link

[BUG] crossborderTrade configuration parameter not working #114

Closed trevorb1 closed 2 years ago

trevorb1 commented 2 years ago

Conda environment check

Current Behavior

Running a BBIN scenario with the value crossborderTrade in the configuration file set to True will throw an error at the result processing stage. Specifically, during the otoole_results rule, a zero division error is triggered. The model will solve and produce a *.sol file.

Running the same scenario with crossborderTrade set to False executes correctly.

Expected Behavior

otoole will generate a results folder from the CBC *.sol file

Steps To Reproduce

  1. Activate the osemosys-global environment
  2. Import the configuration file (copied below)
  3. run the command snakemake -c

Operating System

Linux

Log output

[Fri Mar 11 16:19:22 2022]
Job 2: Generating result csv files...

ZeroDivisionError: float division by zero
[Fri Mar 11 16:19:25 2022]
Error in rule otoole_results:
    jobid: 2
    output: results/BBIN_Trade/results/AccumulatedNewCapacity.csv, results/BBIN_Trade/results/AnnualEmissions.csv, results/BBIN_Trade/results/AnnualFixedOperatingCost.csv, results/BBIN_Trade/results/AnnualTechnologyEmission.csv, results/BBIN_Trade/results/AnnualTechnologyEmissionByMode.csv, results/BBIN_Trade/results/AnnualVariableOperatingCost.csv, results/BBIN_Trade/results/CapitalInvestment.csv, results/BBIN_Trade/results/Demand.csv, results/BBIN_Trade/results/DiscountedTechnologyEmissionsPenalty.csv, results/BBIN_Trade/results/NewCapacity.csv, results/BBIN_Trade/results/ProductionByTechnology.csv, results/BBIN_Trade/results/ProductionByTechnologyAnnual.csv, results/BBIN_Trade/results/RateOfActivity.csv, results/BBIN_Trade/results/RateOfProductionByTechnology.csv, results/BBIN_Trade/results/RateOfProductionByTechnologyByMode.csv, results/BBIN_Trade/results/RateOfUseByTechnology.csv, results/BBIN_Trade/results/RateOfUseByTechnologyByMode.csv, results/BBIN_Trade/results/TotalAnnualTechnologyActivityByMode.csv, results/BBIN_Trade/results/TotalCapacityAnnual.csv, results/BBIN_Trade/results/TotalTechnologyAnnualActivity.csv, results/BBIN_Trade/results/TotalTechnologyModelPeriodActivity.csv, results/BBIN_Trade/results/UseByTechnology.csv
    log: workflow/logs/otoole_results.log (check log file(s) for error message)
    shell:
        otoole results cbc csv results/BBIN_Trade/BBIN_Trade.sol results/BBIN_Trade/results --input_datafile results/BBIN_Trade/PreProcessed_BBIN_Trade.txt --input_datapackage results/BBIN_Trade/datapackage.json 2> workflow/logs/otoole_results.log
        (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

Anything else?

CONFIGURATION FILE

# High Level Configuration
inputDir: 'resources'
outputDir: 'results'
modelName: 'OsemosysGlobal'
region: 'GLOBAL'

# Scenario Name 
scenario: 'BBIN_Trade'

# Temporal Parameters 
startYear: 2015
endYear: 2050
daytype: False
dayparts:
  #daypart : [start_hour, end_hour]
  D1: [0, 12]
  D2: [12, 24]
seasons:
  #season : [month 1, month 2, ...]
  S1: [12, 1, 2]
  S2: [3, 4, 5]
  S3: [6, 7, 8]
  S4: [9, 10, 11]

# Spatial Parameters 
geographic_scope:
 - 'IND'
 - 'BGD'
 - 'BTN'
 - 'NPL'
crossborderTrade: True

# Emission Parameters 
emission_penalty: 50 # M$/MT CO2

# Result Parameters 
results_by_country: True
tniet commented 2 years ago

This is due to the geographic filter not filtering out transmission from other countries into countries within the geographic scope. For example, the BBIN run still has transmission from China (and this is free) so it gets all its energy from China for free.

For now, we will remove all non-geographic scope transmission so there are no imports or exports to/from the study region. For future expansion and consideration of exports and imports we'll have to consider how this can best be included in the model. I'll create a second issue on that specific topic.