Tuesday, November 3, 2009

Reachability

I've added relatively complete notes regarding Chapter 6 of the Astrom and Murray textbook under that tag "Reachability Demo". You'll find the notes themselves under the supplementary materials list, and you can download the matlab files from under downloads.




The point of these notes is to illustrate the key topics of the chapter using Matlab demonstrations. There are some significant extensions as well, especially with regard to the use of convex optimization to compute control open-loop control trajectories.  Please take time to review these notes, and spend time with the "Self-Study Exercises".

To do the optimizations, you'll need to download and install the CVX package for convex optimization in Matlab. You'll be amazed by the capabilities it adds to your Matlab toolkit.

Saturday, October 10, 2009

Monomolecular Kinetics

I've just posted my notes on Monomolecular Kinetics.  This is much the same as we talked about in class, with the addition of a few extra comments on straight-line reaction paths.  There are some suggested exercises on the last page of the notes.

I've also posted Matlab demo illustrating the properties of monomolecular reaction systems.



Friday, October 9, 2009

Linear System Demo

I've uploaded a demo illustrating various techniques for working with linear systems in Matlab. The techniques include
  • linearization of a nonlinear model, 
  • comparing the impulse and step responses of the linear and nonlinear systems, 
  • comparison of linear simulation and use of the matrix exponential
  • finding key points in the impulse and step responses,
  • illustration of frequency response and various methods of computation 


You can see the output from the demo from the link on under Supplementary materials, or download the Matlab code and work with it directly. There are some suggested exercises on the last page. You may want to give these a try, and let me know if you have any questions.

Frequency Response Notes

To augment the textbook's discussion on the frequency response of linear systems, I've some notes (Frequency Response) that you may find useful.  These notes provide a simple derivation of frequency response as outlined in class on 10/8/2009 using complex variables.

Thursday, October 8, 2009

Homework Assignment

The following Assignment is due Tuesday, October 13th:

1.  Problem 5.7.
2.  Do the calculations shown in Example 5.7 (page 151) using Matlab. Compute the impulse, step, and frequency domain response of the system.  The model equations are given on pages 86-87, and assume the following parameter values:
  • V_1 = 0.07 L/kg (blood volume)
  • V_2 = 0.40 L/kg (intracellular fluid volume)
  • q_0 = q = 0.0015 L/min/kg (outflow)
  • c_0 = 1.0 (normalized input concentration)
3.  For the system in problem 2, compute the steady state value of u necessary to obtain C_2 = 1 for the second compartment.
4.  Suppose you can apply an initial impulse and a step function input the system of Example 5.7. These correspond to an initial dose followed by a steady state input to the compartment model. What should be the maximum size of these inputs so that the final value of C_2 is 1.0, and the concentration never goes over 2.0?

Thursday, September 24, 2009

Modal Decomposition

Modal decomposition constructs a similarity transformation for a linear system where the resulting coefficient matrix is a block diagonal structure corresponding to the real and complex eigenvalues. See problem 4.14 of Astrom and Murray for a description of the transformed coefficient matrix.  The download ModelDemo.zip contains a Matlab function modal.m to compute the modal decomposition for an arbitrary coefficient matrix, and a function ModalDemo.m to illustrate the application to a randomly 3D linear system.

Wednesday, September 23, 2009

Eigen Decomposition of Linear Systems

One of the basic tools for understanding linear, time-invariant systems is the 'modal' decomposition on to a set of 'eigendirections'.  This is illustrated in the matlab files in the Eigen Decomposition Demo download.



Run the script S_EigenDemo.m to create versions of the plot shown above. The script selects random eigenvectors and assigns eigenvalues for a 3D system, then calls a function to superimpose a trajectory over a representation of the eigendirections.

To test your understanding, try the following exercises:
  1. Change the real parts of the eigenvalues to obtain other types of behavior.  What happens if you make the real eigenvalue much more negative, or slightly positive? What happens if you make the real part of the complex conjugate pair slightly positive?
  2. How can you make the simulated trajectory orbit the real eigenvector in a plane parallel to the other two eigendirections?

Lorenz Attractor

The Lorenz attractor is a well known system of three differential equations demonstrating deterministic chaos.  The model was originally derived by Edward Lorenz as an abstract description for convection rolls in the atmosphere, but is mainly studied for the insight it gives on the behavior of complex deterministic systems.



Download run the Matlab function LorenzDemo. Rotate and manipulate the resulting figure in phase space, and be sure you understand what is going on.  To test your understanding, modify this function to plot two trajectories on the same axis that start at nearby initial conditions, say less than 0.00001 apart. What happens to the trajectories over time?

Hare and Lynx Demonstration

The dynamics of the Hare and Lynx predator/prey system provides a very useful illustration of phase plane analysis for a system of two ordinary differential equations. The textbook includes a discussion of this example in Section 3.7

Under the downloads you will find a link to a compressed folder holding with Matlab and Simulink files for demonstrating the Hare/Lynx dynamics. The files include a Simulink model, and a separate Matlab script with which you can explore this system.




The qualitative concepts you should learn from this example include
  • Phase plane modeling in Simulink and Matlab
  • Time invariant differential equations as vector fields in phase space.
  • Nullclines, Steady States, and Limit Cycles
  • Linearization
  • Global versus local stability
To test your understanding, consider the following questions:
  1. What do the three steady states represent in terms of the Hare/Lynx populations?
  2. Repeat the simulations setting the parameter b = 0.26. How do the results change?
  3. Repeat again for b = 0.20.  What happened to the third steady state? Interpret this in terms of the Hare/Lynx population dynamics.
  4. What is the critical value of b for which a limit cycle first appears?
  5. What is the critical value of b for which the linear approximation first exhibits complex eigenvalues? How do you interpret this situation?

Saving Matlab figures as pdf's

You'll often see me use the function fig4pdf in the Matlab scripts for this course. This function makes it easier to save Matlab figures as nicely formatted pdf files that can be included in reports and presentations. It sets the background color and paper dimensions to produce what -- to my eyes -- is a visually pleasing result with properly cropped borders.  To use it in your own Matlab programming, just include the function call

fig4pdf;

at some point in the process of preparing a figure.  It will have no visual effect on the figure window. Later, when you want to actually save the figure as a pdf file, use the function call

print('-dpdf','r1200', 'myfigure.pdf');

where myfigure.pdf is the desired file name.  Alternatively, you can format and save the figure in one step with the function call

fig4pdf(gcf,'myfigure.pdf');

where gcf refers to the current figure. Because I use fig4pdf in so many of demonstration scripts for this course, you may want to download and store this file in your default Matlab folder.