ADDED mttroot/mtt/bin/trans/sm2smc_r Index: mttroot/mtt/bin/trans/sm2smc_r ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/sm2smc_r @@ -0,0 +1,176 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: sm2smc_r +# state matrices to controller canonical form + related matrices +# P.J.Gawthrop 12 Jan 1997 +# Copyright (c) P.J.Gawthrop 1997 + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + +# Inform user +echo Creating $1_smc.r -- NOTE this is for SISO systems only. + +# Remove the old log file +rm -f sm2smc_r.log + +# Use reduce to accomplish the transformation +reduce >sm2smc_r.log << EOF + +in "$1_def.r"; +in "$1_sm.r"; +in "$1_tf.r"; + +%Read the formatting function +in "$MTTPATH/trans/reduce_matrix.r"; + + +OFF Echo; +OFF Nat; + +% Find the controllability matrix +MATRIX MTTCon(MTTNx,MTTNX); +MTTAB := MTTB; +FOR j := 1:MTTNx DO + BEGIN + FOR i := 1:MTTNx DO + MTTCon(i,j) := MTTAB(i,1); + MTTAB := MTTA*MTTAB; + END; + + +%Canonical forms: +% This statement makes Gs a scalar transfer function +Gs := MTTtf(1,1); + +% Numerator and denominator polynomials +bs := num(gs); +as := den(gs); + +% extract coeficients and divide by coeff of s^n +% reverse operator puts list with highest oder coeffs first +ai := reverse(coeff(as,s)); +a0 := first(ai); +MTTn := length(ai) - 1; + + +% Normalised coeficients; +ai := reverse(coeff(as/a0,s)); +bi := reverse(coeff(bs/a0,s)); +MTTm := length(bi)-1; + +% Zap the (unity) first element of ai list; +ai := rest(ai); + +% System in controller form +% MTTA_c matrix +matrix MTTA_c(MTTn,MTTn); + +% First row is ai coefficients +for i := 1:MTTn do + MTTA_c(1,i) := -part(ai,i); + +% (MTTn-1)x(MTTn-1) unit matrix in lower left-land corner (if n>1) +if MTTn>1 then + for i := 1:MTTn-1 do + MTTA_c(i+1,i) := 1; + +% B_c vector; +matrix MTTB_c(MTTn,1); +MTTB_c(1,1) := 1; + +% C_c vector; +matrix MTTC_c(1,MTTn); +for i := 1:MTTm+1 do + MTTC_c(1,i+MTTn-MTTm-1) := part(bi,i); + +% D_c +MTTD_c := MTTD; + +%Controllability matrix of controllable form +MATRIX MTTCon_c(MTTNx,MTTNX); +MTTAB := MTTB_c; +FOR j := 1:MTTNx DO + BEGIN + FOR i := 1:MTTNx DO + MTTCon_c(i,j) := MTTAB(i,1); + MTTAB := MTTA_c*MTTAB; + END; + +% Transformation matrix; +MTTT_c := MTTCon_c*MTTCon^(-1); + + + +%Create the output file +OUT "$1_smc.r"; + +%Write out the matrices. + +% Controllable form +write "% - Controller form"; +MTT_Matrix := MTTA_c$ +MTT_Matrix_name := "MTTA_c"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + +MTT_Matrix := MTTB_c$ +MTT_Matrix_name := "MTTB_c"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNu$ +Reduce_Matrix()$ + +MTT_Matrix := MTTC_c$ +MTT_Matrix_name := "MTTC_c"$ +MTT_Matrix_n := MTTNy$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + +MTT_Matrix := MTTD_c$ +MTT_Matrix_name := "MTTD_c"$ +MTT_Matrix_n := MTTNy$ +MTT_Matrix_m := MTTNu$ +Reduce_Matrix()$ + + +write "% - Controllability matrix"; +MTT_Matrix := MTTCon$ +MTT_Matrix_name := "MTTCon"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + + +write "% -Controllability matrix - controller form"; +MTT_Matrix := MTTCon_c$ +MTT_Matrix_name := "MTTCon_c"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + +write "% - Transformation matrix - controller form"; +MTT_Matrix := MTTT_c$ +MTT_Matrix_name := "MTTT_c"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + +write "END;"; + +SHUT "$1_smc.r"; +quit; + +EOF + +# Now invoke the standard error handling. +mtt_error_r sm2smc_r.log ADDED mttroot/mtt/bin/trans/sm2smo_r Index: mttroot/mtt/bin/trans/sm2smo_r ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/sm2smo_r @@ -0,0 +1,132 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: sm2smo_r +# state matrices to cobserver form +# P.J.Gawthrop 12 Jan 1997 +# Copyright (c) P.J.Gawthrop 1998 + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + +# Inform user +echo Creating $1_smo.r -- NOTE this is for SISO systems only. + +# Remove the old log file +rm -f sm2smo_r.log + +# Use reduce to accomplish the transformation +reduce >sm2smo_r.log << EOF + +in "$1_def.r"; +in "$1_sm.r"; +in "$1_smc.r"; + +%Read the formatting function +in "$MTTPATH/trans/reduce_matrix.r"; + + +OFF Echo; +OFF Nat; + +% Find observibility matrix. +MATRIX MTTObs(MTTNx,MTTNX); +MTTCA := MTTC; +FOR i := 1:MTTNx DO + BEGIN + FOR j := 1:MTTNx DO + MTTObs(i,j) := MTTCA(1,j); + MTTCA := MTTCA*MTTA; + END; + + +%Observable form (dual of controller form) +MTTA_o := tp(MTTA_c); +MTTB_o := tp(MTTC_c); +MTTC_o := tp(MTTB_c); +MTTD_o := MTTD; + + +%Observability matrix of observer form +MATRIX MTTObs_o(MTTNx,MTTNX); +MTTCA := MTTC_o; +FOR i := 1:MTTNx DO + BEGIN + FOR j := 1:MTTNx DO + MTTObs_o(i,j) := MTTCA(1,j); + MTTCA := MTTCA*MTTA_o; + END; + +% Transformation matrix; +MTTT_o := MTTObs^(-1)*MTTObs_o; + + +%Create the output file +OUT "$1_smo.r"; + +%Write out the matrices. + +% Observable form +MTT_Matrix := MTTA_o$ +MTT_Matrix_name := "MTTA_o"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + +MTT_Matrix := MTTB_o$ +MTT_Matrix_name := "MTTB_o"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNu$ +Reduce_Matrix()$ + +MTT_Matrix := MTTC_o$ +MTT_Matrix_name := "MTTC_o"$ +MTT_Matrix_n := MTTNy$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + +MTT_Matrix := MTTD_o$ +MTT_Matrix_name := "MTTD_o"$ +MTT_Matrix_n := MTTNy$ +MTT_Matrix_m := MTTNu$ +Reduce_Matrix()$ + +write "% -Observability matrix"; +MTT_Matrix := MTTObs$ +MTT_Matrix_name := "MTTObs"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + + +write "% -Observability matrix - Observer form"; +MTT_Matrix := MTTObs_o$ +MTT_Matrix_name := "MTTObs_o"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + +write "% - Transformation matrix - Observer form"; +MTT_Matrix := MTTT_o$ +MTT_Matrix_name := "MTTT_o"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + + + +SHUT "$1_smo.r"; +quit; + +EOF + +# Now invoke the standard error handling. +mtt_error_r sm2smo_r.log ADDED mttroot/mtt/bin/trans/smc2ssk_r Index: mttroot/mtt/bin/trans/smc2ssk_r ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/smc2ssk_r @@ -0,0 +1,89 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: smc2ssk_r +# controller-form state matrices to controller gain k +# P.J.Gawthrop Jan 1998 +# Copyright (c) P.J.Gawthrop 1998 + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + +# Inform user +echo Creating $1_ssk.r -- NOTE this is for SISO systems only. + +# Remove the old log file +rm -f smc2ssk_r.log + +# Use reduce to accomplish the transformation +reduce >smc2ssk_r.log << EOF + +in "$1_def.r"; +in "$1_smc.r"; + +%Read the formatting function +in "$MTTPATH/trans/reduce_matrix.r"; + + +OFF Echo; +OFF Nat; + + +%%%% Controller design %%%%% + +% gain in controller form: +matrix MTTk_c(1,MTTNx); + +matrix alpha_c(9,1); +alpha_c(1,1) := alpha_c1; +alpha_c(2,1) := alpha_c2; +alpha_c(3,1) := alpha_c3; +alpha_c(4,1) := alpha_c4; +alpha_c(5,1) := alpha_c5; +alpha_c(6,1) := alpha_c6; +alpha_c(7,1) := alpha_c7; +alpha_c(8,1) := alpha_c8; +alpha_c(9,1) := alpha_c9; + + +for i := 1:MTTNx do + MTTk_c(1,i) := alpha_c(i,1) - MTTA_c(1,i); + +% Gain in physical form +MTTk := MTTk_c*MTTT_c; + + +%Create the output file +OUT "$1_ssk.r"; + +%Write out the matrices. + +write "% - Gain matrix - controller form"; +MTT_Matrix := MTTK_c$ +MTT_Matrix_name := "MTTK_c"$ +MTT_Matrix_n := MTTNu$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + +write "% - Gain matrix - physical form"; +MTT_Matrix := MTTK$ +MTT_Matrix_name := "MTTK"$ +MTT_Matrix_n := MTTNu$ +MTT_Matrix_m := MTTNx$ +Reduce_Matrix()$ + +SHUT "$1_ssk.r"; +quit; + +EOF + +# Now invoke the standard error handling. +mtt_error_r smc2ssk_r.log ADDED mttroot/mtt/bin/trans/smo_r2tex Index: mttroot/mtt/bin/trans/smo_r2tex ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/smo_r2tex @@ -0,0 +1,106 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: smo_r2tex +# Reduce constrained-state matrices to LaTex constrained-state matrices. +# P.J.Gawthrop January 8th 1997 +# Copyright (c) P.J.Gawthrop, 1997 + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + +# Inform user +echo Creating $1_smo.tex + +# Remove the old log file +rm -f smo_r2tex.log + +# Use reduce to accomplish the transformation +reduce >smo_r2tex.log<< EOF + +%Read the definitions file +in "$1_def.r"; + +%Read the observer-form matrices file +in "$1_smo.r"; + + +%Read the simplification file +in "$1_simp.r"; + +%Read the formatting function +in "$MTTPATH/trans/latex_matrix.r"; + +OFF Echo; +OFF Nat; +OFF EXP; +%ON Rounded; +%Precision 5; + + +OUT "$1_smo.tex"; + +%Write out the canonical matrices +write "%Canonical-form matrices $1"; +write "%File: $1_smo.tex"; +write""; + + +% Observable form +MTT_Matrix := MTTA_o$ +MTT_Matrix_name := "MTTA_o"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +LaTeX_Matrix()$ + +MTT_Matrix := MTTB_o$ +MTT_Matrix_name := "MTTB_o"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNu$ +LaTeX_Matrix()$ + +MTT_Matrix := MTTC_o$ +MTT_Matrix_name := "MTTC_o"$ +MTT_Matrix_n := MTTNy$ +MTT_Matrix_m := MTTNx$ +LaTeX_Matrix()$ + +MTT_Matrix := MTTD_o$ +MTT_Matrix_name := "MTTD_o"$ +MTT_Matrix_n := MTTNu$ +MTT_Matrix_m := MTTNu$ +LaTeX_Matrix()$ + +write "% - Observability matrix"; +MTT_Matrix := MTTObs$ +MTT_Matrix_name := "MTTObs"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +LaTeX_Matrix()$ + +write "% -Observability matrix - Observer form"; +MTT_Matrix := MTTObs_o$ +MTT_Matrix_name := "MTTObs_o"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +LaTeX_Matrix()$ + +write "% - Transformation matrix - Observer form"; +MTT_Matrix := MTTT_o$ +MTT_Matrix_name := "MTTT_o"$ +MTT_Matrix_n := MTTNx$ +MTT_Matrix_m := MTTNx$ +LaTeX_Matrix()$ + + +SHUT "$1_smo.tex"; +quit; +EOF ADDED mttroot/mtt/bin/trans/ssk_r2tex Index: mttroot/mtt/bin/trans/ssk_r2tex ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/ssk_r2tex @@ -0,0 +1,73 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: ssk_r2tex +# Reduce constrained-state matrices to LaTex constrained-state matrices. +# P.J.Gawthrop January 8th 1997 +# Copyright (c) P.J.Gawthrop, 1997 + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + +# Inform user +echo Creating $1_ssk.tex + +# Remove the old log file +rm -f ssk_r2tex.log + +# Use reduce to accomplish the transformation +reduce >ssk_r2tex.log<< EOF + +%Read the definitions file +in "$1_def.r"; + +%Read the smconical-form matrices file +in "$1_ssk.r"; + + +%Read the simplification file +in "$1_simp.r"; + +%Read the formatting function +in "$MTTPATH/trans/latex_matrix.r"; + +OFF Echo; +OFF Nat; +OFF EXP; +%ON Rounded; +%Precision 5; + + +OUT "$1_ssk.tex"; + +%Write out the canonical matrices +write "%Canonical-form matrices $1"; +write "%File: $1_ssk.tex"; +write""; + + +write "% - Gain matrix - controller form"; +MTT_Matrix := MTTK_c$ +MTT_Matrix_name := "MTTK_c"$ +MTT_Matrix_n := MTTNu$ +MTT_Matrix_m := MTTNx$ +Latex_Matrix()$ + +write "% - Gain matrix - physical form"; +MTT_Matrix := MTTK$ +MTT_Matrix_name := "MTTK"$ +MTT_Matrix_n := MTTNu$ +MTT_Matrix_m := MTTNx$ +Latex_Matrix()$ + +SHUT "$1_ssk.tex"; +quit; +EOF