Overview
Comment:Added -make-sort option and rules to generate simulation using sesx and sesy.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 8d085efec2e5301957ac175b5b1c46d23ef71d6c3c88bb34bc804d0dba430a55
User & Date: geraint@users.sourceforge.net on 2004-08-29 02:59:30
Other Links: branch diff | manifest | tags
Context
2004-08-29
03:00:59
Unused file (cc/sympar_txt2h.sh does this transformation). check-in: 43766fae90 user: geraint@users.sourceforge.net tags: origin/master, trunk
02:59:30
Added -make-sort option and rules to generate simulation using sesx and sesy. check-in: 8d085efec2 user: geraint@users.sourceforge.net tags: origin/master, trunk
01:48:46
Added rules to create headers for sorted systems: sesx and sesy. check-in: fc45617aa4 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/mtt from [d2fa9191c4] to [d9222d6191].

13
14
15
16
17
18
19





20
21
22
23
24
25
26
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31







+
+
+
+
+







# Copyright (C) 2001 by Peter J. Gawthrop

###############################################################
## 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.
##
## Revision 1.392  2004/08/26 12:50:12  geraint
1434
1435
1436
1437
1438
1439
1440



1441
1442
1443
1444
1445
1446
1447
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455







+
+
+







# Default use ps files
ps=ps
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
read_dirs=''

1531
1532
1533
1534
1535
1536
1537





1538
1539
1540

1541
1542
1543
1544
1545
1546
1547
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552

1553
1554
1555
1556
1557
1558
1559
1560







+
+
+
+
+


-
+







			echo $1 is an unknown solver - use hybrd, hooke or reduce;
			exit;;
	        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 )
		directory=$2; cd $directory; shift ;;
	-dc )
1707
1708
1709
1710
1711
1712
1713

1714

1715
1716
1717
1718
1719
1720
1721
1720
1721
1722
1723
1724
1725
1726
1727

1728
1729
1730
1731
1732
1733
1734
1735







+
-
+







    echo '         -optg optimise code generation (global : full vector) (EXPERIMENTAL)'
    echo "         -ntmpvar <N>  declare N temporary variables (default=$num_tmp_var)"
    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 '         -make-sort use sorted equations (sese, generated by make) and Euler integration (EXPERIMENTAL)'
    echo '         -sort use sorted equations (sese) 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 <subsystem> operate on this subsystem'
    echo '         -t  tidy mode (default)'
    echo '         -trace  Just indicate what mtt will do - but do not do it'
    echo '         -u  untidy mode (leaves files in current dir)'
    echo '         -v  verbose mode (multiple uses of -v increase the verbosity level)'
1849
1850
1851
1852
1853
1854
1855

1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877







+







  rm -f *_logic.m *_logic.cc *_logic.oct
  rm -f *_state.m *_state.cc *_state.oct
  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
if [ "$2" = "Clean" ] && [ "$3" = "" ]; then
  echo 'Removing all generated files for system ' $1
1891
1892
1893
1894
1895
1896
1897

1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909

1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924

1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941

1942
1943
1944
1945
1946
1947
1948







+











-
+
















-







  rm -f $1_logic.m $1_logic.cc $1_logic.oct 
  rm -f $1_state.m $1_state.cc $1_state.oct
  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
     documenttype=article
      # 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
     documenttype=section
fi

case $2 in
    nyfr)
	NyquistStyle='True'
	;;
    nifr)
	NyquistStyle='True'
	;;
    *)
	
esac

#SUMMARY abg*	acausal bond graph (fig)
#SUMMARY abg*	acausal bond graph (dia)
#SUMMARY abg*	acausal bond graph (ps)
#SUMMARY abg*	acausal bond graph (view)
# Invoke explicit requests for modification
2100
2101
2102
2103
2104
2105
2106
2107

2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121

2122
2123
2124
2125
2126
2127
2128
2129







-
+







case $2 in
	abg )
		REPTYPE='bg' ;;
	sabg )
		REPTYPE='bg' ;;
	cbg )
		REPTYPE='bg' ;;
    	input )
	input )
		REPTYPE='txt' ;;
	numpar )
		REPTYPE='txt' ;;
	state )
		REPTYPE='txt' ;;
	simpar )
		REPTYPE='txt' ;;
2311
2312
2313
2314
2315
2316
2317
2318

2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332

2333
2334
2335
2336
2337
2338
2339
2340







-
+








if [ -f "$2_rep.make" ]; then
   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
	   echo make -s -f $2_rep.make "MTT_SYS=$1" "MTT_LANG=$3" "MTT_ARG=$4" "MTT_OPTS=$mtt_switches" 
       fi
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438

