Differences From Artifact [e2fc3e22e9]:

To Artifact [e593903528]:


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.17  1998/06/27 14:49:16  peterg
## No change
##
## Revision 1.16  1998/06/25 08:47:23  peterg
## Put correct arguments for _input -- (x,t)
##
## Revision 1.15  1998/05/21 16:20:27  peterg
## Modified to include explicit algebraic loop solution
##
## Revision 1.14  1998/05/19 19:48:02  peterg
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
167

168
169
170
171
172
173
174
175
176
177
178
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
144
145
146
147
148
149
150
151

152
153
154
155
156
157
158
159
160
161
162


163
164
165
166
167
168
169
170
171

172
173
174
175
176
177
178
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
215
216
217
218
219







+
-
+










-
-
+
+




+


-
+

















-
-
+
+



















+
-
+







    X=[];
    dt = (T(2)-T(1))/STEPFACTOR;
    for t=T'
      X = [X; xx'];
      ts = t;
      for i=1:STEPFACTOR
        x = xx(1:nx);
        u = $1_input(xx,ts);
        xx = $1_ode(xx,ts);
        xx = $1_ode(xx,u,ts);
        ts = ts + dt;
        dx = xx(1:nx);
        x = x + dx*dt;
        xx(1:nx) = x;
      end;
    end;
  elseif strcmp(method,'implicitl')
    %Euler integration
    X=[];
    dt = (T(2)-T(1))/STEPFACTOR;
    u = $1_input(x,t);
    A = $1_sm(x,u); 
    u = $1_input(x,u,t);
    A = $1_smx(x,u); 
    inverse = inv(eye(nx) - dt*A);
    for t=T'
      X = [X; xx'];
      ts = t;
      u = $1_input(x,t);
      for i=1:STEPFACTOR
        x = xx(1:nx);
        xx = $1_ode(xx,ts);
        xx = $1_ode(xx,u,ts);
        ts = ts + dt;
        dx = xx(1:nx);
        x = inverse*(x + dt*(dx - A*x));
        xx(1:nx) = x;
      end;
    end;
  elseif strcmp(method,'implicit')
    %Euler integration
    X=[];
    dt = (T(2)-T(1))/STEPFACTOR;
    One = eye(nx);
    for t=T'
      X = [X; xx'];
      ts = t;
      for i=1:STEPFACTOR
        x = xx(1:nx);
        u = $1_input(x,t);
    	A = $1_sm(x,u); 
        xx = $1_ode(xx,ts);
    	A = $1_smx(x,u); 
        xx = $1_ode(xx,u,ts);
        ts = ts + dt;
        dx = xx(1:nx);
        x = (One-A*dt)\(x + dt*(dx - A*x));
        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; X(i,:);
    u = $1_input(x,t);
    y = $1_odeo(X(i,:)',t);
    y = $1_odeo(X(i,:)',u,t);
    Y = [Y; y'];
  end;
  write_matrix([T,Y], '$1_odeso');
end;


EOF

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