︙ | | | ︙ | |
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# Copyright (C) 2001 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.308 2001/04/25 22:17:45 geraint
## Fixed icd.txt2 dependency.
##
## Revision 1.307 2001/04/15 21:15:41 geraint
## Added interface definition rep: _ICD.(txt|c|cc|m).
##
## Revision 1.305 2001/04/11 09:44:26 gawthrop
|
>
>
>
>
>
>
>
>
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# Copyright (C) 2001 by Peter J. Gawthrop
###############################################################
## Version control history
###############################################################
## $Header$
## $Log$
## Revision 1.309.2.1 2001/05/04 04:07:24 geraint
## Numerical solution of algebraic equations.
## sys_ae.cc written for unsolved inputs.
## Solution of equations using hybrd from MINPACK (as used by Octave fsolve).
##
## Revision 1.309 2001/04/28 03:15:03 geraint
## Fixed comment (interfered with "mtt help representations").
##
## Revision 1.308 2001/04/25 22:17:45 geraint
## Fixed icd.txt2 dependency.
##
## Revision 1.307 2001/04/15 21:15:41 geraint
## Added interface definition rep: _ICD.(txt|c|cc|m).
##
## Revision 1.305 2001/04/11 09:44:26 gawthrop
|
︙ | | | ︙ | |
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
|
# Default not verbose
verbose=' -s'
# Default integration method
integration_method=implicit;
# Default no info
info_switch=''
# Default use m, not oct files
m='m';
# Default use ps files
|
>
>
>
|
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
|
# Default not verbose
verbose=' -s'
# Default integration method
integration_method=implicit;
# Default algebraic equation solver
algebraic_solver=Reduce_Solver;
# Default no info
info_switch=''
# Default use m, not oct files
m='m';
# Default use ps files
|
︙ | | | ︙ | |
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
|
integration_method=rk4;
mtt_switches="$mtt_switches rk4";
;;
*)
echo $1 is an unknown integration method - use euler, rk4 or implicit;
exit;;
esac;;
-s )
mtt_switches="$mtt_switches $1";
sensitivity=sensitivity ;;
-ss )
mtt_switches="$mtt_switches $1";
steadystate_computation=yes ;;
-d )
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
|
integration_method=rk4;
mtt_switches="$mtt_switches rk4";
;;
*)
echo $1 is an unknown integration method - use euler, rk4 or implicit;
exit;;
esac;;
-ae )
mtt_switches="$mtt_switches $1";
case $2 in
fsolve | hybrd)
mtt_switches="$mtt_switches $2";
algebraic_solver=Hybrd_Solver;
shift;
;;
hooke)
mtt_switches="$mtt_switches $2";
algebraic_solver=HJ_Solver;
shift;
;;
reduce)
mtt_switches="$mtt_switches $2";
algebraic_solver=Reduce_Solver;
Solve='-A';
shift;
;;
*)
echo $1 is an unknown solver - use hybrd, hooke or reduce;
exit;;
esac;;
-s )
mtt_switches="$mtt_switches $1";
sensitivity=sensitivity ;;
-ss )
mtt_switches="$mtt_switches $1";
steadystate_computation=yes ;;
-d )
|
︙ | | | ︙ | |
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
|
echo ' -I prints more information'
echo ' -abg start at abg.m representation'
echo ' -c c-code generation'
echo ' -d <dir> use directory <dir>'
echo ' -dc Maximise derivative (not integral) causality'
echo ' -dc Maximise derivative (not integral) causality'
echo ' -i <implicit|euler|rk4> Use implicit, euler or rk4 integration'
echo ' -o ode is same as dae'
echo ' -oct use oct files in place of m files where appropriate'
echo ' -opt optimise code generation'
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'
|
>
|
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
|
echo ' -I prints more information'
echo ' -abg start at abg.m representation'
echo ' -c c-code generation'
echo ' -d <dir> use directory <dir>'
echo ' -dc Maximise derivative (not integral) causality'
echo ' -dc Maximise derivative (not integral) causality'
echo ' -i <implicit|euler|rk4> Use implicit, euler or rk4 integration'
echo ' -ae <reduce|hybrd|hooke> Solve algebraic equations with Reduce, hybrd (fsolve) or "Hooke and Jeeves"'
echo ' -o ode is same as dae'
echo ' -oct use oct files in place of m files where appropriate'
echo ' -opt optimise code generation'
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'
|
︙ | | | ︙ | |
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
|
rm -f *_csex.cc *_numpar.cc *_smxa.cc *_state.cc
rm -f *_ode.cc *_odeo.cc
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 -fR *_rep MTT_work
exit
fi
# Clean up named system
if [ "$2" = "Clean" ] && [ "$3" = "" ]; then
echo 'Removing all generated files for system ' $1
|
>
|
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
|
rm -f *_csex.cc *_numpar.cc *_smxa.cc *_state.cc
rm -f *_ode.cc *_odeo.cc
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 -fR *_rep MTT_work
exit
fi
# Clean up named system
if [ "$2" = "Clean" ] && [ "$3" = "" ]; then
echo 'Removing all generated files for system ' $1
|
︙ | | | ︙ | |
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
|
rm -f $1_csex.cc $1_numpar.cc $1_smxa.cc $1_state.cc
rm -f $1_ode.cc $1_odeo.cc
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 -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
|
>
|
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
|
rm -f $1_csex.cc $1_numpar.cc $1_smxa.cc $1_state.cc
rm -f $1_ode.cc $1_odeo.cc
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 -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
|
︙ | | | ︙ | |
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
|
.PRECIOUS: %.cc # Don't let mtt delete them
$1_%.cc: $1_%.m
mtt_m2cc.sh $1 \$* cat
mtt_%.cc: ${MTT_LIB}/cc/mtt_%.cc
cp ${MTT_LIB}/cc/mtt_\$*.cc mtt_\$*.cc
## .o files
.PRECIOUS: $1_%.o
$1_%.o: $1_%.cc $1_def.h $1_sympar.h $1_cr.h
echo Compiling $1_\$*.cc
${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DSTANDALONE
.PRECIOUS: mtt_%.o
|
>
>
>
|
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
|
.PRECIOUS: %.cc # Don't let mtt delete them
$1_%.cc: $1_%.m
mtt_m2cc.sh $1 \$* 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
echo Compiling $1_\$*.cc
${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $< -DSTANDALONE
.PRECIOUS: mtt_%.o
|
︙ | | | ︙ | |
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
|
else
mtt_update $1 logic
endif
# Dummy target
FORCE:
$1_ode2odes_common.m : $1_input.m $1_logic.m $1_numpar.m $1_simpar.m $1_state.m
@echo > /dev/null
$1_ode2odes_common.cc : $1_input.cc $1_logic.cc $1_numpar.cc $1_simpar.cc $1_state.cc
@echo > /dev/null
$1_ode2odes_common.o : $1_input.o $1_logic.o $1_numpar.o $1_simpar.o $1_state.o
@echo "Creating $1_ode2odes_common.o"
ar -cr \$@ \$^
$1_ode2odes_common.oct : $1_input.oct $1_logic.oct $1_numpar.oct $1_simpar.oct $1_state.oct
@echo > /dev/null
$1_ode2odes_euler.m $1_ode2odes_rk4.m : $1_ode.m $1_odeo.m
@echo > /dev/null
$1_ode2odes_euler.cc $1_ode2odes_rk4.cc : $1_ode.cc $1_odeo.cc
@echo > /dev/null
$1_ode2odes_euler.o $1_ode2odes_rk4.o : $1_ode.o $1_odeo.o mtt_euler.o
|
|
|
|
|
|
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
|
else
mtt_update $1 logic
endif
# Dummy target
FORCE:
$1_ode2odes_common.m : $1_ae.m $1_input.m $1_logic.m $1_numpar.m $1_simpar.m $1_state.m
@echo > /dev/null
$1_ode2odes_common.cc : $1_ae.cc $1_input.cc $1_logic.cc $1_numpar.cc $1_simpar.cc $1_state.cc
@echo > /dev/null
$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 \$@ \$^
$1_ode2odes_common.oct : $1_ae.oct $1_input.oct $1_logic.oct $1_numpar.oct $1_simpar.oct $1_state.oct
@echo > /dev/null
$1_ode2odes_euler.m $1_ode2odes_rk4.m : $1_ode.m $1_odeo.m
@echo > /dev/null
$1_ode2odes_euler.cc $1_ode2odes_rk4.cc : $1_ode.cc $1_odeo.cc
@echo > /dev/null
$1_ode2odes_euler.o $1_ode2odes_rk4.o : $1_ode.o $1_odeo.o mtt_euler.o
|
︙ | | | ︙ | |
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
|
@echo > /dev/null
$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_implicit.oct: $1_cseo.oct $1_csex.oct $1_smxa.oct $1_smxax.oct mtt_implicit.oct
@echo > /dev/null
#SUMMARY numpar numerical parameter declaration (m)
$1_numpar.m: $1_numpar.txt $1_sympars.txt
mtt_txt2m $1 numpar
#SUMMARY numpar numerical parameter declaration (c)
#SUMMARY numpar numerical parameter declaration (view)
|
>
>
>
>
>
|
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
|
@echo > /dev/null
$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_implicit.oct: $1_cseo.oct $1_csex.oct $1_smxa.oct $1_smxax.oct mtt_implicit.oct
@echo > /dev/null
mtt_Solver.cc: mtt_Solver.hh
$1_ode2odes_${algebraic_solver}.cc: mtt_Solver.cc mtt_${algebraic_solver}.hh mtt_${algebraic_solver}.cc
$1_ode2odes_${algebraic_solver}.o: mtt_Solver.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
#SUMMARY numpar numerical parameter declaration (c)
#SUMMARY numpar numerical parameter declaration (view)
|
︙ | | | ︙ | |
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
|
$1_dae.m: $1_def.r $1_dae.r $1_sympars.txt
dae_r2m $1; matlab_tidy $1_dae.m; matlab_tidy $1_daeo.m
$1_dae.c: $1_def.r $1_dae.r $1_sympar.r
dae_r2c $1; c_tidy $1_dae.c
$1_dae.tex: $1_dae.r $1_simp.r
dae_r2tex $partition $1; latex_tidy $1_dae.tex
#SUMMARY cse constrained-state equations (r)
#SUMMARY cse* constrained-state equations (m)
#SUMMARY cse* constrained-state equations (oct)
#SUMMARY cse constrained-state equations (tex)
#SUMMARY cse* constrained-state equations (view)
#SUMMARY cse constrained-state equations (ps)
|
>
>
>
>
>
>
>
>
>
|
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
|
$1_dae.m: $1_def.r $1_dae.r $1_sympars.txt
dae_r2m $1; matlab_tidy $1_dae.m; matlab_tidy $1_daeo.m
$1_dae.c: $1_def.r $1_dae.r $1_sympar.r
dae_r2c $1; c_tidy $1_dae.c
$1_dae.tex: $1_dae.r $1_simp.r
dae_r2tex $partition $1; latex_tidy $1_dae.tex
#SUMMARY ae algebraic equations - unknown inputs (r)
#SUMMARY ae algebraic equations - unknown inputs (m)
#SUMMARY ae algebraic equations - unknown inputs (cc)
$1_ae.r: $1_cse.r
touch $1_ae.r
$1_ae.m: $1_ae.r
mtt_r2m $1 ae
#SUMMARY cse constrained-state equations (r)
#SUMMARY cse* constrained-state equations (m)
#SUMMARY cse* constrained-state equations (oct)
#SUMMARY cse constrained-state equations (tex)
#SUMMARY cse* constrained-state equations (view)
#SUMMARY cse constrained-state equations (ps)
|
︙ | | | ︙ | |
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
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
2564
2565
2566
2567
2568
|
$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
endif
endif
ifneq ($integration_method,implicit)
$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
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
endif
endif
#SUMMARY ode2odes Simulation function (m)
#SUMMARY ode2odes Simulation function (cc)
#SUMMARY ode2odes Simulation function (oct)
#SUMMARY ode2odes Simulation function (exe)
$1_ode2odes.exe: $1_def.h $1_sympar.h\
$1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o
echo Creating $1_ode2odes.exe
${MTT_CXX} ${MTT_CXXFLAGS} -o $1_ode2odes.exe\
$1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o\
${MTT_LDFLAGS} ${MTT_CXXLIBS}
$1_ode2odes.o: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o
echo Creating $1_ode2odes.o
${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DSTANDALONE
$1_ode2odes.oct: $1_ode2odes.cc $1_ode2odes_common.oct $1_ode2odes_${integration_method}.oct
touch $1_ode2odes.m
echo Creating $1_ode2odes.oct
$MKOCTFILE $1_ode2odes.cc
$1_ode2odes.cc: $1_def.r $1_sympars.txt\
$1_ode2odes_common.m $1_ode2odes_common.cc\
$1_ode2odes_${integration_method}.m $1_ode2odes_${integration_method}.cc
touch $1_ode2odes.m
make_ode2odes $1 cc $integration_method
#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
|
|
|
|
|
|
|
|
|
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
|
$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
endif
endif
ifneq ($integration_method,implicit)
$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
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
endif
endif
#SUMMARY ode2odes Simulation function (m)
#SUMMARY ode2odes Simulation function (cc)
#SUMMARY ode2odes Simulation function (oct)
#SUMMARY ode2odes Simulation function (exe)
$1_ode2odes.exe: $1_def.h $1_sympar.h\
$1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o
echo Creating $1_ode2odes.exe
${MTT_CXX} ${MTT_CXXFLAGS} -o $1_ode2odes.exe\
$1_ode2odes.o $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o\
${MTT_LDFLAGS} ${MTT_CXXLIBS}
$1_ode2odes.o: $1_ode2odes.cc $1_ode2odes_common.o $1_ode2odes_${integration_method}.o $1_ode2odes_${algebraic_solver}.o
echo Creating $1_ode2odes.o
${MTT_CXX} ${MTT_CXXFLAGS} ${MTT_CXXINCS} -c $1_ode2odes.cc -DSTANDALONE
$1_ode2odes.oct: $1_ode2odes.cc $1_ode2odes_common.oct $1_ode2odes_${integration_method}.oct
touch $1_ode2odes.m
echo Creating $1_ode2odes.oct
$MKOCTFILE $1_ode2odes.cc
$1_ode2odes.cc: $1_def.r $1_sympars.txt\
$1_ode2odes_common.m $1_ode2odes_common.cc\
$1_ode2odes_${integration_method}.m $1_ode2odes_${integration_method}.cc mtt_Solver.cc mtt_${algebraic_solver}.cc mtt_${algebraic_solver}.hh
touch $1_ode2odes.m
make_ode2odes $1 cc $integration_method $algebraic_solver
#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
|
︙ | | | ︙ | |