Skip to main content

bondgraph

A python library for creating bond graphs of physical systems and generating differential equations.

It heavily relies on sympy for manipulation and simplification of equations symbolically.

Installation

Install via pip:

pip install bondgraph

To install with extra dependencies for visualization using graphviz:

pip install bondgraph[visualization]

Usage

Create a BondGraph object and add Bond objects connecting various elements:

# This example generates the following simple bond graph:
#
# Se ---> 1 ---> I
#         |
#         v
#         R

from bondgraph.core import Bond, BondGraph
from bondgraph.junctions import JunctionEqualFlow
from bondgraph.elements import Element_R, Element_I, Source_effort
from sympy import Symbol

force = Source_effort("force", Symbol("F"))
friction = Element_R("friction", Symbol("k_f"))
inertia = Element_I("inertia", Symbol("m"), Symbol("p"))
mass_object = JunctionEqualFlow("mass_object")

graph = BondGraph()
graph.add(Bond(force, mass_object))
graph.add(Bond(mass_object, friction))
graph.add(Bond(mass_object, inertia))

state_equations = graph.get_state_equations()

# Print the dictionary of state variables and the right hand side of their state equations:
print(state_equations)
# {p: F - k_f*p/m}

# If using the optional visualization features, generate and display a graphviz graph:
from bondgraph.visualization import gen_graphviz

output_graph = gen_graphviz(graph)
output.view()

Limitations

  • Algebraic loops are not handled at all and will result in failure to generate equations.
  • Non-integrating (differential) causality for C or I elements is not currently possible.

Release files for bondgraph 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bondgraph 0.2.0
File Size Uploaded
bondgraph-0.2.0.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bondgraph 0.2.0
File Interpreter ABI Platform
bondgraph-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / bondgraph-0.2.0.tar.gz

Download URL bondgraph-0.2.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
507a7d1a36e081f2f4bf1f9b8b1f507521ac18590cd4ffe279f8af7f3045cb5a
BLAKE2b-256 checksum
How to use checksums
39fd0fb548cd4fb44a2dba0001b55290f0ad2e6be24a5fd577e6aee27c8b14b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / bondgraph-0.2.0-py3-none-any.whl

Download URL bondgraph-0.2.0-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
524bffea04126f03ab3bb9edd28723e48578d63d4afc9fd0a21e0e91a70593a3
BLAKE2b-256 checksum
How to use checksums
ff83460771db7962f9e8d31fcdc9f1a5d60350d0e3c09135f04a9565d9ed8a95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release 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