Bond Graph Modeling for Everybody

Mechatronics modeling for education and engineering

Nicolas Venuti	Virtual Dynamics

nicolas@virtualdynamics.fr

• What is a bond graph ?
• Toolbox overview
• Exemples in education and engineering
• Conclusion

What is a bond graph ?

History

Efficient digital computer bond graph simulator program in 1968

Why a bond graph toolbox in Mathematica ?

First reason :  Mathematical universe versius physical universe

The mathematical universe allows to create model of physical systems ... but also unphysical systems! That is a real big issue as soon as one want to create medium or large size models. Therefore the modeling tools that rely directly on mathematical-like-programmation language are probably not the right tools. Physical modeling requires to be expressed using a language that reduces the possible semantics to only-realizable models, this improves reliablity of modeling. The bond graph modeling is just the most simple and universal physical language that avoid the mathematical jungle.

Second reason :  Document-centric -> Notebooks

Experience shows that a model in itself is just a very small part of the modeling task which also requires : documention (drawings texts), parametric informations, validation tests, and other usefull informations. In design there is a also a large part dedicated to symbolic analysis and design, simulation is not the main goal ! Notebooks are the right place to store model informations and keep them alive for long term capitalisation.

Short course

A bond graph is composed of elements (vertices) and bonds (edges). Each element represents a "physical effect" and each bond a possible path of energy flow between the connected elements. Bond graph implicitly embed the first princip of thermodynamics : the conservation of energy. The second princip is also clearly anderstandable using bond graph.

Alphabet of physical effects :

{Se, Sf, I, C, R, TF, GY, 0, 1}

For each element a physical constituve law is attached  (p=m v, F=K x, F = α v, C = kt i ...  ) 

Se and Sf are sources of power, respectively effort and flow
I and C are storage elements they acumulate a bond variable, respectively effort and flow
R is a resistor, it dissipate power
TF and GY are  transformers they allow connexion between different engineering domains
0 and 1 are connecting elements, all other elements connected to them have a common variable, respectively effort and flow

Se Sf and R comunicate power between systems and outside

TF GY 0 and 1 conserve power

I and C store energy, they define the model state

When connecting those elements we create physical models :

A power path is noted by a bond, each power bond has two internal variables the effort and the flow. Here the model allows exchange of power between components A and B

Important relations

The product of bond variables is always a power [Watt] which is universal undependently of the modeling domain.

effort*flow  == power

State is defined by integration of effort or flow. I and C elements are integrating elements.

∫effort \[DifferentialD]t= momentum   ∫flow  \[DifferentialD]t= displacement

Example 1 :  single element model to anderstand element syntax

Those single element are already very physically meaningfull
• an inertial effect I, of parameter m (the mass), and state p (the momentum)
• an capacitive effect C, of parameter C (the capacitance), and state q (the charge)

Example 2 : oscillators to anderstand system semantics

I and C are elements that store energy, by acummulation of one of the variables (effort or flow) repsectively (momentum and displacement)
I-C creates an oscillator, the path allows to convert inertial energy to potentiel energy. Here we have creted a pure mechanical oscillator and a pure electric oscillator. You have andertood the concept, oscillator have the same model whatever the modeling domain is and you can identify it at the first glance, it is a very meaningfull semantic.

Table of variables depending of modeling domain

Effort and flow depends of the engineering field, but because the bond are power path [W] we may connect modeling domain together easilly (using transformers TF and GY)

({{ , Translation, Rotation, Electric, Hydraulic, Thermal, Magnetic, Chemical}, {Domain color, gray, gray, blue, green, red, purple, brown}, {f: Flow, (Subscript[(OverDot[x]), [(m/s)]])
velocity, (Subscript[ω, [(rad/s)]])
rotation speed, (Subscript[i, [A]])
current, (Subscript[(OverDot[V]), [((m^3)/s)]])
volume flow, (Subscript[(OverDot[S]), [(W/K)]])
entropy flow, (Subscript[(OverDot[ϕ]), [(Wb/s)]])
flux, (Subscript[(OverDot[n]), [(mole/s)]])
mole flow}, {e :Effort, (Subscript[F, [N]])
force, (Subscript[τ, [N m]])
torque, (Subscript[V, [V]])
voltage, (Subscript[P, [Pa]])
pressure, (Subscript[T, [K]])
temperature, (Subscript[M, [A]])
magneto 
motive force, (Subscript[μ, [(J/mole)]])
chemical
potential}, {q: Displacement, (Subscript[x, [m]])
position, (Subscript[θ, [rad]])
angle, (Subscript[q, [Cb]])
charge, (Subscript[V, [(m^3)]])
volume, (Subscript[S, [(J/K)]])
entropy, (Subscript[ϕ, [Wb]])
induction, (Subscript[n, [mole]])
mole number}, {p:Momentum, (Subscript[(Subscript[p, x]), [N s]])
momentum, (Subscript[(Subscript[p, θ]), [N m s]])
angular 
momentum, (Subscript[p, [V s]])
electric 
momentum, (Subscript[λ, [((N s)/(m^2))]])
hydraulic momentum, undef., undef., undef.}})

