Changeset 800065 in git


Ignore:
Timestamp:
Apr 30, 2005, 10:34:59 PM (18 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
d462b24fd009524d151b17b9f636c728f0e70e26
Parents:
46f16d4dd0abf5f668386093cdf1bf505129f3bc
Message:
*levandov: big docu-related update, examples are organized in CreateExample


git-svn-id: file:///usr/local/Singular/svn/trunk@7973 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/control.lib

    r46f16d r800065  
    1 version="$Id: control.lib,v 1.28 2005-04-29 14:53:50 levandov Exp $";
     1version="$Id: control.lib,v 1.29 2005-04-30 20:34:59 levandov Exp $";
    22category="System and Control Theory";
    33info="
    4 LIBRARY:  control.lib Procedures for System and Control Theory
     4LIBRARY:  control.lib     Algebraic analysis tools for System and Control Theory
     5
    56AUTHORS:  Oleksandr Iena       yena@mathematik.uni-kl.de
    67@*        Markus Becker        mbecker@mathematik.uni-kl.de
     
    1011and V. Levandovskyy), Uni Kaiserslautern
    1112
    12 NOTE: This library provides algebraic analysis tools for System and Control Theory
    13 
    14 PROCEDURES:
    15 control (R);            analysis of controllability-related properties of R (using Ext modules),
    16 control2 (R);           analysis of controllability-related properties of R (using dimension),
    17 autonom (R);            analysis of autonomy-related properties of R (using Ext modules),
    18 autonom2 (R);           analysis of autonomy-related properties of R (using dimension),
    19 LeftKernel (R);         a left kernel of R,
    20 RightKernel (R);        a right kernel of R,
    21 LeftInverse (R);        a left inverse of R,
    22 RightInverse (R);       a right inverse of R,
    23 smith (M);              a Smith form of a module M,
    24 colrank (M);            a column rank of M as of matrix,
    25 genericity (M);         analysis of the genericity of parameters,
    26 canonize (L);           Groebnerification for modules in the output of control/autonomy procs,
    27 iostruct (R);           computes an I/O-structure of behavior given by a module R
    28 FindTorsion (R, I);     generators of the submodule of a module R, annihilated by the ideal I.
    29 
     13MAIN PROCEDURES:
     14  control(R);            analysis of controllability-related properties of R (using Ext modules)
     15  control2(R);           analysis of controllability-related properties of R (using dimension)
     16  autonom(R);            analysis of autonomy-related properties of R (using Ext modules)
     17  autonom2(R);           analysis of autonomy-related properties of R (using dimension)
     18
     19COMPONENT PROCEDURES:
     20  LeftKernel(R);         a left kernel of R
     21  RightKernel(R);        a right kernel of R
     22  LeftInverse(R);        a left inverse of R
     23  RightInverse(R);       a right inverse of R
     24  smith(M);              a Smith form of a module M
     25  colrank(M);            a column rank of M as of matrix
     26  genericity(M);         analysis of the genericity of parameters
     27  canonize(L);           Groebnerification for modules in the output of control or autonomy procs
     28  iostruct(R);           computes an IO-structure of behavior given by a module R
     29  FindTorsion(R, I);     generators of the submodule of a module R, annihilated by the ideal I
    3030
    3131AUXILIARY PROCEDURES:
    32 declare(NameOfRing,Variables [,Parameters, Ordering]);    define the ring easily
    33 view();                      well-formatted output of lists, modules and matrices
    34 
    35 NOTE (EXAMPLES): In order to use examples below, execute the commands
    36 @* def A = exAntenna(); setring A;
    37 @* Thus A will become a basering from the example with the predefined module R (transposed), corresponding to the system. After that you can just type in
    38 @* control(R); // respectively autonom(R);
    39 and check the result.
    40 
    41 
    42 EXAMPLES (AUTONOMY):
    43 exCauchy();                  example of 1-dimensional Cauchy equation,
    44 exCauchy2();                 example of 2-dimensional Cauchy equation,
    45 exZerz();                    example from the lecture of Eva Zerz,
    46 
    47 EXAMPLES (CONTROLLABILITY):
    48 ex1();                       example of noncontrollable system,   
    49 ex2();                       example of controllable system ,
    50 exAntenna();                 Antenna,
    51 exEinstein();                Einstein equations,
    52 exFlexibleRod();             Flexible Rod,
    53 exTwoPendula();              Two Pendula mounted on a cart,
    54 exWindTunnel();              Wind Tunnel.
     32  ControlExample(s);     set up an example from the mini database inside of the library
     33  declare(N,V,P,O);      defines the ring easily
     34  view();                well-formatted output of lists, modules and matrices
    5535";
    56 
    57 // NOTE: static things should not be shown for end-user
    58 // static Ext_Our(...)                  Copy of Ext_R from 'homolog.lib' in commutative case;
    59 // static is_zero_Our(module R)         Copy of is_zero from 'poly.lib';
    60 //  static space(int n)           Procedure used inside the procedure 'Print' to have a better formatted output
    61 // static control_output();      Generating the output for the procedure 'control'
    62 // static autonom_output();      Generating the output for the procedure 'autonom' and 'autonom2'
    63 // static extgcd_Our(poly p, poly q)  Computes extgcd of p and q. for versions ealier than 2006 extgcd has a bug and is therefore not used
    64 // static normalize_Our(matrix N, matrix Q) normalizes the columns of N and divides the columns of Q through the leading coefficients of the columns of N
    6536
    6637LIB "homolog.lib";
     
    8253  return (v);
    8354}
    84 //---------------------------------------------------------------
    85 proc declare(string NameOfRing, string Variables, list #)
    86 "USAGE: declare(NameOfRing, Variables,[Parameters, Ordering]);
    87 @*          NameOfRing:  string with name of ring,
    88 @*          Variables:   string with names of variables separated by commas(e.g. \"x,y,z\"),
    89 @*          Parameters: string of parameters in the ring separated by commas(e.g. \"a,b,c\"),
    90 @*          Ordering:   string with name of ordering (by default, the ordering (dp,C) is used)
    91 PURPOSE: define the ring easily
    92 RETURN:  no return value
    93 EXAMPLE:  example declare; shows an example
    94 "
    95 {
    96   if(size(#)==0)
    97   {
    98     execute("ring "+NameOfRing+"=0,("+Variables+"),dp;");
    99   }
    100   else
    101   {
    102     if(size(#)==1)
    103     {
    104       execute( "ring " + NameOfRing + "=(0," + #[1] + "),(" + Variables + "),dp;" );
    105     }
    106     else
    107     {
    108       if( (size(#[1])!=0)&&(#[1]!=" ") )
    109       {
    110         execute( "ring " + NameOfRing + "=(0," + #[1] + "),(" + Variables + "),("+#[2]+");" );
    111       }
    112       else
    113       {
    114         execute( "ring " + NameOfRing + "=0,("+Variables+"),("+#[2]+");" );
    115       };
    116     };
    117   };
    118   keepring(basering);
    119 }
    120 example
    121 {"EXAMPLE:";echo = 2;
    122   string v="x,y,z";
    123   string p="q,p";
    124   string Ord ="c,lp";
    125   //----------------------------------
    126   declare("Ring_1",v);
    127   print(nameof(basering));
    128   print(basering);
    129   //----------------------------------
    130   declare("Ring_2",v,p);
    131   print(basering);
    132   print(nameof(basering));
    133   //----------------------------------
    134   declare("Ring_3",v,p,Ord);
    135   print(basering);
    136   print(nameof(basering));
    137   //----------------------------------
    138   declare("Ring_4",v,"",Ord);
    139   print(basering);
    140   print(nameof(basering));
    141   //----------------------------------
    142   declare("Ring_5",v," ",Ord);
    143   print(basering);
    144   print(nameof(basering));
    145 };
    146 //
    147 // maybe reasonable to add this in declare
    148 //
    149 //  print("Please enter your representation matrix in the following form:
    150 //  module R=[1st row],[2nd row],...");
    151 //  print("Type the command: R=transpose(R)");
    152 //  print(" To compute controllability please enter: control(R)");
    153 //  print(" To compute autonomy please enter: autonom(R)");
     55
    15456//-------------------------------------------------------------------------
    15557
    15658static proc space(int n)
    157 "USAGE:spase(n);
    158          n: integer, number of needed spaces
     59"USAGE:spase(n); n is an integer (number of needed spaces)
    15960RETURN:  string consisting of n spaces
    16061NOTE:  the procedure is used in the procedure 'view' to have a better formatted output
    161 "
    162 {
     62"{
    16363  int i;
    16464  string s="";
     
    17171//-----------------------------------------------------------------------------
    17272proc view(M)
    173 "USAGE:  view(M);
    174            M:  any type
     73"USAGE:  view(M);   M is of any type
    17574RETURN:  no return value
    176 PURPOSE:  procedure for ( well-) formatted output of modules, matrices, lists of modules, matrices;
    177           shows everything even if entries are long
     75PURPOSE:  procedure for (well-) formatted output of modules, matrices, lists of modules, matrices; shows everything even if entries are long
    17876NOTE:  in case of other types( not 'module', 'matrix', 'list') works just as standard 'print' procedure 
    17977EXAMPLE:  example view; shows an example
    180 "
    181 {
     78"{
    18279  // to be replaced with something more feasible
    18380  if ( (typeof(M)=="module")||(typeof(M)=="matrix") )
     
    255152RETURN:  module
    256153EXAMPLE: example RightKernel; shows an example
    257 "
    258 {
     154"{
    259155  return(modulo(M,std(0)));
    260156}
     
    295191RETURN:  module
    296192EXAMPLE: example LeftInverse; shows an example
    297 NOTE: exists only in the case when Id \subseteq M!
     193NOTE: exists only in the case when Id belongs to M!
    298194"
    299195{
     
    319215}
    320216example
    321 { // trivial example:
    322 "EXAMPLE:";echo =2;
     217{
     218  "EXAMPLE:";echo =2;
     219  // a trivial example:
    323220  ring r = 0,(x,z),dp;
    324221  matrix M[2][1] = 1,x2z;
     
    326223  print( LeftInverse(M) ); 
    327224  kill r;
    328   // derived from the exTwoPendula
     225  // derived from the example TwoPendula:
    329226  ring r=(0,m1,m2,M,g,L1,L2),Dt,dp;
    330227  matrix U[3][1];
     
    335232  module L = LeftInverse(M);
    336233  print(L);
     234  // check
     235  print(L*M);
    337236};
    338237//-----------------------------------------------------------------------
     
    342241RETURN:  module
    343242EXAMPLE: example RightInverse; shows an example
    344 NOTE: exists only in the case when Id \subseteq M!
     243NOTE: exists only in the case when Id belongs to M!
    345244"
    346245{
     
    349248example
    350249{ "EXAMPLE:";echo =2;
    351   // trivial example:
     250  // a trivial example:
    352251  ring r = 0,(x,z),dp;
    353252  matrix M[1][2] = 1,x2+z;
     
    355254  print( RightInverse(M) ); 
    356255  kill r;
    357   // derived from the exTwoPendula
     256  // derived from the TwoPendula example:
    358257  ring r=(0,m1,m2,M,g,L1,L2),Dt,dp;
    359258  matrix U[1][3];
     
    364263  module L = RightInverse(M);
    365264  print(L);
     265  // check
     266  print(M*L);
    366267};
    367268//-----------------------------------------------------------------------
     
    407308//------------------------------------------------------------------------
    408309static proc control_output(int i, int NVars, module R, module Ext_1, list Gen)
    409 //static proc control_output(int i, int NVars, module R, module Ext_1)
    410 "USAGE:  control_output(i, NVars, R, Ext_1), where
    411            i:  integer, number of first nonzero Ext or
    412              just a number of variables in a base ring + 1 in case that all the Exts are zero,
    413            NVars:  integer, number of variables in a base ring,
    414            R:  module R (cokernel representation),
    415            Ext_1:  module, the first Ext(its cokernel representation)     
     310"USAGE:  control_output(i, NVars, R, Ext_1),
     311PURPOSE: where
     312@*         i is integer (number of first nonzero Ext or a number of variables in a basering + 1 in case that all the Exts are zero),
     313@*         NVars:  integer, number of variables in a base ring,
     314@*         R:  module R (cokernel representation),
     315@*         Ext_1:  module, the first Ext(its cokernel representation)     
    416316RETURN:  list with all the contollability properties of the system which is to be returned in 'control' procedure
    417317NOTE:  this procedure is used in 'control' procedure
    418 "
    419 {
     318"{
    420319  // TODO: NVars to be replaced with the global hom. dimension of basering!!!
    421320  // Is not clear what to do with gl.dim of qrings
     
    523422example
    524423{"EXAMPLE:";echo = 2;
    525   //Wind Tunnel
     424  // a WindTunnel example
    526425  ring A = (0,a, omega, zeta, k),(D1, delta),dp;
    527426  module R;
     
    539438RETURN: list
    540439EXAMPLE:  example control2; shows an example
    541 NOTE: same as control(R); but using dimensions, this procedure only works for full row rank matrices
     440NOTE: this procedure is analogous to 'control' but uses dimension calculations.This approach works for full row rank matrices only.
    542441"
    543442{
     
    559458example
    560459{"EXAMPLE:";echo = 2;
    561   //Wind Tunnel
     460  //a WindTunnel example
    562461  ring A = (0,a, omega, zeta, k),(D1, delta),dp;
    563462  module R;
     
    696595example
    697596{"EXAMPLE:"; echo = 2;
    698   //Cauchy
     597  // Cauchy1 example
    699598  ring r=0,(s1,s2,s3,s4),dp;
    700599  module R= [s1,-s2],
     
    746645}; 
    747646
    748 //----------------------------------------------------------
    749 //
    750 //Some example rings with defined systems
    751 //----------------------------------------------------------
    752 //autonomy:
    753 //
    754 //----------------------------------------------------------
    755 proc exCauchy()
    756 {
    757   ring @r=0,(s1,s2),dp;
    758   module R= [s1,-s2],
    759             [s2, s1];
    760   R=transpose(R);
    761   export R;
    762   return(@r);       
    763 };
    764 //----------------------------------------------------------
    765 proc exCauchy2()
    766 {
    767   ring @r=0,(s1,s2,s3,s4),dp;
    768   module R= [s1,-s2],
    769             [s2, s1],
    770             [s3,-s4],
    771             [s4, s3];       
    772   R=transpose(R);
    773   export R;
    774   return(@r);       
    775 };
    776 //----------------------------------------------------------
    777 proc exZerz()
    778 {
    779   ring @r=0,(d1,d2),dp;
    780   module R=[d1^2-d2],
    781            [d2^2-1];
    782   R=transpose(R);
    783   export R;
    784   return(@r);       
    785 }; 
    786 //----------------------------------------------------------
    787 //control
    788 //----------------------------------------------------------
    789 proc ex1()
    790 {
    791   ring @r=0,(s1,s2,s3),dp;
    792   module R=[0,-s3,s2],
    793            [s3,0,-s1];
    794   R=transpose(R);         
    795   export R;
    796   return(@r);
    797 };
    798 //----------------------------------------------------------
    799 proc ex2()
    800 {
    801   ring @r=0,(s1,s2,s3),dp;
    802   module R=[0,-s3,s2],
    803            [s3,0,-s1],
    804            [-s2,s1,0];
    805   R=transpose(R);         
    806   export R;
    807   return(@r);
    808 };
    809 //----------------------------------------------------------
    810 proc exAntenna()
    811 {
    812   ring @r = (0, K1, K2, Te, Kp, Kc),(Dt, delta), dp;
    813   module R;
    814   R = [Dt, -K1, 0, 0, 0, 0, 0, 0, 0],
    815       [0, Dt+K2/Te, 0, 0, 0, 0, -Kp/Te*delta, -Kc/Te*delta, -Kc/Te*delta],
    816       [0, 0, Dt, -K1, 0, 0, 0, 0, 0],
    817       [0, 0, 0, Dt+K2/Te, 0, 0, -Kc/Te*delta, -Kp/Te*delta, -Kc/Te*delta],
    818       [0, 0, 0, 0, Dt, -K1, 0, 0, 0],
    819       [0, 0, 0, 0, 0, Dt+K2/Te, -Kc/Te*delta, -Kc/Te*delta, -Kp/Te*delta];
    820 
    821   R=transpose(R);
    822   export R;
    823   return(@r); 
    824 };
    825 
    826 //----------------------------------------------------------
    827 
    828 proc exEinstein()
    829 {
    830   ring @r = 0,(D(1..4)),dp;
    831   module R =
    832   [D(2)^2+D(3)^2-D(4)^2, D(1)^2, D(1)^2, -D(1)^2, -2*D(1)*D(2), 0, 0, -2*D(1)*D(3), 0, 2*D(1)*D(4)],
    833   [D(2)^2, D(1)^2+D(3)^2-D(4)^2, D(2)^2, -D(2)^2, -2*D(1)*D(2), -2*D(2)*D(3), 0, 0, 2*D(2)*D(4), 0],
    834   [D(3)^2, D(3)^2, D(1)^2+D(2)^2-D(4)^2, -D(3)^2, 0, -2*D(2)*D(3), 2*D(3)*D(4), -2*D(1)*D(3), 0, 0],
    835   [D(4)^2, D(4)^2, D(4)^2, D(1)^2+D(2)^2+D(3)^2, 0, 0, -2*D(3)*D(4), 0, -2*D(2)*D(4), -2*D(1)*D(4)],
    836   [0, 0, D(1)*D(2), -D(1)*D(2), D(3)^2-D(4)^2, -D(1)*D(3), 0, -D(2)*D(3), D(1)*D(4), D(2)*D(4)],
    837   [D(2)*D(3), 0, 0, -D(2)*D(3),-D(1)*D(3), D(1)^2-D(4)^2, D(2)*D(4), -D(1)*D(2), D(3)*D(4), 0],
    838   [D(3)*D(4), D(3)*D(4), 0, 0, 0, -D(2)*D(4), D(1)^2+D(2)^2, -D(1)*D(4), -D(2)*D(3), -D(1)*D(3)],
    839   [0, D(1)*D(3), 0, -D(1)*D(3), -D(2)*D(3), -D(1)*D(2), D(1)*D(4), D(2)^2-D(4)^2, 0, D(3)*D(4)],
    840   [D(2)*D(4), 0, D(2)*D(4), 0, -D(1)*D(4), -D(3)*D(4), -D(2)*D(3), 0, D(1)^2+D(3)^2, -D(1)*D(2)],
    841   [0, D(1)*D(4), D(1)*D(4), 0, -D(2)*D(4), 0, -D(1)*D(3), -D(3)*D(4), -D(1)*D(2), D(2)^2+D(3)^2];
    842 
    843   R=transpose(R);
    844   export R;
    845   return(@r); 
    846 };
    847 
    848 //----------------------------------------------------------
    849 proc exFlexibleRod()
    850 {
    851   ring @r = 0,(D1, delta), dp;
    852   module R;
    853   R = [D1, -D1*delta, -1], [2*D1*delta, -D1-D1*delta^2, 0];
    854  
    855   R=transpose(R);
    856   export R;
    857   return(@r); 
    858 };
    859 
    860 //----------------------------------------------------------
    861 proc exTwoPendula()
    862 
    863   ring @r=(0,m1,m2,M,g,L1,L2),Dt,dp;
    864   module R = [m1*L1*Dt^2, m2*L2*Dt^2, -1, (M+m1+m2)*Dt^2],
    865              [m1*L1^2*Dt^2-m1*L1*g, 0, 0, m1*L1*Dt^2],
    866              [0, m2*L2^2*Dt^2-m2*L2*g, 0, m2*L2*Dt^2];
    867 
    868   R=transpose(R);
    869   export R;
    870   return(@r); 
    871 };
    872 //----------------------------------------------------------
    873 proc exWindTunnel()
    874 {
    875   ring @r = (0,a, omega, zeta, k),(D1, delta),dp;
    876   module R = [D1+a, -k*a*delta, 0, 0],
    877              [0, D1, -1, 0],
    878              [0, omega^2, D1+2*zeta*omega, -omega^2];
    879 
    880   R=transpose(R);
    881   export R;
    882   return(@r); 
    883 };
     647
    884648//----------------------------------------------------------
    885649proc genericity(matrix M)
     
    1210974 //Example Antenna
    1211975 ring r = (0, K1, K2, Te, Kp, Kc),(Dt, delta), (c,dp);
    1212  
    1213976 module RR;
    1214  RR = [Dt, -K1, 0, 0, 0, 0, 0, 0, 0],
     977 RR =
     978   [Dt, -K1, 0, 0, 0, 0, 0, 0, 0],
    1215979   [0, Dt+K2/Te, 0, 0, 0, 0, -Kp/Te*delta, -Kc/Te*delta, -Kc/Te*delta],
    1216980   [0, 0, Dt, -K1, 0, 0, 0, 0, 0],
     
    1219983   [0, 0, 0, 0, 0, Dt+K2/Te, -Kc/Te*delta, -Kc/Te*delta, -Kp/Te*delta];
    1220984 module R = transpose(RR);
    1221  view(R);
    1222985 view(iostruct(R));
    1223986};     
     
    1225988//---------------------------------------------------------------
    1226989static proc smdeg(matrix N) 
    1227 // returns an intvec of length 2 with the index of an element of N with smallest degree
     990"USAGE: smdeg( N ); N a matrix
     991RETURN:  intvec
     992PURPOSE: returns an intvec of length 2 with the index of an element of N with smallest degree
     993"
    1228994{
    1229995  int n = nrows(N);
     
    12801046//---------------------------------------------------------------
    12811047static proc NoNon0Pol(vector v)
    1282 // returns 1, if there is only one non-zero element in v and 0 else
    1283 {
     1048"USAGE: NoNon0Pol(v), v a vector
     1049RETURN:  int
     1050PURPOSE: returns 1, if there is only one non-zero element in v and 0 else
     1051"{
    12841052  int i,j;
    12851053  int n = nrows(v);
     
    14911259  // see what happens when the matrix is already in Smith-Form
    14921260  module M = [x,0,0],[0,x2,0],[0,0,x3];
    1493   print(M);
    14941261  list L = smith(M);
    14951262  print(L[1]);
     
    15071274}
    15081275//---------------------------------------------------------------
    1509 proc list_tex(L, string name,link l,int nr_loop)
     1276static proc list_tex(L, string name,link l,int nr_loop)
    15101277"USAGE: list_tex(L,name,l), where L is a list, name a string, l a link
    15111278         writes the content of list L in a tex-file 'name'
     
    15661333  }
    15671334}
     1335example
     1336{
     1337  "EXAMPLE:";echo = 2;
     1338}
    15681339//---------------------------------------------------------------
    15691340proc verbatim_tex(string s, link l)
     
    15781349  write(l,"\\end{verbatim}");
    15791350  write(l,"\\par");
     1351}
     1352example
     1353{
     1354  "EXAMPLE:";echo = 2;
    15801355}
    15811356//---------------------------------------------------------------
     
    16211396  print(Tr); // generators of the torsion submodule
    16221397}
     1398
     1399
     1400proc ControlExample(string s)
     1401"USAGE:  ControlExample(s);   s a string
     1402PURPOSE: set up an example from the mini database by initalizing a ring and a module in a ring
     1403RETURN:  ring
     1404NOTE: in order to see the list of available examples, execute @code{ControlExample(\"show\");}
     1405@* To use ab example, one has to do the following. Suppose one calls the ring, where the example will be activated, A. Then, by executing
     1406@*  @code{def A = ControlExample(\"Antenna\");} and @code{setring A;},
     1407@* A will become a basering from the example \"Antenna\" with
     1408the predefined system module R (transposed).
     1409After that one can just execute @code{control(R);} respectively
     1410@code{autonom(R);} to perform the control resp. autonomy analysis of R.
     1411EXAMPLE: example ControlExample; shows an example
     1412"{
     1413  list E, S, D; // E=official name, S=synonym, D=description
     1414  E[1] = "Cauchy1";  S[1] = "cauchy1";  D[1] = "1-dimensional Cauchy equation";
     1415  E[2] = "Cauchy2";  S[2] = "cauchy2";  D[2] = "2-dimensional Cauchy equation";
     1416  E[3] = "Control1"; S[3] = "control1"; D[3] = "example of a simple noncontrollable system";
     1417  E[4] = "Control2"; S[4] = "control2"; D[4] = "example of a simple controllable system";
     1418  E[5] = "Antenna";  S[5] = "antenna";  D[5] = "antenna";
     1419  E[6] = "Einstein"; S[6] = "einstein"; D[6] = "Einstein equations in vacuum";
     1420  E[7] = "FlexibleRod"; S[7] = "flexible rod"; D[7] = "flexible rod";
     1421  E[8] = "TwoPendula";  S[8] = "two pendula";  D[8] = "two pendula mounted on a cart";
     1422  E[9] = "WindTunnel";  S[9] = "wind tunnel";D[9] = "wind tunnel";
     1423  E[10] = "Zerz1";      S[10] = "zerz1"; D[10] = "example from the lecture of Eva Zerz";
     1424  // all the examples so far
     1425  int i;
     1426  if ( (s=="show") || (s=="Show") )
     1427  {
     1428    print("The list of examples:");
     1429    for (i=1; i<=size(E); i++)
     1430    {
     1431      printf("name: %s,  desc: %s", E[i],D[i]);
     1432    }
     1433    return();
     1434  }
     1435  string t;
     1436  for (i=1; i<=size(E); i++)
     1437  {
     1438    if ( (s==E[i]) || (s==S[i]) )
     1439    {
     1440      t = "def @A = ex"+E[i]+"();";
     1441      execute(t);
     1442      return(@A);
     1443    }
     1444  }
     1445  "No example found";
     1446  return();
     1447}
     1448example
     1449{
     1450  "EXAMPLE:";echo = 2;
     1451  ControlExample("show");   // let us see all available examples:
     1452  def B = ControlExample("TwoPendula"); // let us set up a particular example
     1453  setring B;
     1454  print(R);
     1455}
     1456
     1457//----------------------------------------------------------
     1458//
     1459//Some example rings with defined systems
     1460//----------------------------------------------------------
     1461//autonomy:
     1462//
     1463//----------------------------------------------------------
     1464static proc exCauchy1()
     1465{
     1466  ring @r=0,(s1,s2),dp;
     1467  module R= [s1,-s2],
     1468            [s2, s1];
     1469  R=transpose(R);
     1470  export R;
     1471  return(@r);       
     1472};
     1473//----------------------------------------------------------
     1474static proc exCauchy2()
     1475{
     1476  ring @r=0,(s1,s2,s3,s4),dp;
     1477  module R= [s1,-s2],
     1478            [s2, s1],
     1479            [s3,-s4],
     1480            [s4, s3];       
     1481  R=transpose(R);
     1482  export R;
     1483  return(@r);       
     1484};
     1485//----------------------------------------------------------
     1486static proc exZerz1()
     1487{
     1488  ring @r=0,(d1,d2),dp;
     1489  module R=[d1^2-d2],
     1490           [d2^2-1];
     1491  R=transpose(R);
     1492  export R;
     1493  return(@r);       
     1494}; 
     1495//----------------------------------------------------------
     1496//control
     1497//----------------------------------------------------------
     1498static proc exControl1()
     1499{
     1500  ring @r=0,(s1,s2,s3),dp;
     1501  module R=[0,-s3,s2],
     1502           [s3,0,-s1];
     1503  R=transpose(R);         
     1504  export R;
     1505  return(@r);
     1506};
     1507//----------------------------------------------------------
     1508static proc exControl2()
     1509{
     1510  ring @r=0,(s1,s2,s3),dp;
     1511  module R=[0,-s3,s2],
     1512           [s3,0,-s1],
     1513           [-s2,s1,0];
     1514  R=transpose(R);         
     1515  export R;
     1516  return(@r);
     1517};
     1518//----------------------------------------------------------
     1519static proc exAntenna()
     1520{
     1521  ring @r = (0, K1, K2, Te, Kp, Kc),(Dt, delta), dp;
     1522  module R;
     1523  R = [Dt, -K1, 0, 0, 0, 0, 0, 0, 0],
     1524      [0, Dt+K2/Te, 0, 0, 0, 0, -Kp/Te*delta, -Kc/Te*delta, -Kc/Te*delta],
     1525      [0, 0, Dt, -K1, 0, 0, 0, 0, 0],
     1526      [0, 0, 0, Dt+K2/Te, 0, 0, -Kc/Te*delta, -Kp/Te*delta, -Kc/Te*delta],
     1527      [0, 0, 0, 0, Dt, -K1, 0, 0, 0],
     1528      [0, 0, 0, 0, 0, Dt+K2/Te, -Kc/Te*delta, -Kc/Te*delta, -Kp/Te*delta];
     1529
     1530  R=transpose(R);
     1531  export R;
     1532  return(@r); 
     1533};
     1534
     1535//----------------------------------------------------------
     1536
     1537static proc exEinstein()
     1538{
     1539  ring @r = 0,(D(1..4)),dp;
     1540  module R =
     1541  [D(2)^2+D(3)^2-D(4)^2, D(1)^2, D(1)^2, -D(1)^2, -2*D(1)*D(2), 0, 0, -2*D(1)*D(3), 0, 2*D(1)*D(4)],
     1542  [D(2)^2, D(1)^2+D(3)^2-D(4)^2, D(2)^2, -D(2)^2, -2*D(1)*D(2), -2*D(2)*D(3), 0, 0, 2*D(2)*D(4), 0],
     1543  [D(3)^2, D(3)^2, D(1)^2+D(2)^2-D(4)^2, -D(3)^2, 0, -2*D(2)*D(3), 2*D(3)*D(4), -2*D(1)*D(3), 0, 0],
     1544  [D(4)^2, D(4)^2, D(4)^2, D(1)^2+D(2)^2+D(3)^2, 0, 0, -2*D(3)*D(4), 0, -2*D(2)*D(4), -2*D(1)*D(4)],
     1545  [0, 0, D(1)*D(2), -D(1)*D(2), D(3)^2-D(4)^2, -D(1)*D(3), 0, -D(2)*D(3), D(1)*D(4), D(2)*D(4)],
     1546  [D(2)*D(3), 0, 0, -D(2)*D(3),-D(1)*D(3), D(1)^2-D(4)^2, D(2)*D(4), -D(1)*D(2), D(3)*D(4), 0],
     1547  [D(3)*D(4), D(3)*D(4), 0, 0, 0, -D(2)*D(4), D(1)^2+D(2)^2, -D(1)*D(4), -D(2)*D(3), -D(1)*D(3)],
     1548  [0, D(1)*D(3), 0, -D(1)*D(3), -D(2)*D(3), -D(1)*D(2), D(1)*D(4), D(2)^2-D(4)^2, 0, D(3)*D(4)],
     1549  [D(2)*D(4), 0, D(2)*D(4), 0, -D(1)*D(4), -D(3)*D(4), -D(2)*D(3), 0, D(1)^2+D(3)^2, -D(1)*D(2)],
     1550  [0, D(1)*D(4), D(1)*D(4), 0, -D(2)*D(4), 0, -D(1)*D(3), -D(3)*D(4), -D(1)*D(2), D(2)^2+D(3)^2];
     1551
     1552  R=transpose(R);
     1553  export R;
     1554  return(@r); 
     1555};
     1556
     1557//----------------------------------------------------------
     1558static proc exFlexibleRod()
     1559{
     1560  ring @r = 0,(D1, delta), dp;
     1561  module R;
     1562  R = [D1, -D1*delta, -1], [2*D1*delta, -D1-D1*delta^2, 0];
     1563 
     1564  R=transpose(R);
     1565  export R;
     1566  return(@r); 
     1567};
     1568
     1569//----------------------------------------------------------
     1570static proc exTwoPendula()
     1571
     1572  ring @r=(0,m1,m2,M,g,L1,L2),Dt,dp;
     1573  module R = [m1*L1*Dt^2, m2*L2*Dt^2, -1, (M+m1+m2)*Dt^2],
     1574             [m1*L1^2*Dt^2-m1*L1*g, 0, 0, m1*L1*Dt^2],
     1575             [0, m2*L2^2*Dt^2-m2*L2*g, 0, m2*L2*Dt^2];
     1576
     1577  R=transpose(R);
     1578  export R;
     1579  return(@r); 
     1580};
     1581//----------------------------------------------------------
     1582static proc exWindTunnel()
     1583{
     1584  ring @r = (0,a, omega, zeta, k),(D1, delta),dp;
     1585  module R = [D1+a, -k*a*delta, 0, 0],
     1586             [0, D1, -1, 0],
     1587             [0, omega^2, D1+2*zeta*omega, -omega^2];
     1588
     1589  R=transpose(R);
     1590  export R;
     1591  return(@r); 
     1592};
     1593
     1594
     1595//---------------------------------------------------------------
     1596proc declare(string NameOfRing, string Variables, list #)
     1597"USAGE: declare(NameOfRing, Variables,[Parameters, Ordering]);  where
     1598@*         NameOfRing is string with name of ring,
     1599@*         Variables is a string with names of variables separated by commas (e.g. \"x,y,z\"),
     1600@*          Parameters is string of parameters in the ring separated by commas (e.g. \"a,b,c\"),
     1601@*          Ordering is   string with name of ordering (by default, the ordering (dp,C) is used).
     1602PURPOSE: define the ring easily
     1603RETURN:  no return value
     1604 EXAMPLE:  example declare; shows an example
     1605 "
     1606 {
     1607   if(size(#)==0)
     1608   {
     1609     execute("ring "+NameOfRing+"=0,("+Variables+"),dp;");
     1610   }
     1611   else
     1612   {
     1613     if(size(#)==1)
     1614     {
     1615       execute( "ring " + NameOfRing + "=(0," + #[1] + "),(" + Variables + "),dp;" );
     1616     }
     1617     else
     1618     {
     1619       if( (size(#[1])!=0)&&(#[1]!=" ") )
     1620       {
     1621         execute( "ring " + NameOfRing + "=(0," + #[1] + "),(" + Variables + "),("+#[2]+");" );
     1622       }
     1623       else
     1624       {
     1625         execute( "ring " + NameOfRing + "=0,("+Variables+"),("+#[2]+");" );
     1626       };
     1627     };
     1628   };
     1629   keepring(basering);
     1630 }
     1631 example
     1632 {"EXAMPLE:";echo = 2;
     1633   string v="x,y,z";
     1634   string p="q,p";
     1635   string Ord ="c,lp";
     1636   //----------------------------------
     1637   declare("Ring_1",v);
     1638   print(nameof(basering));
     1639   print(basering);
     1640   //----------------------------------
     1641   declare("Ring_2",v,p);
     1642   print(basering);
     1643   print(nameof(basering));
     1644   //----------------------------------
     1645   declare("Ring_3",v,p,Ord);
     1646   print(basering);
     1647   print(nameof(basering));
     1648   //----------------------------------
     1649   declare("Ring_4",v,"",Ord);
     1650   print(basering);
     1651   print(nameof(basering));
     1652   //----------------------------------
     1653   declare("Ring_5",v," ",Ord);
     1654   print(basering);
     1655   print(nameof(basering));
     1656 };
     1657//
     1658// maybe reasonable to add this in declare
     1659//
     1660//  print("Please enter your representation matrix in the following form:
     1661//  module R=[1st row],[2nd row],...");
     1662//  print("Type the command: R=transpose(R)");
     1663//  print(" To compute controllability please enter: control(R)");
     1664//  print(" To compute autonomy please enter: autonom(R)");
Note: See TracChangeset for help on using the changeset viewer.