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

Features/network 0.5 #836

Merged
merged 119 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
3389af5
Rename oemof.network.network.Node to Entity
p-snft Apr 5, 2022
2bf771e
Adhere to Black style
p-snft Apr 5, 2022
91eb8e1
Merge branch 'dev' into features/network-0-5
p-snft Sep 26, 2022
21c721d
Remove node.registry from constraint tests
p-snft Sep 26, 2022
5a2197b
Disuse of oemof.network.Node.registry
p-snft Sep 27, 2022
2ef25fe
Clean up imports
p-snft Sep 27, 2022
31d9fee
Merge branch 'revision/remove_node_registry' into features/network-0-5
p-snft Sep 27, 2022
b4fc959
Require oemof.network v0.5
p-snft Sep 27, 2022
6c5ae8d
Leave old information in whatsnew of old version
p-snft Oct 18, 2022
56a0b13
Start with max keyword
joroeder Nov 9, 2022
6bb4e03
Make kwargs explicit in generic storage component
e-zolotarevskaya Nov 9, 2022
633999a
Make kwargs explicit in generic storage component
e-zolotarevskaya Nov 9, 2022
d2cd829
Merge branch 'dev' into Features/Make_kwargs_explicit
joroeder Nov 9, 2022
931fba0
Merge branch 'dev' into features/explicit_kwargs
e-zolotarevskaya Nov 9, 2022
36baa83
Fix long lines
e-zolotarevskaya Nov 9, 2022
d1386ce
Add label, inputs, outputs arguments
e-zolotarevskaya Nov 9, 2022
31e6762
Fix make max explicit
joroeder Nov 10, 2022
c74f782
Fix black
joroeder Nov 10, 2022
e3f8f28
Add dict template for all allowed attributes
joroeder Nov 10, 2022
bd6b88f
Merge branch 'oemof:dev' into features/explicit_kwargs
e-zolotarevskaya Nov 10, 2022
efa9e21
create difference for initial pr
DFuh Nov 10, 2022
de7a994
Separate positional arguments, remove deprecation warning
e-zolotarevskaya Nov 10, 2022
e088d84
Add default values for all keyword arguments
e-zolotarevskaya Nov 10, 2022
93831a6
Add default values for all keyword arguments
e-zolotarevskaya Nov 10, 2022
b50d1c9
insert explicit kwargs for _transformer
DFuh Nov 10, 2022
357ea1d
Make Sink kwargs explicit
jnnr Nov 10, 2022
0381a9a
Make kwargs explicit for Source component
srhbrnds Nov 10, 2022
1c27995
Add explanation in docstring of ransformer class
DFuh Nov 10, 2022
6a00bf8
Add explanation in docstring of ransformer class
DFuh Nov 10, 2022
4ab9943
remove *args and **kwargs in init of Transformer class
DFuh Nov 10, 2022
eeeb414
Merge branch 'df_mk_kwargs_xplct' of github.com:DFuh/oemof-solph into…
DFuh Nov 10, 2022
a5bc673
Delete *args from _source.py
srhbrnds Nov 10, 2022
e268ad8
Delete whitespaces
srhbrnds Nov 10, 2022
f6f8727
Replace old strcture by explicit kw
joroeder Nov 10, 2022
8eb0575
Fix black
joroeder Nov 10, 2022
178d849
Make black happier
joroeder Nov 10, 2022
cb2acfb
Add inputs outpouts to docstring
DFuh Nov 10, 2022
b839452
Clean code
DFuh Nov 10, 2022
b82c5f9
Resolve checks
DFuh Nov 10, 2022
e25092e
Update docstring for Source object
srhbrnds Nov 10, 2022
d5b68e0
Delete uncommented code
joroeder Nov 10, 2022
9310d5c
Delete kwargs from Source object
srhbrnds Nov 10, 2022
da6afa4
add kwarg options to Transformer
DFuh Nov 10, 2022
ab601e0
add function in _helpers to raise warning for missing attr
DFuh Nov 10, 2022
5139dcf
Update Example in docstring
srhbrnds Nov 10, 2022
3526d2a
Update docstring
srhbrnds Nov 10, 2022
c5695b2
Extend docstring of Sink
jnnr Nov 10, 2022
9bd06d9
Update docstring
srhbrnds Nov 10, 2022
2045588
Merge branch 'features/make-kwargs-explicit-source' of https://github…
srhbrnds Nov 10, 2022
b5091d8
add description for options in docstring
DFuh Nov 10, 2022
6742e5a
add warning for missing attributes
DFuh Nov 10, 2022
a4cd825
fix black
DFuh Nov 10, 2022
87f949f
Fix summed_min summed_max attributes
joroeder Nov 10, 2022
0084e13
Remove errors of old attributes
joroeder Nov 10, 2022
fa25290
Remove summed_max summed_min from need-nominal-value
joroeder Nov 10, 2022
671ba5f
Adapt failing tests
srhbrnds Nov 10, 2022
5e17f73
Add default values for inputs, outputs and label
e-zolotarevskaya Nov 10, 2022
d5848c6
Fix constraint tests
Nov 10, 2022
bd9f933
Explain variable costs better in docstring
joroeder Nov 11, 2022
3cc18d7
Remove unused import
joroeder Nov 11, 2022
ac82942
Remove redundant warning
joroeder Nov 11, 2022
36b8e83
Remove obsolete comments
joroeder Nov 11, 2022
08e001b
Revise docstring
joroeder Nov 11, 2022
569bf4c
Add author dafu
joroeder Nov 11, 2022
5183e12
Remove options
joroeder Nov 11, 2022
dff88b1
Remove options from docstring
joroeder Nov 11, 2022
10dc9a8
Fix imports
joroeder Nov 11, 2022
533e6ef
Fix black
joroeder Nov 11, 2022
08524d8
Add tests for creating empty dict if inputs or outputs are None
joroeder Nov 11, 2022
45e51b4
Finalise Flow API
p-snft Nov 11, 2022
9191e0a
Merge branch 'features/make-kwargs-explicit-flow' of github.com:oemof…
p-snft Nov 11, 2022
3bc583b
Merge branch 'dev' into features/make-kwargs-explicit-flow
p-snft Nov 11, 2022
b6dd47d
Move tests to transformer test class
joroeder Nov 11, 2022
2a8aae0
Merge pull request #891 from oemof/features/make-kwargs-explicit-tran…
joroeder Nov 11, 2022
816eb7d
Fix remaining tests
p-snft Nov 11, 2022
929f2ad
Fix import orders
p-snft Nov 11, 2022
a435c9e
Adhere to Black
p-snft Nov 11, 2022
8167be0
Remove unused imports
p-snft Nov 11, 2022
5d6f20d
Adhere to maximum line length
p-snft Nov 11, 2022
b398192
Remove errorous word from docstring
p-snft Nov 11, 2022
4d50cba
Adapt examples for explicit Flow kwargs
p-snft Nov 12, 2022
3ddba6a
Adapt other docstrings for explicit Flow kwargs
p-snft Nov 12, 2022
5e20d70
Change format
p-snft Nov 12, 2022
82d8cdf
Fix format of integral_limit docstring
p-snft Nov 12, 2022
ffec399
Merge pull request #881 from oemof/features/make-kwargs-explicit-flow
p-snft Nov 12, 2022
681a35a
Merge pull request #878 from e-zolotarevskaya/features/explicit_kwargs
p-snft Dec 2, 2022
7e722a0
Disuse check_node_object_for_missing_attribute in Source
p-snft Dec 2, 2022
f97ec94
Adhere to black
p-snft Dec 2, 2022
33d6861
Remove test_generic_storage_with_old_parameters
p-snft Dec 2, 2022
ebf73ba
Fix import orders
p-snft Dec 2, 2022
319bca6
Merge pull request #886 from oemof/features/make-kwargs-explicit-source
p-snft Dec 2, 2022
b2bfa73
Disuse check_node_object_for_missing_attribute in Sink
p-snft Dec 2, 2022
23441ac
Adhere to black
p-snft Dec 2, 2022
e78208f
Fix test of warning for missing inputs of Sink
p-snft Dec 2, 2022
f49e867
Merge branch 'features/make-kwargs-explicit' into features/sink-kwarg…
p-snft Dec 2, 2022
59a0ef7
Adhere to Black
p-snft Dec 2, 2022
c7b5dda
Fix Sink docsting
p-snft Dec 2, 2022
0749930
Shorten Sink docsting
p-snft Dec 2, 2022
43dc41b
Merge pull request #885 from oemof/features/sink-kwargs-explicit
p-snft Dec 2, 2022
ee035ff
Disuse **kwargs in Sink and Source
p-snft Dec 2, 2022
56bf7dc
Disuse **kwargs in Investment
p-snft Dec 2, 2022
38a684f
Fix Invest tests
p-snft Dec 2, 2022
bf7b2be
Make NonConvex kwargs partly explicit
p-snft Dec 2, 2022
70b5e19
Fix docstring of additional_investment_flow_limit
p-snft Dec 7, 2022
36b6126
Fix link to tox installation doc
p-snft Dec 7, 2022
7f1b538
Make remaining kwargs of NonConvex explicit
p-snft Dec 8, 2022
a341ab8
Make kwargs explicit for GenericCHP
p-snft Dec 8, 2022
153f05c
Make kwargs explicit for ExtractionTurbineCHP
p-snft Dec 8, 2022
54dc5f6
Make kwargs explicit for OffsetTransformer
p-snft Dec 8, 2022
dea60dd
Test suspicious usage of sink and source
p-snft Dec 8, 2022
27b56bf
Merge branch 'dev' into features/make-kwargs-explicit
p-snft Dec 9, 2022
d78ed74
Add tests for NonConvex option
p-snft Dec 10, 2022
a06e0d8
Simplify NonConvex.minimum_down- and -uptime
p-snft Dec 10, 2022
36ca80a
Add test for Flow.fix
p-snft Dec 10, 2022
6ee60b4
Add test for missing nominal_value in Flow
p-snft Dec 10, 2022
6489442
Fix import orders
p-snft Dec 10, 2022
b2cebdc
Merge branch 'dev' into features/network-0-5
p-snft Dec 21, 2022
4d16383
Merge branch 'features/make-kwargs-explicit' into features/network-0-5
p-snft Dec 22, 2022
5a84c03
Limit numpy version
p-snft Dec 25, 2022
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
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Authors
* Clemens Wingenbach
* Cord Kaldemeyer
* Daniel Rank
* David Fuhrländer
* Elisa Gaudchau
* Elisa Papadis
* Fabian Büllesbach
Expand Down
5 changes: 4 additions & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,10 @@ This small example of PV, grid and SinkDSM shows how to use the component

