Differences From Artifact [a02e2cb627]:

To Artifact [cbdd123f7f]:


10
11
12
13
14
15
16



17
18
19
20
21
22
23
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.11  1998/05/21 08:05:23  peterg
## Back under RCS
##
## Revision 1.10  1998/04/14 07:25:02  peterg
## _input now has arguments (x,t)
##
## Revision 1.9  1998/03/30 14:18:07  peterg







>
>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Copyright (c) P.J.Gawthrop 1991, 1994, 1995, 1996

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.12  1998/05/21 12:55:48  peterg
## Put in algebraic equation stuff
##
## Revision 1.11  1998/05/21 08:05:23  peterg
## Back under RCS
##
## Revision 1.10  1998/04/14 07:25:02  peterg
## _input now has arguments (x,t)
##
## Revision 1.9  1998/03/30 14:18:07  peterg
61
62
63
64
65
66
67

68
69
70
71
72
73
74
#Remove the temporary files
rm -f $1_ode.mc
rm -f $1_ode.m1
rm -f $1_ode.m2
rm -f $1_ode.m3
rm -f $1_ode.m4
rm -f $1_odea.m1;


# Use reduce to accomplish the transformation
reduce >ode_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";








>







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#Remove the temporary files
rm -f $1_ode.mc
rm -f $1_ode.m1
rm -f $1_ode.m2
rm -f $1_ode.m3
rm -f $1_ode.m4
rm -f $1_odea.m1;
rm -f $1_odeo.m1;

# Use reduce to accomplish the transformation
reduce >ode_r2m.log << EOF

%Read the reduce definitions file
in "$1_def.r";

179
180
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205

206
207
208
209
210
211
212
213
214
write "%File $1_odea.m;;";
write "%Generated by MTT;;";

%Write algebraic equations if any ...
zero := MTTYz;
SHUT "$1_odea.m";

OFF fort;
% Now do the y = g(x,t) function.

OUT "$1_odeo.m";
  
write "function mtty = $1_odeo(x,t);";
write "% mtty = $1_odeo(x,t);";
write "%ODE in Simulab form for system $1;;";
write "%File $1_odeo.m;;";
write "%Generated by MTT;;";

common();

%Fortran switches - one line expressions
OFF echo;
ON fort$
cardno!* := 1$
fortwidth!* := 500$
OFF period$

MTTy := MTTy;


SHUT "$1_odeo.m";

EOF

# Create the ode.m function
cat <<EOF > $1_ode.m
function mttdx = $1_ode(x,t);
% mttdx = $1_ode(x,t);







<

>
|
|
<
<
<
<
<
|
<
<
<
<
<
|
|
<
|
|
>

<







183
184
185
186
187
188
189

190
191
192
193





194





195
196

197
198
199
200

201
202
203
204
205
206
207
write "%File $1_odea.m;;";
write "%Generated by MTT;;";

%Write algebraic equations if any ...
zero := MTTYz;
SHUT "$1_odea.m";


% Now do the y = g(x,t) function.
% The body of the odeo function
  GENTRANOUT "$1_odeo.m1";
  mtt_matrix := MTTy$





  mtt_matrix_n := MTTNy$





  mtt_matrix_m := 1$
  mtt_matrix_name := MTTy$

  matlab_matrix(); 
  GENTRAN MTTy := mtt_matrix;
  GENTRANSHUT "$1_odeo.m1";



EOF

# Create the ode.m function
cat <<EOF > $1_ode.m
function mttdx = $1_ode(x,t);
% mttdx = $1_ode(x,t);
225
226
227
228
229
230
231
232
233
234


235
236
237
238
239
240
241
242

#Extract internal input from state vector
cat $1_ode.m4 >> $1_ode.m

cat <<EOF >> $1_ode.m
% Solve the algebraic equations (if any)
if nyz>0
  global xx;
  xx = x;
  mttui = fsolve('$1_odea',mttui);


end;
EOF

cat $1_ode.m3 >> $1_ode.m

cat <<EOF >> $1_ode.m

% The differential equations







|
|

>
>
|







218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237

#Extract internal input from state vector
cat $1_ode.m4 >> $1_ode.m

cat <<EOF >> $1_ode.m
% Solve the algebraic equations (if any)
if nyz>0
  global xx tt;
  xx = x; tt=t;
  mttui = fsolve('$1_odea',mttui);
else
 mttui = [];
end
EOF

cat $1_ode.m3 >> $1_ode.m

cat <<EOF >> $1_ode.m

% The differential equations
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281





























282
283
284
285
286
287
EOF

# Create the globals
sympar2global_txt2m $1 >> $1_odea.m

cat <<EOF >> $1_odea.m

global xx t;
x = xx;
EOF

#Common bit
cat $1_ode.mc >> $1_odea.m

# Internal inputs
cat $1_ode.m3 >> $1_odea.m

cat <<EOF >> $1_odea.m

% The algebraic equations
EOF
cat $1_odea.m1 >> $1_odea.m










































|
|













>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
EOF

# Create the globals
sympar2global_txt2m $1 >> $1_odea.m

cat <<EOF >> $1_odea.m

global xx tt;
x = xx; t=tt;
EOF

#Common bit
cat $1_ode.mc >> $1_odea.m

# Internal inputs
cat $1_ode.m3 >> $1_odea.m

cat <<EOF >> $1_odea.m

% The algebraic equations
EOF
cat $1_odea.m1 >> $1_odea.m

# Create the odeo.m function
cat <<EOF > $1_odeo.m
function mtty = $1_odeo(x,t);
% mtty = $1_odeo(x,t);
%Algebraic equations in Octave form for system $1;
%File $1_odeo.m;
%Generated by MTT on `date`;
EOF

# Create the globals
sympar2global_txt2m $1 >> $1_odeo.m


#Common bit
cat $1_ode.mc >> $1_odeo.m

#Extract internal input from state vector
cat $1_ode.m4 >> $1_odeo.m

# Internal inputs
cat $1_ode.m3 >> $1_odeo.m

cat <<EOF >> $1_odeo.m

% The output equations
EOF
cat $1_odeo.m1 >> $1_odeo.m








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