Skip to content
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

Models with stock #33

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5b72beb
test Quota CO2
Yann-Temudjin Feb 26, 2024
7465997
reformatage du fichier test_quota_co2
Yann-Temudjin Mar 4, 2024
8b687c6
Ajout de Short term storage complex dans les modeles standard
Yann-Temudjin Mar 4, 2024
966b4de
Merge branch 'main' into modelesSC
Yann-Temudjin Mar 4, 2024
927cc47
Ajout du test electrolyzer n inputs
Yann-Temudjin Mar 4, 2024
18a4b1f
fix taking in account the comments on the pull request
Yann-Temudjin Mar 4, 2024
d0e8e26
Ajout du isclose et modification des tests pour les electrolyzer n_in…
Yann-Temudjin Mar 13, 2024
82efdad
Fixed test 3 and 4 of the electrolyzer_n_inputs
Yann-Temudjin Mar 18, 2024
4400c46
Merge branch 'main' into stock_pipeline
Yann-Temudjin Mar 22, 2024
51de9e4
test electrolyzer_n_inputs with yaml models
Yann-Temudjin Mar 27, 2024
ffcc3de
quota C02 test with yaml model
Yann-Temudjin Mar 29, 2024
dc08c71
print to test the path
Yann-Temudjin Apr 2, 2024
f6218bd
fixed path for the first n_input_electrolyzer_yaml test
Yann-Temudjin Apr 2, 2024
25b567f
model stock pipeline
Yann-Temudjin Apr 3, 2024
f5a0eec
moved test for models
Yann-Temudjin Apr 3, 2024
d7ce092
added standard_sc.yml
Yann-Temudjin Apr 3, 2024
fccf367
fix of libs path and move of the tests to models
Yann-Temudjin Apr 3, 2024
006131b
factorisation, removal of unused import and move of test files
Yann-Temudjin Apr 5, 2024
cddd635
reformat test
Yann-Temudjin Apr 8, 2024
25d4b79
move tests of model to tests/model
Yann-Temudjin Apr 8, 2024
7739a77
Merge branch 'main' into model_test_yaml
Yann-Temudjin Apr 8, 2024
ed4f8a0
Fix formatting
tbittar Apr 9, 2024
4b949d6
re-added libs_dir to model/conftest.py
Yann-Temudjin Apr 9, 2024
f912f0d
Merge branch 'model_test_yaml' of https://github.com/AntaresSimulator…
Yann-Temudjin Apr 9, 2024
b3ed8e7
added type declaration and removed unused argument
Yann-Temudjin Apr 15, 2024
b4a1bd1
Merge branch 'model_test_yaml' into stock_pipeline
Yann-Temudjin Apr 15, 2024
eb30fbc
changed ports on link with storage model
Yann-Temudjin Apr 19, 2024
564d10f
test stock pipeline fix and added test gas_link_elec_compressor and s…
Yann-Temudjin Apr 26, 2024
7b9fb16
Merge branch 'main' into stock_pipeline
Yann-Temudjin Apr 26, 2024
651ca02
Merge branch 'main' into stock_pipeline
Yann-Temudjin Apr 26, 2024
14bc1e5
added two test for stock pipeline and test and model for gas stock
Yann-Temudjin May 17, 2024
e668672
Merge branch 'main' into stock_pipeline
Yann-Temudjin May 17, 2024
24d0c06
fix test gas link elec compressor
Yann-Temudjin May 21, 2024
6e16230
Added test for gas stock 2 elec compressor with yaml components
Yann-Temudjin May 27, 2024
8fba186
added stock hydro test
Yann-Temudjin May 31, 2024
5bfdfcc
remove model stock_final_level_input
killian-scalian Jul 1, 2024
3765536
move TODO things from stock_pipeline to scalian-stock-pipeline-dev
killian-scalian Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/andromede/libs/standard_sc.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,56 @@
)
],
)

