Django application to run oemof
Project description
Django-Oemof
Django-Oemof is a Django app to provide an API to build and optimize oemof.solph models and deliver results via JSON response.
Requirements
oemof.tabularhas to be installed- CBC solver has to be installed. Install it via (conda):
conda install -c conda-forge coincbc
Django project must use celery and automatically detect celery tasks. (follow https://docs.celeryq.dev/en/stable/django/first-steps-with-django.html to setup celery)
Quick start
-
Add "oemof" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [ ... 'rest_framework' 'django_oemof', ] -
Include the oemof URLconf in your project urls.py like this::
path('oemof/', include('django_oemof.urls')),
-
Run
python manage.py migrateto create the oemof models.
Configuration
You can set following configs via environment:
- DJANGO_OEMOF_IGNORE_SIMULATION_PARAMETERS list of parameter keys which shall be ignored when initializing a simulation
OEMOF Datapackages
Have to be put in folder oemof within djangos MEDIA_ROOT folder.
Name of datapackage folder is used in request for building ES.
Hooks
Hooks can be used to change default behaviour of parameter setup, energysystem build and model solving. This is done by defining custom functions which can be registered in django_oemof and are applied when simulating an ES. Depending on hook type (Parameter/Energysystem/Model), the defined custom functions are applied to parameters, build Es or after creating the model. See following flow chart for order of hooks:
Every hook is scenario-dependent to allow different hooks per scenario, but you can use hooks.ALL_SCENARIO as scenario to aplly hook to all scenarios.
An example hook (changing default behaviour of parameter setup) could be set up as follows:
from django_oemof import hooks
def converting_demand_to_kW(data):
data["demand"] = data["demand"] * 1000
return data
demand_kW_hook = hooks.Hook(scenario="dispatch", function=converting_demand_to_kW)
hooks.register_hook(hooks.HookType.PARAMETER, demand_kW_hook)
Tests
Run tests for standalone app via python runtests.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_oemof-0.18.2.tar.gz.
File metadata
- Download URL: django_oemof-0.18.2.tar.gz
- Upload date:
- Size: 418.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-52-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4009625a1b8574264402352830851d37995a62b188db31f5220b3f4d89430a2f
|
|
| MD5 |
ddae8480314e74b69311f6aa26787244
|
|
| BLAKE2b-256 |
3279aa5f6219106c28ec6f825471874b8bf0bda8ac6963167796c6dc471e101b
|
File details
Details for the file django_oemof-0.18.2-py3-none-any.whl.
File metadata
- Download URL: django_oemof-0.18.2-py3-none-any.whl
- Upload date:
- Size: 466.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-52-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5be7e1c62f6a51947c7fc22d6cbcd9638d66d2abf091a23009c62e6dd0c95164
|
|
| MD5 |
e329fca6bee15372e2e5b75e20b7bcb4
|
|
| BLAKE2b-256 |
b8b2f6dd8ebc56d5829696cc8ce52cef7e661991f179c12185d255d789eb770d
|