Extension package to farn, adding support to build OSP simulation cases using FMUs
Project description
ospx
ospx is an extension package to farn, adding support to build OSP (co-)simulation cases using functional mockup units (FMUs).
ospx supports
- building of case-specific OSP (co-)simulation configuration files
- watching the progress of cosim, and saving final simulation results as a pandas dataframe.
Installation
pip install ospx
ospx requires the following (sub-)package:
- dictIO: foundation package, enabling ospx to handle configuration files in dictIO dict file format.
However, dictIO gets installed automatically with ospx.
Usage Example
ospx provides both an API for use inside Python as well as a CLI for shell execution of core functions.
Reading a caseDict file and building the case-specific OSP (co-)simulation configuration files:
from ospx import OspCaseBuilder
OspCaseBuilder.build('caseDict')
The above task can also be invoked from the command line, using the 'ospCaseBuilder' command line script installed with ospx:
ospCaseBuilder caseDict
For more examples and usage, please refer to ospx's documentation.
File Format
A caseDict is a file in dictIO dict file format used with farn.
For a documentation of the caseDict file format, see File Format in ospx's documentation on GitHub Pages.
For a detailed documentation of the dictIO dict file format used by farn, see dictIO's documentation on GitHub Pages.
Development Setup
-
Install Python 3.9 or higher, i.e. Python 3.10 or Python 3.11
-
Update pip and setuptools:
python -m pip install --upgrade pip setuptools
-
git clone the dictIO repository into your local development directory:
git clone https://github.com/dnv-opensource/ospx path/to/your/dev/ospx
-
In the ospx root folder:
Create a Python virtual environment:
python -m venv .venv
Activate the virtual environment:
..on Windows:
> .venv\Scripts\activate.bat
..on Linux:
source .venv/bin/activate
Update pip and setuptools:
(.venv) $ python -m pip install --upgrade pip setuptools
Install ospx's dependencies:
(.venv) $ pip install -r requirements-dev.txt
This should return without errors.
-
Setup your development environment to locate Python source codes:
For example, Visual Studio Code on Windows assumes the Python environment is specified in a
.env
file.
If you are developing and running the Python code from VSCode, make sure to create a.env
file in the mypackage root folder with below content.
Set the path forPROJ_DIR
to where your mypackage folder is on your system.
Note:.env
is part of.gitignore
, such that you do not commit your.env
file to the repository.PROJ_DIR=<path-to-ospx-root-dir> PYTHONPATH=${PROJ_DIR}/src
-
Test that the installation works (in the mypackage root folder):
(.venv) $ pytest .
Meta
Copyright (c) 2024 DNV open source
Frank Lumpitzsch – @LinkedIn – frank.lumpitzsch@dnv.com
Claas Rostock – @LinkedIn – claas.rostock@dnv.com
Seunghyeon Yoo – @LinkedIn – seunghyeon.yoo@dnv.com
Distributed under the MIT license. See LICENSE for more information.
https://github.com/dnv-opensource/ospx
Contributing
- Fork it (https://github.com/dnv-opensource/ospx/fork)
- Create your branch (
git checkout -b myBranchName
) - Commit your changes (e.g.
git commit -m 'place a descriptive commit message here'
) - Push to the branch (e.g.
git push origin myBranchName
) - Create a new Pull Request in GitHub
For your contribution, please make sure you follow the STYLEGUIDE before creating the Pull Request.
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.