ADDED mttroot/mtt/bin/trans/abg2sabg_fig Index: mttroot/mtt/bin/trans/abg2sabg_fig ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/abg2sabg_fig @@ -0,0 +1,38 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: abg2sabg_fig +# +# Acausal bond graph to causal bond graph: mfile format + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + +# P.J.Gawthrop March 1997 +# Copyright (c) P.J.Gawthrop, 1997 + +infofile='mtt_info.txt' +typefile="$1_type.sh" + +# Remove the old log file +rm -f abg2sabg_fig.log +rm -f $1_cbg.m +rm -f $typefile +rm -f $infofile + + +#Inform user +echo Creating $1_sabg.txt + +awk '{\ + Depth=7;\ + print $Depth}' $1_abg.fig + ADDED mttroot/mtt/bin/trans/abg_m2a4c Index: mttroot/mtt/bin/trans/abg_m2a4c ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/abg_m2a4c @@ -0,0 +1,33 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: abg_m2a4c +# +# Acausal bond graph to ascend format + +infofile='mtt_info.txt' +errorfile='mtt_error.txt' + + +# Remove the old log file +rm -f abg_m2a4c_m.log +rm -f $1_abg.a4c + + + +#Inform user +echo "Creating $1_abg.a4c" + +# Use matrix manipulation to accomplish the transformation +octave -q << EOF >$1_abg.a4c + ABG = $1_abg; + name = "$1"; + abg_m2a4c(ABG,name); +EOF + +if [ "$info" = "info" ]; then + cat $infofile +fi ADDED mttroot/mtt/bin/trans/can_r2m Index: mttroot/mtt/bin/trans/can_r2m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/can_r2m @@ -0,0 +1,122 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: can_r2m +# Reduce canonical forsm to matlab +# P.J.Gawthrop January 8th 1998 +# Copyright (c) P.J.Gawthrop 1998 + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + + +# Inform user +echo Creating $1_can.m + +# Remove the old log file +rm -f can_r2m.log + +# Use reduce to accomplish the transformation +reduce >can_r2m.log << EOF + +%Read in the definitions file +IN "$1_def.r"; + +%Read the reduce state-space A,B,C and D matrices file +IN "$1_can.r"; + +%Set up the number of argument variables to zero in case the user has forgotten +MTTNVar := 0; + +%Read in the parameter file +IN "$1_sympar.r"; + +OUT "$1_can.m"; +%Headings - Matlab style +%(Note. The ;; are deleted by for2mat) + +write "function [A_c,B_c,C_c,D_c,Con,Obs,K,L,A_comp,B_comp,C_comp] = $1_can;;"; +write "%function [A_c,B_c,C_c,D_c,Con,Obs,K,L,A_comp,B_comp,C_comp] = $1_can;;"; + +write "%Canonical forms and controller design for system $1"; +write "%File $1_can.m"; +write "%Generated by MTT"; +write ""; + +IF MTTNvar>0 THEN +BEGIN + write "% Set the parameters"; + write "global ...;;"; + FOR i := 1:MTTNx DO + write "alpha_c",i, " alpha_o",i, "...;;"; + + FOR i := 1:MTTNvar DO + BEGIN + IF numberp(MTTVar(i,1)) + THEN + BEGIN + % Do nowt + END + ELSE + BEGIN + write MTTVar(i,1), " ..."; + END; + END; + write " "; +END; + + +%Fortran switches - one line expressions +OFF echo; +ON fort$ +cardno!* := 1$ +fortwidth!* := 100$ +OFF period$ + +write "MTTA_c = zeros(", MTTNx, ",", MTTNx, ");"; +write "MTTB_c = zeros(", MTTNx, ",", MTTNu, ");"; +write "MTTC_c = zeros(", MTTNy, ",", MTTNx, ");"; +write "MTTD_c = zeros(", MTTNy, ",", MTTNu, ");"; + +write "MTTCon = zeros(", MTTNx, ",", MTTNx, ");"; +write "MTTObs = zeros(", MTTNx, ",", MTTNx, ");"; + +write "MTTK = zeros(", MTTNy, ",", MTTNx, ");"; +write "MTTL = zeros(", MTTNx, ",", MTTNu, ");"; + +write "MTTA_comp = zeros(", MTTNx, ",", MTTNx, ");"; +write "MTTB_comp = zeros(", MTTNx, ",", MTTNy, ");"; +write "MTTC_comp = zeros(", MTTNu, ",", MTTNx, ");"; + + +ON NERO; % Suppress zero elements. +MTTA_c := MTTA_c; +MTTB_c := MTTB_c; +MTTC_c := MTTC_c; +MTTD_c := MTTD_c; + +MTTCon := MTTCon; +MTTObs := MTTObs; + + +MTTK := MTTK; +MTTL := MTTL; + +MTTA_comp := MTTA_comp; +MTTB_comp := MTTB_comp; +MTTC_comp := MTTC_comp; +MTTD_comp := MTTD_comp; + + +OFF FORT; +write ""; + +SHUT "$1_can.m"; ADDED mttroot/mtt/bin/trans/cmp2cmp_m Index: mttroot/mtt/bin/trans/cmp2cmp_m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/cmp2cmp_m @@ -0,0 +1,72 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: cmp2cmp_m +# Revises the component file (cmp) to account for aliases. + +# Copyright (c) P.J.Gawthrop 1998 + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + +# Inform user +echo Revising $1_cmp.m + +# Copy the alias and cmp files. +cat $1_alias.txt $1_cmp.m > junk + +#Create the cmp file complete with headers. +#echo "# Component file ($1_cmp.m)" #> $1_cmp.m +#echo "# Revised by MTT at `date`" #>> $1_cmp.m + +#Write out the variables +awk ' +BEGIN{ +alias_file=1 +Parameter_Regexp = "^_Parameter_" +Line_Regexp = "cr|arg" +quote = "\047" +} +{ + if (alias_file) { + if (match($1,Parameter_Regexp)>0){ + alias[$2] = $1; + sub(Parameter_Regexp,"$",alias[$2]); # Replace by $ format + } + } + else { + if (match($1,Line_Regexp)){ + cr_or_args = substr($3,2,length($3)-3); # It it a cr or arg line + N=split(cr_or_args,a,";"); # Split into parts + for (i=1;i<=N;i++){ + if (a[i] in alias) # Replace by alias + a[i] = alias[a[i]]; + } + cr_or_args = a[1]; # Recombine + for (i=2;i<=N;i++) + cr_or_args = sprintf("%s;%s", cr_or_args, a[i]); + print "\t" $1 "\t" $2 "\t" quote cr_or_args quote + } + else + print $0 + } + if ($1=="###_END_OF_ALIAS_###") + alias_file=0; +}' $1_cmp.m + +rm -f junk + + + + + + + + ADDED mttroot/mtt/bin/trans/convert_simpar.sh Index: mttroot/mtt/bin/trans/convert_simpar.sh ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/convert_simpar.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +## Gets rid of redundant METHOD lines. +echo Converting $1 +## backup +cp $1 $1_old +sed 's/METHOD/## METHOD/'< $1_old > $1 + + + ADDED mttroot/mtt/bin/trans/ctf_r2tex Index: mttroot/mtt/bin/trans/ctf_r2tex ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/ctf_r2tex @@ -0,0 +1,67 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: ctf_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_ctf.tex + +# Remove the old log file +rm -f ctf_r2tex.log + +# Use reduce to accomplish the transformation +reduce >ctf_r2tex.log<< EOF + +%Read the definitions file +in "$1_def.r"; + +%Read the smconical-form matrices file +in "$1_ctf.r"; + +%Read the substitution file +in "$1_subs.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_ctf.tex"; + +%Write out the canonical matrices +write "%Controler TF $1"; +write "%File: $1_ctf.tex"; +write""; + +MTT_Matrix := MTTcTF$ +MTT_Matrix_name := "MTTcTF"$ +MTT_Matrix_n := MTTNu$ +MTT_Matrix_m := MTTNy$ +Latex_Matrix()$ + + +SHUT "$1_ctf.tex"; +quit; +EOF ADDED mttroot/mtt/bin/trans/dae2lde_r Index: mttroot/mtt/bin/trans/dae2lde_r ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/dae2lde_r @@ -0,0 +1,116 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: lde2ode.r +# Reduce differential-algebraic equations to Lagranges equations +# Copyright (C) 2000 by Peter J. Gawthrop + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + +# Create the reduce output code +def2write_r $1 lde +def2write_r $1 ldeo + +#Inform user +echo Creating $1_lde.r +echo Creating $1_ldeo.r + +# Remove the old log file +rm -f cse2lde_r.log + +# Use reduce to accomplish the transformation +$SYMBOLIC << EOF >cse2lde_r.log + +%Read the formatting function +in "$MTTPATH/trans/reduce_matrix.r"; + +%Read the definitions file +in "$1_def.r"; + +%Read the substitution file +in "$1_subs.r"; + +%Read the dae file +in "$1_dae.r"; + +% Zap bits we dont need +clear mttui, mttu, mttdu, mttx, mttdz; + +%% The lagrangian eqns are those set to zero. +MTTL := mttyz; + +% Create the second derivative of z +MATRIX mttddz(MTTNz,1); +FOR i := 1:MTTNz DO +BEGIN + mttuii := mkid(mttui,i); + mttdduii := mkid(mttddui,i); + mttddz(i,1) := sub(mttuii=mttdduii,mttz(i,1)); +END; +mttddz; + +% Create Lagranges Equations +FOR j := 1:MTTNyz DO +BEGIN + %% Create derivative of the equations by substituting: + %du for u + mttuj := mkid(mttu,j); + mttduj := mkid(mttdu,j); + MTTL := sub(mttuj=mttduj,MTTL); + + % dv for v + mttuij := mkid(mttui,j); + mttduij := mkid(mttdui,j); + MTTL := sub(mttuij=mttduij,MTTL); + + % dx for x + mttxj := mkid(mttx,j); + MTTL := sub(mttxj=mttdx(j,1),MTTL); + + % ddz for dz + mttdzj := mkid(mttdz,j); + MTTL := sub(mttdzj=mttddz(j,1),MTTL); + +END; + +L = MTTL; + +OFF Echo; +OFF Nat; + + +%Write out the ordinary differential equations. +OUT "$1_lde.r"; +write "%File: $1_lde.r"; +in ("$1_lde_write.r"); +write "in ""$1_ldeo.r"";"; +write "END;"; +SHUT "$1_lde.r"; + +%Write out the output equations +OUT "$1_ldeo.r"; +write "%File: $1_ldeo.r"; +in ("$1_ldeo_write.r"); +write "END;"; +SHUT "$1_ldeo.r"; +quit; +EOF + +# Now invoke the standard error handling. +mtt_error_r cse2lde_r.log + + + + + + + + ADDED mttroot/mtt/bin/trans/doc2pdf Index: mttroot/mtt/bin/trans/doc2pdf ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/doc2pdf @@ -0,0 +1,43 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: doc2pdf +# Converts doc file to pdf file + +# Copyright (c) P.J.Gawthrop 1998 + + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +## +############################################################### + +system=$1 +documenttype=$2 + +# Inform user +echo "Creating $system.pdf" + +#Run pdflatex , bibtex and makeindex +pdflatex $system.doc > doc2pdf.log +bibtex $system >> doc2pdf.log +pdflatex $system.doc >> doc2pdf.log +pdflatex $system.doc >> doc2pdf.log + +if [ "$documenttype" = "book" ]; then + makeindex $system >> doc2pdf.log +else + touch $system.ind +fi + +pdflatex $system.doc >> doc2pdf.log +pdflatex $system.doc >> doc2pdf.log + +# Make sure transformation succeeeds +exit 0 ADDED mttroot/mtt/bin/trans/doc2ps Index: mttroot/mtt/bin/trans/doc2ps ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/doc2ps @@ -0,0 +1,43 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: doc2dvi +# Converts doc file to dvi file + +# Copyright (c) P.J.Gawthrop 1998 + + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +## Revision 1.4 1999/11/02 07:56:46 peterg +## Removed documenttype in blurb +## +## Revision 1.3 1998/11/24 12:03:27 peterg +## Indexing of book docs. +## +## Revision 1.2 1998/04/15 18:40:43 peterg +## Run LateX three times +## +## Revision 1.1 1998/03/03 08:35:50 peterg +## Initial revision +## +############################################################### + +system=$1 +documenttype=$2 + +# Inform user +echo "Creating $system.ps" + +doc2dvi $system $documenttype + +dvips -o $system.ps $1 + +# Make sure transformation succeeeds +exit 0 ADDED mttroot/mtt/bin/trans/ese_tidy Index: mttroot/mtt/bin/trans/ese_tidy ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/ese_tidy @@ -0,0 +1,29 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + +# Bourne shell script: ese_tidy +# Tidies up Matlab format files +# P.J.Gawthrop May 1998 +# Copyright (c) P.J.Gawthrop, 1990, 1994, 1995. + +#Puts the state & output equations at the end of the file + +grep -v '^MTT' $1_ese.r>junk1 +grep '^MTT' $1_ese.r>junk2 +echo 'END;' >junk3 +cat junk1 junk2 junk3> $1_ese.r + + + + ADDED mttroot/mtt/bin/trans/gdat2fig Index: mttroot/mtt/bin/trans/gdat2fig ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/gdat2fig @@ -0,0 +1,60 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: gdat2ps + +# Converts a data file in gplot format to a ps file + +# Copyright (c) P.J.Gawthrop, 1996. + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +## Revision 1.8 1997/12/07 18:45:44 peterg +## Set to monochrome (not colour). This gives clearer plots. +## +## Revision 1.7 1996/08/26 13:04:43 peterg +## Changed $() to ``. +## +# Revision 1.6 1996/08/16 14:51:21 peter +# Put in some cosmetic postscript options. +# +## Revision 1.5 1996/08/15 09:37:58 peter +## Parameters in title. +## +## Revision 1.4 1996/08/14 09:21:17 peter +## Gnu plot conversion now done externally in dat2gdat +## +## Revision 1.3 1996/08/10 14:12:48 peter +## Revised to new dat format: [x y x y x y] in place of [x y y y]. +## +## Revision 1.2 1996/08/10 12:54:56 peter +## Reorganised data file for gnuplot input. +## +## Revision 1.1 1996/08/10 09:52:39 peter +## Initial revision +## +############################################################### + +echo Creating $1.fig + +gnuplot << EOF + set terminal fig color portrait fontsize 16 size 20 10 metric + set output '$1.fig' + set grid + set title "MTT simulation on `date` " + plot '$1.gdat' with lines + exit + +EOF + +## Add a gold box to give a nice picture +cat >> $1.fig <