Changeset 800065 in git
- Timestamp:
- Apr 30, 2005, 10:34:59 PM (18 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- d462b24fd009524d151b17b9f636c728f0e70e26
- Parents:
- 46f16d4dd0abf5f668386093cdf1bf505129f3bc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/control.lib
r46f16d r800065 1 version="$Id: control.lib,v 1.2 8 2005-04-29 14:53:50levandov Exp $";1 version="$Id: control.lib,v 1.29 2005-04-30 20:34:59 levandov Exp $"; 2 2 category="System and Control Theory"; 3 3 info=" 4 LIBRARY: control.lib Procedures for System and Control Theory 4 LIBRARY: control.lib Algebraic analysis tools for System and Control Theory 5 5 6 AUTHORS: Oleksandr Iena yena@mathematik.uni-kl.de 6 7 @* Markus Becker mbecker@mathematik.uni-kl.de … … 10 11 and V. Levandovskyy), Uni Kaiserslautern 11 12 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 13 MAIN 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 19 COMPONENT 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 30 30 31 31 AUXILIARY 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 55 35 "; 56 57 // NOTE: static things should not be shown for end-user58 // 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 output61 // 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 used64 // 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 N65 36 66 37 LIB "homolog.lib"; … … 82 53 return (v); 83 54 } 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 154 56 //------------------------------------------------------------------------- 155 57 156 58 static 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) 159 60 RETURN: string consisting of n spaces 160 61 NOTE: the procedure is used in the procedure 'view' to have a better formatted output 161 " 162 { 62 "{ 163 63 int i; 164 64 string s=""; … … 171 71 //----------------------------------------------------------------------------- 172 72 proc view(M) 173 "USAGE: view(M); 174 M: any type 73 "USAGE: view(M); M is of any type 175 74 RETURN: 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 75 PURPOSE: procedure for (well-) formatted output of modules, matrices, lists of modules, matrices; shows everything even if entries are long 178 76 NOTE: in case of other types( not 'module', 'matrix', 'list') works just as standard 'print' procedure 179 77 EXAMPLE: example view; shows an example 180 " 181 { 78 "{ 182 79 // to be replaced with something more feasible 183 80 if ( (typeof(M)=="module")||(typeof(M)=="matrix") ) … … 255 152 RETURN: module 256 153 EXAMPLE: example RightKernel; shows an example 257 " 258 { 154 "{ 259 155 return(modulo(M,std(0))); 260 156 } … … 295 191 RETURN: module 296 192 EXAMPLE: example LeftInverse; shows an example 297 NOTE: exists only in the case when Id \subseteqM!193 NOTE: exists only in the case when Id belongs to M! 298 194 " 299 195 { … … 319 215 } 320 216 example 321 { // trivial example: 322 "EXAMPLE:";echo =2; 217 { 218 "EXAMPLE:";echo =2; 219 // a trivial example: 323 220 ring r = 0,(x,z),dp; 324 221 matrix M[2][1] = 1,x2z; … … 326 223 print( LeftInverse(M) ); 327 224 kill r; 328 // derived from the ex TwoPendula225 // derived from the example TwoPendula: 329 226 ring r=(0,m1,m2,M,g,L1,L2),Dt,dp; 330 227 matrix U[3][1]; … … 335 232 module L = LeftInverse(M); 336 233 print(L); 234 // check 235 print(L*M); 337 236 }; 338 237 //----------------------------------------------------------------------- … … 342 241 RETURN: module 343 242 EXAMPLE: example RightInverse; shows an example 344 NOTE: exists only in the case when Id \subseteqM!243 NOTE: exists only in the case when Id belongs to M! 345 244 " 346 245 { … … 349 248 example 350 249 { "EXAMPLE:";echo =2; 351 // trivial example:250 // a trivial example: 352 251 ring r = 0,(x,z),dp; 353 252 matrix M[1][2] = 1,x2+z; … … 355 254 print( RightInverse(M) ); 356 255 kill r; 357 // derived from the exTwoPendula256 // derived from the TwoPendula example: 358 257 ring r=(0,m1,m2,M,g,L1,L2),Dt,dp; 359 258 matrix U[1][3]; … … 364 263 module L = RightInverse(M); 365 264 print(L); 265 // check 266 print(M*L); 366 267 }; 367 268 //----------------------------------------------------------------------- … … 407 308 //------------------------------------------------------------------------ 408 309 static 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), 311 PURPOSE: 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) 416 316 RETURN: list with all the contollability properties of the system which is to be returned in 'control' procedure 417 317 NOTE: this procedure is used in 'control' procedure 418 " 419 { 318 "{ 420 319 // TODO: NVars to be replaced with the global hom. dimension of basering!!! 421 320 // Is not clear what to do with gl.dim of qrings … … 523 422 example 524 423 {"EXAMPLE:";echo = 2; 525 // Wind Tunnel424 // a WindTunnel example 526 425 ring A = (0,a, omega, zeta, k),(D1, delta),dp; 527 426 module R; … … 539 438 RETURN: list 540 439 EXAMPLE: example control2; shows an example 541 NOTE: same as control(R); but using dimensions, this procedure only works for full row rank matrices440 NOTE: this procedure is analogous to 'control' but uses dimension calculations.This approach works for full row rank matrices only. 542 441 " 543 442 { … … 559 458 example 560 459 {"EXAMPLE:";echo = 2; 561 // Wind Tunnel460 //a WindTunnel example 562 461 ring A = (0,a, omega, zeta, k),(D1, delta),dp; 563 462 module R; … … 696 595 example 697 596 {"EXAMPLE:"; echo = 2; 698 // Cauchy597 // Cauchy1 example 699 598 ring r=0,(s1,s2,s3,s4),dp; 700 599 module R= [s1,-s2], … … 746 645 }; 747 646 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 884 648 //---------------------------------------------------------- 885 649 proc genericity(matrix M) … … 1210 974 //Example Antenna 1211 975 ring r = (0, K1, K2, Te, Kp, Kc),(Dt, delta), (c,dp); 1212 1213 976 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], 1215 979 [0, Dt+K2/Te, 0, 0, 0, 0, -Kp/Te*delta, -Kc/Te*delta, -Kc/Te*delta], 1216 980 [0, 0, Dt, -K1, 0, 0, 0, 0, 0], … … 1219 983 [0, 0, 0, 0, 0, Dt+K2/Te, -Kc/Te*delta, -Kc/Te*delta, -Kp/Te*delta]; 1220 984 module R = transpose(RR); 1221 view(R);1222 985 view(iostruct(R)); 1223 986 }; … … 1225 988 //--------------------------------------------------------------- 1226 989 static 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 991 RETURN: intvec 992 PURPOSE: returns an intvec of length 2 with the index of an element of N with smallest degree 993 " 1228 994 { 1229 995 int n = nrows(N); … … 1280 1046 //--------------------------------------------------------------- 1281 1047 static 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 1049 RETURN: int 1050 PURPOSE: returns 1, if there is only one non-zero element in v and 0 else 1051 "{ 1284 1052 int i,j; 1285 1053 int n = nrows(v); … … 1491 1259 // see what happens when the matrix is already in Smith-Form 1492 1260 module M = [x,0,0],[0,x2,0],[0,0,x3]; 1493 print(M);1494 1261 list L = smith(M); 1495 1262 print(L[1]); … … 1507 1274 } 1508 1275 //--------------------------------------------------------------- 1509 proc list_tex(L, string name,link l,int nr_loop)1276 static proc list_tex(L, string name,link l,int nr_loop) 1510 1277 "USAGE: list_tex(L,name,l), where L is a list, name a string, l a link 1511 1278 writes the content of list L in a tex-file 'name' … … 1566 1333 } 1567 1334 } 1335 example 1336 { 1337 "EXAMPLE:";echo = 2; 1338 } 1568 1339 //--------------------------------------------------------------- 1569 1340 proc verbatim_tex(string s, link l) … … 1578 1349 write(l,"\\end{verbatim}"); 1579 1350 write(l,"\\par"); 1351 } 1352 example 1353 { 1354 "EXAMPLE:";echo = 2; 1580 1355 } 1581 1356 //--------------------------------------------------------------- … … 1621 1396 print(Tr); // generators of the torsion submodule 1622 1397 } 1398 1399 1400 proc ControlExample(string s) 1401 "USAGE: ControlExample(s); s a string 1402 PURPOSE: set up an example from the mini database by initalizing a ring and a module in a ring 1403 RETURN: ring 1404 NOTE: 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 1408 the predefined system module R (transposed). 1409 After that one can just execute @code{control(R);} respectively 1410 @code{autonom(R);} to perform the control resp. autonomy analysis of R. 1411 EXAMPLE: 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 } 1448 example 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 //---------------------------------------------------------- 1464 static 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 //---------------------------------------------------------- 1474 static 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 //---------------------------------------------------------- 1486 static 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 //---------------------------------------------------------- 1498 static 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 //---------------------------------------------------------- 1508 static 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 //---------------------------------------------------------- 1519 static 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 1537 static 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 //---------------------------------------------------------- 1558 static 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 //---------------------------------------------------------- 1570 static 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 //---------------------------------------------------------- 1582 static 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 //--------------------------------------------------------------- 1596 proc 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). 1602 PURPOSE: define the ring easily 1603 RETURN: 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.