Re: Re: Re: Representation and Simulation of Dynamic Systems

*To*: mathgroup at smc.vnet.net*Subject*: [mg65850] Re: [mg57072] Re: [mg56984] Re: Representation and Simulation of Dynamic Systems*From*: "Chris Chiasson" <chris at chiasson.name>*Date*: Tue, 18 Apr 2006 06:56:46 -0400 (EDT)*References*: <200505140858.EAA09462@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

To MathGroup, In doing an unrelated problem last week, I decided to implement a basic bond graph package. My original post about this package was lost in the ether, so I am sending this one in its stead. I offer the package under the MIT License and the GPL v2. If you would like to contribute code, please make your updates available to me under these licenses; I will add your code to a new version and attribute you in the credits. If you find a bug in the code or documentation or you have a feature request, let me know via email. Here are the files: http://chris.chiasson.name/Engineering_Optimization/hw2/Bond_Graphs/Bond_Graphs.xhtml http://chris.chiasson.name/Engineering_Optimization/hw2/Bond_Graphs/Bond_Graphs.nb http://chris.chiasson.name/Engineering_Optimization/hw2/Bond_Graphs/Bond_Graphs.pdf Don't ask where the plain html version is. For some reason, Mathematica 5.2 likes to crash while rendering it. Ciao, On 5/14/05, Caffa Vittorio Dr. <Caffa at iabg.de> wrote: > Hi Jens, > > Maybe I should give some background information to better specify the > scope of my message: > > I work in the aerospace industry. My colleges and I do a lot of modeling > of dynamic systems: airplanes, helicopters, rockets, etc. In my company > there is also a department which is involved in automotive applications > where a lot of modeling and simulation is done. > > Dynamic systems can be anything between very simple and extremely > complex. > > If the system of interest is simple, one does exactly what you > suggested: one writes down the equations of the system and solves them, > for instance with NDSolve. In some cases one can also use DSolve or the > Laplace technique to get a symbolic solution. > > On the other hand, some models are huge, frantic. In these cases the > only sensible choice is the usage of special simulation tools of the > kind Chris Chiasson mentioned. Here are some reasons for this choice: > o) Graphic representation of the system, > o) Hierarchical representation in systems and subsystems, > o) Blocks can be represented with transfer functions, > o) Signals can be time-continuous and/or time-discrete, > o) Models can be easily modified, > o) Signal can be easily inspected. > > But often the system of interest has medium complexity. For this case I > have elaborated the simple technique for representing and simulating > dynamic systems that I have described in a previous message. I am > actually curious to know if someone uses a similar or maybe better > technique. > > The ideas I have used are actually simple, but maybe it is useful to > mention them: > o) Engineers like to represent dynamic systems with block diagrams, > o) Block diagrams are actually oriented graphs, > o) Graphs can be represented with lists of rules, > o) A graph editor could be used for generating the graph representation, > o) Actually it is also possible to transform a graph description (maybe > in form of rules) into a graph using DiscreteMath`GraphPlot. > o) Using //. it is possible to transform the system description into > equations for NDSolve, > o) The parameters of the problem can be put into a list rules for > flexibility, > o) With //. one can conveniently inspect "auxiliary" variables (i.e. > variables which are not states). Similarly one can use auxiliary > variables in the specification of termination conditions. > > > > Cheers, Vittorio > > > >-----Original Message----- > >From: Jens-Peer Kuska [mailto:kuska at informatik.uni-leipzig.de] To: mathgroup at smc.vnet.net > >Subject: [mg65850] [mg57072] [mg56984] Re: Representation and Simulation of Dynamic Systems > > > >Hi, > > > >and you can not select your depend output > >variables (like y[t]) in > >your example and just insert the solution that > >NDSolve[] gives for > >your independent variables ? Strange ... > > > >Regards > > Jens > > > >"Caffa Vittorio Dr." <Caffa at iabg.de> schrieb im > >Newsbeitrag news:d5s9bh$lj9$1 at smc.vnet.net... > >> The behavior of (time-continuous, non-linear) > >> dynamic systems can be > >> numerically investigated with NDSolve. One can > >> first sketch a block > >> diagram of the system and then convert it into > >> equations. Here is a toy > >> example after the conversion: > >> > >> pos'[t] = vel[t] > >> vel'[t] = -k pos[t] + force[t] / m > >> > >> This works fine if the variables are all states, > >> as in the example > >> above. But often, in order to describe a given > >> dynamic system you want > >> or you have to introduce some auxiliary > >> variables (i.e. variables which > >> are not states). This is in fact the case if you > >> want to describe a > >> generic dynamic system. Here are the standard > >> equations: > >> > >> x'[t] = f[x[t], u[t], t] (state equations) > >> y[t] = g[x[t], u[t], t] (output equations) > >> > >> where: x = state vector, u = input vector, y = > >> output vector, t = time. > >> In this case the components of the output vector > >> are the "auxiliary" > >> variables. > >> > >> I'm considering here a scheme for representing > >> dynamic systems (possibly > >> using a block diagram as a starting point) which > >> allows the usage of > >> auxiliary variables. This representation can be > >> transformed into > >> equations for NDSolve automatically. After > >> having solved the equations > >> it is possible to inspect not only the state > >> variables but also the > >> auxiliary variables. > >> > >> Comments or alternative solutions to the problem > >> I'm considering are > >> welcome! > >> > >> Procedure > >> > >> o) Sketch the system on a piece of paper. Here > >> is a toy example: > >> > >> ---------- > >> [ -k ] --------- > >> | > >> | > >> V > >> | > >> force[t] --> [ 1/m ] --> + --> [ 1/s ] ---> [ > >> 1/s ] ---> pos[t] > >> | | > >> > >> | --------------> > >> vel[t] > >> | > >> ---------------------------> > >> acc[t] > >> > >> Note: [ 1/s ] is an integrator block > >> [ k ] is a gain block > >> > >> > >> o) Convert the sketch into a system description: > >> > >> In[1]:= sys = {pos'[t] -> vel[t], > >> vel'[t] -> acc[t], > >> acc[t] -> -k pos[t] + force[t] / m}; > >> > >> Note: the arrow points to the source of the > >> signal. > >> > >> o) Make a list of the state variables: > >> > >> In[2]:= states = {pos[t], vel[t]}; > >> > >> o) Form the differential equations (the > >> following steps could be > >> performed by a function): > >> > >> In[3]:= lhs = D[states, t] > >> > >> Out[3]= {pos'[t], vel'[t]} > >> > >> In[4]:= rhs = D[states, t] //. sys > >> > >> force[t] > >> Out[4]= {vel[t], -------- - k pos[t]} > >> m > >> > >> In[5]:= eqns = Join[Thread[lhs == rhs], {pos[0] > >> == pos0, vel[0] == > >> vel0}] > >> > >> force[t] > >> Out[5]= {pos'[t] == vel[t], vel'[t] > >> == -------- - k pos[t], pos[0] == > >> pos0, > >> m > >> vel[0] == vel0} > >> > >> o) Specify the parameters: > >> > >> In[6]:= params = {m -> 10, k -> 2, pos0 -> 0, > >> vel0 -> 0, force[t] -> > >> Sin[t]}; > >> > >> o) Solve the differential equations: > >> > >> In[7]:= sol = First[NDSolve[eqns /. params, > >> states, {t, 0, 10}]] > >> > >> Out[7]= {pos[t] -> InterpolatingFunction[{{0., > >> 10.}}, <>][t], > >> > >> vel[t] -> InterpolatingFunction[{{0., > >> 10.}}, <>][t]} > >> > >> o) Inspect the results (including auxiliary > >> variables) > >> > >> In[8]:= Plot[pos[t] /. sol, {t, 0, 10}] > >> > >> Out[8]= -Graphics- > >> > >> In[9]:= Plot[acc[t] //. sys /. params /. sol, > >> {t, 0, 10}] > >> > >> Out[9]= -Graphics- > >> > >> > >> Cheers, Vittorio > >> > >> -------------------------------------------- > >> Dr.-Ing. Vittorio G. Caffa > >> IABG mbH > >> Abt. VG 32 > >> Einsteinstr. 20 > >> 85521 Ottobrunn / Germany > >> > >> Tel. (089) 6088 2054 > >> Fax: (089) 6088 3990 > >> E-mail: caffa at iabg.de > >> Website : www.iabg.de > >> -------------------------------------------- > >> > > > > -- http://chris.chiasson.name/

**Re: Simplifying equations for Mathematica**

**What is Infinity+Pi*I**

**parenthesis in reactions...**

**What is Infinity+Pi*I**