generated from ie3-institute/python-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Enrich an existing grid container by EVs and EVCS #356
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
Open
danielfeismann
wants to merge
8
commits into
main
Choose a base branch
from
df/#355-enrich_ev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8df1f29
Merge branch 'refs/heads/main' into df/#355-enrich_ev
danielfeismann 6ee02ae
Enrich an existing grid container by EVs and EVCS
danielfeismann 3022ca6
adapt notebook
danielfeismann 0cd0803
Merge branch 'main' into df/#355-enrich_ev
danielfeismann 6561f9d
Merge branch 'main' into df/#355-enrich_ev
danielfeismann 23741c6
Merge branch 'main' into df/#355-enrich_ev
danielfeismann 50c8c27
Merge branch 'main' into df/#355-enrich_ev
danielfeismann a7257d2
Merge branch 'main' into df/#355-enrich_ev
danielfeismann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "initial_id", | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"# Some jupyter notebook magic to reload modules automatically when they change\n", | ||
"# not necessary for this specific notebook but useful in general\n", | ||
"%load_ext autoreload\n", | ||
"%autoreload 2\n", | ||
"\n", | ||
"# Gives you high resolution images within the notebook\n", | ||
"%config InlineBackend.figure_format = 'retina'" | ||
] | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"outputs": [], | ||
"execution_count": null, | ||
"source": [ | ||
"from definitions import ROOT_DIR\n", | ||
"import os\n", | ||
"from pypsdm import GridContainer\n", | ||
"\n", | ||
"# The PSDM specific input models can be imported from the pypsdm.models.input and\n", | ||
"# pypsdm.models.result. The `GridWithResults` container is located in pypsdm.models.gwr\n", | ||
"from pypsdm.models.gwr import GridWithResults\n", | ||
"\n", | ||
"grid_path = os.path.join(ROOT_DIR, \"tests\", \"resources\", \"simple_grid\", \"input\")\n", | ||
"# IO data models in general have a from_csv method to parse psdm files\n", | ||
"gwr = GridContainer.from_csv(grid_path)\n", | ||
"\n", | ||
"# Output directory\n", | ||
"target_grid_path = os.path.join(ROOT_DIR, \"output\", \"enriched_grid\")\n", | ||
"if not os.path.exists(target_grid_path):\n", | ||
" os.makedirs(target_grid_path)" | ||
], | ||
"id": "8a6d151463bebeff" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"outputs": [], | ||
"execution_count": null, | ||
"source": [ | ||
"from pypsdm.io.utils import delete_all_files_in_directory\n", | ||
"\n", | ||
"delete_all_files_in_directory(target_grid_path)" | ||
], | ||
"id": "ece5d5686f9eda0c" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"outputs": [], | ||
"execution_count": null, | ||
"source": [ | ||
"# input parameter, so far we only support to sample p_rated of the EVs in a normal distribution.\n", | ||
"# EVs will have a storage size of 120.0 kWh and a consumption of 0.18 kWh/km each\n", | ||
"# The EVCS will have a charging power of 22.0 kW and two charging points.\n", | ||
"ev_p_rated_mean = 22.0\n", | ||
"ev_p_rated_sigma = 0.0\n", | ||
"ev_p_rated_min = 22.0\n", | ||
"ev_p_rated_max = 22.0\n", | ||
"ev_p_rated_params = [ev_p_rated_mean, ev_p_rated_sigma, ev_p_rated_min, ev_p_rated_max]\n", | ||
"evcs_v2g = False" | ||
], | ||
"id": "dfd54ffa547aa7a6" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"outputs": [], | ||
"execution_count": null, | ||
"source": [ | ||
"# identify nodes to which should be connected. For example, customer nodes most probably have an existing load. So we're looking for nodes in lv grids with an existing load\n", | ||
"lv_nodes = gwr.nodes.data[gwr.nodes.data[\"v_rated\"] <= 1.0]\n", | ||
"household_nodes = lv_nodes[lv_nodes.index.isin(gwr.loads.node)]\n", | ||
"household_nodes.head()" | ||
], | ||
"id": "5e5143be50696313" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"outputs": [], | ||
"execution_count": null, | ||
"source": [ | ||
"from pypsdm.models.input.create.enrich_grid import enrich_grid_by_evs_and_evcs\n", | ||
"from pypsdm.models.input.create.participants import create_electric_vehicles\n", | ||
"from pypsdm.models.input.create.participants import create_ev_charging_stations\n", | ||
"\n", | ||
"# get dictionaries for the ev and evcs as well as DataFrames for POIs and POI Mapping\n", | ||
"ev_dict, evcs_dict, df_poi, df_poi_map = enrich_grid_by_evs_and_evcs(\n", | ||
" nodes=household_nodes,\n", | ||
" ev_p_rated_params=ev_p_rated_params,\n", | ||
" evcs_v2g=evcs_v2g,\n", | ||
" controlling_em=False,\n", | ||
")\n", | ||
"\n", | ||
"# with these the EVs and EVCSs can be created\n", | ||
"evs = create_electric_vehicles(ev_dict)\n", | ||
"evcs = create_ev_charging_stations(evcs_dict)" | ||
], | ||
"id": "6e0ba8c8222b49cf" | ||
}, | ||
{ | ||
"metadata": {}, | ||
"cell_type": "code", | ||
"outputs": [], | ||
"execution_count": null, | ||
"source": [ | ||
"from pypsdm.models.input.container.grid import GridContainer\n", | ||
"from pypsdm.models.input.create.enrich_grid import add_pois_of_enriched_evcs\n", | ||
"\n", | ||
"# we now can create an updated SystemParticipantsContainer and an updated node_participants_map\n", | ||
"updated_participants = gwr.participants.copy(evs=evs, evcs=evcs)\n", | ||
"node_participants = updated_participants.build_node_participants_map(gwr.raw_grid.nodes)\n", | ||
"node_participants_map = updated_participants.build_node_participants_map(\n", | ||
" gwr.raw_grid.nodes\n", | ||
")\n", | ||
"\n", | ||
"# with this we can build our updated grid containing the updated participants.\n", | ||
"updated_grid = GridContainer(\n", | ||
" gwr.raw_grid, updated_participants, gwr.primary_data, node_participants_map\n", | ||
")\n", | ||
"\n", | ||
"# Finally, we can write the updated grid as well as the updated POI and POI Mapping data to our output path\n", | ||
"updated_grid.to_csv(target_grid_path, include_primary_data=True)\n", | ||
"add_pois_of_enriched_evcs(df_poi, df_poi_map, target_grid_path)" | ||
], | ||
"id": "adfcb8863d6ca0b3" | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should add some documentation to this method to specify the order of the parameters.