# Create Energy System
es = solph.EnergySystem(timeindex=datetimeindex)
Node.registry = es

# Create bus representing electricity grid
b_elec = solph.buses.Bus(label='Electricity bus')
es.add(b_elec)

# Create a back supply
grid = solph.components.Source(label='Grid',
Expand All @@ -822,6 +822,7 @@ This small example of PV, grid and SinkDSM shows how to use the component
nominal_value=10000,
variable_costs=50)}
)
es.add(grid)

# PV supply from time series
s_wind = solph.components.Source(label='wind',
Expand All @@ -830,6 +831,7 @@ This small example of PV, grid and SinkDSM shows how to use the component
fix=data['pv'],
nominal_value=3.5)}
)
es.add(s_wind)

# Create DSM Sink
demand_dsm = solph.custom.SinkDSM(label="DSM",
Expand All @@ -843,6 +845,7 @@ This small example of PV, grid and SinkDSM shows how to use the component
max_capacity_down=1,
approach="DIW",
cost_dsm_down=5)
es.add(demand_dsm)

Yielding the following results

Expand Down
9 changes: 7 additions & 2 deletions examples/emission_constraint/emission_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def main():
bel: solph.Flow(
nominal_value=100,
variable_costs=10,
emission_factor=0.01,
fix=[0.1, 0.2, 0.3],
custom_attributes={"emission_factor": 0.01},
)
},
)
Expand All @@ -58,7 +58,12 @@ def main():
energysystem.add(
solph.components.Source(
label="gas-source",
outputs={bgas: solph.Flow(variable_costs=10, emission_factor=0.2)},
outputs={
bgas: solph.Flow(
variable_costs=10,
custom_attributes={"emission_factor": 0.2},
)
},
)
)

