Differences From Artifact [4c330c5fba]:

To Artifact [ee275a282c]:


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.11  1997/08/29 07:56:54  peterg
## Minor updates
##
# Revision 1.10  1997/01/07  09:16:03  peterg
# Added step_factor parameter - gives that number of integration steps
# per sample.
#







>
>
>
>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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
##
# Revision 1.10  1997/01/07  09:16:03  peterg
# Added step_factor parameter - gives that number of integration steps
# per sample.
#
67
68
69
70
71
72
73


74
75
76
77
78
79
80





81
82
83
84
85
86
87
88
89
90
91
92
#  PARAMS=$2;
#fi

# PARAMS="$PARAMS ;"


$MATRIX << EOF > ode2odes_m.log 2>mtt_error.txt



  %Read in parameters
  $1_numpar; 
 
  %Read in state
  x = $1_state






  %Read in simulation parameters
  $1_simpar
  T = [0:DT:LAST]

  [nx,ny,nu,nz,nyz] = $1_def;
  t=0;	%Just in case it appears in the parameter list.


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







>
>





|

>
>
>
>
>

|
|

<







71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

96
97
98
99
100
101
102
#  PARAMS=$2;
#fi

# PARAMS="$PARAMS ;"


$MATRIX << EOF > ode2odes_m.log 2>mtt_error.txt
  %System structure
  [nx,ny,nu,nz,nyz] = $1_def;

  %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;
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
  end;

if nx>0
%  x = lsode('$1_ode', x0, T);

%Euler integration
%  x = x0;
  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;

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

if ny>0
  i=0;
  for tt=T'
    i=i+1;
    y(i,:) = $1_odeo(X(i,:),tt)';
  end;
  write_matrix([T,y], '$1_odeso');
end;

EOF

# Now invoke the standard error handling.
mtt_error mtt_error.txt














|



|
>





>
>
>



<






<
<
<
|
|
|
<












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
  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.
mtt_error mtt_error.txt








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