Overview
Comment:Corrected time skew.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: a2f2177bdb92f4c98d28a04eaba826190a70ca1b0c94003424ee5a10b4f15084
User & Date: gawthrop@users.sourceforge.net on 1998-05-14 08:25:52
Other Links: branch diff | manifest | tags
Context
1998-05-14
15:16:13
Sorted out Differential-Algebraic Equation simulation
Added LSODE methode to ordinary differential equation simulation
check-in: 30264ceab8 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
08:25:52
Corrected time skew. check-in: a2f2177bdb user: gawthrop@users.sourceforge.net tags: origin/master, trunk
08:20:29
Start time at DT - the result at time zero is computed outside the
loop
check-in: aa3caa35d4 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/ode2odes_r2c from [3256eab57b] to [6d811b8791].

16
17
18
19
20
21
22




23
24
25
26
27
28
29
# Copyright (c) P.J.Gawthrop 1997.

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




## Revision 1.14  1998/05/13 08:57:27  peterg
## Now uses simpar.h in place of odes.h
##
## Revision 1.13  1998/02/24 13:34:45  peterg
## Back under RCS
##
# Revision 1.12  1997/05/15  08:39:56  peterg







>
>
>
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright (c) P.J.Gawthrop 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.15  1998/05/14 08:20:29  peterg
## Start time at DT - the result at time zero is computed outside the
## loop
##
## Revision 1.14  1998/05/13 08:57:27  peterg
## Now uses simpar.h in place of odes.h
##
## Revision 1.13  1998/02/24 13:34:45  peterg
## Back under RCS
##
# Revision 1.12  1997/05/15  08:39:56  peterg
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179

%Set up initial state
write "/* Set up initial state */"$
write "  $1_state();"$

%Initialise main (Euler) integration loop
write "/* Initialise main (Euler) integration loop */"$
write "  time = DT;"$
write "  dt = DT/STEPFACTOR;"$
%% write "  for (i=1; i<=MTTNX; i++)"$
%% write "      x[i] = 0.0;"$

%Set up system inputs
write "/* Set up system inputs */"$
write "  for (i=1; i<=", MTTNu, "; i++)"$







|







169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

%Set up initial state
write "/* Set up initial state */"$
write "  $1_state();"$

%Initialise main (Euler) integration loop
write "/* Initialise main (Euler) integration loop */"$
write "  time = 0;"$
write "  dt = DT/STEPFACTOR;"$
%% write "  for (i=1; i<=MTTNX; i++)"$
%% write "      x[i] = 0.0;"$

%Set up system inputs
write "/* Set up system inputs */"$
write "  for (i=1; i<=", MTTNu, "; i++)"$
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
% Compute the first output
write "/* Compute the first output */"$
write "  $1_ode(y,dx,x,u);"$

%Main (Euler) integration loop
write "/* Main (Euler) integration loop */"$

write "  while (time<LAST)"$
write "  {"$

%Write to output to file
write "/* Write to output file */"$
write "    fprintf(fpso, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNY; i++)"$
write "      fprintf(fpso, ""%5.4g "", y[i]);"$
write "    fprintf(fpso, ""\n"");"$

%Write to state to file
write "/* Write to state file */"$
write "    fprintf(fps, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNX; i++)"$
write "      fprintf(fps, ""%5.4g "", x[i]);"$
write "    fprintf(fps, ""\n"");"$



write "/* Inner integration loop */"$
write "    for (k=1; k<=STEPFACTOR; k++)"$
write "    {"$
write "      for (i=1; i<=MTTNX; i++)"$
write "        x[i] = x[i] + dx[i]*dt;"$

write "      /* Set up system inputs */"$
write "      $1_input(time);"$
write "      $1_ode();"$
write "    }"$


write "      time = time + DT;"$
write "  }"$

%Write to files
%Write to output to file
write "/* Write to output file */"$
write "    fprintf(fpso, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNY; i++)"$







|
















>












<
<







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
220
221
222
223
224
225
226
227
228
229


230
231
232
233
234
235
236
% Compute the first output
write "/* Compute the first output */"$
write "  $1_ode(y,dx,x,u);"$

%Main (Euler) integration loop
write "/* Main (Euler) integration loop */"$

write "  while (time<(LAST-DT))"$
write "  {"$

%Write to output to file
write "/* Write to output file */"$
write "    fprintf(fpso, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNY; i++)"$
write "      fprintf(fpso, ""%5.4g "", y[i]);"$
write "    fprintf(fpso, ""\n"");"$

%Write to state to file
write "/* Write to state file */"$
write "    fprintf(fps, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNX; i++)"$
write "      fprintf(fps, ""%5.4g "", x[i]);"$
write "    fprintf(fps, ""\n"");"$

write "      time = time + DT;"$

write "/* Inner integration loop */"$
write "    for (k=1; k<=STEPFACTOR; k++)"$
write "    {"$
write "      for (i=1; i<=MTTNX; i++)"$
write "        x[i] = x[i] + dx[i]*dt;"$

write "      /* Set up system inputs */"$
write "      $1_input(time);"$
write "      $1_ode();"$
write "    }"$



write "  }"$

%Write to files
%Write to output to file
write "/* Write to output file */"$
write "    fprintf(fpso, ""%5.4g "",time);"$
write "    for (i=1; i<=MTTNY; i++)"$


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