Overview
Comment:Modified to include explicit algebraic loop solution
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 4a33a9e0219ccefa77d18e4c84999948c7b865880b3e318651d6bcd079e9ece4
User & Date: gawthrop@users.sourceforge.net on 1998-05-21 16:20:27
Other Links: branch diff | manifest | tags
Context
1998-05-23
10:49:25
Initial revision check-in: 660b1ecb30 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
1998-05-21
16:20:27
Modified to include explicit algebraic loop solution check-in: 4a33a9e021 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
12:55:48
Put in algebraic equation stuff check-in: 15bdf579e7 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/ode2odes_m from [d0d67d2e69] to [6a08492f47].

11
12
13
14
15
16
17



18
19
20
21
22
23
24
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27







+
+
+







# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  1998/05/19 19:48:02  peterg
## Read the simpar file now.
##
## Revision 1.13  1998/05/14 08:05:10  peterg
## Put back under RCS
##
## Revision 1.12  1998/02/25 18:02:39  peterg
## Removed the argument passing stuff .
## Replaced by the simpar.m method.
##
108
109
110
111
112
113
114



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130

131
132

133

134

135

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150

151
152
153
154
155
156
157
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

136
137
138
139

140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158

159
160
161
162
163
164
165
166







+
+
+















-
+


+
-
+

+

+














-
+







    METHOD = 'Euler'
  end;

  if exist('x')==0
    x = zeros(nx,1);
   end;

  % xx is the composite vector containing x and the internal inputs.
  xx = [x; zeros(nyz,1)];

  [n,m]=size(T);
  if m>n
    T=T';
  end;

method = tolower(METHOD)

if nx>0
  if strcmp(method,'lsode')
    X = lsode('$1_ode', x, T);
  elseif strcmp(method,'euler')
    %Euler integration
    X=[];
    dt = (T(2)-T(1))/STEPFACTOR;
    for t=T'
      X = [X; x'];
      X = [X; xx'];
      ts = t;
      for i=1:STEPFACTOR
        x = xx(1:nx);
        dx = $1_ode(x,ts);
        xx = $1_ode(xx,ts);
        ts = ts + dt;
        dx = xx(1:nx);
        x = x + dx*dt;
        xx(1:nx) = x;
      end;
    end;
  else
    error('Method %s not available here', METHOD);
    return;
  end;
  write_matrix([T,X], '$1_odes');
else
  X = zeros(size(T));
end;

if ny>0 % compute y and print it
  i = 0; Y=[];
  for t=T'
    i = i+1;
    i = i+1, X(i,:)
    y = $1_odeo(X(i,:),t);
    Y = [Y; y'];
  end;
  write_matrix([T,Y], '$1_odeso');
end;


Modified mttroot/mtt/bin/trans/ode_r2m from [a02e2cb627] to [cbdd123f7f].

10
11
12
13
14
15
16



17
18
19
20
21
22
23
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
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
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";

OFF fort;
% Now do the y = g(x,t) function.
% The body of the odeo function
OUT "$1_odeo.m";
  
  GENTRANOUT "$1_odeo.m1";
  mtt_matrix := MTTy$
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;;";

  mtt_matrix_n := MTTNy$
common();

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

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

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);
225
226
227
228
229
230
231
232
233


234


235

236
237
238
239
240
241
242
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;
  xx = x;
  global xx tt;
  xx = x; tt=t;
  mttui = fsolve('$1_odea',mttui);
else
 mttui = [];
end;
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
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 t;
x = xx;
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 ]