Skip to main content

A library to create bond graphs and generate differential equations.

Project description

bondgraph

Python package

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.basic 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.

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

bondgraph-0.1.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

bondgraph-0.1.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file bondgraph-0.1.0.tar.gz.

File metadata

  • Download URL: bondgraph-0.1.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for bondgraph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b646132c2e29c3fb050e3da07251714ac9e4a5c6c2ead8eaaf876ebd09a011f2
MD5 2992fccff3f2bc59d7654b29c668aa0e
BLAKE2b-256 c7c2f1cade19b6f7a3958cf4e877a3e977f1a554935050ca2d4bbf6ffa5d1f19

See more details on using hashes here.

File details

Details for the file bondgraph-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bondgraph-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for bondgraph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 490e3b3a40c2f72b0e97dd4184afd993fbc537bdef81fb1c603be9b3870c18d0
MD5 6c637bdcd4f365bbac8320d93e5203f2
BLAKE2b-256 3a013196bb6eb1731be5c0f4c7af96f00e6208e1163a410a7c587bc7053ee13e

See more details on using hashes here.

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