Skip to content

Commit

Permalink
Adjust a couple of examples according to new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Jul 14, 2023
1 parent f521d3d commit c278c5c
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 30 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def setup(app):
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
'sphinx_copybutton',
'sphinx_design',
"sphinx_copybutton",
"sphinx_design",
]
source_suffix = ".rst"
master_doc = "index"
Expand Down
9 changes: 9 additions & 0 deletions examples/activity_costs/activity_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
This is because it relies on the activity status of a component
which is only available for nonconvex flows.
Code
----
Download source code: :download:`activity_costs.py </../examples/activity_costs/activity_costs.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/activity_costs/activity_costs.py
:language: python
:lines: 41-116
Installation requirements
-------------------------
Expand Down
5 changes: 1 addition & 4 deletions examples/basic_example/basic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,18 @@
Code
----
Download source code: :download:`basic_example.py </../examples/basic_example/basic_example.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/basic_example/basic_example.py
:language: python
:lines: 58-301
:lines: 55-298
Data
----
Download data: :download:`basic_example.csv </../examples/basic_example/basic_example.csv>`
Installation requirements
-------------------------
This example requires oemof.solph (v0.5.x), install by:
Expand Down
39 changes: 24 additions & 15 deletions examples/dual_variable_example/dual_variable_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
A basic example to show how to get the dual variables from the system. Try
to understand the plot.
Code
----
Download source code: :download:`dual_variable_example.py </../examples/dual_variable_example/dual_variable_example.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/dual_variable_example/dual_variable_example.py
:language: python
:lines: 32-295
Installation requirements
-------------------------
Expand All @@ -19,28 +29,27 @@
SPDX-License-Identifier: MIT
"""
###########################################################################
# imports
###########################################################################

import pandas as pd
from matplotlib import pyplot as plt
from oemof.tools import logger

from oemof.solph import EnergySystem
from oemof.solph import Model
from oemof.solph import buses
from oemof.solph import components as cmp
from oemof.solph import flows
from oemof.solph import processing


def main():
# *************************************************************************
# ********** PART 1 - Define and optimise the energy system ***************
# *************************************************************************

###########################################################################
# imports
###########################################################################

import pandas as pd
from matplotlib import pyplot as plt
from oemof.tools import logger

from oemof.solph import EnergySystem
from oemof.solph import Model
from oemof.solph import buses
from oemof.solph import components as cmp
from oemof.solph import flows
from oemof.solph import processing

solver = "cbc" # 'glpk', 'gurobi',....
number_of_time_steps = 48
solver_verbose = False # show/hide solver output
Expand Down
10 changes: 10 additions & 0 deletions examples/electrical/lopf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
Note: As oemof currently does not support models with one timesteps, therefore
there are two.
Code
----
Download source code: :download:`lopf.py </../examples/electrical/lopf.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/electrical/lopf.py
:language: python
:lines: 40-217
Installation requirements
-------------------------
This example requires oemof.solph (v0.5.x), install by:
Expand Down
9 changes: 9 additions & 0 deletions examples/electrical/transshipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
This script shows how use the custom component `solph.custom.Link` to build
a simple transshipment model.
Code
----
Download source code: :download:`transshipment.py </../examples/electrical/transshipment.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/electrical/transshipment.py
:language: python
:lines: 36-208
Installation requirements
-------------------------
Expand Down
10 changes: 10 additions & 0 deletions examples/emission_constraint/emission_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
-------------------
Example that shows how to add an emission constraint in a model.
Code
----
Download source code: :download:`emission_constraint.py </../examples/emission_constraint/emission_constraint.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/emission_constraint/emission_constraint.py
:language: python
:lines: 30-127
Installation requirements
-------------------------
Expand Down
14 changes: 12 additions & 2 deletions examples/excel_reader/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@
The pandas package supports the '.xls' and the '.xlsx' format but one can
create read and adept the files with open source software such as libreoffice,
openoffice, gnumeric,...
openoffice, gnumeric, ...
Code
----
Download source code: :download:`dispatch.py </../examples/excel_reader/dispatch.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/excel_reader/dispatch.py
:language: python
:lines: 54-434
Data
----
scenario.xlsx
Download data: :download:`scenario.xlsx </../examples/excel_reader/scenario.xlsx>`
Installation requirements
-------------------------
Expand Down
14 changes: 10 additions & 4 deletions examples/flexible_modelling/add_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
The constraint we add forces a flow to be greater or equal a certain share
of all inflows of its target bus. Moreover we will set an emission constraint.
Code
----
Download source code: :download:`add_constraints.py </../examples/flexible_modelling/add_constraints.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/flexible_modelling/add_constraints.py
:language: python
:lines: 37-154
Installation requirements
-------------------------
This example requires oemof.solph (v0.5.x), install by:
Expand All @@ -24,10 +34,6 @@
`MIT license <https://github.com/oemof/oemof-solph/blob/dev/LICENSE>`_
"""

__copyright__ = "oemof developer group"
__license__ = "GPLv3"

import logging

import pandas as pd
Expand Down
10 changes: 9 additions & 1 deletion examples/flow_count_limit/flow_count_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@
Something...
Code
----
Download source code: :download:`flow_count_limit.py </../examples/flow_count_limit/flow_count_limit.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/flow_count_limit/flow_count_limit.py
:language: python
:lines: 29-149
Installation requirements
-------------------------
This example requires oemof.solph (v0.5.x), install by:
pip install oemof.solph[examples]
Expand Down
14 changes: 12 additions & 2 deletions examples/generic_invest_limit/example_generic_invest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
r"""
General description
-------------------
Example that shows how to use "Generic Investment Limit".
There are two supply chains. The energy systems looks like that:
Expand Down Expand Up @@ -32,6 +34,16 @@
And the total space is limited to 24.
See what happens, have fun ;)
Code
----
Download source code: :download:`example_generic_invest.py </../examples/generic_invest_limit/example_generic_invest.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/generic_invest_limit/example_generic_invest.py
:language: python
:lines: 60-217
Installation requirements
-------------------------
This example requires oemof.solph (v0.5.x), install by:
Expand All @@ -43,8 +55,6 @@
Johannes Röder <johannes.roeder@uni-bremen.de>
`MIT license <https://github.com/oemof/oemof-solph/blob/dev/LICENSE>`_
"""

import logging
Expand Down
9 changes: 9 additions & 0 deletions examples/gradient_example/gradient_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
Change the GRADIENT variable in the example to see the effect on the usage of
the storage.
Code
----
Download source code: :download:`gradient_example.py </../examples/gradient_example/gradient_example.py>`
.. dropdown:: Click to display code
.. literalinclude:: /../examples/gradient_example/gradient_example.py
:language: python
:lines: 33-209
Installation requirements
-------------------------
Expand Down

0 comments on commit c278c5c

Please sign in to comment.