Toolbox overview

What make the life easier ?

User friendly heurisitic editor (only possible since mma6)

1-argurment functions (StateEquations Simulation,TimePlot,default action, a bond graph is a notation it integrates all the information)

Object (copy-paste-inspector-probe-inlineform)

Illustration -Annotation

Palette with beginner stuff : Tutorials & Examples

Analyse and simulate

Analyse symbolically

model=;

Here Se is the electric voltage source, R, C and I are respectively the resistor the capacitor and the inductor. The fact that those elements are connected to the 1 element means that they share the same current, here labeled with i.

Once a model has been entered in Mathematica it is possible to analyse the model symbolically in a spread of ways :

State equations :

StateEquations[model] //LinearForm

Simbolic solution for outputs :

sol=TimeSolution[model ,i[t]] //Simplify

Eigenvalues :

Eigenvalues[model]

Transfer function between a source and an output

tf=Transfer[model,(Vc/U)]

This find the match between the model transfer and a canonic form :

Match[tf,((α )/((s^2)+2 s ζ ωn+((ωn)^2)))]

Output expression dependent of state varaibles

Output[model,{i,Vl}]

Basic simulation

This define a parameter set for the model :

par={U->1,R->.2,C->1,L->1};

This plot the simulation :

TimePlot[(Overscript[(model^(t<20)), (Overscript[¨, par])])]

• Tips  : hoover the curves to see their names

Numeric parameters could also be defined directly on the model :

modelN=;

In this case Probe is a feature that allow to explore instant simulation on the model. Just hoover the output variables with the mouse to get instant probing of the variable.

Probe[modelN]

• Tips  : To compare two variables, hold down the shift key before going to the variable to compare.

This plot the transfer :

tf=Transfer[model,(Vc/U)];

(1/(2 π))(Sqrt[(1/( C L))]) /. par//N

FrequencyPlot[tf/.par,{f,.01,1}]

Examples

One-page model samples

1. Forced mass-spring oscillator animation

forcedoscillator=;

par={V->0.5Sin[ω t],ω->2, k->4,x0->0.,M->.5,α->.2,g->9.81};

Tune[(Overscript[(forcedoscillator^(t<20)), (Overscript[¨, par])]),Evaluate@MassSpringDrwg[{xm,xg,yg},Fk,Fα],{α,0,5},{ω,0,5}]

• Tips  : Evaluation of the above manipulator gives the tuned parameter, then you can use those parameters (here using the previous resuslt represented by symbol %) to display the actual time simulation :

TimePlot[(Overscript[(forcedoscillator^(t<20)), (Overscript[¨, %])]),xm]

2. Interactive parameter tuning for proportionnal derivative controller

Goal  : get the best response time with a peak power dissipation under  < 5 Watt

TunePlot[(Overscript[t<10, (Overscript[¨, {θu->Boole[Sin[t]>0],R->10,kt->0.1`,J->0.01`,G->1,Δ->-1}])]),{θu,θ,(Subscript[e, 1])*(Subscript[f, 1])},{G,1,10},{Δ,0,-10},PlotRange->{-1,5},PlotStyle->{Blue,Black,Red},FrameLabel->{"time [s]","command[V] output[V] power [W]"}]

Using the ⊕ menu at the upper right allows to bookmark your settings. A "Tuned" bookmark is already recorded in the example, and you may compare your own solution to it.

3. Advanced control design

activedamper=;

• Note the measurements { (OverDot[X]),V}, and the control laws { (Overscript[Sf, (Overscript[¨, -h (OverDot[Zc])+γ(Z+ZC)])]) , (Overscript[R, (Overscript[¨, B (OverDot[Z])-Ba (OverDot[Zc])&⊣])])}
directly in the model, no bloc diagram required, no wire required, it is just symbolic !

• Note that the vehicule velocity vx may vary during the simulation.

• Note that the vertival road velocity depends of the road shape zr[•] and the vehicule position x

Numerical experiments

Bump[x_]:=If[0<x<π,.4 Sin[x],0];Derivative[1,0][Mod][x__]:=1;

