ADDED mttroot/mtt/bin/trans/dat22dat Index: mttroot/mtt/bin/trans/dat22dat ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/dat22dat @@ -0,0 +1,18 @@ +#! /bin/sh + +case $2 in + odeso) + i=1; + ;; + odes) + i=2; + ;; + *) + i=1; + ;; +esac + +echo Creating $1_$2.dat + +awk -F# '{print $1}' i=$1 <$1_odes.dat2 > $1_$2.dat + ADDED mttroot/mtt/bin/trans/m/mtt_update.m Index: mttroot/mtt/bin/trans/m/mtt_update.m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/m/mtt_update.m @@ -0,0 +1,5 @@ +function [x] = mtt_update(dx,x,dt,Nx,METHOD); + + x = x + dx*dt; + +endfunction; ADDED mttroot/mtt/bin/trans/p/mtt_update.p Index: mttroot/mtt/bin/trans/p/mtt_update.p ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/p/mtt_update.p @@ -0,0 +1,15 @@ +PROCEDURE mtt_update(VAR xnew : StateVector; + dx,x : StateVector; + DT : REAL; + Nx : INTEGER; + METHOD : IntegrationMethod); + +VAR +i : INTEGER; + +BEGIN + FOR i := 1 TO Nx DO + xnew[i] := xnew[i] + dx[i]*DT; +END; + + ADDED mttroot/mtt/bin/trans/switch_txt2m Index: mttroot/mtt/bin/trans/switch_txt2m ================================================================== --- /dev/null +++ mttroot/mtt/bin/trans/switch_txt2m @@ -0,0 +1,36 @@ +#! /bin/sh + + ###################################### + ##### Model Transformation Tools ##### + ###################################### + +# Bourne shell script: switch_txt2m + +# Convert switch file from txt to m +# P.J.Gawthrop May 1997 +# Copyright (c) P.J.Gawthrop, 1997. + + +echo Creating $1_switch.m + +# Find system constants +Nx=`grep "MTTNx " <$1_def.r | awk '{print $3}' | sed 's/;//'` + +#Write some file headers +lang_header $1 switch m mttx '[mttxs]' > $1_switch.m + +# This is the main transformation using gawk +awk '{ + if (NR==1){ + printf("for i=1:%s\n",Nx) + printf(" mttxs(i) = mttx(i);\n") + printf("end;\n\n") + } + printf("if (%s==0.0)\n mttxs(%s)=0.0;\nend;\n\n", $1,$2) + printf("if (%s<0.0)\n if (mttx(%s)<0.0)\n mttxs(%s)=0.0;\n end;\nend;\n", $1,$2,$2) +}' Nx=$Nx < $1_switch.txt >> $1_switch.m + + + + +