[PDF version of this document]| [HV Home]

Causal Block Diagram assignment

Causal Block Diagram assignment

   



Latest update: Monday 23 September 2002 !
See the updates section at the bottom of this document.

General Information

The assignment

You will use the meta-modelling environment AToM3 AToM3.asgn.tgz to interactively construct two Causal Block Diagram models:

  1. The ``circle test'' model (already given in the directory ModelExpCircletest).

    harmonic.png

  2. The ``ballistic'' model (to be constructed and put in the directory ModelExpBallistic). This model must describe the trajectory of a football thrown from a height of 2m with an initial velocity v0 of 20 m s-1 at an angle q with the surface of the earth. A host of simplifications apply: Different values for q Î [0, p/2] will result in different trajectories.

    ballistic.png

The assignment consists of four parts, some of which are optional.

  1. Build and document Causal Block Diagram models for the circle test and the ballistic problems described above (the first is already done, but you're welcome to modify it).
  2. (optional) Implement EXPORT_LaTeX.py which will export a LATEXfile giving the ``denotational semantics'' of a model when the appropriate button is pressed in the modelling environment. To obtain for example
    ì
    ï
    ï
    í
    ï
    ï
    î
     dx

    dt
    = y
    x(0) = 0
     dy

    dt
    = -Kx
    y(0) = 1, K=1
    from the circle test model, the model's data structure must be traversed and the following written to file:
     \documentclass[12pt]{article}
     \begin{document}
     \[
      \left\{
       \begin{array}{ll}
        \frac{dx}{dt} =   y & x(0) = 0\\
        \frac{dy}{dt} = -Kx & y(0) = 1, K=1
       \end{array}
      \right.
     \]
     \end{document}
     
    
  3. (optional if you're working alone) Implement EXPORT_Mfile.py which will produce a representation of the model suitable for processing by a tool such as Matlab/Simulink (www.matlab.com) or a public version such as Octave www.octave.org. The following gives the circle test model in a format suitable for Octave:
     function xdot=f(x,t)
      xdot=zeros(2,1);
      xdot(1)=x(2);
      xdot(2)=-x(1);
     endfunction
     x0=[0;1];
    
    
    To obtain a solution and plot it in Octave:
     t=linspace(0,50,1000);
     y=lsode("f", x0, t);
     plot (t,y);
     plot (y(:,1), y(:,2))
    
    
    A similar syntax is used by Matlab. Demonstrate the working of your exporter by applying it at least to the circle and ballistic tests.
    1. Implement (in the files MODEL_plotWindow.py, SIM_pause.py, SIM_reset.py, SIM_startResume.py) a Time Slicing simulator. This includes algebraic loop detection, topological sorting of blocks, and the actual time slicing.
    2. Demonstrate the correct working on the circle test (with a small and with a large Dt stepsize).
    3. Perform a series of simulation experiments to determine the optimal throwing angle q if one wants to hit a target at 30 m distance and 1 m height as fast as possible for the given v0.

Derivation of the Ballistic motion ODE

The following derives the equations of motion for the ballistic problem above. You have to convert these into a Causal Block Diagram.

One of our assumption states that the ball's motion is abstracted to that of its centre of mass. Hence we start from Newton's Second Law of motion:
F = m·a,
where the force F and the acceleration a are both vectors. In the plane, we thus have
ì
ï
í
ï
î
Fx
  =  m· ax
Fy
  =  m· ay.
(1)
The only force that influences our football is the gravitational force, hence Fx = 0 and Fy = -m· g, with g the gravitational acceleration (9.81  m/s2 in our problem). Substituting this in equation 1, we get
ì
ï
í
ï
î
ax
  =  0
ay
  =  -g.
(2)

Recall that the acceleration is the second derivative of the position with respect to time: hence ax = [x\ddot], ay = [y\ddot] (a dot denotes a derivative with respect to time). We now have a system of two second-order equations. Since most ODE solvers (including our Time Slicing simulator) operate on a system of first-order equations, we use the standard technique of introducing extra variables: we let vx = [x\dot], and vy = [y\dot] (respectively, the horizontal and vertical velocities). We then have the following system to solve:
ì
ï
ï
ï
ï
ï
í
ï
ï
ï
ï
ï
î
×
x
 
  =  vx
×
y
 
  =  vy
×
v
 

x 
  =  0
×
v
 

y 
  =  -g
(3)

The above model describes a class of behaviours. To specify a unique solution trajectory (our Time Slicing simulator is not capable of producing a class of solutions as a symbolic solver is), we need to specify initial conditions. The initial conditions for each of the variables in equation 3 should be easy to determine from the problem specification (recall that the given v0 is the magnitude of a velocity vector v0.

Using the AToM3 environment

Download AToM3.asgn.tgz archive.

Expand it locally (for example with the command tar -ungzip -xvof AToM3.asgn.tgz if you're working on a UNIX machine. This will create a directory AToM3.asgn.

To start the AToM3 environment, python ATOM3.py. python should be at least version 2.2 of Python (this is installed in the SOCS labs). On UNIX, the script atom3 is a shortcut for the above command. On windows, you can just click on the ATOM3 icon to launch it.

AToM3 will be started with the CausalBlockDiagram formalism loaded. You can either build your own model (and File/Save it) or File/open an existing one. In the directory ModelExpCircletest you will find the example model circle_CausalBlockDiagram_mdl.py.

A directory ModelExpBallistic has been set up for your ballistic model and experiments.

When AToM3 starts with the CausalBlockDiagram formalism, it will use a number of files in the CausalBlockDiagram directory:

A pretty-printed version of these files (with enscript -color -E -Whtml -toc -p pretty_print.html *.py) is here.

Updates




Translated from TEX by TTH, version 3.02 (minor customizations by HV). On 23 Sep 2002, 13:02.