Public Documentation
Documentation for BondGraph.jl's public interface.
See the Internals section of the manual covering the internal functions.
Contents
Index
BondGraphBondGraph.DamperBondGraph.Junction0BondGraph.Junction1BondGraph.MassBondGraph.SeBondGraph.SfBondGraph.SpringBondGraph.generate_graphBondGraph.isindependentBondGraph.mGYBondGraph.mTFBondGraph.simplifysys
Public Interface
BondGraph — ModuleMain module for BongGraph.jl – a bond graph modeling toolkit based on ModelingToolkit.jl Julia package.
Exports
- Power
- Se
- Sf
- Dq
- Junction1
- Junction0
- mGY
- mTF
- Mass
- Spring
- Damper
- reducedobs
- isindependent
- generate_graph
- simplifysys
Imports
BaseCoreDocStringExtensionsDomainSetsGraphRecipesModelingToolkitPlotsReexport
License
The LICENSE abbreviation can be used in the same way for the LICENSE.md file.
Bond graph elements
BondGraph.Se — FunctionSe(expr; name)Creates a source of effort element in the bond graph model. TODO: Improve
Arguments:
- expr: Expression representing the source value.
- name: Name of the source element.
Returns:
An ODESystem representing the source element.
Example:
julia> @named s1 = Se(2.0)BondGraph.Sf — FunctionSf(expr; name)Creates a source of flow in the bond graph model TODO: Improvess
Arguments:
expr: Expression representing the flow source value.- name: Name of the flow source element.
Returns:
An ODESystem representing the flow source element.
Example:
julia> @named s2 = Sf(3.5)BondGraph.Junction1 — FunctionJunction1(ps...; name="", couple=true)Create a one-junction element in the bond graph model.
Arguments
ps...: One or more elements to be connected to the one-junction.name::String: The name of the one-junction element (default: "").
Returns
An ODESystem representing the one-junction element in the bond graph model.
Remarks
- The
psargument accepts one or more elements to be connected to the one-junction. - The function automatically determines the flow directions and subsystems based on the signs of the connections.
Examples
# Create a one-junction connecting multiple elements
julia> junction = Junction1(damper1, damper2, spring1, spring2, name="junction")BondGraph.Junction0 — FunctionJunction0(ps...; name="", couple=true)Create a zero-junction element in the bond graph model.
Arguments
ps...: One or more elements to be connected to the zero-junction.name::String: The name of the zero-junction element (default: "").
Returns
An ODESystem representing the zero-junction element in the bond graph model.
Remarks
- The
psargument accepts one or more elements to be connected to the zero-junction. - The function automatically determines the flow directions and subsystems based on the signs of the connections.
Examples
# Create a zero-junction connecting multiple elements
julia> junction = Junction0(damper1, damper2, spring1, spring2, name="junction")BondGraph.mGY — FunctionmGY(subsys...; name="", g=1.0, coneqs=[])Create a gyrator element in the bond graph model.
Arguments
subsys...: One or more subsystems to be connected to the gyrator.name::String: The name of the gyrator element (default: "").g::Number|Symbol: A value or a expression representing the gyrator relationship (default: 1.0).coneqs::Vector{Equation}: Additional output connection equations of the modulated gyrator (default: []).
Returns
An ODESystem representing the gyrator element in the bond graph model.
Examples
# Create a gyrator with a variable value
@variables c
julia> gyrator = mGY(subsys1, subsys2, g=c, name="gyrator")BondGraph.mTF — FunctionmTF(subsys...; name="", r=1.0, coneqs=[])Create a transformer element in the bond graph model.
Arguments
subsys...: One or more subsystems to be connected to the transformer.name::String: The name of the transformer element (default: "").r::Number|Symbol: A value or a expression representing the transformer relationship (default: 1.0).coneqs::Vector{Equation}: Additional output connection equations of the modulated gyrator (default: []).
Returns
An ODESystem representing the transformer element in the bond graph model.
Examples
# Create a transformer with a variable value
@variables c
julia> transformer = mTF(subsys1, subsys2, g=c, name="transformer")BondGraph.Mass — FunctionMass(; name="", m=1.0, u=0.0)Create a mass element in the bond graph model.
Arguments
name::String: The name of the mass element (default: "").m::Float64: The mass value (default: 1.0).u::Float64: The initial value for the flow variable (default: 0.0).
Returns
An ODESystem representing the mass element in the bond graph model.
Examples
julia> mass = Mass(name="my_mass", m=2.0, u=1.0)BondGraph.Spring — FunctionSpring(; name="", k=10, x=0.0)Create a spring element in the bond graph model.
Arguments
name::String: The name of the spring element (default: "").k::Float64: The spring stiffness (default: 10).x::Float64: The initial displacement (default: 0.0).
Returns
An ODESystem representing the spring element in the bond graph model.
Examples
julia> spring = Spring(name="my_spring", k=5.0, x=0.1)BondGraph.Damper — FunctionDamper(; name="", c=10, u=1.0)Create a damper element in the bond graph model.
Arguments
name::String: The name of the damper element (default: "").c::Float64: The damping coefficient (default: 10).u::Float64: The initial flow variable value (default: 1.0).
Returns
An ODESystem representing the damper element in the bond graph model.
Examples
julia> damper = Damper(name="my_damper", c=5.0, u=0.1)Utilities function
BondGraph.generate_graph — Functiongenerate_graph(mdl, var=:e; method=:stress)Generates a graph visualization of the bond graph model.
Arguments:
- mdl: Bond graph model.
- var: Variable to visualize connections for. Can be :e (effort) or :f (flow). Default is :e.
- method: Graph layout method. Default is :stress.
Example:
julia> generate_graph(mdl, var=:e, method=:stress)BondGraph.simplifysys — Functionsimplifysys(sys::ODESystem; name)Simplify an ODE system by expanding connections, performing structural simplification and reducing the observed variables.
Arguments:
- sys::ODESystem: The ODE system to simplify.
- name: Optional name for the simplified system.
Returns:
- The simplified ODE system.
BondGraph.isindependent — Functionisindependent(var::Num)Check if a variable is independent.
Arguments:
- var::Num: The variable to check.
Returns:
- true if the variable is independent.
- false if the variable is not independent.