-
Notifications
You must be signed in to change notification settings - Fork 10
first draft - Linking transformer stations #156
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
base: dev
Are you sure you want to change the base?
Changes from all commits
15f889c
efadf7a
0c05abc
f8d1ae3
00410b2
3e43cab
35bd2a8
929b67f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,5 @@ | |
| /docs/_build/ | ||
| /docs/_build/doctrees/ | ||
| /docs/_build/html/ | ||
| /.idea/ | ||
| /.idea/ | ||
| /inputs/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,7 @@ | |
| ELECTRICITY_MG_FOLDER, | ||
| STORAGE_FOLDER, | ||
| LP_FILES_FOLDER, | ||
| USE_BIDIRECTIONAL_INVERTER_CONSTRAINT, | ||
| ) | ||
|
|
||
| # requires xlrd | ||
|
|
@@ -414,6 +415,12 @@ def get_case_definitions(file, sheet_project_sites): | |
| f"Parameter {EVALUATION_PERSPECTIVE} has to be either {AC_SYSTEM} or {DC_SYSTEM}, but is {case_definitions[case][EVALUATION_PERSPECTIVE]}" | ||
| ) | ||
|
|
||
| if USE_BIDIRECTIONAL_INVERTER_CONSTRAINT not in case_definitions[case]: | ||
| case_definitions[case][USE_BIDIRECTIONAL_INVERTER_CONSTRAINT] = False | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Especially because of this, I think you need to use
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will the json.update() do? |
||
| logging.error( | ||
| f"Parameter {USE_BIDIRECTIONAL_INVERTER_CONSTRAINT} was not defined in excel input sheet and thus set to False." | ||
| ) | ||
|
|
||
| case_definitions[case].update( | ||
| { | ||
| NUMBER_OF_EQUAL_GENERATORS: int( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,11 @@ | |
| STORAGE_FIXED_CAPACITY, | ||
| STORAGE_FIXED_POWER, | ||
| RECTIFIER_AC_DC_FIXED_CAPACITY, | ||
| RECTIFIER_AC_DC_COST_INVESTMENT, | ||
| INVERTER_DC_AC_FIXED_CAPACITY, | ||
| INVERTER_DC_AC_COST_INVESTMENT, | ||
| INVERTER_RECTIFIER_CAPACITY_RATIO_FACTOR, | ||
| USE_BIDIRECTIONAL_INVERTER_CONSTRAINT, | ||
| ALLOW_SHORTAGE, | ||
| STABILITY_CONSTRAINT, | ||
| SHARE_BACKUP, | ||
|
|
@@ -220,9 +224,9 @@ def build(experiment, case_dict): | |
| # ------------point of coupling (feedin)------------# | ||
| if case_dict[PCC_FEEDIN_FIXED_CAPACITY] == None: | ||
| pass | ||
| # pointofcoupling_feedin = None | ||
| pointofcoupling_feedin = None | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional removal of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is an intentional removal because I need it later on in the code for the constraint_equate_bidirectional_transformer_capacities function (see line 462-471) in case PCC_FEEDIN_FIXED_CAPACITY is None. |
||
| elif case_dict[PCC_FEEDIN_FIXED_CAPACITY] is False: | ||
| generate.pointofcoupling_feedin_oem( | ||
| pointofcoupling_feedin = generate.pointofcoupling_feedin_oem( | ||
| micro_grid_system, | ||
| bus_electricity_ac, | ||
| bus_electricity_ng_feedin, | ||
|
|
@@ -231,7 +235,7 @@ def build(experiment, case_dict): | |
| ) | ||
|
|
||
| elif isinstance(case_dict[PCC_FEEDIN_FIXED_CAPACITY], float): | ||
| generate.pointofcoupling_feedin_fix( | ||
| pointofcoupling_feedin = generate.pointofcoupling_feedin_fix( | ||
| micro_grid_system, | ||
| bus_electricity_ac, | ||
| bus_electricity_ng_feedin, | ||
|
|
@@ -452,6 +456,45 @@ def build(experiment, case_dict): | |
| + " faulty at renewable_share_constraint. Value can only be True or False" | ||
| ) | ||
|
|
||
| # ------------Link transformer station capacities constraint ------------# | ||
| if case_dict[PCC_CONSUMPTION_FIXED_CAPACITY] != None and case_dict[PCC_FEEDIN_FIXED_CAPACITY] != None: | ||
| logging.info("Added constraint: Linking transformer station capacities.") | ||
| constraints_custom.constraint_equate_bidirectional_transformer_capacities( | ||
| model, | ||
| case_dict, | ||
| bus_electricity_ng_feedin, | ||
| bus_electricity_ng_consumption, | ||
| pointofcoupling_feedin, | ||
| pointofcoupling_consumption, | ||
| PCC_FEEDIN_FIXED_CAPACITY, | ||
| PCC_CONSUMPTION_FIXED_CAPACITY | ||
| ) | ||
|
|
||
| # ------------Link rectifier and inverter capacities constraint------------# | ||
| if case_dict[USE_BIDIRECTIONAL_INVERTER_CONSTRAINT] != None: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can it be
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be false indeed |
||
| if case_dict[USE_BIDIRECTIONAL_INVERTER_CONSTRAINT] is True: | ||
| logging.info("Added constraint: Linking rectifier and inverter capacities.") | ||
| constraints_custom.constraint_equate_bidirectional_transformer_capacities( | ||
| model, | ||
| case_dict, | ||
| bus_electricity_dc, | ||
| bus_electricity_ac, | ||
| inverter, | ||
| rectifier, | ||
| INVERTER_DC_AC_FIXED_CAPACITY, | ||
| RECTIFIER_AC_DC_FIXED_CAPACITY, | ||
| experiment[INVERTER_RECTIFIER_CAPACITY_RATIO_FACTOR] | ||
| ) | ||
| if experiment[RECTIFIER_AC_DC_COST_INVESTMENT] != 0: | ||
| logging.warning( | ||
| "Case definition of " | ||
| + case_dict[CASE_NAME] | ||
| + ": Are you sure that you want to define both rectifier and inverter costs if " | ||
| + "you link the capacties to receive a biderectional inverter? " | ||
| + "This would result in effective investment costs of " | ||
| + str(float(experiment[RECTIFIER_AC_DC_COST_INVESTMENT])+float(case_dict[INVERTER_AC_DC_COST_INVESTMENT])) | ||
| + " currency/kW bidirectional inverter." | ||
| ) | ||
| # ------------Force charge from maingrid------------# | ||
| if case_dict[FORCE_CHARGE_FROM_MAINGRID] is False: | ||
| pass | ||
|
|
@@ -497,6 +540,7 @@ def build(experiment, case_dict): | |
| + " faulty at enable_inverter_at_backout. Value can only be True or False" | ||
| ) | ||
|
|
||
|
|
||
| """ | ||
| # ------------Allow shortage only for certain percentage of demand in a timestep------------# | ||
| if case_dict['allow_shortage'] is True: | ||
|
|
@@ -507,6 +551,7 @@ def build(experiment, case_dict): | |
| shortage_constraints.timestep(model, case_dict, experiment, sink_demand_dc, | ||
| source_shortage, bus_electricity_dc) | ||
| """ | ||
|
|
||
| return micro_grid_system, model | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import pyomo.environ as po | ||
| import logging | ||
| import pandas as pd | ||
| import oemof.solph as solph | ||
| from src.constants import ( | ||
| SHORTAGE_LIMIT, | ||
| NUMBER_OF_EQUAL_GENERATORS, | ||
|
|
@@ -954,6 +955,18 @@ def inverter_only_at_blackout_test(case_dict, oemof_results, e_flows_df): | |
|
|
||
| return | ||
|
|
||
| # equate bi-directional transformer capacities | ||
| def constraint_equate_bidirectional_transformer_capacities(model, case_dict, bus_transformer_in, bus_transformer_out, transformer_in, transformer_out, name_transformer_in, name_transformer_out, factor = 1): | ||
| CAP_inverter = 0 | ||
| CAP_rectifier = 0 | ||
| if case_dict[name_transformer_in] != None and case_dict[name_transformer_out] != None: | ||
| if case_dict[name_transformer_in] is False and case_dict[name_transformer_out] is False: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this loop do? Dont forget to use in-line comments (
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alright will add comments for the next PR
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually I took the idea from one of your comments (#155 (comment)) but I'm not sure in what case case_dict[name_transformer_in] is false and why different capacities need to be added (see code below) since there's just one converter |
||
| CAP_inverter += model.InvestmentFlow.invest[bus_transformer_in, transformer_in] | ||
| CAP_rectifier += model.InvestmentFlow.invest[bus_transformer_out, transformer_out] | ||
| solph.constraints.equate_variables(model,CAP_rectifier, CAP_inverter, factor) | ||
|
|
||
| return model | ||
|
|
||
|
|
||
| # todo shortage constraint / stbaility constraint only relates to AC bus | ||
| def timestep(model, case_dict, experiment, el_bus, sink_demand, source_shortage): | ||
|
|
||
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.
Looking good. Maybe write a pytest for this function that makes sure that your two outcomes (
USE_BIDIRECTIONAL_INVERTER_CONSTRAINTis not and is in settings) are checked.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.
yes will look into pytest next