calliope-project / calliope

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

Error when building a model #112

Closed mlgarchery closed 6 years ago

mlgarchery commented 6 years ago

Hello guys ! I submit bellow my entire configuration and output of the problem :)

Problem description

#model.yaml
import:
    - 'techs.yaml'
    - 'locations.yaml'
    - 'links.yaml'
model:
    name: Calliope Model
    calliope_version: 0.6.1
    timeseries_data_path: timeseries_data
    timeseries_dateformat: '%Y'
run:
    solver: glpk
    ensure_feasibility: 'true'
    bigM: 1000000.0
    zero_threshold: 1.0e-10
    mode: plan

#techs.yaml
techs:
  gas-transmission:
      essentials:
          name: 'Gas pipeline transmission'
          color: '#8465A9'
          parent: transmission
          carrier: gas
      constraints:
        lifetime: 25 # year
      costs:
          monetary:
            energy_cap_per_distance: 0.3894
            interest_rate: 0.1

  lng-import:
      essentials:
          name: 'LNG import'
          color: 'blue'
          parent: supply
          carrier_out: gas
      constraints:
          resource: file=LNGimport.csv
          energy_eff: 0.99
          energy_cap_max: 40000  # kW
          energy_cap_max_systemwide: 100000  # kW
          lifetime: 25
      costs:
          monetary:
              om_con: 0.02  # USD per kWh

  pipe-import:
      essentials:
          name: 'PIPE import'
          color: 'red'
          parent: supply
          carrier_out: gas
      constraints:
          resource: file=PIPEimport.csv
          energy_eff: 0.99
          energy_cap_max: 40000  # kW
          energy_cap_max_systemwide: 100000  # kW
          lifetime: 25
      costs:
          monetary:
              om_con: 0.02  # USD per kWh

  prod:
        essentials:
            name: 'Province gas production'
            color: 'orange'
            parent: supply
            carrier_out: gas
        constraints:
            resource: file=prod.csv

    # demand
  gas-demand:
      essentials:
          name: 'Province gas demand'
          color: 'black'
          parent: demand
          carrier: gas
      constraints:
          resource: file=demand.csv

#locations.yaml
locations:
    Xinjiang:
        coordinates: {lat: 84.9023, lon: 42.148}
    Tibet:
        coordinates: {lat: 87.8695, lon: 31.6846}
    Inner Mongolia:
        coordinates: {lat: 112.5977, lon: 46.3408}
    Qinghai:
        coordinates: {lat: 95.2402, lon: 35.4199}
    Sichuan:
        coordinates: {lat: 101.9199, lon: 30.1904}
 ...etc (31 provinces)

#links.yaml
links:
    Shaanxi,Beijing:
        techs:
            gas-transmission:
                constraints:
                    energy_cap_max: 49.7
                costs:
                    monetary:
                        energy_cap_per_distance: 0.2857
    Beijing,Liaoning:
        techs:
            gas-transmission:
                constraints:
                    energy_cap_max: 49.7
                costs:
                    monetary:
                        energy_cap_per_distance: 0.2857
    Xinjiang,Ningxia:
        techs:
            gas-transmission:
                constraints:
                    energy_cap_max: 56.5
                costs:
                    monetary:
                        energy_cap_per_distance: 0.1442
    Qinghai,Gansu:
        techs:
            gas-transmission:
                constraints:
                    energy_cap_max: 56.5
                costs:
                    monetary:
                        energy_cap_per_distance: 0.1442
 ...etc

My .csv files are all following the format:

,location1, location2, ...etc (31 locations)
2010, 2.3, 6.3 ...
...
2020, 5.2, 4.5 ..

~/anaconda3/envs/calliope1/lib/python3.6/site-packages/calliope/core/model.py in init(self, config, model_data, *args, *kwargs) 64 log_time(self._timings, 'model_creation', comment='Model: initialising') 65 if isinstance(config, str): ---> 66 model_run, debug_data = model_run_from_yaml(config, args, **kwargs) 67 self._init_from_model_run(model_run, debug_data) 68 elif isinstance(config, dict):

~/anaconda3/envs/calliope1/lib/python3.6/site-packages/calliope/core/preprocess/model_run.py in model_run_from_yaml(model_file, override_file, override_dict) 54 ) 55 ---> 56 return generate_model_run(config_with_overrides, debug_comments) 57 58

~/anaconda3/envs/calliope1/lib/python3.6/site-packages/calliope/core/preprocess/model_run.py in generate_model_run(config, debug_comments) 479 # Raises ModelErrors if there are problems with timeseries data at this stage 480 model_run['timeseries_data'], model_run['timesteps'] = ( --> 481 process_timeseries_data(config, model_run) 482 ) 483

~/anaconda3/envs/calliope1/lib/python3.6/site-packages/calliope/core/preprocess/model_run.py in process_timeseries_data(config_model, model_run) 432 if file not in cluster_filenames 433 ] --> 434 first_file, first_index = indices[0] 435 for file, idx in indices[1:]: 436 if not first_index.equals(idx):

IndexError: list index out of range



## Steps to reproduce the problem ##

import calliope
calliope.core.util.logging.set_log_level('DEBUG')
m = calliope.Model('china/model.yaml')

## Calliope version ##

0.6.1
brynpickering commented 6 years ago

Thanks @FirstWorldSlardar! It looks like you have a few issues here:

  1. You're not assigning your demand techs to any locations. Once you've defined them in techs you need to also assign them under locations, e.g.:
locations:
    Xinjiang:
        techs:
            gas_demand:
            etc...
        coordinates: {lat: 84.9023, lon: 42.148}

If you have the same techs at every location, then you can use comma separation to keep things simple:

locations:
    Xinjiang,Tibet,etc.:
        techs:
            gas_demand:
            etc...
  1. Your file structure might also cause issues. The way it looks at the moment suggests that you have:

The import and timeseries_data_path strings are relative to the model.yaml file, not to the directory from which you call calliope.Model.

I would strongly suggest playing around more with the example models and having a detailed read through our documentation, as it will likely clear up a number of things!

mlgarchery commented 6 years ago

My file structure is the following:

The import and timeseries_data_path strings are indeed relative to the model.yaml (I edited my mistake in model.yaml, it is indeed "timeseries_data_path: timeseries_data"). Sorry for that. I'll try adding the techs to the locations, and come back asap. Thanks!

brynpickering commented 6 years ago

Hi @FirstWorldSlardar , I assume you solved this issue in the end? If so, we'll close the issue!

mlgarchery commented 6 years ago

yes indeed :)