Skip to main content

ESCLAB

Engineering Simulation and Control Lab

This software provides an environment for time-series simulation and control of complex multi-component systems. The approach used here relies on iterative (successive substitution) solving to converge on values for a given step, allowing compartmentalization of calculations between individual system components.

The simulation is configured and managed in Python scripts.

A graphical plotting interface provides real-time simulation results and a network topology rendering tool.

The software is structured to support both research and teaching activities and is used in the upper-graduate course "ME 964: Simulation and Optimal Control of Energy Systems" at the University of Wisconsin-Madison.

Installation

  1. Download and install a Python package manager. This program was developed using miniconda, and it's recommended for environment creation and maintenance.

  2. Download and install VS Code (or your favorite Python IDE, though VS Code is currently recommended)

  3. Open a command console and create a new conda environment. You can call this what you'd like, but I assume the name 'esclab_dev' in the documentation:

# Create and activate a new conda environment
conda create -n esclab_dev python=3.13
conda activate esclab_dev

Installing from source code

Use this option when you plan on extending the component or model libraries with code that will closely integrate. This allows direct modification of the ESCLab source code and incorporation of the latest updates that are pushed to the GitHub repository.

  1. Change to a convenient location for the repository. A path with no spaces is recommended.
cd C:\repositories
  1. Collect the ESCLab package source code. If you're using git, clone the repository. Otherwise, you can download and unzip the repository.
# Clone
git clone https://github.com/uw-esolab/esclab.git
  1. Install the ESCLab project to the python package you just created.
# The -e flag makes the installation editable.
pip install -e .
# ESCLab currently requires the most recent version of EESLib (published by uw-esolab). 
# Clone and install the editable version to this conda environment. 
# Make sure C:\repositories is replace with the path to your repository directory.
pip install -e C:\repositories\eeslib
# Ensure the editable version is correctly installed in esclab_dev.
python -c "import eeslib; print(eeslib.__file__)"

Installing from the package manager (PyPi)

Do this instead of the source code option if you're happy with a relatively stable release of the ESCLab core source code and will only be developing models and components for your own use without intending to share them as part of the ESCLab distribution.

Following step #3 above:

  1. Install the package using pip:
pip install esclab

Getting started

  • Source code for constructing and simulating models is found in the /src/esclab directory
  • Components are defined in the /src/esclab/components folder
  • Models are defined in the /src/esclab/models folder

To create a new model, prepare one or more component files that contain instance(s) of Component classes that are units in the system you want to model. Connect components together in a model file.

Templates and examples for Components and Models are provided in their respective folders.

  • template_model.py provides a template for building new system models
  • template_component.py provides a template for a component library
  • sample_circuit_secsub.py gives and example of a simple solve loop using successive substitution (no coupled equations)
  • sample_circuit.py gives an equivalent example using the coupled equation approach. sample_circuit_tee.py, and sample_circuit_hilopass.py also give examples of solving coupled equations for increasingly complex topologies.

The main calculation and plotting scripts are:

  • simulate.py | core simulation engine
  • network_topology.py | tools for detecting, organizing, and rendering coupled network systems
  • online_plotter.py | Qt-based window for real-time plotting

Definitions:

Term Definition
Component Building block for a system model. Components take input and compute output values, and they connect with other components
Model Collection of one or more components together into a simulated system
Simulation Time-dependent evaluation of a model
Step Calculations done at a specific value in time. A simulation contains many steps
Coupled equations Equations that are designated to be solved together using matrix inversion, outside of the normal successive-substitution method
Absolute tolerance Absolute difference between connection values on succesive iterations
Relative tolerance Difference relative to the magnitude of the last connection value
Learning rate Fraction of the difference between the new and old computed values to apply when iterating

Uploading a new version to PyPi (developers only!)

To upload a new version of ESCLab to Pypi, follow the steps outlined in the Python packaging tutorial.

The preferred packaging tool is setuptools.

The most relevant steps are as follows:

  1. Don't forget to update the code version number in pyproject.toml and in the src/__init__.py file.

  2. Open a command window and navigate to the esclab directory, such as

    cd C:\repositories\esclab
    
  3. Ensure the build and packaging tools are installed in the Conda environment that you're using. The preferred method will install a developer tools, including build, pytest, and twine, specified in the pyproject.toml file in the esclab directory:

    pip install .[dev]
    

    Alternatively, you can manually install packages:

    python -m pip install --upgrade build 
    python -m pip install --upgrade twine
    
  4. Build the Python distributable

    python -m build
    

    This should create a folder dist/ that contains a wheel (.whl) and tar.gz file.

  5. Upload the file to Pypi. You will need to have first created a username and API token, following the packing tutorial instructions. If uploading to the production server, use the command:

    twine upload dist/*
    

    If you receive the warning WARNING This environment is not supported for trusted publishing, you can ignore it.

    If using the test server, use the command:

    python -m twine upload --repository testpypi dist/*
    

    To test installation from the test server in a new, temporary environment:

    conda create -n test_esclab python=3.13
    conda activate test_esclab
    pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ esclab==0.0.1
    
    python -c "import esclab; print(esclab.__file__);"
    >> C:\Users\username\AppData\Local\miniconda3\envs\test_esclab\Lib\site-packages\esclab\__init__.py
    
    conda activate base
    conda env remove -n test_esclab
    
  6. To install the package, activate the Conda environment (e.g., conda activate esclab_dev), and install. If running from the production environment use:

    pip install esclab
    

    If you have previous versions of esclab already installed, force use of the most recent version using:

    pip install --force-reinstall --upgrade esclab
    

Authors

Lead author: Mike Wagner | Associate Professor, University of Wisconsin-Madison | GitHub: uw-esolab | Profile

Contributors:

Download files

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

Source Distribution

esclab-0.0.3.tar.gz (74.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

esclab-0.0.3-py3-none-any.whl (76.6 kB view details)

Uploaded Python 3

File details

Details for the file esclab-0.0.3.tar.gz.

File metadata

  • Download URL: esclab-0.0.3.tar.gz
  • Upload date:
  • Size: 74.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.13

File hashes

Hashes for esclab-0.0.3.tar.gz
Algorithm Hash digest
SHA256 9b5948dc2fd71a4bd0451ec6b9f5be8b09d09f3df65983fbc9db0540232e2677
MD5 c90f4f78532f80b17c320b685ae914d5
BLAKE2b-256 d6b84672745529aaf146bc92383f58c246da631449f1f8404be7a6beb06519a2

See more details on using hashes here.

File details

Details for the file esclab-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: esclab-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 76.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.13

File hashes

Hashes for esclab-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe969a6d9f2b848b563c844ee574ddfce306aed23eb97417ae680d940418e07
MD5 8001fe46464737454e1b17ff337737e6
BLAKE2b-256 3e335ffd1f5af9347c62f63341bae14f6bff33b18cf2c912e113b7330903452a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page