2439
2440
2441
2442
2443
2444
2445







-







.PRECIOUS: %.cc # Don't let mtt delete them
.PRECIOUS: $1_%.cc # Don't let mtt delete them
$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
.PRECIOUS: $1_%.o
$1_%.o: $1_%.cc $1_def.h $1_sympar.h $1_cr.h
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2474
2475
2476
2477
2478
2479
2480

2481
2482
2483
2484
2485
2486
2487







-







ifneq ("$level","0")
# If level>0, try and get subsystem files; creating if necessary
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
$1_args.m:
	touch $1_args.m
2539
2540
2541
2542
2543
2544
2545
2546

2547
2548
2549
2550
2551
2552
2553
2554
2555

2556
2557
2558
2559
2560
2561
2562
2563
2552
2553
2554
2555
2556
2557
2558

2559
2560
2561
2562
2563
2564
2565
2566
2567

2568

2569
2570
2571
2572
2573
2574
2575







-
+








-
+
-







#SUMMARY icd	interface definitions for each subsystem (txt)
$1_icd.txt: $1_lbl.txt
	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)
$1_cr.r: $1_cr.txt
	cr_txt2r $1
2584
2585
2586
2587
2588
2589
2590

2591
2592






2593
2594
2595
2596
2597
2598
2599
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618







+


+
+
+
+
+
+







	mtt_make_sympar $1

#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

#SUMMARY sympar	symbolic parameters (tex)
2726
2727
2728
2729
2730
2731
2732

2733
2734
2735
2736
2737







2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756

2757
2758
2759
2760
2761
2762
2763
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782

2783
2784
2785
2786
2787
2788
2789
2790







+





+
+
+
+
+
+
+


















-
+








$1_ode2odes_common_%.stamp: $1_ae.% $1_input.% $1_logic.% $1_numpar.% $1_simpar.% $1_state.%
	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"
	ar -cr \$@ \$^

$1_ode2odes_dassl_oct.stamp: $1_ode.oct $1_odeo.oct mtt_dassl.oct
	touch \$@
$1_ode2odes_dassl_o.stamp: $1_ode.o $1_odeo.o mtt_dassl.o
	touch \$@
$1_ode2odes_dassl_%.stamp: $1_ode.% $1_odeo.%
	touch \$@
$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) 
$1_numpar.m:  $1_numpar.txt $1_sympars.txt
	mtt_txt2m $1 numpar
2824
2825
2826
2827
2828
2829
2830
2831

2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2851
2852
2853
2854
2855
2856
2857

2858
2859
2860

2861
2862
2863
2864
2865
2866
2867







-
+


-








#SUMMARY rbg	raw bond graph (m)
#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


2907
2908
2909
2910
2911
2912
2913

2914

2915
2916
2917

2918


















2919
2920
2921
2922
2923
2924
2925
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943

2944
2945

2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970







+

+

-

+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







#SUMMARY struc*	structure - list of inputs, outputs and states (txt)
#SUMMARY struc	structure - list of inputs, outputs and states (tex)
#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
	echo Creating \$@
	   cbg2sese_m2r $info_switch $Subsystem
	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
$1_aliased.txt: $1_ese.r
	touch $1_aliased.txt
3091
3092
3093
3094
3095
3096
3097
3098

3099
3100
3101
3102

3103
3104
3105





3106
3107
3108
3109

3110
3111
3112
3113
3114
3115
3116

3117
3118
3119
3120
3121
3122
3123
3136
3137
3138
3139
3140
3141
3142

3143
3144
3145
3146

3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166

3167
3168
3169
3170
3171
3172
3173
3174







-
+



-
+



+
+
+
+
+




+






-
+







                $1_smxa.m $1_smxax.m\
                $1_simpar.m $1_numpar.m $1_state.m $1_input.m \
                $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)
#SUMMARY ode2odes Simulation function (oct)
#SUMMARY ode2odes Simulation function (exe)
3146
3147
3148
3149
3150
3151
3152
3153

3154
3155
3156
3157
3158
3159
3160
3197
3198
3199
3200
3201
3202
3203

3204
3205
3206
3207
3208
3209
3210
3211







-
+







	${MTT_LIB}/cc/mtt_kpathsea.cc ${MTT_LIB}/cc/mtt_matlab_octave.cc

$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) 
#SUMMARY state	state declaration (p) 
$1_simpar.p : $1_def.r $1_simpar.m


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]