Plot[Bump[Mod[x,25]],{x,0,50},AspectRatio->.1]

A parameter set to begin :

par={
γ->0,Ba->0,h->0,ZC->0,(* controle *) 
 B->500,k->160000,K->4500, m->25, M->203, (* constitution *)
vx->10, (* vitesse longitudinales *)
 g->0 9.81,(* environnement *)
zr->(Bump[Mod[#,25]]&)
};

The goal is to get the best chassis response Zc assumming a minimal instant power dissipation in the control source. Note that ZC is the chassis altitude control and should not be to slow. Try to change ZC when the control parameters Ba,γ,h are tuned for the best response.

TunePlot[(Overscript[(activedamper^(t<4)), (Overscript[¨, par])]) ,{zr[x],Zc,.001*(Subscript[π, 1])},{Ba,0,1000},{γ,0,10},{h,0,10},{ZC,-1,1},PlotRange->{-.5,.5}]

• Tips  : using the ⊕ menu at the upper right allows to bookmark your settings. A "Tuned" bookmark is already recorded in this example, and you may compare your own solution to it. You may also enter a numerical value in the value imputfield rather than using the slider {Tuned :> {Ba = 800, h = 1.26`, Xc = 0, γ = 3}}

You may note that energy could be sinked by the actuator, not sourced, what does this mean ? Is it possible to create a better suspension without using an active source ? Where does that energy comes from.

tuned parameters from the manipulator {Tuned :> {Ba = 800, h = 1.26`, Xc = 0, γ = 3}}

tuned parameters :

par={
γ->3,Ba->800,h->1.26,ZC->0,(* controle *) 
 B->500,k->160000,K->4500, m->25, M->203, (* constitution *)
vx->0, (* vitesse longitudinales *)
 g->9.81,(* environnement *)
zr->(Bump[Mod[#,25]]&)
};

TuneAnimate[(Overscript[(activedamper^(t<50)), (Overscript[¨, par])]),{vx,-5,20},{K,1000,7000},{B,0,1000},{ZC,-1,1},Drawing->Dwgactivedamper,RefreshRate->10]

inits

MassPringDrwg[{0,0,0},1,.1]

MassSpringDrwg[{xm_,xg_,yg_},Fk_:0,Fα_:0]:=Graphics[{
{Blue,AbsoluteThickness[1.5],AbsolutePointSize[8],
Mass[{2.5+xm,0},1,2],
Spring[{{xg,-.5}, {2+xm,-.5}}, 8,1],Force[{xg,-.5},Fk],
Damper[{{xg,.5}, {2+xm,.5}},.5,1],Force[{xg,.5},Fα],
Ground[{{xg,1},{xg,-1}},.2]
}},PlotRange->{{-1,4},{-1.2,1.2}},ImageSize->200]

roadLine[l_,dz_]=Line@Table[{x,Bump[Mod[x+l,25]]-dz},{x,-5,5,.2}];

Dwgactivedamper=DynamicModule[{x=0,zk=0.,Z=0.2,zK=0.3,zr=0},Dynamic@Graphics[GraphicsGroup[{Blue,AbsoluteThickness[1.5],AbsolutePointSize[8],
Translate[
{Mass[{0,5.-zk-Z},1,2/3],GravityCenter[{0,5.-zk-Z}],(* chassis *)
Source[{{-.5,2-zk},{-.5,3-zk-Z+zK}},.6],Spring[{{-.5,3-zk-Z+zK}, {-.5,5-zk-Z}}, 5,1], (* actuator with spring *)Damper[{{.5,2-zk}, {.5,5-zk-Z}},.6,1.5], (* damper *)
Mass[{0,2-zk},1,.5], (* wheel *)
Spring[{{0,0}, {0,2-zk}}, 5,1], (* tire *)
(* Ground[{{-.5,0},{.5,0}},.2], *)
Roller[{0,0},.2]
},{0,Bump[Mod[x,25]]}],(* road roller contact *)
roadLine[x,.2] (* ground rolling line *) 
},ContentSelectable->False],PlotRange->{{-5,5},{-1,6}},ImageSize->280]];

Cases[ParametricPlot[{x,Z},{t,0,2}], Line[x_],∞]

Trace[{x,5.-zk-Z},FileLength->10]

Derivative[1,0][Mod][x__]:=1

Plot[D[Bump[Mod[x,25] ],x],{x,0,50},AspectRatio->.1]

Conclusion

• Targets education (answers 99% of bg books) and engineering (answers 99% of our own needs)
• In beta test now

email : nicolas@virtualdynamics.com
web: www.virtualdynamics.com/softwares.html



... Thank you for your attention