calliope-project / calliope

A multi-scale energy systems modelling framework
https://www.callio.pe
Apache License 2.0
287 stars 93 forks source link

Remove `_equals` and `_scale` parameters #466

Closed brynpickering closed 11 months ago

brynpickering commented 1 year ago

Fixes issue #422

Summary of changes in this pull request:

Reviewer checklist:

codecov[bot] commented 1 year ago

Codecov Report

Merging #466 (63df809) into main (cbed4c8) will decrease coverage by 2.79%. Report is 9 commits behind head on main. The diff coverage is 95.66%.

@@            Coverage Diff             @@
##             main     #466      +/-   ##
==========================================
- Coverage   94.98%   92.20%   -2.79%     
==========================================
  Files          31       32       +1     
  Lines        3890     4016     +126     
  Branches        0      957     +957     
==========================================
+ Hits         3695     3703       +8     
- Misses        195      198       +3     
- Partials        0      115     +115     
Files Coverage Δ
src/calliope/__init__.py 100.00% <ø> (ø)
src/calliope/_version.py 100.00% <ø> (ø)
src/calliope/backend/helper_functions.py 99.35% <ø> (ø)
src/calliope/backend/where_parser.py 98.55% <100.00%> (ø)
src/calliope/cli.py 81.67% <100.00%> (ø)
src/calliope/core/__init__.py 100.00% <ø> (ø)
src/calliope/core/attrdict.py 99.50% <ø> (ø)
src/calliope/core/io.py 91.75% <100.00%> (ø)
src/calliope/core/model.py 94.05% <100.00%> (ø)
src/calliope/core/util/generate_runs.py 87.09% <ø> (ø)
... and 22 more
sjpfenninger commented 1 year ago

Did we now check to what extent this affects the actual mathematical model, and possible numerical issues?

brynpickering commented 1 year ago

Checked this by adding 26 new nodes to the national scale model (see overrides applied below) and then doing some memory profiling. It's not perfect because the new nodes don't actually add any complexity to the optimisation problem, but it gives a sense of memory footprint and whether CBC would trip up on the same min/max in the LP.

The result is less memory footprint when using min/max not equals!

memory footprints (MB, max / final allocations) using current main, where both equals and min/max can be tested:

  1. national example model, 10 days, with equals: 166.9/166.9
  2. national example model, 10 days, without equals: 159.9/159.9 <- 155.4 when using the implementation on this branch.
  3. national example model, 2 days, with equals: 73.2/73.2
  4. national example model, 2 days, without equals: 61.8/61.8

Either way, CBC takes the same time to solve (~1 second) and the model takes the same time to load and build the problem.

So, seems a good idea to go ahead with this. I imagine that much bigger models might have different responses, but I can't test that.

national_model_more_regions.yaml ```yaml overrides: new_nodes: nodes: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z: coordinates: { lat: 39, lon: -8 } techs: ccgt: csp.constraints.resource: file=csp_resource.csv:region1-1 energy_cap_no_equals: techs.ccgt.constraints.energy_cap_max_systemwide: 100000 techs.ccgt.constraints.energy_cap_min_systemwide: 100000 energy_cap_equals: techs.ccgt.constraints.energy_cap_equals_systemwide: 100000 variables_equals: nodes: region1.techs.ccgt.constraints.energy_cap_equals: 30000 region2.techs.battery.constraints.energy_cap_equals: 1000 region2.techs.battery.constraints.storage_cap_equals: 5240 region1-1.techs.csp.constraints.energy_cap_equals: 10000 region1-1.techs.csp.constraints.storage_cap_equals: 244301 region1-1.techs.csp.constraints.resource_area_equals: 130385 region1-2.techs.csp.constraints.energy_cap_equals: 0 region1-2.techs.csp.constraints.storage_cap_equals: 0 region1-2.techs.csp.constraints.resource_area_equals: 0 region1-3.techs.csp.constraints.energy_cap_equals: 2534 region1-3.techs.csp.constraints.storage_cap_equals: 25301 region1-3.techs.csp.constraints.resource_area_equals: 8487 links: region1,region2.techs.ac_transmission.constraints.energy_cap_equals: 3231 region1,region1-1.techs.free_transmission.constraints.energy_cap_equals: 9000 region1,region1-2.techs.free_transmission.constraints.energy_cap_equals: 0 region1,region1-3.techs.free_transmission.constraints.energy_cap_equals: 2281 variables_no_equals: nodes: region1.techs.ccgt.constraints.energy_cap_min: 30000 region1.techs.ccgt.constraints.energy_cap_max: 30000 region2.techs.battery.constraints.energy_cap_min: 1000 region2.techs.battery.constraints.energy_cap_max: 1000 region2.techs.battery.constraints.storage_cap_min: 5240 region2.techs.battery.constraints.storage_cap_max: 5240 region1-1.techs.csp.constraints.energy_cap_min: 10000 region1-1.techs.csp.constraints.energy_cap_max: 10000 region1-1.techs.csp.constraints.storage_cap_min: 244301 region1-1.techs.csp.constraints.storage_cap_max: 244301 region1-1.techs.csp.constraints.resource_area_min: 130385 region1-1.techs.csp.constraints.resource_area_max: 130385 region1-2.techs.csp.constraints.energy_cap_min: 0 region1-2.techs.csp.constraints.energy_cap_max: 0 region1-2.techs.csp.constraints.storage_cap_min: 0 region1-2.techs.csp.constraints.storage_cap_max: 0 region1-2.techs.csp.constraints.resource_area_min: 0 region1-2.techs.csp.constraints.resource_area_max: 0 region1-3.techs.csp.constraints.energy_cap_min: 2534 region1-3.techs.csp.constraints.energy_cap_max: 2534 region1-3.techs.csp.constraints.storage_cap_min: 25301 region1-3.techs.csp.constraints.storage_cap_max: 25301 region1-3.techs.csp.constraints.resource_area_min: 8487 region1-3.techs.csp.constraints.resource_area_max: 8487 links: region1,region2.techs.ac_transmission.constraints.energy_cap_min: 3231 region1,region2.techs.ac_transmission.constraints.energy_cap_max: 3231 region1,region1-1.techs.free_transmission.constraints.energy_cap_min: 9000 region1,region1-1.techs.free_transmission.constraints.energy_cap_max: 9000 region1,region1-2.techs.free_transmission.constraints.energy_cap_min: 0 region1,region1-2.techs.free_transmission.constraints.energy_cap_max: 0 region1,region1-3.techs.free_transmission.constraints.energy_cap_min: 2281 region1,region1-3.techs.free_transmission.constraints.energy_cap_max: 2281 scenarios: linear_equals: "new_nodes,energy_cap_equals,variables_equals" linear_no_equals: "new_nodes,energy_cap_no_equals,variables_no_equals" ```
brynpickering commented 11 months ago

@sjpfenninger this is now up-to-date and ready for review