Modelling tool for linear bond graph systems in Python
Project description
pyBondGraph
pyBondGraph is a Python library for modeling and analyzing linear bond graph systems using symbolic computation.
The library allows users to construct bond graph models programmatically, automatically derive the governing equations, and analyze the resulting dynamic systems using tools from control theory.
Bond graphs provide a domain-independent modeling framework for physical systems. Using a unified representation of power exchange, the same modeling approach can be used for electrical, mechanical, hydraulic, and multi-domain systems.
Features
- Programmatic construction of bond graph models
- Automatic symbolic equation derivation using SymPy
- Conversion of models to state-space systems
- Example models for electrical and mechanical systems
Installation
Install directly from GitHub
The easiest way to install the library is directly via pip:
pip install git+https://github.com/MrP123/pyBondGraph.git
This installs the latest version of the package from the repository.
Development installation
To work with the source code:
git clone https://github.com/MrP123/pyBondGraph.git
cd pyBondGraph
pip install -e .
Dependencies
The main dependencies are:
sympynumpynetworkxmatplotlibcontrolonly needed for the examples
Optional dependencies are used for experimental visualization tools.
Basic Usage
A bond graph model is constructed by creating elements and connecting them via bonds.
Simple RC-Filter circuit:
from pyBondGraph import BondGraph, SourceEffort, Resistor, Capacitor, OneJunction, Bond, Causality
bg = BondGraph()
# create elements
voltage_source = SourceEffort("U", "u_in")
resistor = Resistor("R", "R")
capacitor = Capacitor("C", "C")
series_junction = OneJunction("J1")
# connect elements
# causalities need to be assigned manually
bg.add_bond(Bond(voltage_source, series_junction, Causality.EFFORT_OUT))
bg.add_bond(Bond(series_junction, resistor, Causality.EFFORT_OUT))
bg.add_bond(Bond(series_junction, capacitor, Causality.FLOW_OUT))
# plot the resulting BondGraph
bg.plot()
# derive system equations in linear state space form
A, B, C, D, x, n_states, n_inputs, n_outputs = bond_graph.get_state_space()
The library automatically derives the symbolic system equations describing the dynamics of the model.
Core Concepts
Bond graphs represent power exchange between system components, where power is the product of effort and flow associated with the following components:
Elements
| Element | Meaning |
|---|---|
| R | Dissipation |
| C | Energy storage (compliance, capacitance) |
| I | Energy storage (inertia, inductance) |
| Se | Effort source |
| Sf | Flow source |
Junctions
| Junction | Meaning |
|---|---|
| 0 | Common effort |
| 1 | Common flow |
Sensors
| Sensor | Meaning |
|---|---|
| IntegratedEffortSensor | Measures integral of the effort at its bond |
| IntegratedFlowSensor | Measures integral of the flow at its bond |
In mechanical bond graph models:
- flow corresponds to velocity
- effort corresponds to force
An integrated flow sensor can therefore be used to compute position:
Example Systems
The repository contains example models illustrating typical applications of bond graphs.
RLC Circuit
Demonstrates modeling of an electrical circuit using bond graph elements.
DC Motor
A multi-domain electromechanical system coupling electrical and mechanical dynamics.
Transformer
Example of energy transformation between two ports.
Two DOF Mass–Spring–Damper System
Classical mass-spring-damper system with two degrees of freedom.
Typical Applications
Bond graph modeling is particularly useful for:
- electromechanical systems
- robotics and mechatronics
- multi-domain energy systems
- control system modeling
- teaching system dynamics
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 pybondgraph-0.1.0.tar.gz.
File metadata
- Download URL: pybondgraph-0.1.0.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
653cc59607d1f2fc77b0c35dafa2f921cc5c8ee54f24461b1b5cafd8c67be997
|
|
| MD5 |
8b833a812e16a20afe065785df1c73b6
|
|
| BLAKE2b-256 |
1546e8563e9be65d4df1790972968e3b4389f6b5be75541f72d2ded4631fb48b
|
File details
Details for the file pybondgraph-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pybondgraph-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74125ca39cb6ec46f2c120332c4e542b77774ff1e9429883a545f37ac6f75048
|
|
| MD5 |
1f596f264bf9e900a6eb7869ff6c3703
|
|
| BLAKE2b-256 |
7ef2f07b838b2e0afa8ae0f9ec0ad2f3d6b7a1d5d07d459ae9a11f732fbf1bf2
|