LINK_WITH_STORAGE = model(
id="Link with storage model",
parameters=[
float_parameter("f_from_max", CONSTANT),
float_parameter("f_to_max", CONSTANT),
Comment on lines +218 to +219
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
float_parameter("f_from_max", CONSTANT),
float_parameter("f_to_max", CONSTANT),
float_parameter("f_from_min", CONSTANT),
float_parameter("f_to_min", CONSTANT),
float_parameter("f_from_max", CONSTANT),
float_parameter("f_to_max", CONSTANT),

float_parameter("capacity", CONSTANT),
float_parameter("initial_level", CONSTANT),
],
variables=[
float_variable("r", lower_bound=literal(0), upper_bound=param("capacity")),
float_variable(
"f_from", lower_bound=-param("f_from_max"), upper_bound=param("f_from_max")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"f_from", lower_bound=-param("f_from_max"), upper_bound=param("f_from_max")
"f_from", lower_bound=param("f_from_min"), upper_bound=param("f_from_max")

),
float_variable(
"f_to", lower_bound=-param("f_to_max"), upper_bound=param("f_to_max")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"f_to", lower_bound=-param("f_to_max"), upper_bound=param("f_to_max")
"f_to", lower_bound=param("f_to_min"), upper_bound=param("f_to_max")

),
float_variable("f_from+", lower_bound=literal(0)),
float_variable("f_from-", lower_bound=literal(0)),
float_variable("f_to+", lower_bound=literal(0)),
float_variable("f_to-", lower_bound=literal(0)),
],
ports=[
ModelPort(port_type=BALANCE_PORT_TYPE, port_name="flow_from"),
ModelPort(port_type=BALANCE_PORT_TYPE, port_name="flow_to"),
ModelPort(port_type=BALANCE_PORT_TYPE, port_name="flow_from_pos"),
ModelPort(port_type=BALANCE_PORT_TYPE, port_name="flow_to_pos"),
],
port_fields_definitions=[
PortFieldDefinition(
port_field=PortFieldId("flow_from", "flow"),
definition=-var("f_from"),
),
PortFieldDefinition(
port_field=PortFieldId("flow_to", "flow"),
definition=var("f_to"),
),
PortFieldDefinition(
port_field=PortFieldId("flow_from_pos", "flow"),
definition=var("f_from+"),
),
PortFieldDefinition(
port_field=PortFieldId("flow_to_pos", "flow"),
definition=var("f_to+"),
),
],
constraints=[
Constraint(
name="Level",
expression=var("f_from") == (var("f_from+") - var("f_from-")),
),
],
Comment on lines +260 to +265
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This model is incomplete (missing shift operators at least). Was it superseded by the yml ? If so, I suggest removing standard_sc.py completely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it seems to be superseeded by the model in the yml

)
220 changes: 220 additions & 0 deletions src/andromede/libs/standard_sc.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some models are defined in local libraries for tests, delete the incomplete, unsed ones from here (storage_final_level, storage_final_level_input), maybe others ?

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,226 @@ library:
- name: emission

models:
- id: link_with_storage
description: A link with energy storage
parameters:
- name: f_from_max
time-dependent: false
scenario-dependent: false
- name: f_to_max
time-dependent: false
scenario-dependent: false
- name: capacity
time-dependent: false
scenario-dependent: false
- name: initial_level
time-dependent: false
scenario-dependent: false
variables:
- name: r
lower-bound: 0
upper-bound: capacity
- name: f_from
lower-bound: -f_from_max
upper-bound: f_from_max
- name: f_to
lower-bound: -f_to_max
upper-bound: f_to_max
- name: f_from_p
lower-bound: 0
- name: f_from_m
lower-bound: 0
- name: f_to_p
lower-bound: 0
- name: f_to_m
lower-bound: 0
ports:
- name: flow_from
type: flow
- name: flow_to
type: flow
- name: flow_from_pos
type: flow
- name: flow_to_pos
type: flow
port-field-definitions:
- port: flow_from
field: flow
definition: -f_from
- port: flow_to
field: flow
definition: f_to
constraints:
- name: max0_from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More explicit name : positive_part_flow_from

expression: f_from = f_from_p - f_from_m
- name: max0_to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

