Skip to main content

Optimization of District Heating Networks

Project description

Latest version Python versions License Build status

Optimization of District Heating Networks

This package provides the solver server.

Installation

Install redis

It should be available from the package manager in most Linux distributions.

aptitude install redis

Install ipopt

Install dependencies:

aptitude install make g++ gfortran pkgconf liblapack-dev

Use coinbrew to fetch and compile Ipopt and dependencies:

# Run as unprivileged user
git clone --depth=1 https://github.com/coin-or/coinbrew
cd coinbrew
./coinbrew Ipopt:releases/3.13.4 fetch
./coinbrew build Ipopt

Copy files to project directory:

cp -r ./coinbrew/dist /path/to/project/ipopt

Install pyodhean

Use pip:

pip install pyodhean-server

pyodhean-server supports Python >= 3.7.

Development configuration

Launch solver server

Add path to ipopt to the PATH (should be added to .bashrc):

export PATH=$PATH:/path/to/project/ipopt/bin/

Check ipopt is correctly installed:

ldd `which ipopt`
ipopt -v

Launch worker:

celery -A pyodhean_server worker

Configure and launch web API server

# Set FLASK_ENV variable
export FLASK_ENV=development

# Alternatively, use a .env file
echo "FLASK_ENV=development" > .env

# Run application
flask run

Production configuration

Configure and launch web API server

The following lines explain hwo to run pyodhean server with apache. They do not cover creating and using an SSL certificate.

Copy apache2 directory from docs/deployment/etc into /etc.

Create a pyodhean directory to hold the application files.

Create a Pyhton 3 virtual environment in the pyodhean directory:

virtualenv -p /usr/bin/python3 venv-pyodhean

Pull code from pyodhean and pyodhean-server repositories and install them in the virtual environment:

source venv-pyodhean/bin/activate
pip install ./pyodhean
pip install ./pyodhean-server

Copy files from docs/deployment/pyodhean into the pyodhean directory.

Customize them if needed. At least the path to the virtual environment must be specified.

Make sure settings.conf can be read by apache user:

chown root:www-data application/settings.conf
chmod 640 application/settings.conf

The pyodhean directory should look like this::

pyodhean/
    application/
        application.wsgi
        settings.conf
    venv-pyodhean
    pyodhean
    pyodhean-server

Note: The pyodhean and pyodhean-server repositories can be stored anywhere. They do not have to be in the pyodhean directory.

Edit /etc/apache2/sites-available/pyodhean.conf.

Reload apache2.

The API should be available as https://domain.tld/api/v0/.

Create directories to store log files:

mkdir /var/log/pyodhean
chmod pyodhean:pyodhean /var/log/pyodhean

Configure and launch solver service

Create pyodhean user:

adduser --system --no-create-home --group pyodhean

Create log directory:

mkdir -m 755 /var/log/pyodhean-celery
chown pyodhean:pyodhean /var/log/pyodhean-celery

Copy systemd directory from docs/deployment/etc into /etc.

Edit pyodhean-celery configuration file to specify the paths.

/etc/systemd/system/pyodhean-celery.service.d/pyodhean-celery.conf

Start the service and enable it for automatic start on system startup:

systemctrl enable pyodhean-celery
systemctrl start pyodhean-celery

Configure log files rotation

Copy logrotate.d directory from docs/deployment/etc into /etc.

Configure authentication

Create a users DB file the apache user can read:

touch /path/to/project/users.db
chown root:www-data /path/to/project/users.db
chmod 640 /path/to/project/users.db

Add users to the DB file:

source venv-pyodhean/bin/activate
export FLASK_APP=pyodhean_server.app
flask add-user /path/to/project/users.db user password

Edit application configuration to enable authorization and pass users BD file:

AUTH_ENABLED=True
AUTH_USERS=/path/to/project/users.db

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyodhean-server-1.0.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

pyodhean_server-1.0.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file pyodhean-server-1.0.0.tar.gz.

File metadata

  • Download URL: pyodhean-server-1.0.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for pyodhean-server-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e435757d1df0138ace3bfdae29469cd066613726c97631ed0ce9cb4386df5209
MD5 21a99bac39b188b7e3fe42db21280b4d
BLAKE2b-256 3edd19759a11b22f5d707bed5634b45c2e4fe7a141243a862efff53ae24e9790

See more details on using hashes here.

Provenance

File details

Details for the file pyodhean_server-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyodhean_server-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.3

File hashes

Hashes for pyodhean_server-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3f85a4eb0039394c7548db90b0e6a20dcc11b573c4151c500522fd34a7e084c
MD5 181d956ef98fcae21f2a1b2388018271
BLAKE2b-256 965912ca082067c3ea7fc2b6b8c55e859351f04425e26648a4b869d348b9d227

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page