Expand Down
90 changes: 50 additions & 40 deletions examples/flow_count_limit/flow_count_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ def main():
energy_system = solph.EnergySystem(
timeindex=pd.date_range("1/1/2012", periods=4, freq="H")
)
Node.registry = energy_system

bel = solph.Bus(label="bel")
energy_system.add(bel)

# There are a sink and a source, both creating a revenue (negative cost),
# so it would be optimal to use both at the same time. To suppress this,
Expand All @@ -48,54 +48,64 @@ def main():
# ...)
# But also any existing one (e.g. "emission_factor") can be used.

solph.components.Source(
label="source1",
outputs={
bel: solph.Flow(
nonconvex=solph.NonConvex(),
nominal_value=210,
variable_costs=[-1, -5, -1, -1],
max=[1, 1, 1, 0],
my_keyword=True,
)
},
energy_system.add(
solph.components.Source(
label="source1",
outputs={
bel: solph.Flow(
nonconvex=solph.NonConvex(),
nominal_value=210,
variable_costs=[-1, -5, -1, -1],
max=[1, 1, 1, 0],
custom_attributes={"my_keyword": True},
)
},
)
)

# Note: The keyword is also defined when set to False.
solph.components.Sink(
label="sink1",
inputs={
bel: solph.Flow(
nonconvex=solph.NonConvex(),
variable_costs=[-2, -1, -2, -2],
nominal_value=250,
max=[1, 1, 1, 0],
my_keyword=False,
)
},
energy_system.add(
solph.components.Sink(
label="sink1",
inputs={
bel: solph.Flow(
nonconvex=solph.NonConvex(),
variable_costs=[-2, -1, -2, -2],
nominal_value=250,
max=[1, 1, 1, 0],
custom_attributes={"my_keyword": False},
)
},
)
)

# Should be ignored because my_keyword is not defined.
solph.components.Source(
label="source2",
outputs={
bel: solph.Flow(
variable_costs=1,
nonconvex=solph.NonConvex(),
max=[1, 1, 1, 0],
nominal_value=145,
)
},
energy_system.add(
solph.components.Source(
label="source2",
outputs={
bel: solph.Flow(
variable_costs=1,
nonconvex=solph.NonConvex(),
max=[1, 1, 1, 0],
nominal_value=145,
)
},
)
)

# Should be ignored because it is not NonConvex.
solph.components.Sink(
label="sink2",
inputs={
bel: solph.Flow(
my_keyword=True, fix=[0, 1, 1, 0], nominal_value=130
)
},
energy_system.add(
solph.components.Sink(
label="sink2",
inputs={
bel: solph.Flow(
custom_attributes={"my_keyword": True},
fix=[0, 1, 1, 0],
nominal_value=130,
)
},
)
)

model = solph.Model(energy_system)
Expand Down
5 changes: 4 additions & 1 deletion examples/generic_invest_limit/example_generic_invest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
import logging
import os

import matplotlib.pyplot as plt
try:
import matplotlib.pyplot as plt
except ModuleNotFoundError:
plt = None

from oemof import solph

Expand Down
4 changes: 2 additions & 2 deletions examples/gradient_example/gradient_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def main():
outputs={
bel: flows.Flow(
nominal_value=10e5,
negative_gradient={"ub": gradient},
positive_gradient={"ub": gradient},
negative_gradient_limit=gradient,
positive_gradient_limit=gradient,
)
},
conversion_factors={bel: 0.58},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ def heat_demand(d):
max=1.0,
min=0.9,
variable_costs=0.1,
minimum_uptime=5,
initial_status=1,
nonconvex=solph.NonConvex(
minimum_uptime=5,
initial_status=1,
),
investment=solph.Investment(
ep_costs=epc,
minimum=1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ def solar_thermal(d):
min=0.4,
max=1.0,
variable_costs=0.1,
minimum_uptime=2,
initial_status=1,
nonconvex=solph.NonConvex(),
nonconvex=solph.NonConvex(
minimum_uptime=2,
initial_status=1,
),
)
},
)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ def read(*names, **kwargs):
install_requires=[
"blinker",
"dill",
"numpy",
"numpy < 1.24",
Copy link
Member

Choose a reason for hiding this comment

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

You are working on making it support never numpy versions, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

In my opinion, this should be done before the release of v0.5. However, as the problem was just discovered here, it should be fixed in another PR.

"pandas",
"pyomo >= 6.0.0, < 7.0",
"networkx",
"oemof.tools >= 0.4.2",
"oemof.network",
"oemof.network >= 0.5.0a1",
],
extras_require={
"dev": [
Expand Down
24 changes: 15 additions & 9 deletions src/oemof/solph/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
SPDX-FileCopyrightText: Cord Kaldemeyer
SPDX-FileCopyrightText: Stephan Günther
SPDX-FileCopyrightText: Birgit Schachler
SPDX-FileCopyrightText: David Fuhrländer
SPDX-FileCopyrightText: Johannes Röder

SPDX-License-Identifier: MIT

Expand All @@ -29,12 +31,16 @@ def check_node_object_for_missing_attribute(obj, attribute):

"""
if not getattr(obj, attribute):
msg = (
"Attribute <{0}> is missing in Node <{1}> of {2}.\n"
"If this is intended and you know what you are doing you can"
"disable the SuspiciousUsageWarning globally."
)
warn(
msg.format(attribute, obj.label, type(obj)),
debugging.SuspiciousUsageWarning,
)
warn_if_missing_attribute(obj, attribute)


def warn_if_missing_attribute(obj, attribute):
msg = (
"Attribute <{0}> is missing in Node <{1}> of {2}.\n"
"If this is intended and you know what you are doing you can"
"disable the SuspiciousUsageWarning globally."
)
warn(
msg.format(attribute, obj.label, type(obj)),
debugging.SuspiciousUsageWarning,
)
10 changes: 2 additions & 8 deletions src/oemof/solph/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,21 +348,15 @@ def _add_parent_block_sets(self):
)

self.BIDIRECTIONAL_FLOWS = po.Set(
initialize=[
k
for (k, v) in self.flows.items()
if hasattr(v, "bidirectional")
],
initialize=[k for (k, v) in self.flows.items() if v.bidirectional],
ordered=True,
dimen=2,
within=self.FLOWS,
)

self.UNIDIRECTIONAL_FLOWS = po.Set(
initialize=[
k
for (k, v) in self.flows.items()
if not hasattr(v, "bidirectional")
k for (k, v) in self.flows.items() if not v.bidirectional
],
ordered=True,
dimen=2,
Expand Down
Loading