expression: f_to = f_to_p - f_to_m
- name: r_t1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More explicit name : storage_dynamics

expression: r[t+1] = r[t] + f_from - f_to
- name: r0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initial_level

expression: r[0] = initial_level
- name: rt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final_level

There is a problem here ! How to specify the level of final time of the block in the yaml and even in our lower-level expressions @sylvlecl, I think it is not possible for now ?

expression: r[t] = initial_level
binding-constraints:
- name: FlowFromPos
expression: sum_connections(flow_from_pos.flow) = f_from_p
- name: FlowToPos
expression: sum_connections(flow_to_pos.flow) = f_to_p

- id: link_with_storage_2
description: A link with energy storage without flow_from/to_pos
parameters:
- name: f_from_max
time-dependent: false
scenario-dependent: false
- name: f_to_max
time-dependent: false
scenario-dependent: false
- name: capacity
time-dependent: false
scenario-dependent: false
- name: initial_level
time-dependent: false
scenario-dependent: false
variables:
- name: r
lower-bound: 0
upper-bound: capacity
- name: f_from
lower-bound: -f_from_max
upper-bound: f_from_max
- name: f_to
lower-bound: -f_to_max
upper-bound: f_to_max
- name: f_from_p
lower-bound: 0
- name: f_from_m
lower-bound: 0
- name: f_to_p
lower-bound: 0
- name: f_to_m
lower-bound: 0
ports:
- name: flow_from
type: flow
- name: flow_to
type: flow
port-field-definitions:
- port: flow_from
field: flow
definition: -f_from
- port: flow_to
field: flow
definition: f_to
constraints:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same remarks on constraints name

- name: r_t1
expression: r[t+1] = r[t] + f_from - f_to
- name: r0
expression: r[0] = initial_level
- name: rt
expression: r[t] = initial_level

- id: stock_final_level_input
description: A stock model with multiple input
parameters:
- name: p_max_in
time-dependent: false
scenario-dependent: false
- name: p_max_out
time-dependent: false
scenario-dependent: false
- name: capacity
time-dependent: false
scenario-dependent: false
- name: initial_level
time-dependent: false
scenario-dependent: false
- name: final_level
time-dependent: false
scenario-dependent: false
variables:
- name: r
lower-bound: 0
upper-bound: capacity
- name: u_in
lower-bound: 0
upper-bound: p_max_in
- name: u_out
lower-bound: 0
upper-bound: p_max_out
ports:
- name: flow_s
type: flow
- name: flow_c
type: flow
port-field-definitions:
- port: flow_s
field: flow
definition: u_out - u_in
constraints:
- name: r_h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storage dynamics

expression: r[t+1] = r[t] + u_in[t] - u_out[t]
binding-constraints:
- name: flow_in
expression: sum_connections(flow_c.flow) = u_in

- id: stock_final_level
description: A stock model
parameters:
- name: p_max_in
time-dependent: false
scenario-dependent: false
- name: p_max_out
time-dependent: false
scenario-dependent: false
- name: capacity
time-dependent: false
scenario-dependent: false
- name: initial_level
time-dependent: false
scenario-dependent: false
- name: final_level
time-dependent: false
scenario-dependent: false
variables:
- name: r
lower-bound: 0
upper-bound: capacity
- name: u_in
lower-bound: 0
upper-bound: p_max_in
- name: u_out
lower-bound: 0
upper-bound: p_max_out
ports:
- name: flow_s
type: flow
- name: flow_c
type: flow
port-field-definitions:
- port: flow_s
field: flow
definition: u_out - u_in
constraints:
- name: r_h
expression: r[t+1] = r[t] + u_in[t] - u_out[t]
binding-constraints:
- name: flow_in
expression: sum_connections(flow_c.flow) = u_in

- id: repartition_key
description: A repartition key
parameters:
- name: alpha
time-dependent: false
scenario-dependent: false
ports:
- name: flow_k
type: flow
binding-constraints:
- name: sum
expression: sum_connections(flow_k.flow) = 0

- id: convertor
description: A basic convertor model
parameters:
Expand Down
Loading
Loading