Index: mttroot/mtt/bin/trans/struc2input_txt2txt ================================================================== --- mttroot/mtt/bin/trans/struc2input_txt2txt +++ mttroot/mtt/bin/trans/struc2input_txt2txt @@ -12,10 +12,13 @@ ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ +## Revision 1.10 1998/07/27 11:10:38 peterg +## Put in octave-mode line for Emacs +## ## Revision 1.9 1998/07/25 20:10:37 peterg ## lower case mttu ## ## Revision 1.8 1998/07/25 09:42:09 peterg ## Just sets finrst input to 1 - rest to zero @@ -49,51 +52,58 @@ switches=no while [ -n "`echo $1 | grep '-'`" ]; do case $1 in -s ) switches=yes ;; + -ss ) + steadystate_computation=yes ;; *) echo "$1 is an invalid argument - ignoring" ;; esac shift done -# Inform user -echo Creating $1_input.txt #Create the input file complete with headers. echo '# -*-octave-*- Put Emacs into octave-mode' > $1_input.txt echo "# Numerical parameter file ($1_input.txt)" >> $1_input.txt echo "# Generated by MTT at `date`" >> $1_input.txt cat $MTTPATH/trans/rcs_header.sh >> $1_input.txt - -#Write out the defaults -- inputs to steady-state values -#echo "# Set the inputs" >> $1_input.txt -#cat $1_ss.r $1_struc.txt | sed 's/\$//' |\ -#awk '{ -# if(match($1,"MTTu")) { -# j++ -# u[j]=$3; -# } -# -# if($1=="input") { -# i++; -# print "u(" i ") =\t", u[i], "+ 1.0; \# " $4 " (" $3 ")" -# } -#}' >> $1_input.txt - +echo "# Set the inputs" >> $1_input.txt + +if [ -n "$steadystate_computation" ]; then +# Compute inputs from ss.r file +# Inform user +echo Creating $1_input.txt - compute from steady-state information + +cat $1_ss.r $1_struc.txt | sed 's/\$//' |\ +awk '{ + if(match($1,"MTTu")>0) { + j++ + split($0,a,"="); + u[j]=a[2]; + } + + if($1=="input") { + i++; + if (length(u[i])==0) u[i]="0.0;"; + print "u(" i ") =\t", u[i], " \# " $4 " (" $3 ")" + } +}' >> $1_input.txt +else #Write out the defaults -- unit inputs -echo "# Set the inputs" >> $1_input.txt +echo Creating $1_input.txt - defaults awk '{ if ($1=="input") { if ($2==1) printf("mttu(%s) = 1.0; \t\# %s (%s)\n", $2,$3,$4) else printf("mttu(%s) = 0.0; \t\# %s (%s)\n", $2,$3,$4) } }' Nu=$Nu <$1_struc.txt >> $1_input.txt +fi #Set some switches if [ "$switches" = "yes" ]; then echo >> $1_input.txt echo "# Set the switches" >> $1_input.txt