Differences From Artifact [ee275a282c]:

To Artifact [d0d67d2e69]:


11
12
13
14
15
16
17



18
19
20
21
22
23
24
# Copyright (c) P.J.Gawthrop, 1996.

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



## Revision 1.12  1998/02/25 18:02:39  peterg
## Removed the argument passing stuff .
## Replaced by the simpar.m method.
##
## Revision 1.11  1997/08/29 07:56:54  peterg
## Minor updates
##







>
>
>







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.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.
##
## Revision 1.11  1997/08/29 07:56:54  peterg
## Minor updates
##
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103




104
105
106
107
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
  %Read in parameters
  $1_numpar; 
 
  %Read in state
  x = $1_state;

  %Set the initial output
  if ny>0
    y = $1_odeo(x,0);
  end; 
 
  %Read in simulation parameters
  $1_simpar;
  T = [0:DT:LAST];

  t=0;	%Just in case it appears in the parameter list.


  %Defaults
  if exist('T')==0
    T=[0:1:100]
  end;





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

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



if nx>0

%  x = lsode('$1_ode', x0, T);

%Euler integration
%  x = x0;
  X=[]; Y=[];
  dt = (T(2)-T(1))/STEPFACTOR;

  for t=T'
    X = [X; x'];
    Y = [Y; y'];
    ts = t;
    for i=1:STEPFACTOR
      dx = $1_ode(x,ts);
      ts = ts + dt;
      x = x + dx*dt;
      if ny>0
        y = $1_odeo(x,ts);
      end;
    end;



  end;

  write_matrix([T,X], '$1_odes');
else
  X = zeros(size(T));
end;

if ny>0






  write_matrix([T,Y], '$1_odeso');
end;


EOF

# Now invoke the standard error handling.







|
|
|













>
>
>
>
|
|
<
|






>
>

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


>
>
>

<





|
>
>
>
>
>
>







84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
158
159
160
  %Read in parameters
  $1_numpar; 
 
  %Read in state
  x = $1_state;

  %Set the initial output
  %if ny>0
  %  y = $1_odeo(x,0);
  %end; 
 
  %Read in simulation parameters
  $1_simpar;
  T = [0:DT:LAST];

  t=0;	%Just in case it appears in the parameter list.


  %Defaults
  if exist('T')==0
    T=[0:1:100]
  end;

  if exist('METHOD')==0
    METHOD = 'Euler'
  end;

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

   end;

  [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'];

      ts = t;
      for i=1:STEPFACTOR
        dx = $1_ode(x,ts);
        ts = ts + dt;
        x = x + dx*dt;


      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;
    y = $1_odeo(X(i,:),t);
    Y = [Y; y'];
  end;
  write_matrix([T,Y], '$1_odeso');
end;


EOF

# Now invoke the standard error handling.

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