This tool is the Django-based implementation of the already existing Offgridplanner tool, which originated from the PeopleSun project and was originally written using FastAPI. The optimizer code is hosted separately in the optimizer-offgridplanner repository.
The open-source tool originated from the PeopleSuN project and serves the planning of off-grid systems in Nigeria. The tool aims to perform a spatial optimization of the distribution grid as well as the design of the energy converters and energy storage.
The features of the tool are listed below:
- Automatic Identification of Buildings from OpenStreetMap: Utilizes OpenStreetMap data to automatically identify building locations.
- Spatial Optimization of the Distribution Grid: Enhances the efficiency of the distribution grid through spatial optimization techniques.
- Design Optimization of Generation Systems: Optimizes the design of PV systems, battery systems, inverters, and diesel-engines.
- Automatic Identification for Individual Solar Home Systems: Identifies buildings that are more suitably served by individual solar home systems.
The energy system and grid optimizations are performed on a dedicated server, where the Offgridplanner app will send the requests to and fetch the results from. More information and deployment instructions for the simulation server can be found in the optimizer-offgridplanner repository.
To perform the simulation, weather data is currently fetched through the renewables.ninja API. Therefore, you will need a user account and corresponding API token, which gets stored within an environment variable.
The application is composed of the following services:
django: the application running behind Gunicorn.postgres: PostgreSQL database with the application’s data.redis: Redis instance for caching.traefik: Traefik reverse proxy with HTTPS on by default.celeryworker: Dunning a Celery worker process.flower: To manage and monitor the celery task queue.
The environment variables for Docker are defined within the .envs folder. To build the container, open a terminal at
the project root and run the following for local development:
docker compose -f docker-compose.local.yml up -d --buildIf you want to emulate production environment use docker-compose.production.yml instead. For more information please
refer to the cookiecutter-django documentation.
Make sure you have the following installed:
- Python 3.12
- PostgreSQL
- Redis (you may have to install the Windows Subsystem for Linux (WSL) if developing on Windows)
- Mailpit
Then proceed to the next steps.
- Create a virtual environment using
python=3.12 - Activate your virtual environment
- Create a new postgreSQL database
- Define your environment variables (you can create a
.envfile at the root level, it will be read by Django)
POSTGRES_ENGINE=django.db.backends.postgresql
POSTGRES_DB=<your db name>
POSTGRES_USER=<your username>
POSTGRES_PASSWORD=<your password>
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
USE_DOCKER=(yes|no)
DJANGO_DEBUG=(True|False)
SIM_API_HOST=<simulation server address>
RN_API_HOST=https://www.renewables.ninja/api/
RN_API_TOKEN=<renewables.ninja API token>
- Execute the local_setup.sh file (
sh local_setup.sh/. local_setup.sh) - Start your local mail server in a new terminal with
mailpit. To view the UI, access http://127.0.0.1:8025/ - Start the local development server in a new terminal with
python manage.py runserver:)
For more information on developing locally, refer to the cookiecutter-django documentation.
For more information about Django settings.
