-
Notifications
You must be signed in to change notification settings - Fork 4
Add st storage to input converter w tests #83
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
Changes from 2 commits
e8aa128
75074ec
e0763fb
647c3f4
49578da
7de4f2d
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
from antares.craft.model.area import Area, AreaProperties | ||
from antares.craft.model.hydro import HydroProperties | ||
from antares.craft.model.renewable import RenewableClusterProperties | ||
from antares.craft.model.st_storage import STStorageProperties | ||
from antares.craft.model.study import Study, create_study_local | ||
from antares.craft.model.thermal import ThermalClusterProperties | ||
from antares.craft.tools.ini_tool import IniFile, InitializationFilesTypes | ||
|
@@ -139,7 +140,22 @@ def actual_renewable_list_ini(local_study_with_renewable) -> IniFile: | |
|
||
|
||
@pytest.fixture | ||
def local_study_with_st_storage(local_study_with_renewable) -> Study: | ||
def default_thermal_cluster_properties() -> STStorageProperties: | ||
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. Renommer la fonction |
||
return STStorageProperties( | ||
injection_nominal_capacity=10, | ||
withdrawal_nominal_capacity=10, | ||
reservoir_capacity=0, | ||
efficiency=1, | ||
initial_level=0.5, | ||
initial_level_optim=False, | ||
enabled=True, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def local_study_with_st_storage( | ||
local_study_with_renewable, default_thermal_cluster_properties | ||
) -> Study: | ||
""" | ||
Create an empty study | ||
Create 2 areas with custom area properties | ||
|
@@ -148,8 +164,10 @@ def local_study_with_st_storage(local_study_with_renewable) -> Study: | |
Create a renewable cluster | ||
Create a short term storage | ||
""" | ||
storage_name = "short term storage" | ||
local_study_with_renewable.get_areas()["fr"].create_st_storage(storage_name) | ||
storage_name = "battery" | ||
local_study_with_renewable.get_areas()["fr"].create_st_storage( | ||
storage_name, properties=default_thermal_cluster_properties | ||
) | ||
return local_study_with_renewable | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,6 +215,152 @@ def test_convert_renewables_to_component( | |
assert renewables_components == expected_renewable_component | ||
assert renewable_connections == expected_renewable_connections | ||
|
||
def test_convert_st_storages_to_component( | ||
self, local_study_with_st_storage, lib_id: str | ||
): | ||
areas, converter = self._init_area_reading(local_study_with_st_storage) | ||
study_path = converter.study_path | ||
( | ||
storage_components, | ||
storage_connections, | ||
) = converter._convert_st_storage_to_component_list(areas, lib_id) | ||
|
||
inflows_path = ( | ||
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. Tu pourrais introduire une variable pour stocker |
||
study_path | ||
/ "input" | ||
/ "st-storage" | ||
/ "series" | ||
/ "fr" | ||
/ "battery" | ||
/ "inflows" | ||
) | ||
lower_rule_curve_path = ( | ||
study_path | ||
/ "input" | ||
/ "st-storage" | ||
/ "series" | ||
/ "fr" | ||
/ "battery" | ||
/ "lower-rule-curve" | ||
) | ||
pmax_injection_path = ( | ||
study_path | ||
/ "input" | ||
/ "st-storage" | ||
/ "series" | ||
/ "fr" | ||
/ "battery" | ||
/ "PMAX-injection" | ||
) | ||
pmax_withdrawal_path = ( | ||
study_path | ||
/ "input" | ||
/ "st-storage" | ||
/ "series" | ||
/ "fr" | ||
/ "battery" | ||
/ "PMAX-withdrawal" | ||
) | ||
upper_rule_curve_path = ( | ||
study_path | ||
/ "input" | ||
/ "st-storage" | ||
/ "series" | ||
/ "fr" | ||
/ "battery" | ||
/ "upper-rule-curve" | ||
) | ||
expected_storage_connections = [ | ||
InputPortConnections( | ||
component1="battery", | ||
port1="injection_port", | ||
component2="fr", | ||
port2="balance_port", | ||
) | ||
] | ||
expected_storage_component = [ | ||
InputComponent( | ||
id="battery", | ||
model=f"{lib_id}.short-term-storage", | ||
scenario_group=None, | ||
parameters=[ | ||
InputComponentParameter( | ||
id="efficiency_injection", | ||
time_dependent=False, | ||
scenario_dependent=False, | ||
scenario_group=None, | ||
value=1, | ||
), | ||
InputComponentParameter( | ||
id="initial_level", | ||
time_dependent=False, | ||
scenario_dependent=True, | ||
scenario_group=None, | ||
value=0.5, | ||
), | ||
InputComponentParameter( | ||
id="reservoir_capacity", | ||
time_dependent=False, | ||
scenario_dependent=False, | ||
scenario_group=None, | ||
value=0.0, | ||
), | ||
InputComponentParameter( | ||
id="injection_nominal_capacity", | ||
time_dependent=False, | ||
scenario_dependent=False, | ||
scenario_group=None, | ||
value=10.0, | ||
), | ||
InputComponentParameter( | ||
id="withdrawal_nominal_capacity", | ||
time_dependent=False, | ||
scenario_dependent=False, | ||
scenario_group=None, | ||
value=10.0, | ||
), | ||
InputComponentParameter( | ||
id="inflows", | ||
time_dependent=True, | ||
scenario_dependent=True, | ||
scenario_group=None, | ||
value=f"{inflows_path}", | ||
), | ||
InputComponentParameter( | ||
id="lower_rule_curve", | ||
time_dependent=True, | ||
scenario_dependent=True, | ||
scenario_group=None, | ||
value=f"{lower_rule_curve_path}", | ||
), | ||
InputComponentParameter( | ||
id="p_max_injection_modulation", | ||
time_dependent=True, | ||
scenario_dependent=True, | ||
scenario_group=None, | ||
value=f"{pmax_injection_path}", | ||
), | ||
InputComponentParameter( | ||
id="p_max_withdrawal_modulation", | ||
time_dependent=True, | ||
scenario_dependent=True, | ||
scenario_group=None, | ||
value=f"{pmax_withdrawal_path}", | ||
), | ||
InputComponentParameter( | ||
id="upper_rule_curve", | ||
time_dependent=True, | ||
scenario_dependent=True, | ||
scenario_group=None, | ||
value=f"{upper_rule_curve_path}", | ||
), | ||
], | ||
) | ||
] | ||
|
||
assert storage_components == expected_storage_component | ||
assert storage_connections == expected_storage_connections | ||
|
||
def test_convert_thermals_to_component( | ||
self, | ||
local_study_w_thermal: Study, | ||
|
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.
Pour la lisibilité, c'est mieux de mettre lower/upper rule curve à la suite