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

oemof.solph installation error #84

Open
HANSBIBI opened this issue Jul 28, 2023 · 2 comments
Open

oemof.solph installation error #84

HANSBIBI opened this issue Jul 28, 2023 · 2 comments

Comments

@HANSBIBI
Copy link

Hello community, after installing oemof.solph, I wanted to test the first example. Unfortunately I got an error message afterwards. What is my problem?

Traceback (most recent call last):
File "F:\python\0728\pf_oemof_0728.py", line 1, in
from oemof.solph import EnergySystem, Model, Bus, Flow, Source, Sink
ImportError: cannot import name 'Source' from 'oemof.solph' (G:\Python\Lib\site-packages\oemof\solph_init_.py)

add my pip list
Package Version


blinker 1.6.2
colorama 0.4.6
deepdiff 6.3.1
dill 0.3.7
networkx 3.1
numpy 1.25.1
oemof.network 0.5.0a1
oemof.solph 0.5.0
oemof.tools 0.4.2
ordered-set 4.1.0
packaging 23.1
pandapower 2.13.1
pandas 2.0.3
pip 23.1.2
ply 3.11
Pyomo 6.6.1
python-dateutil 2.8.2
pytz 2023.3
scipy 1.11.1
setuptools 65.5.0
six 1.16.0
tqdm 4.65.0
tzdata 2023.3

@HANSBIBI
Copy link
Author

and the example
from oemof.solph import EnergySystem, Model, Bus, Flow, Source, Sink
from oemof.solph.components import GenericStorage

创建时间索引,假设有24个小时

time_index = range(24)

创建能源系统对象

es = EnergySystem(timeindex=time_index)

创建电力总线

electricity_bus = Bus(label="electricity")

创建风力发电机

wind_generator = Source(
label="wind_generator",
outputs={electricity_bus: Flow(nominal_value=100, variable_costs=0)},
)

创建电力线路

transmission_line = Flow(
label="transmission_line",
bus_in=electricity_bus,
bus_out=Bus(label="electricity_output"),
nominal_value=150,
variable_costs=0.1,
)

创建负荷

load = Sink(
label="load",
inputs={electricity_bus: Flow(nominal_value=80, fixed=True)},
)

将组件添加到能源系统

es.add(electricity_bus, wind_generator, transmission_line, load)

创建模型对象

optimization_model = Model(es)

求解模型

optimization_model.solve()

查看模型结果

print("Wind power production:")
print(wind_generator["sequences"])
print("Transmission line flow:")
print(transmission_line["sequences"])
print("Load demand:")
print(load["sequences"])

@p-snft
Copy link
Member

p-snft commented Jul 30, 2023

Hi @HANSBIBI. You are using solph v0.5, the examples are for legacy versions of solph. For v0.5 (and following) we have moved them to the solph repository. See https://github.com/oemof/oemof-solph/tree/v0.5/examples for examples working with the version you have installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants