Index: mttroot/mtt/bin/mtt ================================================================== --- mttroot/mtt/bin/mtt +++ mttroot/mtt/bin/mtt @@ -15,10 +15,15 @@ ############################################################### ## Version control history ############################################################### ## $Header$ ## $Log$ +## Revision 1.395 2004/08/28 23:48:06 geraint +## Removed dependency of ae.r on cse.r if -ae is not specified as an option. +## This prevents an implicit -A and thus removes a dependency on cse +## (and hence Reduce) for sorted systems. +## ## Revision 1.394 2004/08/28 22:14:12 geraint ## Removed -ibg option: now the default method. ## ## Revision 1.393 2004/08/26 16:20:17 geraint ## Creates postscript files of either dia or fig bond graphs. @@ -1436,10 +1441,13 @@ eps=eps psview=$PSVIEW # Default declare 500 temporary variables num_tmp_var=500 + +# Default no equation sorting +use_sorted_equations='' #Initialise list of switches mtt_switches=''; #Initialise read dirs @@ -1533,13 +1541,18 @@ esac;; -s ) sensitivity_switch='-s'; mtt_switches="$mtt_switches $1"; sensitivity=sensitivity ;; + -make-sort ) + mtt_switches="$mtt_switches $1"; + use_sorted_equations="make"; + num_tmp_var=0; + integration_method="euler";; -sort ) mtt_switches="$mtt_switches $1"; - use_sorted_equations="yes"; + use_sorted_equations="seqn"; integration_method="sorted_euler";; -ss ) mtt_switches="$mtt_switches $1"; steadystate_computation=yes ;; -d ) @@ -1709,11 +1722,12 @@ echo ' -p print environment variables' echo ' -partition partition hierachical system' echo ' -pdf generate pdf in place of ps' echo ' -r reset time stamp on representation' echo ' -s generate sensitivity BG (use mtt -s sSys rep lang)' - echo ' -sort use sorted equations (sese) and Euler integration (EXPERIMENTAL)' + echo ' -make-sort use sorted equations (sese, generated by make) and Euler integration (EXPERIMENTAL)' + echo ' -sort use sorted equations (sese, generated by seqn) and Euler integration (EXPERIMENTAL)' echo ' -ss use steady-state info to initialise simulations' echo ' -stdin read input data from standard input for simulations' echo ' -sub operate on this subsystem' echo ' -t tidy mode (default)' echo ' -trace Just indicate what mtt will do - but do not do it' @@ -1851,10 +1865,11 @@ rm -f *_ode2odes.* *.dat2 MTT.core rm -f *_modpar.txt *_modpar.r rm -f *_ICD.txt *_ICD.c *_ICD.cc *_ICD.m rm -f *_ae.r *_ae.m *_ae.cc *_ae.oct rm -f *_sese.r *_sese.m + rm -f *_sese.make *_sesx.* *_sesy.* rm -fR *_rep MTT_work exit fi # Clean up named system @@ -1893,10 +1908,11 @@ rm -f $1_ode2odes.* $1.dat2 rm -f $1_modpar.txt $1_modpar.r rm -f $1_ICD.txt $1_ICD.c $1_ICD.cc $1_ICD.m rm -f $1_ae.r $1_ae.m $1_ae.cc $1_ae.oct rm -f $1_sese.r $1_sese.m + rm -f $1_sese.make $1_sesx.* $1_sesy.* rm -fR $1_rep MTT_work exit fi if [ "$2" = "rep" ]; then @@ -1904,11 +1920,11 @@ # See if we are making a book -- ie representation rep on a directory isMTT_work=`pwd | grep 'MTT_work'` if [ -n "$isMTT_work" ]; then dotdot='../' fi - + #isdirectory=`file $dotdot$1 | gawk '{print $2}' | grep directory` if [ -d "$dotdot$1" ]; then documenttype=book fi else @@ -1921,11 +1937,10 @@ ;; nifr) NyquistStyle='True' ;; *) - esac #SUMMARY abg* acausal bond graph (fig) #SUMMARY abg* acausal bond graph (dia) #SUMMARY abg* acausal bond graph (ps) @@ -2102,11 +2117,11 @@ REPTYPE='bg' ;; sabg ) REPTYPE='bg' ;; cbg ) REPTYPE='bg' ;; - input ) + input ) REPTYPE='txt' ;; numpar ) REPTYPE='txt' ;; state ) REPTYPE='txt' ;; @@ -2313,11 +2328,11 @@ if [ -n "$4" ]; then filename=$1_$2-$4.$3 else filename=$1_$2.$3 fi - + #if [ -f "$filename" ]; then # echo $filename exists #else if [ ! -f "$2_rep.make.ignore" ]; then if [ -n "$Verbose" ]; then @@ -2419,11 +2434,10 @@ $1_%.cc: $1_%.m mtt_m2cc.sh $1 \$* cc cat mtt_%.cc:: ${MTT_LIB}/cc/mtt_%.cc cp ${MTT_LIB}/cc/mtt_\$*.cc mtt_\$*.cc - mtt_%.hh:: ${MTT_LIB}/cc/mtt_%.hh cp ${MTT_LIB}/cc/mtt_\$*.hh mtt_\$*.hh ## .o files @@ -2462,11 +2476,10 @@ ifneq ("\$(wildcard $1_abg.dia)","$1_abg.dia") $1_abg.fig: mtt -q -u $mtt_switches compcopy $1 else $1_abg.fig: - endif endif endif # Create an arg file if it doesn't exist @@ -2541,21 +2554,20 @@ lbl2icd_txt2txt.sh $1 #SUMMARY cr constitutive relationship for each subsystem (txt) $1_cr.txt: $1_abg.m $1_sub.sh abg2cr_m2txt $1 - + if [ "$level" = "0" ]; then \ mv $1_cr.txt MTT_cr.txt; \ else \ cat $1_cr.txt >> MTT_cr.txt; \ fi sh $1_sub.sh "rm -f " '_cr.txt' # Remove the txt.cr files sh $1_sub.sh "mtt $mtt_switches -q -u -l $level+1 " ' cr txt' #Create new ones - - + if [ "$level" = "0" ]; then \ sort -u MTT_cr.txt> $1_cr.txt; \ fi #SUMMARY cr constitutive relationship for each subsystem (r) @@ -2586,12 +2598,19 @@ #SUMMARY sympar symbolic parameters (r) $1_sympar.r: $1_sympar.txt sympar_txt2r $1 $1_sympar.m: $1_sympar.txt sympar_txt2m $1 +ifneq ($use_sorted_equations,make) $1_sympar.h: $1_sympar.txt sympar_txt2h.sh $1 $num_tmp_var +else +$1_sympar.h: $1_sympar.txt $1_sese.make + sympar_txt2h.sh $1 $num_tmp_var + declaration="static double" \ + make -f $1_sese.make declare_tmpvars >> \$@ +endif #SUMMARY sympar symbolic parameters (c) # txt to c sympar conversion $1_sympar.c: $1_sympar.txt sympar_txt2c $1 @@ -2728,15 +2747,23 @@ touch \$@ $1_ode2odes_common.o: $1_ae.o $1_input.o $1_logic.o $1_numpar.o $1_simpar.o $1_state.o @echo "Creating $1_ode2odes_common.o" ar -cr \$@ \$^ +ifeq ($use_sorted_equations,) $1_ode2odes_euler_%.stamp $1_ode2odes_rk4_%.stamp: $1_ode.% $1_odeo.% touch \$@ $1_ode2odes_euler.o $1_ode2odes_rk4.o: $1_ode.o $1_odeo.o mtt_euler.o @echo "Creating \$@" ar -cr \$@ \$^ +else +$1_ode2odes_euler_%.stamp $1_ode2odes_rk4_%.stamp: $1_sesx.% $1_sesy.% + touch \$@ +$1_ode2odes_euler.o $1_ode2odes_rk4.o: $1_sesx.o $1_sesy.o mtt_euler.o + @echo "Creating \$@" + ar -cr \$@ \$^ +endif $1_ode2odes_implicit_%.stamp: $1_cseo.% $1_csex.% $1_smxa.% $1_smxax.% touch \$@ $1_ode2odes_implicit.o: $1_cseo.o $1_csex.o $1_smxa.o $1_smxax.o mtt_implicit.o @echo "Creating $1_ode2odes_implicit.o" @@ -2751,11 +2778,11 @@ $1_ode2odes_dassl.o: $1_ode.o $1_odeo.o mtt_dassl.o @echo "Creating \$@" ar -cr \$@ \$^ $1_ode2odes_${algebraic_solver}.cc: mtt_Solver.cc mtt_AlgebraicSolver.cc mtt_${algebraic_solver}.hh mtt_${algebraic_solver}.cc - + $1_ode2odes_${algebraic_solver}.o: mtt_Solver.o mtt_AlgebraicSolver.o mtt_${algebraic_solver}.o @echo "Creating $1_ode2odes_${algebraic_solver}.o" ar -cr \$@ \$^ #SUMMARY numpar numerical parameter declaration (m) @@ -2826,14 +2853,13 @@ #Raw bond graph: fig file to mfile $1_rbg.m: $1_abg.fig $1_lbl.txt rbg_fig2m $1 $1_cmp.m: $1_lbl.txt $1_cmp.txt - lbl2cmp_txt2m.pl --sys=$1 #--debug + lbl2cmp_txt2m.pl --sys=$1 --$debug $1_fig.fig: $1_rbg.m - #SUMMARY sabg stripped acausal bond graph (fig) #SUMMARY sabg stripped acausal bond graph (ps) #SUMMARY sabg stripped acausal bond graph (view) $1_sabg.fig: $1_rbg.m @@ -2909,15 +2935,34 @@ #SUMMARY struc* structure - list of inputs, outputs and states (view) #Elementary system equations + definitions ${sys}_ese.r: ${sys}_cbg.m cbg2ese_m2r $partition $info_switch $Subsystem; #ese_tidy $1 +# sorted equations generated from seqn ${sys}_sese.m: ${sys}_def.r ${sys}_sese.r ${sys}_sympar.txt + echo Creating \$@ mtt_r2m ${sys} sese m - ${sys}_sese.r: ${sys}_cbg.m ${sys}_struc.m - cbg2sese_m2r $info_switch $Subsystem + echo Creating \$@ + cbg2sese_m2r $info_switch $Subsystem + +# sorted equations generated by make +${sys}_sesx.m: ${sys}_def.r ${sys}_sesx.r ${sys}_sympar.txt + echo Creating \$@ + mtt_r2m ${sys} sesx m +${sys}_sesy.m: ${sys}_def.r ${sys}_sesy.r ${sys}_sympar.txt + echo Creating \$@ + mtt_r2m ${sys} sesy m +${sys}_sesx.r: ${sys}_sese.make + echo Creating \$@ + make -f \$< MTTdX > \$@ +${sys}_sesy.r: ${sys}_sese.make + echo Creating \$@ + make -f \$< MTTy > \$@ +${sys}_sese.make: ${sys}_ese.r + echo Creating \$@ + ese_r2make.pl --sys=${sys} --outfile=\$@ --$debug $1_def.r: $1_ese.r touch $1_def.r $1_struc.txt: $1_ese.r touch $1_struc.txt @@ -3093,29 +3138,35 @@ $1_csex.m $1_cseo.m $1_logic.m ifeq ($using_oct,yes) touch $1_ode2odes.m # Create a dummy which wont' be used mtt $mtt_switches -q -u $1 ode2odes oct else - make_ode2odes $1 m $integration_method $algebraic_solver + make_ode2odes $1 m $integration_method $algebraic_solver $use_sorted_equations endif endif ifneq ($integration_method,implicit) -ifeq ($integration_method,sorted_euler) +ifeq ($use_sorted_equations,seqn) $1_ode2odes.m : $1_def.r $1_sympars.txt\ $1_simpar.m $1_numpar.m $1_state.m $1_input.m \ $1_sese.m $1_logic.m +else +ifeq ($use_sorted_equations,make) +$1_ode2odes.m : $1_def.r $1_sympars.txt\ + $1_simpar.m $1_numpar.m $1_state.m $1_input.m \ + $1_sesx.m $1_sesy.m $1_logic.m else $1_ode2odes.m : $1_def.r $1_sympars.txt\ $1_simpar.m $1_numpar.m $1_state.m $1_input.m \ $1_ode.m $1_odeo.m $1_logic.m +endif endif ifeq ($using_oct,yes) echo "*** Warning: Shouldn't be here! Creating dummy $1_ode2odes.m" touch $1_ode2odes.m # Create a dummy which wont' be used mtt $mtt_switches -q -u $1 ode2odes oct else - make_ode2odes $1 m $integration_method $algebraic_solver + make_ode2odes $1 m $integration_method $algebraic_solver $use_sorted_equations endif endif #SUMMARY ode2odes Simulation function (m) #SUMMARY ode2odes Simulation function (cc) @@ -3148,11 +3199,11 @@ $1_ode2odes.cc: $1_def.r $1_sympars.txt\ $1_ode2odes_common_m.stamp $1_ode2odes_common_cc.stamp\ $1_ode2odes_${integration_method}_m.stamp $1_ode2odes_${integration_method}_cc.stamp\ mtt_Solver.cc mtt_AlgebraicSolver.cc mtt_${algebraic_solver}.cc mtt_${algebraic_solver}.hh touch $1_ode2odes.m - make_ode2odes $1 cc $integration_method $algebraic_solver + make_ode2odes $1 cc $integration_method $algebraic_solver $use_sorted_equations #Conversion of m to p to c #SUMMARY ode ordinary differential equations (c) #SUMMARY ode ordinary differential equations (p) #SUMMARY state state declaration (c)