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

Fix/multiple in out transformer #949

Merged
merged 13 commits into from Sep 8, 2022
Merged

Conversation

NargesChinichian
Copy link
Collaborator

@NargesChinichian NargesChinichian commented Jul 19, 2022

fix #802, fix #799, fix #541, fix #599, fix #507

fix transformer_constant_efficiency_fix to accept multiple inputs OR multiple outputs.

Changes proposed in this pull request:

  • transformer_constant_efficiency_fix and transformer_constant_efficiency_optimize accepts multiple in/outputs.

transformer_constant_efficiency_fix

  • For multiple inputs, "DISPATCH_PRICE"s (variable_costs) and EFFICIENCY (conversion_factors parameter of Transformer object) are assigned to input flows and "INSTALLED_CAP"s (nominal_values) are assigned to output.
  • For multiple outputs, same as above but DISPATCH_PRICE and EFFICIENCY are provided to output flows and input flow is left empty
  • if the values of the parameters DISPATCH_PRICE, EFFICIENCY are not provided as a list, there is an error raised
  • the case multiple input and multiple output (like a CHP) hasn't been covered yet

transformer_constant_efficiency_optimize

  • For multiple inputs, DISPATCH_PRICEs (variable_costs) and EFFICIENCY (conversion_factors parameter of Transformer object) are assigned to input flows and INSTALLED_CAP (existing parameter of Investment object), MAXIMUM_ADD_CAP (maximum parameter of Investment object) and SIMULATION_ANNUITY (ep_costs parameter of Investment object) are assigned to output.
  • For multiple outputs, same as above but DISPATCH_PRICE and EFFICIENCY are provided to output flows and input flow is left empty
  • if the values of the parameters DISPATCH_PRICE, EFFICIENCY are not provided as a list, there is an error raised
  • the case multiple input and multiple output (like a CHP) hasn't been covered yet

The following steps were realized, as well (if applies):

  • Use in-line comments to explain your code
  • Write docstrings to your code (example docstring)
  • For new functionalities: Explain in readthedocs
  • Write test(s) for your new patch of code (pytests, assertion debug messages)
  • Update the CHANGELOG.md
  • Apply black (black . --exclude docs/)
  • Check if benchmark tests pass locally (EXECUTE_TESTS_ON=master pytest)

For more information on how to contribute check the CONTRIBUTING.md.

@Bachibouzouk Bachibouzouk force-pushed the fix/multiple_in_out_transformer branch from f6c7620 to 09da536 Compare August 16, 2022 13:51
@Bachibouzouk
Copy link
Collaborator

Multiple outputs and one input

mvs_tool -i tests/benchmark_test_inputs/Feature_output_flows_as_list -ext csv -f

t1 = solph.Transformer(
  label='diesel_generator',
  inputs={Electricity (diesel): solph.Flow(max=1, min=0)},
  outputs={Electricity: solph.Flow(variable_costs=0.3, max=1, nominal_value=1250, min=0), Heat: solph.Flow(variable_costs=0.5, max=1, nominal_value=1250, min=0)},
  conversion_factors={Electricity: [0.3], Heat: [0.5], Electricity (diesel): [1]},
)

Multiple inputs and one output

t1 = solph.Transformer(
  label='diesel_generator',
  inputs={Electricity (diesel): solph.Flow(min=0, max=1), Electricity: solph.Flow(min=0, variable_costs=0.15, max=1)},
  outputs={Electricity: solph.Flow(nominal_value=1250, min=0, max=1)},
  conversion_factors={Electricity (diesel): [0.6], Electricity: [1]},
)

If the transformer has multiple input or multiple output, it
is expected that the parameter dispatch_price as well as efficiency
is provided twice

Co-authored-by: 19248728+NargesChinichian@users.noreply.github.com
@Bachibouzouk Bachibouzouk force-pushed the fix/multiple_in_out_transformer branch from f762ea1 to 5266358 Compare August 19, 2022 12:47
This flagged as failed with newest version of pytest, as it also passed
with older version it make sense to change it anyway
@Bachibouzouk Bachibouzouk force-pushed the fix/multiple_in_out_transformer branch from 91bf56a to 44dbbe5 Compare August 22, 2022 09:01
CHANGELOG.md Outdated
@@ -61,6 +61,7 @@ Here is a template for new release sections
- Calculation of `total_feedin` and `total_consumption_from_providers`, where multiple providers of one energy carrier were not aggregated correctly (#931)
- Used `pandas.concat` instead of `DataFrame.append` to add rows to a `pandas.DataFrame` instance to suppress UserWarning (#937)
- Add missing file for test `test_F0_output.TestLogCreation.test_parse_simulation_log` (#937)
- Transformers can have multiple input or output busses (#949)
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe include and refer to where this is tested?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Done

@Bachibouzouk
Copy link
Collaborator

I only changed the changelog and the tests did not trigger, I will merge as the previous status was passing

@Bachibouzouk Bachibouzouk merged commit 040d1e3 into dev Sep 8, 2022
@Bachibouzouk Bachibouzouk deleted the fix/multiple_in_out_transformer branch September 8, 2022 06:39
@Bachibouzouk Bachibouzouk mentioned this pull request Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment