ADDED mttroot/mtt/bin/trans/awk/rep_txt2make.awk Index: mttroot/mtt/bin/trans/awk/rep_txt2make.awk ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/awk/rep_txt2make.awk @@ -0,0 +1,34 @@ +###################################### +##### Model Transformation Tools ##### +###################################### + +# gawk script: rep_txt2make +# Converts the text file describing a report to makefile dependencies +# P.J.Gawthrop August 1996 +# Copyright (c) P.J.Gawthrop, 1996. + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + +BEGIN { + split(ARGV[1],a,"_"); + system_name = a[1]; + } +{ + if (NF==2) { + if( match("tex txt r m ps",$2)>0) { + printf("%s_%s.%s ", system_name, $1, $2) + } + } +} +END { + +} + + + ADDED mttroot/mtt/bin/trans/awk/rep_txt2tex.awk Index: mttroot/mtt/bin/trans/awk/rep_txt2tex.awk ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/awk/rep_txt2tex.awk @@ -0,0 +1,56 @@ +###################################### +##### Model Transformation Tools ##### +###################################### + +# gawk script: rep_txt2tex +# Converts the text file describing a report to a report. +# P.J.Gawthrop August 1996 +# Copyright (c) P.J.Gawthrop, 1996. + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + +BEGIN { + split(ARGV[1],a,"_"); + system_name = a[1]; + args = ARGV[2]; +} +{ + if (NF==2) { +# tex files + if( match("tex",$2)>0) { + print "\\section{Representation " $1 ", language " $2 "}"; + printf(" \\input{%s_%s.%s}\n", system_name, $1, $2); + } +# text files + if( match("txt r m",$2)>0) { + print "\\section{Representation " $1 ", language " $2 "}"; + print " \\begin{verbatim}"; + command = sprintf("cat %s_%s.%s", system_name, $1, $2); + system(command); + print " \\end{verbatim}"; + } +# ps files + if( match("ps",$2)>0) { + print "\\section{Representation " $1 ", language " $2 "}"; + printf("This representation is given as Figure \\ref{fig:%s}.\n", $1); + print " \\begin{figure}"; + printf(" \\epsfig{file=%s_%s.%s,width=\\linewidth}\n", \ + system_name, $1, $2); + printf(" \\caption{System %s, representation %s}\n", system_name, $1); + printf(" \\label{fig:%s}\n", system_name, $1); + print " \\end{figure}"; + } + } +} +END { + +} + + + ADDED mttroot/mtt/bin/trans/awk/tex2doc.awk Index: mttroot/mtt/bin/trans/awk/tex2doc.awk ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/awk/tex2doc.awk @@ -0,0 +1,34 @@ +###################################### +##### Model Transformation Tools ##### +###################################### + +# gawk script: tex2doc +# Encapsulates a tex file in a document. +# P.J.Gawthrop August 1996 +# Copyright (c) P.J.Gawthrop, 1996. + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + + +BEGIN { + split(ARGV[1],a,"_"); + system_name = a[1]; + split(a[2],b,"."); + representation = b[1]; + makefile = sprintf("%s_rep.make", system_name, representation); + print "\\documentclass[12pt,a4paper]{article}"; + printf("\\title{System %s, representation %s}\n", \ + system_name, representation) + print "\\author{Generated by MTT}"; + print " \\usepackage{epsfig}"; + print ; + print "\\begin{document}"; + print " \\maketitle"; + printf(" \\input{%s_%s}\n", system_name, representation); + print "\\end{document}" +} ADDED mttroot/mtt/bin/trans/dae2dm_r Index: mttroot/mtt/bin/trans/dae2dm_r ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/dae2dm_r @@ -0,0 +1,294 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: dae2dm_r +# Differential-algebraic equation to linear descriptor matrices conversion +# P.J.Gawthrop 8th May 1991, 7 June 1991, April 1994. +# Copyright (c) P.J.Gawthrop, 1991, 1994. + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + +#Inform user +echo Creating $1_dm.r + +# Remove the old log file +rm -f dae2dm_r.log + +# Use reduce to accomplish the transformation +reduce >dae2dm_r.log << EOF + +in "$1_def.r"; +in "$1_dae.r"; +in "$1_cr.r"; +in "$1_sympar.r"; + +OFF Echo; +OFF Nat; + + +%Total number of descriptor variables +MTTN := MTTNx + 2*MTTNz + MTTNyz; + +IF MTTN>0 THEN +BEGIN +% Find MTTE : the E matrix +matrix MTTE(MTTN,MTTN); + +% First row partition +IF MTTNx>0 THEN + FOR j := 1:MTTNx DO + MTTE(j,j) := 1; + +% Second row partition + IF MTTNz>0 THEN + FOR j := 1:MTTNz DO + MTTE(j+MTTNx, j+MTTNx) := 1; + +% Find MTTA : the A matrix +matrix MTTA(MTTN,MTTN); + +% First row partition: x +IF MTTNx>0 THEN + BEGIN + FOR j := 1:MTTNx DO + BEGIN + xj := MTTX(j,1); + FOR i := 1:MTTNx DO + MTTA(i,j) := df(MTTdX(i,1), xj, 1); + END; + + IF MTTNz>0 THEN + FOR j := 1:MTTNz DO + BEGIN + dzj := MTTdz(j,1); + FOR i := 1:MTTNx DO + MTTA(i, j + MTTNx + MTTNz) := df(MTTdX(i,1), dzj, 1); + END; + + IF MTTNyz>0 THEN + FOR j := 1:MTTNyz DO + BEGIN + uij := MTTUi(j,1); + FOR i := 1:MTTNx DO + MTTA(i, j + MTTNx + 2*MTTNz) := df(MTTdX(i,1), uij, 1); + END; + END; + +% Second row partition: z +IF MTTNz>0 THEN + FOR j := 1:MTTNz DO + MTTA(j + MTTNx, j + MTTNx + MTTNz) := 1; + +% Third row partition +IF MTTNz>0 THEN + BEGIN + IF MTTNx>0 THEN + FOR j := 1:MTTNx DO + BEGIN + xj := MTTX(j,1); + FOR i := 1:MTTNz DO + MTTA(i + MTTNx + MTTNz,j) := df(MTTZ(i,1), xj, 1); + END; + + FOR j := 1:MTTNz DO + MTTA(j + MTTNx + MTTNz, j + MTTNx) := -1; + + FOR j := 1:MTTNz DO + BEGIN + dzj := MTTdz(j,1); + FOR i := 1:MTTNz DO + MTTA(i + MTTNx + MTTNz, j + MTTNx + MTTNz) := df(MTTZ(i,1), dzj, 1); + END; + + IF MTTNyz>0 THEN + FOR j := 1:MTTNyz DO + BEGIN + uij := MTTUi(j,1); + FOR i := 1:MTTNz DO + MTTA(i+MTTNx+MTTNz, j+MTTNx+2*MTTNz) := df(MTTZ(i,1), uij, 1); + END; + END; + + +% Fourth row partition +IF MTTNyz>0 THEN + BEGIN + IF MTTNx>0 THEN + FOR j := 1:MTTNx DO + BEGIN + xj := MTTX(j,1); + FOR i := 1:MTTNyz DO + MTTA(i + MTTNx + 2*MTTNz,j) := df(MTTYz(i,1), xj, 1); + END; + + IF MTTNz>0 THEN + FOR j := 1:MTTNz DO + BEGIN + dzj := MTTdz(j,1); + FOR i := 1:MTTNyz DO + MTTA(i + MTTNx + 2*MTTNz, j + MTTNx + MTTNz) := df(MTTYz(i,1), dzj, 1); + END; + + IF MTTNyz>0 THEN + FOR j := 1:MTTNyz DO + BEGIN + uij := MTTUi(j,1); + FOR i := 1:MTTNyz DO + MTTA(i+MTTNx+2*MTTNz, j+MTTNx+2*MTTNz) := df(MTTYz(i,1), uij, 1); + END; + END; + +% Find MTTB : the B matrix +matrix MTTB(MTTN,MTTNu); + +IF MTTNu>0 THEN +BEGIN + +% First row partition +IF MTTNx>0 THEN + BEGIN + FOR j := 1:MTTNu DO + BEGIN + uj := MTTU(j,1); + FOR i := 1:MTTNx DO + MTTB(i,j) := df(MTTdX(i,1), uj, 1); + END; + END; + +% Third row partition +IF MTTNz>0 THEN + BEGIN + FOR j := 1:MTTNu DO + BEGIN + uj := MTTU(j,1); + FOR i := 1:MTTNz DO + MTTB(i + MTTNx + MTTNz ,j) := df(MTTZ(i,1), uj, 1); + END; + END; + +% Fourth row partition +IF MTTNyz>0 THEN + BEGIN + FOR j := 1:MTTNu DO + BEGIN + uj := MTTU(j,1); + FOR i := 1:MTTNyz DO + MTTB(i + MTTNx + 2*MTTNz,j) := df(MTTYz(i,1), uj, 1); + END; + END; + +END; + +% Find MTTC : the C matrix +matrix MTTC(MTTNy,MTTN); +IF MTTNy>0 THEN +BEGIN + +% First column partition +IF MTTNx>0 THEN + BEGIN + FOR i := 1:MTTNy DO + FOR j := 1:MTTNx DO + BEGIN + xj := MTTX(j,1); + MTTC(i,j) := df(MTTY(i,1), xj, 1); + END; + END; + +% Third column partition +IF MTTNz>0 THEN + BEGIN + FOR i := 1:MTTNy DO + FOR j := 1:MTTNz DO + BEGIN + dzj := MTTdZ(j,1); + MTTC(i, j + MTTNx + MTTNz) := df(MTTY(i,1), dzj, 1); + END; + END; + +% Fourth column partition +IF MTTNyz>0 THEN + BEGIN + FOR i := 1:MTTNy DO + FOR j := 1:MTTNyz DO + BEGIN + uij := MTTUi(j,1); + MTTC(i, j + MTTNx + 2*MTTNz) := df(MTTY(i,1), uij, 1); + END; + END; + +END; +END; %of MTTN>0 + +% Find MTTD : the D matrix +matrix MTTD(MTTNy,MTTNu); +IF MTTNy>0 THEN +IF MTTNu>0 THEN +BEGIN + FOR i := 1:MTTNy DO + FOR j := 1:MTTNu DO + BEGIN + uj := MTTU(j,1); + MTTD(i,j) := df(MTTY(i,1), uj, 1); + END; +END; + +%Substitute the ss values +in "$1_ss.r"; + +%Create the output file +OUT "$1_dm.r"; + +%Write out the matrices. +IF MTTN>0 THEN +BEGIN + write "matrix MTTE(", MTTN, ",", MTTN, ");"; + FOR i := 1:MTTN DO + FOR j := 1:MTTN DO IF MTTE(i,j) NEQ 0 THEN + write "MTTE(", i, ",", j, ") := ", MTTE(i,j); + + write "matrix MTTA(", MTTN, ",", MTTN, ");"; + FOR i := 1:MTTN DO + FOR j := 1:MTTN DO IF MTTA(i,j) NEQ 0 THEN + write "MTTA(", i, ",", j, ") := ", MTTA(i,j); +END; + +IF MTTN>0 THEN +IF MTTNu>0 THEN +BEGIN + write "matrix MTTB(", MTTN, ",", MTTNu, ");"; + FOR i := 1:MTTN DO + FOR j := 1:MTTNu DO IF MTTB(i,j) NEQ 0 THEN + write "MTTB(", i, ",", j, ") := ", MTTB(i,j); +END; + +%Write it out +IF MTTNy>0 THEN +IF MTTN>0 THEN +BEGIN + write "matrix MTTC(", MTTNy, ",", MTTN, ");"; + FOR i := 1:MTTNy DO + FOR j := 1:MTTN DO IF MTTC(i,j) NEQ 0 THEN + write "MTTC(", i, ",", j, ") := ", MTTC(i,j); +END; + +IF MTTNy>0 THEN IF MTTNu>0 THEN +BEGIN + write "matrix MTTD(", MTTNy, ",", MTTNu, ");"; + FOR i := 1:MTTNy DO + FOR j := 1:MTTNu DO IF MTTD(i,j) NEQ 0 THEN + write "MTTD(", i, ",", j, ") := ", MTTD(i,j); +END; + +SHUT "$1_dm.r"; +quit; + +EOF ADDED mttroot/mtt/bin/trans/latex_tidy Index: mttroot/mtt/bin/trans/latex_tidy ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/latex_tidy @@ -0,0 +1,96 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: latex_tidy +# Tidies up LaTex format files +# P.J.Gawthrop 12 June 1990, Dec 1994 +# Copyright (c) P.J.Gawthrop, 1990, 1994 + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + +cat $1 | \ +tr "[A-Z]" "[a-z]" | \ +sed -e "s/\// \\\over /g" \ + -e "s/mttex/\\\chi/g" \ + -e "s/mttdx/\\\dot x/g" \ + -e "s/mttdz/\\\dot z/g" \ + -e "s/mttdu/\\\dot u_/g" \ + -e "s/dot_/ \\\dot /g" \ + -e "s/mtta/A/g" \ + -e "s/mttb/B/g" \ + -e "s/mttc/C/g" \ + -e "s/mttd/D/g" \ + -e "s/mtte/E/g" \ + -e "s/mttg/G/g" \ + -e "s/mtti/I/g" \ + -e "s/mttm/M/g" \ + -e "s/mtto/O/g" \ + -e "s/mttv/V/g" \ + -e "s/mttx0/X_0/g" \ + -e "s/mttx1/x_1/g" \ + -e "s/mttx2/x_2/g" \ + -e "s/mttx3/x_3/g" \ + -e "s/mttx4/x_4/g" \ + -e "s/mttx5/x_5/g" \ + -e "s/mttx6/x_6/g" \ + -e "s/mttui0/v_0/g" \ + -e "s/mttui1/v_1/g" \ + -e "s/mttui2/v_2/g" \ + -e "s/mttui3/v_3/g" \ + -e "s/mttui4/v_4/g" \ + -e "s/mttui5/v_5/g" \ + -e "s/mttui6/v_6/g" \ + -e "s/mttui7/v_7/g" \ + -e "s/mttui8/v_8/g" \ + -e "s/mttui9/v_9/g" \ + -e "s/mttu/u_/g" \ + -e "s/mtty0/y_0/g" \ + -e "s/mttu0/u_0/g" \ + -e "s/mttx/x/g" \ + -e "s/mttz/z/g" \ + -e "s/mttu/u/g" \ + -e "s/mttyy/Y/g" \ + -e "s/mtty/y/g" \ + -e "s/mttw/w/g" \ + -e "s/mtttf/G/g" \ + -e "s/mttpar//g" \ + -e "s/\*\*/\^/g" \ + -e "s/\*/ /g" \ + -e "s/!/\\\/g" \ + -e "s/\\$//g" \ + -e "s/(/{(/g" \ + -e "s/)/)}/g" \ + -e "s/\left/\left (/g" \ + -e "s/\right/\right )/g" \ + -e "s/sqrt/\\\sqrt/g" \ + -e "s/theta/\\\theta/g" \ + -e "s/tau/\\\tau/g" \ + -e "s/alpha/\\\alpha/g" \ + -e "s/beta/\\\beta/g" \ + -e "s/epsilon/\\\epsilon/g" \ + -e "s/lambda/\\\lambda/g" \ + -e "s/mu/\\\mu/g" \ + -e "s/phi/\\\phi/g" \ + -e "s/rho/\\\rho/g" \ + -e "s/sigma/\\\sigma/g" \ + -e "s/omega/\\\omega/g" \ + -e "s/zeta/\\\zeta/g" \ + -e "s/sin/\\\sin/g" \ + -e "s/cos/\\\cos/g" \ + -e "s/23/{23}/g" \ + -e "s/+-/ -/g" |\ +cat -s | \ +sed -e "s/ $//g" | \ +tr -s '\012' '\012' \ +>junk + +mv junk $1 + ADDED mttroot/mtt/bin/trans/m/makedef.m Index: mttroot/mtt/bin/trans/m/makedef.m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/m/makedef.m @@ -0,0 +1,70 @@ +function makedef(structure,deffile); + +if nargin<2 + deffile = 'stdout'; +end; + +states = structure(1); +nonstates=structure(2); +inputs=structure(3); +outputs=structure(4); +zero_outputs = structure(5); + +pc = '%'; +% Declare reduce constants; +fprintf(deffile, 'MTTNx := %1.0f;\n', states); +fprintf(deffile, 'MTTNz := %1.0f;\n', nonstates); +fprintf(deffile, 'MTTNu := %1.0f;\n', inputs); +fprintf(deffile, 'MTTNy := %1.0f;\n', outputs); +fprintf(deffile, 'MTTNyz := %1.0f;\n', zero_outputs); + +% Declare reduce matrices +fprintf(deffile, '%s Declare reduce matrices\n', pc); +if states>0 + fprintf(deffile, 'matrix MTTx(%1.0f,1);\n', states); + fprintf(deffile, 'matrix MTTdx(%1.0f,1);\n', states); +end; +if nonstates>0 + fprintf(deffile, 'matrix MTTz(%1.0f,1);\n', nonstates); + fprintf(deffile, 'matrix MTTdz(%1.0f,1);\n', nonstates); +end; +if inputs>0 + fprintf(deffile, 'matrix MTTu(%1.0f,1);\n', inputs); +end; +if outputs>0 + fprintf(deffile, 'matrix MTTy(%1.0f,1);\n', outputs); +end; +if zero_outputs>0 + fprintf(deffile, 'matrix MTTyz(%1.0f,1);\n', zero_outputs); + fprintf(deffile, 'matrix MTTui(%1.0f,1);\n', zero_outputs); +end; + +% Make an Nx x Nx unit matrix +if states>0 + fprintf(deffile, 'matrix MTTI(%1.0f,%1.0f);\n', states,states); + for i = 1:states + fprintf(deffile, 'MTTI(%1.0f,%1.0f) := 1;\n', i, i); + end +end; + +% Set the y, yz, u, x and dx matrices +fprintf(deffile, '%s Set the y, yz, u and x matrices\n', pc); +for i=1:outputs + fprintf(deffile, 'MTTy(%1.0f,1) := MTTy%1.0f;\n', i, i); +end; +for i=1:zero_outputs + fprintf(deffile, 'MTTyz(%1.0f,1) := MTTyz%1.0f;\n', i, i); + fprintf(deffile, 'MTTui(%1.0f,1) := MTTui%1.0f;\n', i, i); +end; +for i=1:inputs + fprintf(deffile, 'MTTu(%1.0f,1) := MTTu%1.0f;\n', i, i); +end; +for i=1:states + fprintf(deffile, 'MTTx(%1.0f,1) := MTTx%1.0f;\n', i, i); +end; +for i=1:nonstates + fprintf(deffile, 'MTTdz(%1.0f,1) := MTTdz%1.0f;\n', i, i); +end; + + + ADDED mttroot/mtt/bin/trans/m/mtt_info.m Index: mttroot/mtt/bin/trans/m/mtt_info.m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/m/mtt_info.m @@ -0,0 +1,24 @@ +function mtt_info(info, infofile); +% mtt_info(info, infofile); + +% function [bonds, status] = abg2cbg(bonds,components,system_name,filename) +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +if nargin<2 + infofile = 'mtt_info.txt'; +end; + +fprintf(infofile, 'INFORMATION: %s\n', info); +% fflush(infofile); ADDED mttroot/mtt/bin/trans/tex2doc Index: mttroot/mtt/bin/trans/tex2doc ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/tex2doc @@ -0,0 +1,31 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: tex2doc +# Encapsulates a tex file in a document. + +# P.J.Gawthrop August 1996 +# Copyright (c) P.J.Gawthrop, 1996. + +############################################################### +## Version control history +############################################################### +## $Id$ +## $Log$ +############################################################### + +# Inform user +echo "Creating $1_$2.doc" + +# This is the main transformation using gawk +gawk -f $MTTPATH/tex2doc.awk $1_$2.txt > $1_$2.doc + + + + + + +