|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Start of topic | Skip to actions
Acumen User GuideRelease Notes: Version 1.0, based on Acumen alpha_2007_11_01.Authors: The Acumen Development Team at Rice. Acumen is a simulation environment for continous-time physical systems containing event-driven controllers. This document is aimed at mechanical engineers interested in modeling and simulating such systems. The document familiarizes the user with the layout and functionality of graphical user interface, and explains how to write physical descriptions in the PhyDL component of Acumen, as well as how to write reactive controllers using the RIDL component. The document also defines the syntax for the primitive operations provided by Acumen, and explain how to control a simulation. Acknowledgements: This work was funded by the National Science Foundation and Schlumberger. Preliminaries. Acumen = PhyDL + RIDLWhen the Acumen environment is started, the language for modeling physical part is located on the left-hand column of the screen, which is called PhyDL (Physical Description Language). The language for modeling controller part is located on the upper right-hand area of the screen, which is called RIDL (Reactive Interrupt Driven Language). Following is a snapshot of Acumen user interface.
Comments in Acumen are enclosed in (* This is just comment of the program. *) Important Note on Syntax: Throughout this guide, when example syntax is given for a code, the semi-colons found at the end of some lines of code are necessary for the code to run properly. PhyDLA PhyDL program is organized into several modules, namely:
System Module (Inputting System Equations and Constants)A dynamical system can be described by a set of differential equations together with definitions of the variables in these equations. For example, a simple pendulum can be described by a differential equation with some boundary conditions:theta''=-1/I* (m*l*sin(theta) + F*l*cos(theta); theta(0) = 0.1; theta'(0)=0; The first equation above describes the dynamics of this system, that is, the second derivative of theta. The next two equations give the initial conditions of the system, in this case, the initial position and initial velocity of the pendulum (theta and the first derivative of theta.) The following is a picture of a simple pendulum.
Differential equations and constants for a system are listed under the System Module in Acumen. First let us explain how to code differential equations: PhyDL allows you to write differential equations directly. However, some restrictions apply:
system
<var>^(n) = exp;
where
system
theta''= -1/I* (m*l*sin(theta) + F*l*cos(theta);
Now, we will cover how to code variables. In a PhyDL program, no free variables are allowed. In other words, if a variable appears in any equation, then it must be defined within the program. For example, the differential equation we have been working with has variables which represent mass (m), length (l), etc. So in order to describe the system these variables must be defined. In Acumen, this should be done in the System Module. The following code for the System Module is an example of how to code both variables and the differential equation of the system:
system
m = 0.5; (* mass *)
l = 0.3; (* length *)
I = m * l * l; (* moment of inertia *)
theta''= -1/I* (m*l*sin(theta) + F*l*cos(theta); (*differential equation of system*)
Boundary Module (Inputting Boundary Conditions)To describe a system in PhyDL, we must list boundary conditions in the Boundary Module. Keep in mind that if the highest order of derivative of a variable is n, then the boundary conditions listed must include the value of this variable for each derivative from the (n-1)th derivative to the 0th derivative. The syntax for listing boundary conditions is as follows:
boundary
<var> with <var>(0) = <number>, <var>'(0)=<number>;
For example:
boundary
theta with theta(0) = 0.1, theta'(0)=0;
Simulation ModuleThe first module listed in PhyDL, the Simulation Module, gives PhyDL information about the simulation. With representing any number, the syntax for the commands that are used to specify the conditions of starting time, ending time and step size at which the system should be evaluated are:
simulation
starting_time = <number>;
ending_time = <number>;
step_size = <number>;
Here, the unit of time is second. The value of the starting time must be less than or equal to the value of the ending time. The step size value is used for numerical computation, it is the mesh of partition to discretize the continuous time. An example of correct simulation code is:
simulation
starting_time = 0;
ending_time = 30;
step_size = 0.001;
External Module for RIDL Code (Interaction with Control Description)A RIDL program describes the control information of the system. A PhyDL program can interact with a RIDL program in the External Module. However, the External Module is not simply for RIDL functions. (We shall see soon how PhyDL can interact with MATLAB as well in the following section.) The control input is taken from an external program written in RIDL. The syntax for calling an external RIDL controller is:
external ridl "filename.ridl"
reads <var>, <var>, ... ;
writes <var>, <var>, ... ;
observes event <var> rate t = <number>,
event <var> when t = <number>;
Each In the external ridl "simple_pendulum_control.ridl" reads theta ; writes F ; observes event clock rate t = 0.1; External Module for MATLAB (Interaction with MATLAB)The External Module in PhyDL links the PhyDL program to an external program. One commonly used external program is MATLAB. In order to plot simulation results of a function to produce a program visualization, you use the following syntax:external matlab reads <variable>, <variable>, ... ; Here we have "reads" which specifies that MATLAB will read the system data for the listed variables and plot it. These variables are the dependent variables of a system and MATLAB plots them with respect to time. If a variable is defined as a constant in system equations, Acumen will choose not to display it and throw an error message. RIDLRIDL programs are coded separately from PhyDL programs and are meant to act as interchangable controllers for a given PhyDL program. As stated before, while simulation takes place, the PhyDL program needs to acquire control information from a given RIDL program, while this RIDL programs must "observe" the system state from the PhyDL program. In order to understand how to code a RIDL program, it is best to study examples. Let us first take a look at the following simple RIDL program:
theta = 0.1;
F = init 0 in
{ clock => -4.9 * theta }
We suppose here that we have a global event named "clock". The frequency of this event is not determined in the RIDL program, but is specified in the PhyDL code that calls the RIDL program. The first line in this example program states "theta" is simply a variable with value 0.1. The second and third lines in this program define a variable "F". In this case, F is a "reactive behavior," which means that the value of F will be updated when some event happens (in this case, the event is called "clock".) The syntax "init 0" means that the initial value of F is 0, that is, at time t=0 or just after the system is reset F = 0. The information within the curly brackets is the event handler, Now let's examine a more complex RIDL example:
theta = init y=0.1 in
{ clock => -1 * y }
We now have re-defined "theta" to be a "reactive behavior" as well. The first line of code states that at time t = 0, theta = 0.1. The variable y is a temporary variable name for theta. Temporary variables are used when the new value of a variable is dependent on the former value. The second line specifies that when the event "clock" occurs, RIDL should compute theta using the formula A Complete ExampleIn Acumen, PhyDL and RIDL work together through the External RIDL Module in PhyDL. (Please see "External Module for RIDL Code" above.) Thus, it is possible to use a variable in RIDL whose value is only defined in PhyDL or vice versa. For example, the following RIDL program uses theta in order to compute F but only defines theta in PhyDL.
(* RIDL program *)
F = init 0 in
{ clock => -4.9 * theta }
(* PhyDL program *)
simulation
starting_time = 0; ending_time = 30; step_size = 0.001;
external ridl "pendulum_control.ridl"
reads theta;
writes F;
observes event clock rate t = 0.1;
external matlab
reads theta, F;
boundary
theta with theta(0)= 0.1, theta'(0)= 0;
system
m = 0.5;
g = 9.8;
l = 0.3;
I = m * l * l;
theta'' = - 1/I * (m*g*l*sin(theta) + F*l*cos(theta));
The following picture illustrates the result.
Primitive Values and Functions in PhyDLIn PhyDL, We support following primitive functions:
Running an Acumen ProgramIn the Simulation Controls section located in the middle of the right hand portion of the screen, there are two buttons which control the running of a simulation. One is "reset" and the other is "step". The "reset" button resets the system settings and state to the initial conditions. This button should be clicked on before performing any new simulation in order to ensure that the simulation begins from the initial conditions. In order to actually run a simulation, one must simply click on the "step" button which triggers the simulation. Acumen will generate information on the final state of the system that can be found within the Simulation Controls box under the tab "Final State" as well as run this information through MATLAB (assuming the External Module for MATLAB is included in the PhyDL code) which will return the desired plot. The "Trace" in the Simulation Controls box displays information about the system at intervals from the initial state to the final state.As far as plotting the results of a simulation, whenever "reset" is clicked Acumen clears the picture of the last trace. Then, when "step" is clicked, Acumen updates the current plot with the newest simulation results. In the current Acumen package, "trace_matlab" is the file that keeps the trace after simulation. If the External Module for MATLAB is used in a code, MATLAB is triggered when we click on "step". When the simulation results are updated the file "trigger_matlab" holds these results. Thus, when an action happens in PhyDL, we write some information into this file. This is monitored by Acumen and when the file has some new information, MATLAB will be triggered again and make modifications according to the information in the file "trigger_matlab". ReferencesAccess Permissions
Topic Actions: Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r97 < r96 < r95 < r94 < r93 | More topic actions
Webs: Main | TWiki | Africa | Gpce | Houston | International | K12 | MetaOCaml | MulticoreOCR | ProgrammingLanguages | RAP | RIDL | Sandbox | Teaching | Texbot | WG211 Web Actions:
RAP.MemoAcumenUserGuide moved from RAP.TaskAcumenUserGuide on 01 Nov 2007 - 21:03 by Main.WalidTaha - put it back
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This work is licensed under a Creative Commons Attribution 2.5 License. Please follow our citation guidelines.