-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature EV controlled charging custom constraints #356
Feature EV controlled charging custom constraints #356
Conversation
…github.com/adrienmellot/euro-calliope into feature-ev-controlled-charging-constraints
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
for more information, see https://pre-commit.ci
Co-Authored-By: Francesco Sanvito <[email protected]>
…github.com/adrienmellot/euro-calliope into feature-ev-controlled-charging-constraints
Co-Authored-By: Francesco Sanvito <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @adrienmellot, shows how complex our EV modelling is. Too complex...?
Anyway, some reasonably major comments about reorganising file structures:
run.py
could be restructured into a snakemake rule script that calls constraint adding scripts on-the-fly- the controlled EV annual demand and installed capacities rule should probably be split in two since they have some mutually exclusive inputs/params. They can use the same script (since they share the regionalisation step) but some parameter / wildcard is used in the script to decide whether
df_demand
ordf_charging_potentials
is generated.
config/run.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest having a run.py
in scripts
and then a add_constraints.py
in the scripts/transport/
directory. The run.py
has most of the content of this file except the constraints. It then lods constraints as modules and loads them into the model:
import importlib.util
model = calliope.read_netcdf(path_to_temp_model)
model.run(build_only=True)
for file in constraint_files:
spec=importlib.util.spec_from_file_location("constraints", file)
# creates a new module based on spec
constraint_adder = importlib.util.module_from_spec(spec)
# executes the module in its own namespace
# when a module is imported or reloaded.
spec.loader.exec_module(constraint_adder)
constraint_adder.add_eurocalliope_constraints(model)
new_model = model.backend.rerun()
new_model.to_netcdf(path_to_output)
Then you can have the run step be a snakemake rule with the reference to the constraint scripts in the inputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is untested by me, loading files as modules might need some trial and error work
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
Co-Authored-By: Francesco Sanvito <[email protected]>
@brynpickering I've addressed the first part of the comments regarding style, not yet the part concerning the Regarding your comment about splitting the controlled EV annual demand and installed capacities rule into two rules, I've discussed it with Tim and it makes life harder to split it. The reason for that is that the rule outputs one Splitting the rule into two would either require generating two |
OK, it's because the template filler can only handle one location-specific CSV. This probably needs fixing as it leads to quite messy implementations like this. Not something to solve in this PR! |
For now custom constraints are not implemented (#385). I've thus removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final set of suggestions, otherwise OK to go ahead!
country_codes=([ | ||
pycountry.countries.lookup(c).alpha_3 for c in snakemake.params.countries | ||
]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
country_codes=([ | |
pycountry.countries.lookup(c).alpha_3 for c in snakemake.params.countries | |
]), | |
country_codes=utils.convert_valid_countries(snakemake.params.countries).values() |
@@ -0,0 +1,103 @@ | |||
import pandas as pd | |||
import pycountry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import pycountry | |
from eurocalliopelib import utils |
config/schema.yaml
Outdated
@@ -368,9 +371,43 @@ properties: | |||
motorcycles: | |||
type: string | |||
description: JRC-IDEES name of motorcycles. | |||
ev-battery-sizes: | |||
type: object | |||
description: EV battery size per vehicle type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give unit here rather than as a comment in the config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, can't approve - it needs a changelog entry ;)
…controlled-charging-constraints Feature EV controlled charging custom constraints
…controlled-charging-constraints Feature EV controlled charging custom constraints
…controlled-charging-constraints Feature EV controlled charging custom constraints
Fixes #350.
Fixes #81.
Within the realm of full electrification of road transport, this PR allows the controlled charging share of this electricity demand to be constrained.
Possibly, we want to have the run.py file to be integrated in a better way, and also in workflow tests.
Checklist
Any checks which are not relevant to the PR can be pre-checked by the PR creator. All others should be checked by the reviewer. You can add extra checklist items here if required by the PR.